From bf3aeede478e51bffa1be8dd8599fd6f6ee28a54 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 29 Oct 2024 09:55:40 -0700 Subject: [PATCH] Vulkan: zero-initialize descriptor write info in CommitDynamicResources --- .../src/PipelineResourceSignatureVkImpl.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp index 352653e5d..1f92ce0c7 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp @@ -639,23 +639,23 @@ void PipelineResourceSignatureVkImpl::CommitDynamicResources(const ShaderResourc auto AccelStructIt = DescrAccelStructArr.begin(); auto WriteDescrSetIt = WriteDescrSetArr.begin(); - const auto DynamicSetIdx = GetDescriptorSetIndex(); - const auto& SetResources = ResourceCache.GetDescriptorSet(DynamicSetIdx); - const auto& LogicalDevice = GetDevice()->GetLogicalDevice(); - const auto DynResIdxRange = GetResourceIndexRange(SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); + const Uint32 DynamicSetIdx = GetDescriptorSetIndex(); + const ShaderResourceCacheVk::DescriptorSet& SetResources = ResourceCache.GetDescriptorSet(DynamicSetIdx); + const VulkanUtilities::VulkanLogicalDevice& LogicalDevice = GetDevice()->GetLogicalDevice(); + const std::pair DynResIdxRange = GetResourceIndexRange(SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); - constexpr auto CacheType = ResourceCacheContentType::SRB; + constexpr ResourceCacheContentType CacheType = ResourceCacheContentType::SRB; for (Uint32 ResIdx = DynResIdxRange.first, ArrElem = 0; ResIdx < DynResIdxRange.second;) { - const auto& Attr = GetResourceAttribs(ResIdx); - const auto CacheOffset = Attr.CacheOffset(CacheType); - const auto ArraySize = Attr.ArraySize; - const auto DescrType = Attr.GetDescriptorType(); + const PipelineResourceAttribsType& Attr = GetResourceAttribs(ResIdx); + const Uint32 CacheOffset = Attr.CacheOffset(CacheType); + const Uint32 ArraySize = Attr.ArraySize; + const DescriptorType DescrType = Attr.GetDescriptorType(); #ifdef DILIGENT_DEBUG { - const auto& Res = GetResourceDesc(ResIdx); + const PipelineResourceDesc& Res = GetResourceDesc(ResIdx); VERIFY_EXPR(ArraySize == GetResourceDesc(ResIdx).ArraySize); VERIFY_EXPR(Res.VarType == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); } @@ -670,14 +670,17 @@ void PipelineResourceSignatureVkImpl::CommitDynamicResources(const ShaderResourc WriteDescrSetIt->dstArrayElement = ArrElem; // descriptorType must be the same type as that specified in VkDescriptorSetLayoutBinding for dstSet at dstBinding. // The type of the descriptor also controls which array the descriptors are taken from. (13.2.4) - WriteDescrSetIt->descriptorType = DescriptorTypeToVkDescriptorType(DescrType); - WriteDescrSetIt->descriptorCount = 0; + WriteDescrSetIt->descriptorType = DescriptorTypeToVkDescriptorType(DescrType); + WriteDescrSetIt->descriptorCount = 0; + WriteDescrSetIt->pImageInfo = nullptr; + WriteDescrSetIt->pBufferInfo = nullptr; + WriteDescrSetIt->pTexelBufferView = nullptr; auto WriteArrayElements = [&](auto DescrType, auto& DescrIt, const auto& DescrArr) // { while (ArrElem < ArraySize && DescrIt != DescrArr.end()) { - if (const auto& CachedRes = SetResources.GetResource(CacheOffset + (ArrElem++))) + if (const ShaderResourceCacheVk::Resource& CachedRes = SetResources.GetResource(CacheOffset + (ArrElem++))) { *DescrIt = CachedRes.GetDescriptorWriteInfo(); ++DescrIt; @@ -786,7 +789,7 @@ void PipelineResourceSignatureVkImpl::CommitDynamicResources(const ShaderResourc } } - auto DescrWriteCount = static_cast(std::distance(WriteDescrSetArr.begin(), WriteDescrSetIt)); + Uint32 DescrWriteCount = static_cast(std::distance(WriteDescrSetArr.begin(), WriteDescrSetIt)); if (DescrWriteCount > 0) LogicalDevice.UpdateDescriptorSets(DescrWriteCount, WriteDescrSetArr.data(), 0, nullptr); }