@@ -417,15 +417,18 @@ void PipelineResourceSignatureVkImpl::CreateSetLayouts(const bool IsSerialized)
417417
418418 if (!IsPushConstant && m_pDevice)
419419 {
420- // Create a USAGE_DYNAMIC uniform buffer for emulating inline constants
420+ // Create a USAGE_STAGING uniform buffer for emulating inline constants.
421+ // Using USAGE_STAGING ensures the buffer has a backing VkBuffer resource with
422+ // persistently mapped host-visible memory, avoiding Dynamic Buffer ID reuse issues
423+ // that can occur with USAGE_DYNAMIC buffers (which suballocate from dynamic heap).
421424 // All SRBs created from this signature will share the same inline constant buffer.
422425 std::string Name = m_Desc.Name ;
423426 Name += " - " ;
424427 Name += ResDesc.Name ;
425428 BufferDesc CBDesc;
426429 CBDesc.Name = Name.c_str ();
427430 CBDesc.Size = ResDesc.ArraySize * sizeof (Uint32);
428- CBDesc.Usage = USAGE_DYNAMIC ;
431+ CBDesc.Usage = USAGE_STAGING ;
429432 CBDesc.BindFlags = BIND_UNIFORM_BUFFER;
430433 CBDesc.CPUAccessFlags = CPU_ACCESS_WRITE;
431434
@@ -686,7 +689,7 @@ void PipelineResourceSignatureVkImpl::InitSRBResourceCache(ShaderResourceCacheVk
686689 {
687690 // Ensure the cache reports inline constants so DeviceContextVkImpl
688691 // updates emulated buffers even if no data has been written yet.
689- ResourceCache.MarkHasInlineConstants ();
692+ // ResourceCache.MarkHasInlineConstants();
690693
691694 // Count push constant buffers and calculate total memory size
692695 Uint32 NumPushConstantBuffers = 0 ;
@@ -1340,11 +1343,12 @@ void PipelineResourceSignatureVkImpl::UpdateInlineConstantBuffers(const ShaderRe
13401343 const void * pInlineConstantData = ResourceCache.GetInlineConstantData (InlineCBAttr.DescrSet , InlineCBAttr.BindingIndex );
13411344 VERIFY_EXPR (pInlineConstantData != nullptr );
13421345
1343- // Map the buffer and copy the data
1344- void * pMappedData = nullptr ;
1345- Ctx.MapBuffer (InlineCBAttr.pBuffer , MAP_WRITE, MAP_FLAG_DISCARD, pMappedData);
1346- memcpy (pMappedData, pInlineConstantData, DataSize);
1347- Ctx.UnmapBuffer (InlineCBAttr.pBuffer , MAP_WRITE);
1346+ // Copy data directly to the buffer's CPU address.
1347+ // USAGE_STAGING buffer has a backing VkBuffer resource with persistently mapped
1348+ // host-visible memory, so we can write directly without Map/Unmap.
1349+ void * pDstData = InlineCBAttr.pBuffer ->GetCPUAddress ();
1350+ VERIFY_EXPR (pDstData != nullptr );
1351+ memcpy (pDstData, pInlineConstantData, DataSize);
13481352 continue ;
13491353 }
13501354 }
0 commit comments