LiteFX 0.4.1.2025
Computer Graphics Engine
Loading...
Searching...
No Matches
LiteFX::Rendering::TimingEvent Class Referencefinal

An event that is used to measure timestamps in a command queue. More...

#include <rendering_api.hpp>

Inherits LiteFX::SharedObject.

Classes

class  TimingEventImpl
 

Public Member Functions

 ~TimingEvent () noexcept override
 Releases the render target instance.
 
 TimingEvent (TimingEvent &&) noexcept=delete
 
 TimingEvent (const TimingEvent &)=delete
 
auto operator= (TimingEvent &&) noexcept=delete
 
auto operator= (const TimingEvent &)=delete
 
StringView name () const noexcept
 Gets the name of the timing event.
 
UInt64 readTimestamp () const
 Reads the current timestamp (as a tick count) of the event.
 
UInt32 queryId () const
 Returns the query ID for the timing event.
 
- Public Member Functions inherited from LiteFX::SharedObject
virtual ~SharedObject () noexcept=default
 Destroys the shared object.
 
template<typename TSelf >
auto shared_from_this (this TSelf &&self) noexcept
 Returns a shared pointer to the current object instance.
 
template<typename TSelf >
auto weak_from_this (this TSelf &&self) noexcept -> WeakPtr< std::remove_reference_t< TSelf > >
 Returns a weak pointer to the current object instance.
 

Friends

class ISwapChain
 
struct SharedObject::Allocator< TimingEvent >
 

Additional Inherited Members

- Protected Member Functions inherited from LiteFX::SharedObject
 SharedObject () noexcept=default
 Initializes a new shared object.
 
 SharedObject (SharedObject &&) noexcept=default
 
 SharedObject (const SharedObject &)=default
 
SharedObjectoperator= (SharedObject &&) noexcept=default
 
SharedObjectoperator= (const SharedObject &)=default
 
- Static Protected Member Functions inherited from LiteFX::SharedObject
template<typename T , typename... TArgs>
static auto create (TArgs &&... args) -> SharedPtr< T >
 Generic factory method used to create instances of the shared object.
 

Detailed Description

An event that is used to measure timestamps in a command queue.

Timing events are used to collect GPU time stamps asynchronously. A timing event can be inserted to a ICommandBuffer by calling ICommandBuffer::writeTimingEvent. This will cause the GPU to write the current time stamp when the command gets executed. Since command order is not preserved within command buffers, this is not guaranteed to be accurate an accurate point of time for when a certain command in order has been executed. However, since a time stamp is always written at the bottom of the pipe, the difference between two timestamps resembles the actual time the GPU was occupied with the commands between them.

Timing events are asynchronous. They are set for a certain back buffer of a ISwapChain. Reading the time stamp requires the back buffer to be ready (i.e., the frame in flight needs to have executed). The earliest point where this is guaranteed is, if the swap chain swaps to the back buffer again. This means that the time stamps issued in one frame can only be read the next time the frame's back buffer is used again.

Note that timing events are only supported on graphics and compute ICommandQueues.

<seeaslo cref="ISwapChain" >

Constructor & Destructor Documentation

◆ ~TimingEvent()

TimingEvent::~TimingEvent ( )
overridedefaultnoexcept

Releases the render target instance.

◆ TimingEvent() [1/2]

LiteFX::Rendering::TimingEvent::TimingEvent ( TimingEvent && )
deletenoexcept

◆ TimingEvent() [2/2]

LiteFX::Rendering::TimingEvent::TimingEvent ( const TimingEvent & )
delete

Member Function Documentation

◆ name()

StringView TimingEvent::name ( ) const
noexcept

Gets the name of the timing event.

Returns
The name of the timing event.

◆ operator=() [1/2]

auto LiteFX::Rendering::TimingEvent::operator= ( const TimingEvent & )
delete

◆ operator=() [2/2]

auto LiteFX::Rendering::TimingEvent::operator= ( TimingEvent && )
deletenoexcept

◆ queryId()

UInt32 TimingEvent::queryId ( ) const

Returns the query ID for the timing event.

Returns
The query ID for the timing event.
See also
ISwapChain::resolveQueryId
Exceptions
RuntimeExceptionThrown, if the parent device instance is already released.

◆ readTimestamp()

UInt64 TimingEvent::readTimestamp ( ) const

Reads the current timestamp (as a tick count) of the event.

In order to convert the number of ticks to (milli-)seconds, this value needs to be divided by IGraphicsDevice::ticksPerMillisecond. To improve precision, calculate the difference between two time stamps in ticks first and only then convert them to seconds.

Returns
The current time stamp of the event as a tick count.
See also
ISwapChain::readTimingEvent
Exceptions
RuntimeExceptionThrown, if the parent device instance is already released.

Friends And Related Symbol Documentation

◆ ISwapChain

friend class ISwapChain
friend

◆ SharedObject::Allocator< TimingEvent >

friend struct SharedObject::Allocator< TimingEvent >
friend