From 414fa5ee38e2055b41883fc9a8ecb42ec1483f6d Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 24 Aug 2020 21:52:38 -0700 Subject: Implemented duration queries in D3D11 backend; added duration query test --- Graphics/GraphicsEngine/include/QueryBase.hpp | 15 +++++++++++++++ Graphics/GraphicsEngine/interface/DeviceCaps.h | 3 +++ 2 files changed, 18 insertions(+) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/QueryBase.hpp b/Graphics/GraphicsEngine/include/QueryBase.hpp index 322fbf54..5b066b29 100644 --- a/Graphics/GraphicsEngine/include/QueryBase.hpp +++ b/Graphics/GraphicsEngine/include/QueryBase.hpp @@ -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"); } @@ -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/DeviceCaps.h b/Graphics/GraphicsEngine/interface/DeviceCaps.h index 1f0dc257..efb657df 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); -- cgit v1.2.3