From a8d6acd496404dc5b01df997ad9d07504d6ccf1b Mon Sep 17 00:00:00 2001 From: azhirnov Date: Wed, 18 Nov 2020 05:01:18 +0300 Subject: Removed SWAP_CHAIN_USAGE_UNORDERED_ACCESS, fixed shader group checks --- Graphics/GraphicsEngine/interface/GraphicsTypes.h | 6 +---- .../src/PipelineStateD3D12Impl.cpp | 4 ++-- .../include/SwapChainD3DBase.hpp | 1 + .../src/PipelineStateVkImpl.cpp | 18 ++++++++++----- .../GraphicsEngineVulkan/src/SwapChainVkImpl.cpp | 27 ++++++---------------- 5 files changed, 23 insertions(+), 33 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 08fc3571..736f7b3c 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -1261,12 +1261,8 @@ DILIGENT_TYPED_ENUM(SWAP_CHAIN_USAGE_FLAGS, Uint32) /// Swap chain images can be used as source of copy operation SWAP_CHAIN_USAGE_COPY_SOURCE = 0x04L, - - /// Swap chain images will define an unordered access view that will be used - /// for unordered read/write operations from the shaders - SWAP_CHAIN_USAGE_UNORDERED_ACCESS = 0x08L, - SWAP_CHAIN_USAGE_LAST = SWAP_CHAIN_USAGE_UNORDERED_ACCESS, + SWAP_CHAIN_USAGE_LAST = SWAP_CHAIN_USAGE_COPY_SOURCE, }; DEFINE_FLAG_ENUM_OPERATORS(SWAP_CHAIN_USAGE_FLAGS) diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp index 3c63b7d7..f98781eb 100644 --- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp @@ -205,7 +205,7 @@ void BuildRTPipelineDescription(const RayTracingPipelineStateCreateInfo& CreateI Subobjects.push_back({D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP, &HitGroupDesc}); } - constexpr Uint32 MaxPayloadSize = sizeof(float) * 8; + constexpr Uint32 DefaultPayloadSize = sizeof(float) * 8; constexpr Uint32 RecursionDepthLimit = D3D12_RAYTRACING_MAX_DECLARABLE_TRACE_RECURSION_DEPTH - 1; if (CreateInfo.RayTracingPipeline.MaxRecursionDepth > RecursionDepthLimit) @@ -218,7 +218,7 @@ void BuildRTPipelineDescription(const RayTracingPipelineStateCreateInfo& CreateI auto& ShaderConfig = *TempPool.Construct(); ShaderConfig.MaxAttributeSizeInBytes = CreateInfo.MaxAttributeSize == 0 ? D3D12_RAYTRACING_MAX_ATTRIBUTE_SIZE_IN_BYTES : CreateInfo.MaxAttributeSize; - ShaderConfig.MaxPayloadSizeInBytes = CreateInfo.MaxPayloadSize == 0 ? MaxPayloadSize : CreateInfo.MaxPayloadSize; + ShaderConfig.MaxPayloadSizeInBytes = CreateInfo.MaxPayloadSize == 0 ? DefaultPayloadSize : CreateInfo.MaxPayloadSize; Subobjects.push_back({D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG, &ShaderConfig}); #undef LOG_PSO_ERROR_AND_THROW } diff --git a/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp b/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp index 701361d1..f26bcc5e 100644 --- a/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp +++ b/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp @@ -157,6 +157,7 @@ protected: swapChainDesc.SampleDesc.Quality = 0; DEV_CHECK_ERR(m_SwapChainDesc.Usage != 0, "No swap chain usage flags defined"); + static_assert(SWAP_CHAIN_USAGE_LAST == SWAP_CHAIN_USAGE_COPY_SOURCE, "Please update this function to handle the new swapchain usage"); swapChainDesc.BufferUsage = 0; if (m_SwapChainDesc.Usage & SWAP_CHAIN_USAGE_RENDER_TARGET) swapChainDesc.BufferUsage |= DXGI_USAGE_RENDER_TARGET_OUTPUT; diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index fe7aa4c6..2949c928 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -428,8 +428,10 @@ void BuildRTPipelineDescription(const RayTracingPipelineStateCreateInfo& #ifdef DILIGENT_DEVELOPMENT auto Iter = NameToGroupIndex.find(GeneralShader.Name); - LOG_PSO_ERROR_AND_THROW(Iter != NameToGroupIndex.end(), "Can't find general shader '", GeneralShader.Name, "'"); - LOG_PSO_ERROR_AND_THROW(Iter->second == ShaderGroups.size(), "General shader group '", GeneralShader.Name, "' index mismatch: (", Iter->second, ") != (", ShaderGroups.size(), ")"); + if (Iter == NameToGroupIndex.end()) + LOG_PSO_ERROR_AND_THROW("Can't find general shader '", GeneralShader.Name, "'"); + if (Iter->second != ShaderGroups.size()) + LOG_PSO_ERROR_AND_THROW("General shader group '", GeneralShader.Name, "' index mismatch: (", Iter->second, ") != (", ShaderGroups.size(), ")"); #endif ShaderGroups.push_back(Group); @@ -450,8 +452,10 @@ void BuildRTPipelineDescription(const RayTracingPipelineStateCreateInfo& #ifdef DILIGENT_DEVELOPMENT auto Iter = NameToGroupIndex.find(TriHitShader.Name); - LOG_PSO_ERROR_AND_THROW(Iter != NameToGroupIndex.end(), "Can't find triangle hit group '", TriHitShader.Name, "'"); - LOG_PSO_ERROR_AND_THROW(Iter->second == ShaderGroups.size(), "Triangle hit group '", TriHitShader.Name, "' index mismatch: (", Iter->second, ") != (", ShaderGroups.size(), ")"); + if (Iter == NameToGroupIndex.end()) + LOG_PSO_ERROR_AND_THROW("Can't find triangle hit group '", TriHitShader.Name, "'"); + if (Iter->second != ShaderGroups.size()) + LOG_PSO_ERROR_AND_THROW("Triangle hit group '", TriHitShader.Name, "' index mismatch: (", Iter->second, ") != (", ShaderGroups.size(), ")"); #endif ShaderGroups.push_back(Group); @@ -472,8 +476,10 @@ void BuildRTPipelineDescription(const RayTracingPipelineStateCreateInfo& #ifdef DILIGENT_DEVELOPMENT auto Iter = NameToGroupIndex.find(ProcHitShader.Name); - LOG_PSO_ERROR_AND_THROW(Iter != NameToGroupIndex.end(), "Can't find procedural hit group '", ProcHitShader.Name, "'"); - LOG_PSO_ERROR_AND_THROW(Iter->second == ShaderGroups.size(), "Procedural hit group '", ProcHitShader.Name, "' index mismatch: (", Iter->second, ") != (", ShaderGroups.size(), ")"); + if (Iter == NameToGroupIndex.end()) + LOG_PSO_ERROR_AND_THROW("Can't find procedural hit group '", ProcHitShader.Name, "'"); + if (Iter->second != ShaderGroups.size()) + LOG_PSO_ERROR_AND_THROW("Procedural hit group '", ProcHitShader.Name, "' index mismatch: (", Iter->second, ") != (", ShaderGroups.size(), ")"); #endif ShaderGroups.push_back(Group); diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp index d32f9788..7fbe6265 100644 --- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp @@ -423,26 +423,13 @@ void SwapChainVkImpl::CreateVulkanSwapChain() swapchain_ci.imageColorSpace = ColorSpace; DEV_CHECK_ERR(m_SwapChainDesc.Usage != 0, "No swap chain usage flags defined"); - static_assert(SWAP_CHAIN_USAGE_LAST == SWAP_CHAIN_USAGE_UNORDERED_ACCESS, "Please update this function to handle the new swapchain usage"); - - { - auto SCUsage = m_SwapChainDesc.Usage; - while (SCUsage != SWAP_CHAIN_USAGE_NONE) - { - auto UsageBit = static_cast(1 << PlatformMisc::GetLSB(Uint32{SCUsage})); - switch (UsageBit) - { - // clang-format off - case SWAP_CHAIN_USAGE_RENDER_TARGET: swapchain_ci.imageUsage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; break; - case SWAP_CHAIN_USAGE_SHADER_INPUT: swapchain_ci.imageUsage |= VK_IMAGE_USAGE_SAMPLED_BIT; break; - case SWAP_CHAIN_USAGE_COPY_SOURCE: swapchain_ci.imageUsage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; break; - case SWAP_CHAIN_USAGE_UNORDERED_ACCESS: swapchain_ci.imageUsage |= VK_IMAGE_USAGE_STORAGE_BIT; break; - // clang-format on - default: UNEXPECTED("unknown swapchain usage flag"); - } - SCUsage &= ~UsageBit; - } - } + static_assert(SWAP_CHAIN_USAGE_LAST == SWAP_CHAIN_USAGE_COPY_SOURCE, "Please update this function to handle the new swapchain usage"); + if (m_SwapChainDesc.Usage & SWAP_CHAIN_USAGE_RENDER_TARGET) + swapchain_ci.imageUsage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + if (m_SwapChainDesc.Usage & SWAP_CHAIN_USAGE_SHADER_INPUT) + swapchain_ci.imageUsage |= VK_IMAGE_USAGE_SAMPLED_BIT; + if (m_SwapChainDesc.Usage & SWAP_CHAIN_USAGE_COPY_SOURCE) + swapchain_ci.imageUsage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; // vkCmdClearColorImage() command requires the image to use VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL layout // that requires VK_IMAGE_USAGE_TRANSFER_DST_BIT to be set -- cgit v1.2.3