CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::GPUTimerQuery Class Referenceabstract

A GPU query that allows measuring the time a GPU device takes execute a set of commands on a command buffer. More...

#include <CeresEngine/RenderAPI/GPUQuery.hpp>

Inheritance diagram for CeresEngine::GPUTimerQuery:
CeresEngine::GPUQuery CeresEngine::TDeviceObject< GPUTimerQueryDescriptor > CeresEngine::GPUDeviceObject CeresEngine::GPUObject CeresEngine::VKTimerQuery

Classes

class  Scope
 A helper class that begins a scoped timer query. More...
 

Public Member Functions

 GPUTimerQuery (const GPUTimerQuery &)=delete
 Deleted copy constructor.
 
GPUTimerQueryoperator= (const GPUTimerQuery &)=delete
 
 GPUTimerQuery (GPUTimerQuery &&)=delete
 Deleted move constructor.
 
GPUTimerQueryoperator= (GPUTimerQuery &&)=delete
 
virtual void begin (GPUCommandBuffer &commandBuffer, UInt32 timerIndex=0)=0
 Begins the timer query.
 
virtual void end (GPUCommandBuffer &commandBuffer, UInt32 timerIndex=0)=0
 Ends the timer query.
 
virtual bool isComplete (UInt32 timerIndex=0) const =0
 Checks if the timer query is complete and ready to get the value.
 
virtual void wait (UInt32 timerIndex=0) const =0
 Waits until the timer query is complete.
 
virtual GPUTimerQueryResult getValue (UInt32 timerIndex=0) const =0
 Gets the amount of seconds the GPU took to run the commands between the begin() and the end() cals.
 
virtual void reset ()=0
 Resets the timer query so that it can be re-used by another command buffer.
 
