From a979f2e10e87ea534c923fa6303248df834521e3 Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 6 Jan 2020 22:42:47 -0800 Subject: Vulkan backend: fixed issues with occlusion and pipeline stats queries if they are not supported by device --- Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp | 4 ++-- Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp index 6c457ce2..24e0c614 100644 --- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp @@ -196,8 +196,8 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& _E ENABLE_FEATURE(shaderStorageImageExtendedFormats) #undef ENABLE_FEATURE - DeviceFeatures.pipelineStatisticsQuery = VK_TRUE; - DeviceFeatures.occlusionQueryPrecise = VK_TRUE; + DeviceFeatures.pipelineStatisticsQuery = PhysicalDeviceFeatures.pipelineStatisticsQuery; + DeviceFeatures.occlusionQueryPrecise = PhysicalDeviceFeatures.occlusionQueryPrecise; DeviceCreateInfo.pEnabledFeatures = &DeviceFeatures; // NULL or a pointer to a VkPhysicalDeviceFeatures structure that contains // boolean indicators of all the features to be enabled. diff --git a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp index d7a47a6d..18db0546 100644 --- a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp @@ -47,8 +47,14 @@ QueryManagerVk::QueryManagerVk(RenderDeviceVkImpl* pRenderDeviceVk, VkCommandBuffer vkCmdBuff; pRenderDeviceVk->AllocateTransientCmdPool(CmdPool, vkCmdBuff, "Transient command pool to reset queries before first use"); + const auto& deviceFeatures = PhysicalDevice.GetFeatures(); + for (Uint32 QueryType = QUERY_TYPE_UNDEFINED + 1; QueryType < QUERY_TYPE_NUM_TYPES; ++QueryType) { + if (QueryType == QUERY_TYPE_OCCLUSION && !deviceFeatures.occlusionQueryPrecise || + QueryType == QUERY_TYPE_PIPELINE_STATISTICS && !deviceFeatures.pipelineStatisticsQuery) + continue; + // clang-format off static_assert(QUERY_TYPE_OCCLUSION == 1, "Unexpected value of QUERY_TYPE_OCCLUSION. EngineVkCreateInfo::QueryPoolSizes must be updated"); static_assert(QUERY_TYPE_BINARY_OCCLUSION == 2, "Unexpected value of QUERY_TYPE_BINARY_OCCLUSION. EngineVkCreateInfo::QueryPoolSizes must be updated"); -- cgit v1.2.3