class GpuProfiler

Profiler that measures time and amount of various GPU operations.

Public

Methods

~GpuProfiler

~GpuProfiler() noexcept

CreateCommandBufferProfiler

SPtr<GpuCommandBufferProfiler> CreateCommandBufferProfiler(render::GpuCommandBuffer &commandBuffer)

Creates a profiler that can be used for profiling commands on the provided command buffer.

Query pool reset command will be issued on the provided command buffer. Command buffer cannot be in render pass.

ResolveProfileWhenReady

void ResolveProfileWhenReady(const ProfilerString &name, const SPtr<GpuCommandBufferProfiler> &profiler)

Notifies the GPU profiler that we're done recording samples into the provided command buffer profiler.

The systems will then internally monitor command buffer completion resolve the profiler results when they are ready.

name
Name you can use to retrieve the results when ready.
profiler
Profiler holding the samples to resolve.

GetResults

TOptional<GpuProfilerResults> GetResults(const ProfilerString &name)

Returns latest profiling results, if available.

Profiling results are consumed once retrieved and cannot be retrieved again.

name
Name given to the samples in call to ResolveProfileWhenReady.

Returns: Set of resolved root samples, or null if no results are available.

staticInstance

static T &Instance()

Returns a reference to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticInstancePtr

static T *InstancePtr()

Returns a pointer to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticShutDown

static void ShutDown()

Shuts down this module and frees any resources it is using.

staticIsStarted

static bool IsStarted()

Query if the module has been started.

Internal

Methods

Update

void Update()

To be called once per frame from the render thread.

Clear

void Clear()

Releases all GPU resources held by the profiler.

Must be called on the render thread before shutdown.

Protected

Methods

~Module<T>

virtual ~Module<T>() = default

OnStartUp

virtual void OnStartUp()

Override if you want your module to be notified once it has been constructed and started.

OnShutDown

virtual void OnShutDown()

Override if you want your module to be notified just before it is deleted.

staticInstanceInternal

static T *&InstanceInternal()

Returns a singleton instance of this module.

staticIsDestroyed

static bool &IsDestroyed()

Checks has the Module been shut down.

staticIsStartedUp

static bool &IsStartedUp()

Checks has the Module been started up.

Private

Methods

FindOrCreateQueryPool

SPtr<render::GpuQueryPool> FindOrCreateQueryPool() const

Attempts to find an existing free pool, or creates a new one if free one cannot be found.

ReleaseQueryPool

void ReleaseQueryPool(const SPtr<render::GpuQueryPool> &queryPool)

Notifies the system that the query pool is no longer used and can be re-used.

Fields

mUnresolvedProfilerData

UnorderedMap<ProfilerString, UnresolvedCommandBufferProfilerData> mUnresolvedProfilerData

mResolvedProfilerData

UnorderedMap<ProfilerString, ResolvedCommandBufferProfilerData> mResolvedProfilerData

mFreeCommandBufferProfilers

TArray<SPtr<GpuCommandBufferProfiler>> mFreeCommandBufferProfilers

mFreeTimestampQueryPools

TArray<SPtr<render::GpuQueryPool>> mFreeTimestampQueryPools

mMutex

Mutex mMutex