Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
foray::bench::DeviceBenchmark Class Reference

A device benchmark based on Vulkans DeviceQuery Api. Timestamps are recorded in milliseconds. Timestamp names must be set in advance. More...

#include <foray_devicebenchmark.hpp>

Inheritance diagram for foray::bench::DeviceBenchmark:
foray::bench::BenchmarkBase foray::core::ManagedResource foray::NoMoveDefaults

Public Member Functions

void Create (core::Context *context, const std::vector< const char * > &queryNames, uint32_t uniqueSets=INFLIGHT_FRAME_COUNT)
 Prepares object for operation.
 
virtual bool Exists () const
 Return true, if the managed resource is allocated.
 
virtual void Destroy ()
 Destroy the resource.
 
void CmdResetQuery (VkCommandBuffer cmdBuffer, uint64_t frameIndex)
 Resets the queries stored in current set indexes query pool.
 
void CmdWriteTimestamp (VkCommandBuffer cmdBuffer, uint64_t frameIndex, const char *name, VkPipelineStageFlagBits stageFlagBit)
 Writes a timestamp to the current set indexes query pool.
 
bool LogQueryResults (uint64_t frameIndex)
 Instructs the benchmark object to retrieve the query results for a frame.
 
virtual ~DeviceBenchmark ()
 
- Public Member Functions inherited from foray::bench::BenchmarkBase
 BenchmarkBase ()
 
- Public Member Functions inherited from foray::core::ManagedResource
virtual std::string_view GetTypeName () const
 Return a hint for the type of resource managed by the instantiation.
 
 ManagedResource ()
 Default constructor registers the resource.
 
 ManagedResource (std::string_view name)
 Registers the resource and sets its name.
 
virtual ~ManagedResource ()
 Unregisters the resource.
 
std::string_view GetName () const
 Return a custom name for the object.
 
virtual void SetName (std::string_view name)
 Set a custom name for the object.
 
std::string Print () const
 Print name and type in one string.
 
- Public Member Functions inherited from foray::NoMoveDefaults
 NoMoveDefaults ()=default
 
 NoMoveDefaults (const NoMoveDefaults &other)=delete
 
 NoMoveDefaults (NoMoveDefaults &&other)=default
 
NoMoveDefaultsoperator= (const NoMoveDefaults &other)=delete
 

Protected Member Functions

fp64_t ConvertQueryResultToMillis (uint64_t result)
 
- Protected Member Functions inherited from foray::bench::BenchmarkBase
void Begin (fp64_t timestamp)
 Begins a new benchmark and records the "Begin" timestamp.
 
void LogTimestamp (const char *id, fp64_t timestamp)
 Logs timestamp of id.
 
void End (fp64_t timestamp)
 Records the "End" timestamp and finalizes the benchmark.
 

Protected Attributes

core::ContextmContext = nullptr
 
std::vector< VkQueryPool > mQueryPools
 
fp64_t mTimestampPeriod = 0.f
 
std::vector< const char * > mQueryNames
 
std::unordered_map< const char *, uint32_t > mQueryIds
 
- Protected Attributes inherited from foray::bench::BenchmarkBase
std::vector< BenchmarkLogmLogs
 
BenchmarkLog mCurrentLog
 
bool mRecording = false
 
- Protected Attributes inherited from foray::core::ManagedResource
std::string mName
 This objects custom name.
 

Additional Inherited Members

- Static Public Member Functions inherited from foray::core::ManagedResource
static void sPrintAllocatedResources (bool printAsWarning)
 Print a list of all registered existing resources.
 
static const std::unordered_set< ManagedResource * > * GetTotalAllocatedResources ()
 

Detailed Description

A device benchmark based on Vulkans DeviceQuery Api. Timestamps are recorded in milliseconds. Timestamp names must be set in advance.

Constructor & Destructor Documentation

◆ ~DeviceBenchmark()

virtual foray::bench::DeviceBenchmark::~DeviceBenchmark ( )
inlinevirtual

Member Function Documentation

◆ CmdResetQuery()

void foray::bench::DeviceBenchmark::CmdResetQuery ( VkCommandBuffer  cmdBuffer,
uint64_t  frameIndex 
)

Resets the queries stored in current set indexes query pool.

Parameters
cmdBufferCommand Buffer
frameIndexFrame index for determining the query pool to access (frameIndex % uniqueSets)

◆ CmdWriteTimestamp()

void foray::bench::DeviceBenchmark::CmdWriteTimestamp ( VkCommandBuffer  cmdBuffer,
uint64_t  frameIndex,
const char *  name,
VkPipelineStageFlagBits  stageFlagBit 
)

Writes a timestamp to the current set indexes query pool.

Parameters
cmdBufferCommand Buffer
frameIndexFrame index for determining the query pool to access (frameIndex % uniqueSets)
nameId name. Pointer must have been passed in the create method before!
stageFlagBitTimestamp is written immediately before the pipelinestage defined here is invoked

◆ ConvertQueryResultToMillis()

fp64_t foray::bench::DeviceBenchmark::ConvertQueryResultToMillis ( uint64_t  result)
protected

◆ Create()

void foray::bench::DeviceBenchmark::Create ( core::Context context,
const std::vector< const char * > &  queryNames,
uint32_t  uniqueSets = INFLIGHT_FRAME_COUNT 
)

Prepares object for operation.

Parameters
contextRequires DispatchTable, PhysicalDevice
queryNamesMust define all query names used (As they're mapped to integer Ids)
uniqueSetscount of unique sets

◆ Destroy()

virtual void foray::bench::DeviceBenchmark::Destroy ( )
virtual

Destroy the resource.

Remarks
This method must be callable even if the resource has not been initialized yet. This method must call any Destroy() overloads of child objects and of base classes

Implements foray::core::ManagedResource.

◆ Exists()

virtual bool foray::bench::DeviceBenchmark::Exists ( ) const
inlinevirtual

Return true, if the managed resource is allocated.

Example: Vulkan object stored could be nullptr or instantiated

Implements foray::core::ManagedResource.

◆ LogQueryResults()

bool foray::bench::DeviceBenchmark::LogQueryResults ( uint64_t  frameIndex)

Instructs the benchmark object to retrieve the query results for a frame.

Parameters
frameIndexFrame index for determining the query pool to access (frameIndex % uniqueSets)
Returns
True, if log operation succeeds

Member Data Documentation

◆ mContext

core::Context* foray::bench::DeviceBenchmark::mContext = nullptr
protected

◆ mQueryIds

std::unordered_map<const char*, uint32_t> foray::bench::DeviceBenchmark::mQueryIds
protected

◆ mQueryNames

std::vector<const char*> foray::bench::DeviceBenchmark::mQueryNames
protected

◆ mQueryPools

std::vector<VkQueryPool> foray::bench::DeviceBenchmark::mQueryPools
protected

◆ mTimestampPeriod

fp64_t foray::bench::DeviceBenchmark::mTimestampPeriod = 0.f
protected

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