summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-08-25 03:31:20 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-08-25 03:31:20 +0000
commit67fec45e6b5ec70b477c529fb2b1f4bd08682831 (patch)
tree7d9d66be7b83ced2e72228b69464301b163aad9b /Graphics
parentFixed buffer creation test on Vulkan/Intel; improved texture test failure output (diff)
downloadDiligentCore-67fec45e6b5ec70b477c529fb2b1f4bd08682831.tar.gz
DiligentCore-67fec45e6b5ec70b477c529fb2b1f4bd08682831.zip
Added QUERY_TYPE_DURATION value and QueryDataDuration struct
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp4
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h43
-rw-r--r--Graphics/GraphicsEngine/interface/Query.h46
-rw-r--r--Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp8
-rw-r--r--Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp6
6 files changed, 75 insertions, 34 deletions
diff --git a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
index 9be83ddf..0cec67ac 100644
--- a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
+++ b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
@@ -1081,6 +1081,10 @@ const char* GetQueryTypeString(QUERY_TYPE QueryType)
case QUERY_TYPE_BINARY_OCCLUSION: return "QUERY_TYPE_BINARY_OCCLUSION";
case QUERY_TYPE_TIMESTAMP: return "QUERY_TYPE_TIMESTAMP";
case QUERY_TYPE_PIPELINE_STATISTICS: return "QUERY_TYPE_PIPELINE_STATISTICS";
+ case QUERY_TYPE_DURATION: return "QUERY_TYPE_DURATION";
+
+ static_assert(QUERY_TYPE_NUM_TYPES == 6, "Not all QUERY_TYPE enum values are handled");
+
default:
UNEXPECTED("Unepxected query type");
return "Unknown";
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.
diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp
index 1759663f..88c1fb2d 100644
--- a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp
@@ -494,7 +494,9 @@ D3D12_QUERY_HEAP_TYPE QueryTypeToD3D12QueryHeapType(QUERY_TYPE QueryType)
case QUERY_TYPE_BINARY_OCCLUSION: return D3D12_QUERY_HEAP_TYPE_OCCLUSION;
case QUERY_TYPE_TIMESTAMP: return D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
case QUERY_TYPE_PIPELINE_STATISTICS: return D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS;
+ case QUERY_TYPE_DURATION: return D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
+ static_assert(QUERY_TYPE_NUM_TYPES == 6, "Not all QUERY_TYPE enum values are handled");
default:
UNEXPECTED("Unexpected query type");
return static_cast<D3D12_QUERY_HEAP_TYPE>(-1);
diff --git a/Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp
index 2391e2a6..6e122832 100644
--- a/Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp
@@ -45,6 +45,7 @@ static Uint32 GetQueryDataSize(QUERY_TYPE QueryType)
case QUERY_TYPE_OCCLUSION:
case QUERY_TYPE_BINARY_OCCLUSION:
case QUERY_TYPE_TIMESTAMP:
+ case QUERY_TYPE_DURATION:
return sizeof(Uint64);
break;
@@ -52,6 +53,8 @@ static Uint32 GetQueryDataSize(QUERY_TYPE QueryType)
return sizeof(D3D12_QUERY_DATA_PIPELINE_STATISTICS);
break;
+ static_assert(QUERY_TYPE_NUM_TYPES == 6, "Not all QUERY_TYPE enum values are tested");
+
default:
UNEXPECTED("Unexpected query type");
return 0;
@@ -70,7 +73,8 @@ QueryManagerD3D12::QueryManagerD3D12(ID3D12Device* pd3d12Device,
static_assert(QUERY_TYPE_BINARY_OCCLUSION == 2, "Unexpected value of QUERY_TYPE_BINARY_OCCLUSION. EngineD3D12CreateInfo::QueryPoolSizes must be updated");
static_assert(QUERY_TYPE_TIMESTAMP == 3, "Unexpected value of QUERY_TYPE_TIMESTAMP. EngineD3D12CreateInfo::QueryPoolSizes must be updated");
static_assert(QUERY_TYPE_PIPELINE_STATISTICS== 4, "Unexpected value of QUERY_TYPE_PIPELINE_STATISTICS. EngineD3D12CreateInfo::QueryPoolSizes must be updated");
- static_assert(QUERY_TYPE_NUM_TYPES == 5, "Unexpected value of QUERY_TYPE_NUM_TYPES. EngineD3D12CreateInfo::QueryPoolSizes must be updated");
+ static_assert(QUERY_TYPE_DURATION == 5, "Unexpected value of QUERY_TYPE_DURATION. EngineD3D12CreateInfo::QueryPoolSizes must be updated");
+ static_assert(QUERY_TYPE_NUM_TYPES == 6, "Unexpected value of QUERY_TYPE_NUM_TYPES. EngineD3D12CreateInfo::QueryPoolSizes must be updated");
// clang-format on
auto& HeapInfo = m_Heaps[QueryType];
@@ -79,6 +83,8 @@ QueryManagerD3D12::QueryManagerD3D12(ID3D12Device* pd3d12Device,
HeapInfo.HeapSize = QueryHeapSizes[QueryType];
d3d12HeapDesc.Type = QueryTypeToD3D12QueryHeapType(static_cast<QUERY_TYPE>(QueryType));
d3d12HeapDesc.Count = HeapInfo.HeapSize;
+ if (QueryType == QUERY_TYPE_DURATION)
+ d3d12HeapDesc.Count *= 2;
auto hr = pd3d12Device->CreateQueryHeap(&d3d12HeapDesc, __uuidof(HeapInfo.pd3d12QueryHeap), reinterpret_cast<void**>(&HeapInfo.pd3d12QueryHeap));
CHECK_D3D_RESULT_THROW(hr, "Failed to create D3D12 query heap of type");
diff --git a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp
index ebc57289..f56f58f2 100644
--- a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp
@@ -61,7 +61,8 @@ QueryManagerVk::QueryManagerVk(RenderDeviceVkImpl* pRenderDeviceVk,
static_assert(QUERY_TYPE_BINARY_OCCLUSION == 2, "Unexpected value of QUERY_TYPE_BINARY_OCCLUSION. EngineVkCreateInfo::QueryPoolSizes must be updated");
static_assert(QUERY_TYPE_TIMESTAMP == 3, "Unexpected value of QUERY_TYPE_TIMESTAMP. EngineVkCreateInfo::QueryPoolSizes must be updated");
static_assert(QUERY_TYPE_PIPELINE_STATISTICS== 4, "Unexpected value of QUERY_TYPE_PIPELINE_STATISTICS. EngineVkCreateInfo::QueryPoolSizes must be updated");
- static_assert(QUERY_TYPE_NUM_TYPES == 5, "Unexpected value of QUERY_TYPE_NUM_TYPES. EngineVkCreateInfo::QueryPoolSizes must be updated");
+ static_assert(QUERY_TYPE_DURATION == 5, "Unexpected value of QUERY_TYPE_DURATION. EngineVkCreateInfo::QueryPoolSizes must be updated");
+ static_assert(QUERY_TYPE_NUM_TYPES == 6, "Unexpected value of QUERY_TYPE_NUM_TYPES. EngineVkCreateInfo::QueryPoolSizes must be updated");
// clang-format on
auto& HeapInfo = m_Heaps[QueryType];
@@ -80,6 +81,7 @@ QueryManagerVk::QueryManagerVk(RenderDeviceVkImpl* pRenderDeviceVk,
break;
case QUERY_TYPE_TIMESTAMP:
+ case QUERY_TYPE_DURATION:
QueryPoolCI.queryType = VK_QUERY_TYPE_TIMESTAMP;
break;
@@ -114,6 +116,8 @@ QueryManagerVk::QueryManagerVk(RenderDeviceVkImpl* pRenderDeviceVk,
}
QueryPoolCI.queryCount = HeapInfo.PoolSize;
+ if (QueryType == QUERY_TYPE_DURATION)
+ QueryPoolCI.queryCount *= 2;
HeapInfo.vkQueryPool = LogicalDevice.CreateQueryPool(QueryPoolCI, "QueryManagerVk: query pool");