summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-08-31 12:04:27 +0000
committerazhirnov <zh1dron@gmail.com>2020-08-31 12:09:36 +0000
commitab1149384b1185eb1b22eab8344055f82f9e10cb (patch)
tree8221754353a7250d0a0b3ef84d229200c623f67b /Graphics/GraphicsEngine
parentremoved unused DXILUtils, fixed some Codacy issues (diff)
parentAdded C API for IReferenceCounters (diff)
downloadDiligentCore-ab1149384b1185eb1b22eab8344055f82f9e10cb.tar.gz
DiligentCore-ab1149384b1185eb1b22eab8344055f82f9e10cb.zip
Merge branch 'master' into mesh_shader
# Conflicts: # Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/QueryBase.hpp21
-rw-r--r--Graphics/GraphicsEngine/interface/APIInfo.h2
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceCaps.h3
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h43
-rw-r--r--Graphics/GraphicsEngine/interface/Query.h46
5 files changed, 79 insertions, 36 deletions
diff --git a/Graphics/GraphicsEngine/include/QueryBase.hpp b/Graphics/GraphicsEngine/include/QueryBase.hpp
index 322fbf54..f0252c0d 100644
--- a/Graphics/GraphicsEngine/include/QueryBase.hpp
+++ b/Graphics/GraphicsEngine/include/QueryBase.hpp
@@ -52,7 +52,7 @@ public:
{
Inactive,
Querying,
- Complete
+ Ended
};
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, QueryDesc>;
@@ -69,6 +69,7 @@ public:
TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal}
{
const auto& deviceFeatures = pDevice->GetDeviceCaps().Features;
+ static_assert(QUERY_TYPE_NUM_TYPES == 6, "Not all QUERY_TYPE enum values are handled below");
switch (Desc.Type)
{
case QUERY_TYPE_OCCLUSION:
@@ -91,6 +92,11 @@ public:
LOG_ERROR_AND_THROW("Pipeline statistics queries are not supported by this device");
break;
+ case QUERY_TYPE_DURATION:
+ if (!deviceFeatures.DurationQueries)
+ LOG_ERROR_AND_THROW("Duration queries are not supported by this device");
+ break;
+
default:
UNEXPECTED("Unexpected device type");
}
@@ -160,7 +166,7 @@ public:
return false;
}
- m_State = QueryState::Complete;
+ m_State = QueryState::Ended;
return true;
}
@@ -171,7 +177,7 @@ public:
bool CheckQueryDataPtr(void* pData, Uint32 DataSize)
{
- if (m_State != QueryState::Complete)
+ if (m_State != QueryState::Ended)
{
LOG_ERROR_MESSAGE("Attempting to get data of query '", this->m_Desc.Name, "' that has not been ended");
return false;
@@ -185,6 +191,7 @@ public:
return false;
}
+ static_assert(QUERY_TYPE_NUM_TYPES == 6, "Not all QUERY_TYPE enum values are handled below");
switch (this->m_Desc.Type)
{
case QUERY_TYPE_UNDEFINED:
@@ -223,6 +230,14 @@ public:
}
break;
+ case QUERY_TYPE_DURATION:
+ if (DataSize != sizeof(QueryDataDuration))
+ {
+ LOG_ERROR_MESSAGE("The size of query data (", DataSize, ") is incorrect: ", sizeof(QueryDataDuration), " (aka sizeof(QueryDataDuration)) is expected");
+ return false;
+ }
+ break;
+
default:
UNEXPECTED("Unexpected query type");
return false;
diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h
index 8d14c8c2..cd46602d 100644
--- a/Graphics/GraphicsEngine/interface/APIInfo.h
+++ b/Graphics/GraphicsEngine/interface/APIInfo.h
@@ -30,7 +30,7 @@
/// \file
/// Diligent API information
-#define DILIGENT_API_VERSION 240066
+#define DILIGENT_API_VERSION 240067
#include "../../../Primitives/interface/BasicTypes.h"
diff --git a/Graphics/GraphicsEngine/interface/DeviceCaps.h b/Graphics/GraphicsEngine/interface/DeviceCaps.h
index 77095307..104481d3 100644
--- a/Graphics/GraphicsEngine/interface/DeviceCaps.h
+++ b/Graphics/GraphicsEngine/interface/DeviceCaps.h
@@ -136,6 +136,9 @@ struct DeviceFeatures
/// Indicates if device supports pipeline statistics queries (see Diligent::QUERY_TYPE_PIPELINE_STATISTICS).
Bool PipelineStatisticsQueries DEFAULT_INITIALIZER(False);
+ /// Indicates if device supports duration queries (see Diligent::QUERY_TYPE_DURATION).
+ Bool DurationQueries DEFAULT_INITIALIZER(False);
+
/// Indicates if device supports depth bias clamping
Bool DepthBiasClamp DEFAULT_INITIALIZER(False);
diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
index 2cc6aa78..95d3dd76 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
;
@@ -1777,14 +1811,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.