From 67fec45e6b5ec70b477c529fb2b1f4bd08682831 Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 24 Aug 2020 20:31:20 -0700 Subject: Added QUERY_TYPE_DURATION value and QueryDataDuration struct --- Graphics/GraphicsEngine/interface/GraphicsTypes.h | 43 +++++++++++++++++++-- Graphics/GraphicsEngine/interface/Query.h | 46 +++++++++-------------- 2 files changed, 57 insertions(+), 32 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 1d16ac82..9bcd9a05 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -1420,6 +1420,39 @@ struct FullScreenModeDesc }; typedef struct FullScreenModeDesc FullScreenModeDesc; + +/// Query type. +enum QUERY_TYPE +{ + /// Query type is undefined. + QUERY_TYPE_UNDEFINED = 0, + + /// Gets the number of samples that passed the depth and stencil tests in between IDeviceContext::BeginQuery + /// and IDeviceContext::EndQuery. IQuery::GetData fills a Diligent::QueryDataOcclusion struct. + QUERY_TYPE_OCCLUSION, + + /// Acts like QUERY_TYPE_OCCLUSION except that it returns simply a binary true/false result: false indicates that no samples + /// passed depth and stencil testing, true indicates that at least one sample passed depth and stencil testing. + /// IQuery::GetData fills a Diligent::QueryDataBinaryOcclusion struct. + QUERY_TYPE_BINARY_OCCLUSION, + + /// Gets the GPU timestamp corresponding to IDeviceContext::EndQuery call. Fot this query + /// type IDeviceContext::BeginQuery is disabled. IQuery::GetData fills a Diligent::QueryDataTimestamp struct. + QUERY_TYPE_TIMESTAMP, + + /// Gets pipeline statistics, such as the number of pixel shader invocations in between IDeviceContext::BeginQuery + /// and IDeviceContext::EndQuery. IQuery::GetData fills a Diligent::QueryDataPipelineStatistics struct. + QUERY_TYPE_PIPELINE_STATISTICS, + + /// Gets the number of high-frequency counter ticks between IDeviceContext::BeginQuery and + /// IDeviceContext::EndQuery calls. IQuery::GetData fills a Diligent::QueryDataDuration struct. + QUERY_TYPE_DURATION, + + /// The number of query types in the enum + QUERY_TYPE_NUM_TYPES +}; + + /// Engine creation attibutes struct EngineCreateInfo { @@ -1640,14 +1673,15 @@ struct EngineD3D12CreateInfo DILIGENT_DERIVE(EngineCreateInfo) Uint32 NumDynamicHeapPagesToReserve DEFAULT_INITIALIZER(1); /// Query pool size for each query type. - Uint32 QueryPoolSizes[5] + Uint32 QueryPoolSizes[QUERY_TYPE_NUM_TYPES] #if DILIGENT_CPP_INTERFACE { 0, // Ignored 128, // QUERY_TYPE_OCCLUSION 128, // QUERY_TYPE_BINARY_OCCLUSION 512, // QUERY_TYPE_TIMESTAMP - 128 // QUERY_TYPE_PIPELINE_STATISTICS + 128, // QUERY_TYPE_PIPELINE_STATISTICS + 256, // QUERY_TYPE_DURATION } #endif ; @@ -1774,14 +1808,15 @@ struct EngineVkCreateInfo DILIGENT_DERIVE(EngineCreateInfo) Uint32 DynamicHeapPageSize DEFAULT_INITIALIZER(256 << 10); /// Query pool size for each query type. - Uint32 QueryPoolSizes[5] + Uint32 QueryPoolSizes[QUERY_TYPE_NUM_TYPES] #if DILIGENT_CPP_INTERFACE { 0, // Ignored 128, // QUERY_TYPE_OCCLUSION 128, // QUERY_TYPE_BINARY_OCCLUSION 512, // QUERY_TYPE_TIMESTAMP - 128 // QUERY_TYPE_PIPELINE_STATISTICS + 128, // QUERY_TYPE_PIPELINE_STATISTICS + 256 // QUERY_TYPE_DURATION } #endif ; diff --git a/Graphics/GraphicsEngine/interface/Query.h b/Graphics/GraphicsEngine/interface/Query.h index b30b070b..975cb5d2 100644 --- a/Graphics/GraphicsEngine/interface/Query.h +++ b/Graphics/GraphicsEngine/interface/Query.h @@ -31,41 +31,14 @@ /// Defines Diligent::IQuery interface and related data structures #include "DeviceObject.h" +#include "GraphicsTypes.h" DILIGENT_BEGIN_NAMESPACE(Diligent) - // {70F2A88A-F8BE-4901-8F05-2F72FA695BA0} static const INTERFACE_ID IID_Query = {0x70f2a88a, 0xf8be, 0x4901, {0x8f, 0x5, 0x2f, 0x72, 0xfa, 0x69, 0x5b, 0xa0}}; -/// Query type. -enum QUERY_TYPE -{ - /// Query type is undefined. - QUERY_TYPE_UNDEFINED = 0, - - /// Gets the number of samples that passed the depth and stencil tests in between IDeviceContext::BeginQuery - /// and IDeviceContext::EndQuery. IQuery::GetData fills a Diligent::QueryDataOcclusion struct. - QUERY_TYPE_OCCLUSION, - - /// Acts like QUERY_TYPE_OCCLUSION except that it returns simply a binary true/false result: false indicates that no samples - /// passed depth and stencil testing, true indicates that at least one sample passed depth and stencil testing. - /// IQuery::GetData fills a Diligent::QueryDataBinaryOcclusion struct. - QUERY_TYPE_BINARY_OCCLUSION, - - /// Gets the GPU timestamp corresponding to IDeviceContext::EndQuery call. Fot this query - /// type IDeviceContext::BeginQuery is disabled. IQuery::GetData fills a Diligent::QueryDataTimestamp struct. - QUERY_TYPE_TIMESTAMP, - - /// Gets pipeline statistics, such as the number of pixel shader invocations in between IDeviceContext::BeginQuery - /// and IDeviceContext::EndQuery. IQuery::GetData will fills a Diligent::QueryDataPipelineStatistics struct. - QUERY_TYPE_PIPELINE_STATISTICS, - - /// The number of query types in the enum - QUERY_TYPE_NUM_TYPES -}; - /// Occlusion query data. /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_OCCLUSION query type. struct QueryDataOcclusion @@ -154,6 +127,23 @@ struct QueryDataPipelineStatistics }; typedef struct QueryDataPipelineStatistics QueryDataPipelineStatistics; +/// Duration query data. +/// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_DURATION query type. +struct QueryDataDuration +{ + /// Query type - must be Diligent::QUERY_TYPE_DURATION + const enum QUERY_TYPE Type DEFAULT_INITIALIZER(QUERY_TYPE_DURATION); + + /// The number of high-frequency counter ticks between + /// BeginQuery and EndQuery calls. + Uint64 Duration DEFAULT_INITIALIZER(0); + + /// The counter frequency, in Hz (ticks/second). If there was an error + /// while getting the timestamp, this value will be 0. + Uint64 Frequency DEFAULT_INITIALIZER(0); +}; +typedef struct QueryDataDuration QueryDataDuration; + // clang-format off /// Query description. -- cgit v1.2.3