From 4a30933359205a2bc72db600175ce783b61b0f5f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 12 Jan 2023 19:09:24 +0100 Subject: [PATCH] [dxvk] Add UBO set property to descriptor info Used to explicitly propagate storage buffer bindings to the respective UBO set. --- src/d3d11/d3d11_video.cpp | 2 +- src/d3d9/d3d9_fixed_function.cpp | 6 ++++++ src/d3d9/d3d9_swvp_emu.cpp | 1 + src/dxbc/dxbc_compiler.cpp | 1 + src/dxso/dxso_compiler.cpp | 4 ++++ src/dxvk/dxvk_pipelayout.cpp | 12 +++++++----- src/dxvk/dxvk_pipelayout.h | 1 + 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/d3d11/d3d11_video.cpp b/src/d3d11/d3d11_video.cpp index 0e0a4897a..e98210330 100644 --- a/src/d3d11/d3d11_video.cpp +++ b/src/d3d11/d3d11_video.cpp @@ -329,7 +329,7 @@ namespace dxvk { SpirvCodeBuffer fsCode(d3d11_video_blit_frag); const std::array fsBindings = {{ - { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, VK_IMAGE_VIEW_TYPE_MAX_ENUM, VK_SHADER_STAGE_FRAGMENT_BIT, VK_ACCESS_UNIFORM_READ_BIT }, + { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, VK_IMAGE_VIEW_TYPE_MAX_ENUM, VK_SHADER_STAGE_FRAGMENT_BIT, VK_ACCESS_UNIFORM_READ_BIT, VK_TRUE }, { VK_DESCRIPTOR_TYPE_SAMPLER, 1, VK_IMAGE_VIEW_TYPE_MAX_ENUM, VK_SHADER_STAGE_FRAGMENT_BIT, 0 }, { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 2, VK_IMAGE_VIEW_TYPE_2D, VK_SHADER_STAGE_FRAGMENT_BIT, VK_ACCESS_SHADER_READ_BIT }, { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 3, VK_IMAGE_VIEW_TYPE_2D, VK_SHADER_STAGE_FRAGMENT_BIT, VK_ACCESS_SHADER_READ_BIT }, diff --git a/src/d3d9/d3d9_fixed_function.cpp b/src/d3d9/d3d9_fixed_function.cpp index f8225222e..7b6b379bb 100644 --- a/src/d3d9/d3d9_fixed_function.cpp +++ b/src/d3d9/d3d9_fixed_function.cpp @@ -423,6 +423,7 @@ namespace dxvk { binding.resourceBinding = getSpecConstantBufferSlot(); binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; + binding.uboSet = VK_TRUE; bindings.push_back(binding); return specBlock; @@ -1577,6 +1578,7 @@ namespace dxvk { binding.resourceBinding = bindingId; binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); } @@ -1616,6 +1618,7 @@ namespace dxvk { binding.resourceBinding = bindingId; binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_SHADER_READ_BIT; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); } @@ -2227,6 +2230,7 @@ namespace dxvk { binding.resourceBinding = bindingId; binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); // Load constants @@ -2314,6 +2318,7 @@ namespace dxvk { binding.resourceBinding = bindingId; binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); } @@ -2353,6 +2358,7 @@ namespace dxvk { binding.resourceBinding = bindingId; binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); // Declare output array for clip distances diff --git a/src/d3d9/d3d9_swvp_emu.cpp b/src/d3d9/d3d9_swvp_emu.cpp index 39bf3da1d..210edf01f 100644 --- a/src/d3d9/d3d9_swvp_emu.cpp +++ b/src/d3d9/d3d9_swvp_emu.cpp @@ -135,6 +135,7 @@ namespace dxvk { m_bufferBinding.resourceBinding = bufferSlot; m_bufferBinding.stage = VK_SHADER_STAGE_GEOMETRY_BIT; m_bufferBinding.access = VK_ACCESS_SHADER_WRITE_BIT; + m_bufferBinding.uboSet = VK_TRUE; // Load our builtins uint32_t primitiveIdPtr = m_module.newVar(m_module.defPointerType(uint_t, spv::StorageClassInput), spv::StorageClassInput); diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index 110f9b0d4..01f715e04 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -862,6 +862,7 @@ namespace dxvk { binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; binding.resourceBinding = bindingId; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); } diff --git a/src/dxso/dxso_compiler.cpp b/src/dxso/dxso_compiler.cpp index f453f8172..00e734247 100644 --- a/src/dxso/dxso_compiler.cpp +++ b/src/dxso/dxso_compiler.cpp @@ -307,6 +307,7 @@ namespace dxvk { binding.resourceBinding = bindingId; binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); } @@ -398,6 +399,7 @@ namespace dxvk { binding.access = asSsbo ? VK_ACCESS_SHADER_READ_BIT : VK_ACCESS_UNIFORM_READ_BIT; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); return constantBufferId; @@ -483,6 +485,7 @@ namespace dxvk { binding.resourceBinding = bindingId; binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); } @@ -3457,6 +3460,7 @@ void DxsoCompiler::emitControlFlowGenericLoop( binding.resourceBinding = bindingId; binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; + binding.uboSet = VK_TRUE; m_bindings.push_back(binding); // Declare output array for clip distances diff --git a/src/dxvk/dxvk_pipelayout.cpp b/src/dxvk/dxvk_pipelayout.cpp index ef40431b9..88b9083b6 100644 --- a/src/dxvk/dxvk_pipelayout.cpp +++ b/src/dxvk/dxvk_pipelayout.cpp @@ -34,11 +34,12 @@ namespace dxvk { bool DxvkBindingInfo::eq(const DxvkBindingInfo& other) const { - return descriptorType == other.descriptorType - && resourceBinding == other.resourceBinding - && viewType == other.viewType - && stage == other.stage - && access == other.access; + return descriptorType == other.descriptorType + && resourceBinding == other.resourceBinding + && viewType == other.viewType + && stage == other.stage + && access == other.access + && uboSet == other.uboSet; } @@ -49,6 +50,7 @@ namespace dxvk { hash.add(uint32_t(viewType)); hash.add(uint32_t(stage)); hash.add(access); + hash.add(uint32_t(uboSet)); return hash; } diff --git a/src/dxvk/dxvk_pipelayout.h b/src/dxvk/dxvk_pipelayout.h index 8c03d6dd6..66599ea0f 100644 --- a/src/dxvk/dxvk_pipelayout.h +++ b/src/dxvk/dxvk_pipelayout.h @@ -36,6 +36,7 @@ namespace dxvk { VkImageViewType viewType; ///< Image view type VkShaderStageFlagBits stage; ///< Shader stage VkAccessFlags access; ///< Access mask for the resource + VkBool32 uboSet; ///< Whether to include this in the UBO set /** * \brief Computes descriptor set index for the given binding