Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
foray_devicebenchmark.hpp
Go to the documentation of this file.
1#pragma once
2#include "../core/foray_managedresource.hpp"
3#include "../core/foray_core_declares.hpp"
5#include <unordered_map>
6
7namespace foray::bench {
8
9 struct VkContext;
10
13 {
14 public:
19 void Create(core::Context* context, const std::vector<const char*>& queryNames, uint32_t uniqueSets = INFLIGHT_FRAME_COUNT);
20
21 inline virtual bool Exists() const { return mQueryPools.size() > 0; }
22 virtual void Destroy();
23
27 void CmdResetQuery(VkCommandBuffer cmdBuffer, uint64_t frameIndex);
33 void CmdWriteTimestamp(VkCommandBuffer cmdBuffer, uint64_t frameIndex, const char* name, VkPipelineStageFlagBits stageFlagBit);
34
38 bool LogQueryResults(uint64_t frameIndex);
39
40 inline virtual ~DeviceBenchmark() { Destroy(); }
41
42 protected:
44
46 std::vector<VkQueryPool> mQueryPools;
48
49 std::vector<const char*> mQueryNames;
50 std::unordered_map<const char*, uint32_t> mQueryIds;
51 };
52} // namespace foray::bench
Base class for all benchmark types.
Definition foray_benchmarkbase.hpp:44
A device benchmark based on Vulkans DeviceQuery Api. Timestamps are recorded in milliseconds....
Definition foray_devicebenchmark.hpp:13
void Create(core::Context *context, const std::vector< const char * > &queryNames, uint32_t uniqueSets=INFLIGHT_FRAME_COUNT)
Prepares object for operation.
bool LogQueryResults(uint64_t frameIndex)
Instructs the benchmark object to retrieve the query results for a frame.
core::Context * mContext
Definition foray_devicebenchmark.hpp:45
virtual ~DeviceBenchmark()
Definition foray_devicebenchmark.hpp:40
void CmdResetQuery(VkCommandBuffer cmdBuffer, uint64_t frameIndex)
Resets the queries stored in current set indexes query pool.
std::vector< const char * > mQueryNames
Definition foray_devicebenchmark.hpp:49
std::vector< VkQueryPool > mQueryPools
Definition foray_devicebenchmark.hpp:46
virtual bool Exists() const
Return true, if the managed resource is allocated.
Definition foray_devicebenchmark.hpp:21
void CmdWriteTimestamp(VkCommandBuffer cmdBuffer, uint64_t frameIndex, const char *name, VkPipelineStageFlagBits stageFlagBit)
Writes a timestamp to the current set indexes query pool.
std::unordered_map< const char *, uint32_t > mQueryIds
Definition foray_devicebenchmark.hpp:50
fp64_t mTimestampPeriod
Definition foray_devicebenchmark.hpp:47
virtual void Destroy()
Destroy the resource.
fp64_t ConvertQueryResultToMillis(uint64_t result)
Base class enforcing common interface for all classes wrapping a device resource.
Definition foray_managedresource.hpp:11
Definition foray_bench_declares.hpp:3
constexpr uint32_t INFLIGHT_FRAME_COUNT
Inflight frame count is the amount of frames 'in flight' aka frames recorded on the host before waiti...
Definition foray_basics.hpp:35
double fp64_t
stdint.h style 64 bit floating point type alias (double)
Definition foray_basics.hpp:15
Non owning context object.
Definition foray_context.hpp:16