Diligent Engine  v.2.4.g
QueryVkImpl.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 <array>
34 
35 #include "EngineVkImplTraits.hpp"
36 #include "QueryBase.hpp"
37 #include "QueryManagerVk.hpp"
38 
39 namespace Diligent
40 {
41 
43 class QueryVkImpl final : public QueryBase<EngineVkImplTraits>
44 {
45 public:
47 
48  QueryVkImpl(IReferenceCounters* pRefCounters,
49  RenderDeviceVkImpl* pRendeDeviceVkImpl,
50  const QueryDesc& Desc,
51  bool IsDeviceInternal = false);
52  ~QueryVkImpl();
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 
63  {
64  VERIFY_EXPR(QueryId == 0 || m_Desc.Type == QUERY_TYPE_DURATION && QueryId == 1);
65  return m_QueryPoolIndex[QueryId];
66  }
67 
68  bool OnEndQuery(IDeviceContext* pContext);
69  bool OnBeginQuery(IDeviceContext* pContext);
70 
71 private:
72  bool AllocateQueries();
73  void DiscardQueries();
74 
75  std::array<Uint32, 2> m_QueryPoolIndex = {QueryManagerVk::InvalidIndex, QueryManagerVk::InvalidIndex};
76 
77  Uint64 m_QueryEndFenceValue = 0;
78 };
79 
80 } // namespace Diligent
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
Diligent::RenderDeviceVkImpl
Render device implementation in Vulkan backend.
Definition: RenderDeviceVkImpl.hpp:58
Diligent::QueryVkImpl::GetData
virtual bool GetData(void *pData, Uint32 DataSize, bool AutoInvalidate) override final
Implementation of IQuery::GetData().
Definition: QueryVkImpl.cpp:133
Diligent::QueryDesc
Query description.
Definition: Query.h:150
Diligent::Uint64
uint64_t Uint64
64-bit unsigned integer
Definition: BasicTypes.h:50
Diligent::DeviceObjectBase< EngineVkImplTraits ::QueryInterface, EngineVkImplTraits ::RenderDeviceImplType, QueryDesc >::m_Desc
QueryDesc m_Desc
Object description.
Definition: DeviceObjectBase.hpp:182
QueryBase.hpp
Diligent::QueryVkImpl::QueryVkImpl
QueryVkImpl(IReferenceCounters *pRefCounters, RenderDeviceVkImpl *pRendeDeviceVkImpl, const QueryDesc &Desc, bool IsDeviceInternal=false)
Definition: QueryVkImpl.cpp:38
Diligent::QueryVkImpl
Query implementation in Vulkan backend.
Definition: QueryVkImpl.hpp:43
Diligent::QueryDesc::Type
enum QUERY_TYPE Type
Query type, see Diligent::QUERY_TYPE.
Definition: Query.h:153
Diligent::QueryVkImpl::OnBeginQuery
bool OnBeginQuery(IDeviceContext *pContext)
Definition: QueryVkImpl.cpp:104
Diligent::QueryVkImpl::OnEndQuery
bool OnEndQuery(IDeviceContext *pContext)
Definition: QueryVkImpl.cpp:111
IMPLEMENT_QUERY_INTERFACE_IN_PLACE
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
Diligent::QueryVkImpl::GetQueryPoolIndex
Uint32 GetQueryPoolIndex(Uint32 QueryId) const
Definition: QueryVkImpl.hpp:62
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::QueryVkImpl::~QueryVkImpl
~QueryVkImpl()
Definition: QueryVkImpl.cpp:54
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::QueryManagerVk::InvalidIndex
static constexpr Uint32 InvalidIndex
Definition: QueryManagerVk.hpp:60
Diligent::IDeviceContext
Device context interface.
Definition: DeviceContext.h:1460
Diligent::QueryVkImpl::Invalidate
virtual void Invalidate() override final
Implementation of IQuery::Invalidate().
Definition: QueryVkImpl.cpp:74
VERIFY_EXPR
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
EngineVkImplTraits.hpp
QueryManagerVk.hpp
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