Diligent Engine  v.2.4.g
QueryD3D11Impl.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include <memory>
34 #include <atlbase.h>
35 
37 #include "QueryBase.hpp"
38 #include "DisjointQueryPool.hpp"
39 
40 namespace Diligent
41 {
42 
44 class QueryD3D11Impl final : public QueryBase<EngineD3D11ImplTraits>
45 {
46 public:
48 
49  QueryD3D11Impl(IReferenceCounters* pRefCounters,
50  RenderDeviceD3D11Impl* pDevice,
51  const QueryDesc& Desc);
53 
55 
56 
57  virtual bool DILIGENT_CALL_TYPE GetData(void* pData, Uint32 DataSize, bool AutoInvalidate) override final;
58 
60  virtual void DILIGENT_CALL_TYPE Invalidate() override final
61  {
62  m_DisjointQuery.reset();
64  }
65 
67  virtual ID3D11Query* DILIGENT_CALL_TYPE GetD3D11Query(Uint32 QueryId) override final
68  {
69  VERIFY_EXPR(QueryId == 0 || m_Desc.Type == QUERY_TYPE_DURATION && QueryId == 1);
70  return m_pd3d11Query[QueryId];
71  }
72 
73  void SetDisjointQuery(std::shared_ptr<DisjointQueryPool::DisjointQueryWrapper> DisjointQuery)
74  {
75  m_DisjointQuery = DisjointQuery;
76  }
77 
78 private:
79  CComPtr<ID3D11Query> m_pd3d11Query[2];
80 
81  std::shared_ptr<DisjointQueryPool::DisjointQueryWrapper> m_DisjointQuery;
82 };
83 
84 } // namespace Diligent
Diligent::QueryD3D11Impl::Invalidate
virtual void Invalidate() override final
Implementation of IQuery::Invalidate().
Definition: QueryD3D11Impl.hpp:60
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
Diligent::QueryDesc
Query description.
Definition: Query.h:150
DisjointQueryPool.hpp
Diligent::DeviceObjectBase< EngineD3D11ImplTraits ::QueryInterface, EngineD3D11ImplTraits ::RenderDeviceImplType, QueryDesc >::m_Desc
QueryDesc m_Desc
Object description.
Definition: DeviceObjectBase.hpp:182
Diligent::QueryD3D11Impl::QueryD3D11Impl
QueryD3D11Impl(IReferenceCounters *pRefCounters, RenderDeviceD3D11Impl *pDevice, const QueryDesc &Desc)
Definition: QueryD3D11Impl.cpp:37
QueryBase.hpp
Diligent::QueryD3D11Impl
Query implementation in Direct3D11 backend.
Definition: QueryD3D11Impl.hpp:44
Diligent::QueryD3D11Impl::GetData
virtual bool GetData(void *pData, Uint32 DataSize, bool AutoInvalidate) override final
Implementation of IQuery::GetData().
Definition: QueryD3D11Impl.cpp:82
Diligent::QueryDesc::Type
enum QUERY_TYPE Type
Query type, see Diligent::QUERY_TYPE.
Definition: Query.h:153
Diligent::QueryD3D11Impl::~QueryD3D11Impl
~QueryD3D11Impl()
Definition: QueryD3D11Impl.cpp:78
Diligent::QueryD3D11Impl::GetD3D11Query
virtual ID3D11Query * GetD3D11Query(Uint32 QueryId) override final
Implementation of IQueryD3D11::GetD3D11Query().
Definition: QueryD3D11Impl.hpp:67
IMPLEMENT_QUERY_INTERFACE_IN_PLACE
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::QUERY_TYPE_DURATION
@ QUERY_TYPE_DURATION
Gets the number of high-frequency counter ticks between IDeviceContext::BeginQuery and IDeviceContext...
Definition: GraphicsTypes.h:1470
Diligent::QueryD3D11Impl::SetDisjointQuery
void SetDisjointQuery(std::shared_ptr< DisjointQueryPool::DisjointQueryWrapper > DisjointQuery)
Definition: QueryD3D11Impl.hpp:73
EngineD3D11ImplTraits.hpp
Diligent::QueryBase< EngineD3D11ImplTraits >::Invalidate
virtual void Invalidate() override
Definition: QueryBase.hpp:119
VERIFY_EXPR
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
Diligent::RenderDeviceD3D11Impl
Render device implementation in Direct3D11 backend.
Definition: RenderDeviceD3D11Impl.hpp:40
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
Diligent::QueryBase
Template class implementing base functionality of the query object.
Definition: QueryBase.hpp:45