summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-03 06:29:01 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-03 06:29:01 +0000
commit7501af2487700060526c5b0c7fc78cc1ee2965cf (patch)
treeed71d7704284e995bfbf17361fb82f4aa7e8dd79 /Graphics/GraphicsEngine
parentUpdated third-party submodules (diff)
downloadDiligentCore-7501af2487700060526c5b0c7fc78cc1ee2965cf.tar.gz
DiligentCore-7501af2487700060526c5b0c7fc78cc1ee2965cf.zip
Added query interface; implemented queries in D3D11 and D3D12
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/CMakeLists.txt2
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.h46
-rw-r--r--Graphics/GraphicsEngine/include/QueryBase.h211
-rw-r--r--Graphics/GraphicsEngine/include/RenderDeviceBase.h7
-rw-r--r--Graphics/GraphicsEngine/interface/APIInfo.h2
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceContext.h25
-rw-r--r--Graphics/GraphicsEngine/interface/Fence.h2
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h10
-rw-r--r--Graphics/GraphicsEngine/interface/Query.h182
-rw-r--r--Graphics/GraphicsEngine/interface/RenderDevice.h15
10 files changed, 498 insertions, 4 deletions
diff --git a/Graphics/GraphicsEngine/CMakeLists.txt b/Graphics/GraphicsEngine/CMakeLists.txt
index 38db75e2..2ebddc5b 100644
--- a/Graphics/GraphicsEngine/CMakeLists.txt
+++ b/Graphics/GraphicsEngine/CMakeLists.txt
@@ -15,6 +15,7 @@ set(INCLUDE
include/FenceBase.h
include/pch.h
include/PipelineStateBase.h
+ include/QueryBase.h
include/RenderDeviceBase.h
include/ResourceMappingImpl.h
include/SamplerBase.h
@@ -44,6 +45,7 @@ set(INTERFACE
interface/InputLayout.h
interface/MapHelper.h
interface/PipelineState.h
+ interface/Query.h
interface/RasterizerState.h
interface/RenderDevice.h
interface/ResourceMapping.h
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h
index b57d13ce..f7b94118 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.h
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h
@@ -75,6 +75,7 @@ public:
using TextureImplType = typename ImplementationTraits::TextureType;
using PipelineStateImplType = typename ImplementationTraits::PipelineStateType;
using TextureViewImplType = typename TextureImplType::ViewImplType;
+ using QueryImplType = typename ImplementationTraits::QueryType;
/// \param pRefCounters - reference counters object that controls the lifetime of this device context.
/// \param pRenderDevice - render device.
@@ -211,6 +212,10 @@ protected:
bool ClearRenderTarget(ITextureView* pView);
+ bool BeginQuery(IQuery* pQuery, int);
+
+ bool EndQuery(IQuery* pQuery, int);
+
#ifdef DEVELOPMENT
// clang-format off
bool DvpVerifyDrawArguments (const DrawAttribs& Attribs)const;
@@ -890,6 +895,47 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::ClearRenderT
return true;
}
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::BeginQuery(IQuery* pQuery, int)
+{
+ if (pQuery == nullptr)
+ {
+ LOG_ERROR_MESSAGE("IDeviceContext::BeginQuery: pQuery must not be null");
+ return false;
+ }
+
+ if (m_bIsDeferred)
+ {
+ LOG_ERROR_MESSAGE("IDeviceContext::BeginQuery: Deferred contexts do not support queries");
+ return false;
+ }
+
+ if (!ValidatedCast<QueryImplType>(pQuery)->OnBeginQuery(this))
+ return false;
+
+ return true;
+}
+
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::EndQuery(IQuery* pQuery, int)
+{
+ if (pQuery == nullptr)
+ {
+ LOG_ERROR_MESSAGE("IDeviceContext::EndQuery: pQuery must not be null");
+ return false;
+ }
+
+ if (m_bIsDeferred)
+ {
+ LOG_ERROR_MESSAGE("IDeviceContext::EndQuery: Deferred contexts do not support queries");
+ return false;
+ }
+
+ if (!ValidatedCast<QueryImplType>(pQuery)->OnEndQuery(this))
+ return false;
+
+ return true;
+}
template <typename BaseInterface, typename ImplementationTraits>
inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
diff --git a/Graphics/GraphicsEngine/include/QueryBase.h b/Graphics/GraphicsEngine/include/QueryBase.h
new file mode 100644
index 00000000..871d1b18
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/QueryBase.h
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2019-2020 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Implementation of Diligent::QueryBase template class
+
+#include "Query.h"
+#include "DeviceObjectBase.h"
+#include "GraphicsTypes.h"
+#include "RefCntAutoPtr.h"
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality for a Query object
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::IQueryD3D11, Diligent::IQueryD3D12,
+/// Diligent::IQueryGL or Diligent::IQueryVk).
+/// \tparam RenderDeviceImplType - type of the render device implementation
+template <class BaseInterface, class RenderDeviceImplType>
+class QueryBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, QueryDesc>
+{
+public:
+ enum class QueryState
+ {
+ Inactive,
+ Querying,
+ Complete
+ };
+
+ using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, QueryDesc>;
+
+ /// \param pRefCounters - reference counters object that controls the lifetime of this command list.
+ /// \param pDevice - pointer to the device.
+ /// \param Desc - Query description
+ /// \param bIsDeviceInternal - flag indicating if the Query is an internal device object and
+ /// must not keep a strong reference to the device.
+ QueryBase(IReferenceCounters* pRefCounters,
+ RenderDeviceImplType* pDevice,
+ const QueryDesc& Desc,
+ bool bIsDeviceInternal = false) :
+ TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal}
+ {}
+
+ ~QueryBase()
+ {
+ if (m_State == QueryState::Querying)
+ {
+ LOG_ERROR_MESSAGE("Destroying query '", m_Desc.Name,
+ "' that is in querying state. End the query before releasing it.");
+ }
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Query, TDeviceObjectBase)
+
+ bool OnBeginQuery(IDeviceContext* pContext)
+ {
+ if (m_Desc.Type == QUERY_TYPE_TIMESTAMP)
+ {
+ LOG_ERROR_MESSAGE("Timestamp queries are never begun. Call EndQuery to set the timestamp.");
+ return false;
+ }
+
+ if (m_State == QueryState::Querying)
+ {
+ LOG_ERROR_MESSAGE("Attempting to begin query '", m_Desc.Name,
+ "' that is already in querying state.");
+ return false;
+ }
+
+ m_pContext = pContext;
+ m_State = QueryState::Querying;
+ return true;
+ }
+
+ bool OnEndQuery(IDeviceContext* pContext)
+ {
+ if (m_Desc.Type != QUERY_TYPE_TIMESTAMP)
+ {
+ if (m_State != QueryState::Querying)
+ {
+ LOG_ERROR_MESSAGE("Attempting to end query '", m_Desc.Name, "' that has not been begun");
+ return false;
+ }
+ }
+
+ if (m_pContext == nullptr)
+ {
+ if (m_Desc.Type != QUERY_TYPE_TIMESTAMP)
+ {
+ LOG_ERROR_MESSAGE("Ending query '", m_Desc.Name, "' that has not been begun");
+ return false;
+ }
+
+ m_pContext = pContext;
+ }
+ else if (m_pContext != pContext)
+ {
+ LOG_ERROR_MESSAGE("Query '", m_Desc.Name, "' has been begun by another context");
+ return false;
+ }
+
+ m_State = QueryState::Complete;
+ return true;
+ }
+
+ QueryState GetState() const
+ {
+ return m_State;
+ }
+
+ bool CheckQueryDataPtr(void* pData, Uint32 DataSize)
+ {
+ if (pData == nullptr)
+ {
+ LOG_ERROR_MESSAGE("Query data must not be null");
+ return false;
+ }
+
+ if (m_State != QueryState::Complete)
+ {
+ LOG_ERROR_MESSAGE("Attempting to get data of query '", m_Desc.Name, "' that has not been ended");
+ return false;
+ }
+
+ if (*reinterpret_cast<QUERY_TYPE*>(pData) != m_Desc.Type)
+ {
+ LOG_ERROR_MESSAGE("Incorrect query data structure type.");
+ return false;
+ }
+
+ switch (m_Desc.Type)
+ {
+ case QUERY_TYPE_UNDEFINED:
+ UNEXPECTED("Undefined query type is unexpected");
+ return false;
+
+ case QUERY_TYPE_OCCLUSION:
+ if (DataSize != sizeof(QueryDataOcclusion))
+ {
+ LOG_ERROR_MESSAGE("The size of query data (", DataSize, ") is incorrect: ", sizeof(QueryDataOcclusion), " (aka sizeof(QueryDataOcclusion)) is expected");
+ return false;
+ }
+ break;
+
+ case QUERY_TYPE_BINARY_OCCLUSION:
+ if (DataSize != sizeof(QueryDataBinaryOcclusion))
+ {
+ LOG_ERROR_MESSAGE("The size of query data (", DataSize, ") is incorrect: ", sizeof(QueryDataBinaryOcclusion), " (aka sizeof(QueryDataBinaryOcclusion)) is expected");
+ return false;
+ }
+ break;
+
+ case QUERY_TYPE_TIMESTAMP:
+ if (DataSize != sizeof(QueryDataTimestamp))
+ {
+ LOG_ERROR_MESSAGE("The size of query data (", DataSize, ") is incorrect: ", sizeof(QueryDataTimestamp), " (aka sizeof(QueryDataTimestamp)) is expected");
+ return false;
+ }
+ break;
+
+ case QUERY_TYPE_PIPELINE_STATISTICS:
+ if (DataSize != sizeof(QueryDataPipelineStatistics))
+ {
+ LOG_ERROR_MESSAGE("The size of query data (", DataSize, ") is incorrect: ", sizeof(QueryDataPipelineStatistics), " (aka sizeof(QueryDataPipelineStatistics)) is expected");
+ return false;
+ }
+ break;
+
+ default:
+ UNEXPECTED("Unexpected query type");
+ return false;
+ }
+
+ return true;
+ }
+
+protected:
+ RefCntAutoPtr<IDeviceContext> m_pContext;
+
+ QueryState m_State = QueryState::Inactive;
+};
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.h b/Graphics/GraphicsEngine/include/RenderDeviceBase.h
index 77ca3f3f..2712b9d8 100644
--- a/Graphics/GraphicsEngine/include/RenderDeviceBase.h
+++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.h
@@ -217,6 +217,9 @@ public:
/// Size of the fence object (FenceD3D12Impl, FenceVkImpl, etc.), in bytes
const size_t FenceSize;
+
+ /// Size of the query object (QueryD3D12Impl, QueryVkImpl, etc.), in bytes
+ const size_t QuerySize;
};
/// \param pRefCounters - reference counters object that controls the lifetime of this render device
@@ -249,7 +252,8 @@ public:
m_PSOAllocator {RawMemAllocator, ObjectSizes.PSOSize, 128 },
m_SRBAllocator {RawMemAllocator, ObjectSizes.SRBSize, 1024},
m_ResMappingAllocator {RawMemAllocator, sizeof(ResourceMappingImpl), 16 },
- m_FenceAllocator {RawMemAllocator, ObjectSizes.FenceSize, 16 }
+ m_FenceAllocator {RawMemAllocator, ObjectSizes.FenceSize, 16 },
+ m_QueryAllocator {RawMemAllocator, ObjectSizes.QuerySize, 16 }
// clang-format on
{
// Initialize texture format info
@@ -421,6 +425,7 @@ protected:
FixedBlockMemoryAllocator m_SRBAllocator; ///< Allocator for shader resource binding objects
FixedBlockMemoryAllocator m_ResMappingAllocator; ///< Allocator for resource mapping objects
FixedBlockMemoryAllocator m_FenceAllocator; ///< Allocator for fence objects
+ FixedBlockMemoryAllocator m_QueryAllocator; ///< Allocator for query objects
};
diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h
index aca39527..1686e3f7 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 240048
+#define DILIGENT_API_VERSION 240049
#include "../../../Primitives/interface/BasicTypes.h"
diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h
index c05a15c3..d101faa9 100644
--- a/Graphics/GraphicsEngine/interface/DeviceContext.h
+++ b/Graphics/GraphicsEngine/interface/DeviceContext.h
@@ -48,6 +48,7 @@
#include "BlendState.h"
#include "PipelineState.h"
#include "Fence.h"
+#include "Query.h"
#include "CommandList.h"
#include "SwapChain.h"
@@ -1007,6 +1008,30 @@ public:
virtual void WaitForIdle() = 0;
+ /// Marks the beginning of a query.
+
+ /// \param [in] pQuery - A pointer to a query object.
+ ///
+ /// \remarks Only immediate context can begin a query.
+ virtual void BeginQuery(IQuery* pQuery) = 0;
+
+
+ /// Marks the end of a query.
+
+ /// \param [in] pQuery - A pointer to a query object.
+ ///
+ /// \remarks A query must be ended by the same context that began it.
+ ///
+ /// In Direct3D12 and Vulkan, queries (except for timestamp queries)
+ /// cannot span command list boundaries, so the engine will never flush
+ /// the context even if the number of commands exceeds the user-specified limit
+ /// if there is an active query.
+ /// It is an error to explicitly flush the context while a query is active.
+ ///
+ /// All queries must be ended when IDeviceContext::FinishFrame() is called.
+ virtual void EndQuery(IQuery* pQuery) = 0;
+
+
/// Submits all pending commands in the context for execution to the command queue.
/// \remarks Only immediate contexts can be flushed.\n
diff --git a/Graphics/GraphicsEngine/interface/Fence.h b/Graphics/GraphicsEngine/interface/Fence.h
index 58701dbe..97264913 100644
--- a/Graphics/GraphicsEngine/interface/Fence.h
+++ b/Graphics/GraphicsEngine/interface/Fence.h
@@ -39,7 +39,7 @@ namespace Diligent
static constexpr INTERFACE_ID IID_Fence =
{0x3b19184d, 0x32ab, 0x4701, {0x84, 0xf4, 0x9a, 0xc, 0x3, 0xae, 0x16, 0x72}};
-/// Buffer description
+/// Fence description
struct FenceDesc : DeviceObjectAttribs
{
};
diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
index da1baf9b..b5ce083c 100644
--- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h
+++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
@@ -1461,6 +1461,16 @@ namespace Diligent
/// Number of dynamic heap pages that will be reserved by the
/// global dynamic heap manager to avoid page creation at run time.
Uint32 NumDynamicHeapPagesToReserve = 1;
+
+ /// The size of query pool for each query type.
+ Uint32 QueryPoolSizes[5] =
+ {
+ 0, // Ignored
+ 128, // QUERY_TYPE_OCCLUSION
+ 128, // QUERY_TYPE_BINARY_OCCLUSION
+ 512, // QUERY_TYPE_TIMESTAMP
+ 128 // QUERY_TYPE_PIPELINE_STATISTICS
+ };
};
/// Attributes specific to Vulkan engine
diff --git a/Graphics/GraphicsEngine/interface/Query.h b/Graphics/GraphicsEngine/interface/Query.h
new file mode 100644
index 00000000..dadcb37a
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/Query.h
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2019-2020 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Defines Diligent::IQuery interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+// {70F2A88A-F8BE-4901-8F05-2F72FA695BA0}
+static constexpr 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
+{
+ /// Query type - must be Diligent::QUERY_TYPE_OCCLUSION
+ const QUERY_TYPE Type = QUERY_TYPE_OCCLUSION;
+
+ /// The number of samples that passed the depth and stencil tests in between
+ /// IDeviceContext::BeginQuery and IDeviceContext::EndQuery.
+ Uint64 NumSamples = 0;
+};
+
+/// Binary occlusion query data.
+/// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_BINARY_OCCLUSION query type.
+struct QueryDataBinaryOcclusion
+{
+ /// Query type - must be Diligent::QUERY_TYPE_BINARY_OCCLUSION
+ const QUERY_TYPE Type = QUERY_TYPE_BINARY_OCCLUSION;
+
+ /// Indicates if at least one sample passed depth and stencil testing in between
+ /// IDeviceContext::BeginQuery and IDeviceContext::EndQuery.
+ bool AnySamplePassed = 0;
+};
+
+/// Timestamp query data.
+/// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_TIMESTAMP query type.
+struct QueryDataTimestamp
+{
+ /// Query type - must be Diligent::QUERY_TYPE_TIMESTAMP
+ const QUERY_TYPE Type = QUERY_TYPE_TIMESTAMP;
+
+ /// The value of a high-frequency counter.
+ Uint64 NumTicks = 0;
+
+ /// The counter frequency, in Hz (ticks/second). If there was an error
+ /// while getting the timestamp, this value will be 0.
+ Uint64 Frequency = 0;
+};
+
+/// Pipeline statistics query data.
+/// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_PIPELINE_STATISTICS query type.
+struct QueryDataPipelineStatistics
+{
+ /// Query type - must be Diligent::QUERY_TYPE_PIPELINE_STATISTICS
+ const QUERY_TYPE Type = QUERY_TYPE_PIPELINE_STATISTICS;
+
+ /// Number of vertices processed by the input assembler stage.
+ Uint64 InputVertices = 0;
+
+ /// Number of primitives processed by the input assembler stage.
+ Uint64 InputPrimitives = 0;
+
+ /// Number of primitives output by a geometry shader.
+ Uint64 GSPrimitives = 0;
+
+ /// Number of primitives that were sent to the clipping stage.
+ Uint64 ClippingInvocations = 0;
+
+ /// Number of primitives that were output by the clipping stage and were rendered.
+ /// This may be larger or smaller than ClippingInvocations because after a primitive is
+ /// clipped sometimes it is either broken up into more than one primitive or completely culled.
+ Uint64 ClippingPrimitives = 0;
+
+ /// Number of times a vertex shader was invoked.
+ Uint64 VSInvocations = 0;
+
+ /// Number of times a geometry shader was invoked.
+ Uint64 GSInvocations = 0;
+
+ /// Number of times a pixel shader shader was invoked.
+ Uint64 PSInvocations = 0;
+
+ /// Number of times a hull shader shader was invoked.
+ Uint64 HSInvocations = 0;
+
+ /// Number of times a domain shader shader was invoked.
+ Uint64 DSInvocations = 0;
+
+ /// Number of times a compute shader was invoked.
+ Uint64 CSInvocations = 0;
+};
+
+/// Query description.
+struct QueryDesc : DeviceObjectAttribs
+{
+ /// Query type, see Diligent::QUERY_TYPE.
+ QUERY_TYPE Type = QUERY_TYPE_UNDEFINED;
+};
+
+
+/// Query interface.
+
+/// Defines the methods to manipulate a Query object
+class IQuery : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details.
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
+
+ /// Returns the Query description used to create the object.
+ virtual const QueryDesc& GetDesc() const override = 0;
+
+ /// Gets the query data.
+
+ /// \param [in] pData - pointer to the query data structure. Depending on the type of the query,
+ /// this must be the pointer to Diligent::QueryDataOcclusion, Diligent::QueryDataBinaryOcclusion,
+ /// Diligent::QueryDataTimestamp, or Diligent::QueryDataPipelineStatistics
+ /// structure.
+ /// \param [in] DataSize - Size of the data structure.
+ /// \return true if the query data is available and false otherwise.
+ virtual bool GetData(void* pData, Uint32 DataSize) = 0;
+};
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h
index 62cd5d46..843aecc5 100644
--- a/Graphics/GraphicsEngine/interface/RenderDevice.h
+++ b/Graphics/GraphicsEngine/interface/RenderDevice.h
@@ -45,6 +45,7 @@
#include "BufferView.h"
#include "PipelineState.h"
#include "Fence.h"
+#include "Query.h"
#include "DepthStencilState.h"
#include "RasterizerState.h"
@@ -153,7 +154,7 @@ public:
IPipelineState** ppPipelineState) = 0;
- /// Creates a new pipeline state object
+ /// Creates a new fence object
/// \param [in] Desc - Fence description, see Diligent::FenceDesc for details.
/// \param [out] ppFence - Address of the memory location where the pointer to the
@@ -164,9 +165,21 @@ public:
IFence** ppFence) = 0;
+ /// Creates a new query object
+
+ /// \param [in] Desc - Query description, see Diligent::QueryDesc for details.
+ /// \param [out] ppQuery - Address of the memory location where the pointer to the
+ /// query interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one reference.
+ virtual void CreateQuery(const QueryDesc& Desc,
+ IQuery** ppQuery) = 0;
+
+
/// Gets the device capabilities, see Diligent::DeviceCaps for details
virtual const DeviceCaps& GetDeviceCaps() const = 0;
+
/// Returns the basic texture format information.
/// See Diligent::TextureFormatInfo for details on the provided information.