diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-01-03 06:29:01 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-01-03 06:29:01 +0000 |
| commit | 7501af2487700060526c5b0c7fc78cc1ee2965cf (patch) | |
| tree | ed71d7704284e995bfbf17361fb82f4aa7e8dd79 /Graphics/GraphicsEngineVulkan | |
| parent | Updated third-party submodules (diff) | |
| download | DiligentCore-7501af2487700060526c5b0c7fc78cc1ee2965cf.tar.gz DiligentCore-7501af2487700060526c5b0c7fc78cc1ee2965cf.zip | |
Added query interface; implemented queries in D3D11 and D3D12
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
9 files changed, 219 insertions, 1 deletions
diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt index af3dbcd4..df141edb 100644 --- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt +++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt @@ -17,6 +17,7 @@ set(INCLUDE include/pch.h include/PipelineLayout.h include/PipelineStateVkImpl.h + include/QueryVkImpl.h include/RenderDeviceVkImpl.h include/RenderPassCache.h include/SamplerVkImpl.h @@ -55,6 +56,7 @@ set(INTERFACE interface/EngineFactoryVk.h interface/FenceVk.h interface/PipelineStateVk.h + interface/QueryVk.h interface/RenderDeviceVk.h interface/SamplerVk.h interface/ShaderVk.h @@ -79,6 +81,7 @@ set(SRC src/GenerateMipsVkHelper.cpp src/PipelineLayout.cpp src/PipelineStateVkImpl.cpp + src/QueryVkImpl.cpp src/RenderDeviceVkImpl.cpp src/RenderPassCache.cpp src/SamplerVkImpl.cpp diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index dd8c622e..48a3a41b 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -44,6 +44,7 @@ #include "BufferVkImpl.h" #include "TextureVkImpl.h" #include "PipelineStateVkImpl.h" +#include "QueryVkImpl.h" #include "HashUtils.h" #include "ManagedVulkanObject.h" @@ -59,6 +60,7 @@ struct DeviceContextVkImplTraits using PipelineStateType = PipelineStateVkImpl; using DeviceType = RenderDeviceVkImpl; using ICommandQueueType = ICommandQueueVk; + using QueryType = QueryVkImpl; }; /// Device context implementation in Vulkan backend. @@ -206,6 +208,12 @@ public: /// Implementation of IDeviceContext::WaitForIdle() in Vulkan backend. virtual void WaitForIdle() override final; + /// Implementation of IDeviceContext::BeginQuery() in Vulkan backend. + virtual void BeginQuery(IQuery* pQuery) override final; + + /// Implementation of IDeviceContext::EndQuery() in Vulkan backend. + virtual void EndQuery(IQuery* pQuery) override final; + /// Implementation of IDeviceContext::Flush() in Vulkan backend. virtual void Flush() override final; diff --git a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h index 600b90c0..4743ba11 100644 --- a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h @@ -53,6 +53,8 @@ public: bool IsDeviceInternal = false); ~FenceVkImpl(); + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_FenceVk, TFenceBase); + /// Implementation of IFence::GetCompletedValue() in Vulkan backend. /// Note that this method is not thread-safe. The reason is that VulkanFencePool is not thread /// safe, and DeviceContextVkImpl::SignalFence() adds the fence to the pending fences list that diff --git a/Graphics/GraphicsEngineVulkan/include/QueryVkImpl.h b/Graphics/GraphicsEngineVulkan/include/QueryVkImpl.h new file mode 100644 index 00000000..3574cdfd --- /dev/null +++ b/Graphics/GraphicsEngineVulkan/include/QueryVkImpl.h @@ -0,0 +1,61 @@ +/* + * 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 +/// Declaration of Diligent::QueryVkImpl class + +#include "QueryVk.h" +#include "QueryBase.h" +#include "RenderDeviceVkImpl.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Query implementation in Vulkan backend. +class QueryVkImpl final : public QueryBase<IQueryVk, RenderDeviceVkImpl> +{ +public: + using TQueryBase = QueryBase<IQueryVk, RenderDeviceVkImpl>; + + QueryVkImpl(IReferenceCounters* pRefCounters, + RenderDeviceVkImpl* pRendeDeviceVkImpl, + const QueryDesc& Desc, + bool IsDeviceInternal = false); + ~QueryVkImpl(); + + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_QueryVk, TQueryBase); + + virtual bool GetData(void* pData, Uint32 DataSize) override final; + +private: +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h index 8545f95a..bbdab268 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h @@ -92,6 +92,9 @@ public: /// Implementation of IRenderDevice::CreateFence() in Vulkan backend. virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence) override final; + /// Implementation of IRenderDevice::CreateQuery() in Vulkan backend. + virtual void CreateQuery(const QueryDesc& Desc, IQuery** ppQuery) override final; + /// Implementation of IRenderDeviceVk::GetVkDevice(). virtual VkDevice GetVkDevice() override final { return m_LogicalVkDevice->GetVkDevice(); } diff --git a/Graphics/GraphicsEngineVulkan/interface/QueryVk.h b/Graphics/GraphicsEngineVulkan/interface/QueryVk.h new file mode 100644 index 00000000..b4debdfe --- /dev/null +++ b/Graphics/GraphicsEngineVulkan/interface/QueryVk.h @@ -0,0 +1,47 @@ +/* + * 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 +/// Definition of the Diligent::IQueryVk interface + +#include "../../GraphicsEngine/interface/Query.h" + +namespace Diligent +{ + +// {161C015B-1FE2-4452-8BFF-E35F27B3103C} +static constexpr INTERFACE_ID IID_QueryVk = + {0x161c015b, 0x1fe2, 0x4452, {0x8b, 0xff, 0xe3, 0x5f, 0x27, 0xb3, 0x10, 0x3c}}; + +/// Exposes Vulkan-specific functionality of a Query object. +class IQueryVk : public IQuery +{ +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 1a9ca867..d6e9b826 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -1990,6 +1990,23 @@ void DeviceContextVkImpl::WaitForIdle() m_pDevice->IdleCommandQueue(m_CommandQueueId, true); } +void DeviceContextVkImpl::BeginQuery(IQuery* pQuery) +{ + if (!TDeviceContextBase::BeginQuery(pQuery, 0)) + return; + + auto* pQueryVkImpl = ValidatedCast<QueryVkImpl>(pQuery); +} + +void DeviceContextVkImpl::EndQuery(IQuery* pQuery) +{ + if (!TDeviceContextBase::EndQuery(pQuery, 0)) + return; + + auto* pQueryVkImpl = ValidatedCast<QueryVkImpl>(pQuery); +} + + void DeviceContextVkImpl::TransitionImageLayout(ITexture* pTexture, VkImageLayout NewLayout) { VERIFY_EXPR(pTexture != nullptr); diff --git a/Graphics/GraphicsEngineVulkan/src/QueryVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/QueryVkImpl.cpp new file mode 100644 index 00000000..c76b3461 --- /dev/null +++ b/Graphics/GraphicsEngineVulkan/src/QueryVkImpl.cpp @@ -0,0 +1,62 @@ +/* + * 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 neVkigence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly neVkigent 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. + */ + +#include "pch.h" + +#include "QueryVkImpl.h" +#include "EngineMemory.h" +#include "RenderDeviceVkImpl.h" + +namespace Diligent +{ + +QueryVkImpl::QueryVkImpl(IReferenceCounters* pRefCounters, + RenderDeviceVkImpl* pRendeDeviceVkImpl, + const QueryDesc& Desc, + bool IsDeviceInternal) : + // clang-format off + TQueryBase + { + pRefCounters, + pRendeDeviceVkImpl, + Desc, + IsDeviceInternal + } +// clang-format on +{ +} + +QueryVkImpl::~QueryVkImpl() +{ +} + +bool QueryVkImpl::GetData(void* pData, Uint32 DataSize) +{ + return false; +} + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 63d2e38c..8b6c93da 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -36,6 +36,7 @@ #include "ShaderResourceBindingVkImpl.h" #include "DeviceContextVkImpl.h" #include "FenceVkImpl.h" +#include "QueryVkImpl.h" #include "EngineMemory.h" namespace Diligent @@ -69,7 +70,8 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters* sizeof(SamplerVkImpl), sizeof(PipelineStateVkImpl), sizeof(ShaderResourceBindingVkImpl), - sizeof(FenceVkImpl) + sizeof(FenceVkImpl), + sizeof(QueryVkImpl) } }, m_VulkanInstance {Instance }, @@ -563,4 +565,17 @@ void RenderDeviceVkImpl::CreateFence(const FenceDesc& Desc, IFence** ppFence) ); } +void RenderDeviceVkImpl::CreateQuery(const QueryDesc& Desc, IQuery** ppQuery) +{ + CreateDeviceObject( + "Query", Desc, ppQuery, + [&]() // + { + QueryVkImpl* pQueryVk(NEW_RC_OBJ(m_QueryAllocator, "QueryVkImpl instance", QueryVkImpl)(this, Desc)); + pQueryVk->QueryInterface(IID_Query, reinterpret_cast<IObject**>(ppQuery)); + OnCreateDeviceObject(pQueryVk); + } // + ); +} + } // namespace Diligent |
