Skip to content

Commit 08d88fd

Browse files
committed
1 parent 820adc3 commit 08d88fd

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,13 +1146,21 @@ void PipelineResourceSignatureVkImpl::CommitInlineConstants(const CommitInlineCo
11461146
}
11471147
else
11481148
{
1149-
VERIFY_EXPR(InlineCBAttr.pBuffer);
1150-
1151-
// Map the shared buffer and copy the data
1149+
// Get the buffer from the SRB cache (not from the signature's InlineCBAttr.pBuffer).
1150+
// This ensures we update the same buffer that was bound to the descriptor set during SRB initialization.
1151+
// When an SRB created from a compatible but different signature is used (e.g., via PSO serialization),
1152+
// the SRB's cache contains buffer pointers from the original signature's shared buffers.
1153+
// By updating the buffer from cache, we maintain consistency with D3D11's design.
1154+
const ShaderResourceCacheVk::DescriptorSet& DescrSet = ResourceCache.GetDescriptorSet(InlineCBAttr.DescrSet);
1155+
const ShaderResourceCacheVk::Resource& CachedRes = DescrSet.GetResource(InlineCBAttr.SRBCacheOffset);
1156+
BufferVkImpl* pBuffer = CachedRes.pObject.RawPtr<BufferVkImpl>();
1157+
VERIFY(pBuffer != nullptr, "Inline constant buffer is null in SRB cache");
1158+
1159+
// Map the buffer from SRB cache and copy the data
11521160
void* pMappedData = nullptr;
1153-
Attribs.Ctx.MapBuffer(InlineCBAttr.pBuffer, MAP_WRITE, MAP_FLAG_DISCARD, pMappedData);
1161+
Attribs.Ctx.MapBuffer(pBuffer, MAP_WRITE, MAP_FLAG_DISCARD, pMappedData);
11541162
memcpy(pMappedData, pInlineConstantData, DataSize);
1155-
Attribs.Ctx.UnmapBuffer(InlineCBAttr.pBuffer, MAP_WRITE);
1163+
Attribs.Ctx.UnmapBuffer(pBuffer, MAP_WRITE);
11561164
}
11571165
}
11581166
}

0 commit comments

Comments
 (0)