template<typename Func >
decltype(autowith (GPUCommandBuffer &commandBuffer, Func &&func)
 Measures the time the GPU takes to run the commands run in commandBuffer from inside the given func.
 
template<typename Func >
decltype(autowith (GPUCommandBuffer &commandBuffer, const UInt32 timerIndex, Func &&func)
 
 TDeviceObject (GPUDevice &device, const Descriptor &descriptor)
 Inherited constructors.
 
 TDeviceObject (const TDeviceObject &)=delete
 Inherited constructors.
 
 TDeviceObject (TDeviceObject &&)=delete
 Inherited constructors.
 
- Public Member Functions inherited from CeresEngine::TDeviceObject< GPUTimerQueryDescriptor >
 TDeviceObject (GPUDevice &device, const Descriptor &descriptor)
 Initializes a new RenderAPI device object instance.
 
 TDeviceObject (const TDeviceObject &)=delete
 
 TDeviceObject (TDeviceObject &&)=delete
 
 ~TDeviceObject () override=default
 
TDeviceObjectoperator= (const TDeviceObject &)=delete
 
TDeviceObjectoperator= (TDeviceObject &&)=delete
 
- Public Member Functions inherited from CeresEngine::GPUDeviceObject
 GPUDeviceObject (GPUDevice &device)
 
 ~GPUDeviceObject () override
 
- Public Member Functions inherited from CeresEngine::GPUObject
 GPUObject ()=default
 
virtual ~GPUObject ()=default
 
 GPUObject (const GPUObject &)=delete
 
GPUObjectoperator= (const GPUObject &)=delete
 
 GPUObject (GPUObject &&)=delete
 
GPUObjectoperator= (GPUObject &&)=delete
 
void retain () noexcept
 Retains the object by increment it's reference count by one.
 
bool release () noexcept
 Releases the object by decrementing it's reference count by one.
 

Public Attributes

Event< void(GPUTimerQueryResult)> didComplete
 An event triggered whenever the query result becomes available.
 
- Public Attributes inherited from CeresEngine::TDeviceObject< GPUTimerQueryDescriptor >
const Descriptordescriptor
 A structure that describes the object and it's properties.
 
- Public Attributes inherited from CeresEngine::GPUDeviceObject
GPUDevicedevice
 The owning device this object was created from.
 

Additional Inherited Members

- Public Types inherited from CeresEngine::TDeviceObject< GPUTimerQueryDescriptor >
using Descriptor = GPUTimerQueryDescriptor
 An type-alias to the descriptor struct type.
 
- Protected Member Functions inherited from CeresEngine::GPUObject
virtual void destroy () noexcept
 A internal method called by the system when the object reference count reaches zero.
 

Detailed Description

A GPU query that allows measuring the time a GPU device takes execute a set of commands on a command buffer.

Constructor & Destructor Documentation

◆ GPUTimerQuery() [1/2]

CeresEngine::GPUTimerQuery::GPUTimerQuery ( const GPUTimerQuery )
delete

Deleted copy constructor.

◆ GPUTimerQuery() [2/2]

CeresEngine::GPUTimerQuery::GPUTimerQuery ( GPUTimerQuery &&  )
delete

Deleted move constructor.

Member Function Documentation

◆ begin()

virtual void CeresEngine::GPUTimerQuery::begin ( GPUCommandBuffer commandBuffer,
UInt32  timerIndex = 0 
)
pure virtual

Begins the timer query.

This will insert a command to write the current timestamp and use it as the starting timestamp.

Note
You must manually call end() to ensure that the measurement is ended. You can alternatively use with() which will measure all GPU commands triggered inside it.
Parameters
commandBufferThe command buffer to start the timer query at.
timerIndexThe index of the timer query to be started.

Implemented in CeresEngine::VKTimerQuery.

◆ end()

virtual void CeresEngine::GPUTimerQuery::end ( GPUCommandBuffer commandBuffer,
UInt32  timerIndex = 0 
)
pure virtual

Ends the timer query.

This will insert a command to write the current timestamp and use it as the ending timestamp.

Parameters
commandBufferThe command buffer to end the timer query at.
timerIndexThe index of the timer query to be ended.

Implemented in CeresEngine::VKTimerQuery.

◆ getValue()

virtual GPUTimerQueryResult CeresEngine::GPUTimerQuery::getValue ( UInt32  timerIndex = 0) const
pure virtual

Gets the amount of seconds the GPU took to run the commands between the begin() and the end() cals.

Note
This will block the CPU until the GPU finishes executing all the commands before the end() call, if isReady() returns false.

Implemented in CeresEngine::VKTimerQuery.

◆ isComplete()

virtual bool CeresEngine::GPUTimerQuery::isComplete ( UInt32  timerIndex = 0) const
pure virtual

Checks if the timer query is complete and ready to get the value.

Returns
True if the query is complete and calls to getValue() won't block.

Implemented in CeresEngine::VKTimerQuery.

◆ operator=() [1/2]

GPUTimerQuery & CeresEngine::GPUTimerQuery::operator= ( const GPUTimerQuery )
delete

◆ operator=() [2/2]

GPUTimerQuery & CeresEngine::GPUTimerQuery::operator= ( GPUTimerQuery &&  )
delete

◆ reset()

virtual void CeresEngine::GPUTimerQuery::reset ( )
pure virtual

Resets the timer query so that it can be re-used by another command buffer.

Implemented in CeresEngine::VKTimerQuery.

◆ TDeviceObject() [1/3]

Inherited constructors.

◆ TDeviceObject() [2/3]

CeresEngine::TDeviceObject< TDescriptor, TParent >::TDeviceObject ( GPUDevice device,
const Descriptor descriptor 
)
inlineexplicit

Inherited constructors.

◆ TDeviceObject() [3/3]

CeresEngine::TDeviceObject< TDescriptor, TParent >::TDeviceObject ( TDeviceObject &&  )
delete

Inherited constructors.

◆ wait()

virtual void CeresEngine::GPUTimerQuery::wait ( UInt32  timerIndex = 0) const
pure virtual

Waits until the timer query is complete.

Note
This will block the CPU until the GPU finishes executing all the commands before the end() call.

Implemented in CeresEngine::VKTimerQuery.

◆ with() [1/2]

template<typename Func >
decltype(auto) CeresEngine::GPUTimerQuery::with ( GPUCommandBuffer commandBuffer,
const UInt32  timerIndex,
Func &&  func 
)
inline

◆ with() [2/2]

template<typename Func >
decltype(auto) CeresEngine::GPUTimerQuery::with ( GPUCommandBuffer commandBuffer,
Func &&  func 
)
inline

Measures the time the GPU takes to run the commands run in commandBuffer from inside the given func.

Template Parameters
FuncA callable object that adds commands to the command buffer.
Parameters
commandBufferThe command buffer to start the query on.
funcA callable object that adds commands to the command buffer.

Member Data Documentation

◆ didComplete

Event<void(GPUTimerQueryResult)> CeresEngine::GPUTimerQuery::didComplete

An event triggered whenever the query result becomes available.


The documentation for this class was generated from the following file: