Skip to content

Commit 00d63c4

Browse files
InlineConstantBufferAttribsVk: add SRBCacheOffset to facilitate data retrieval
1 parent f8d2a37 commit 00d63c4

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ ASSERT_SIZEOF(ImmutableSamplerAttribsVk, 8, "The struct is used in serialization
6868
/// one inline constant is selected to be the native push constant block.
6969
struct InlineConstantBufferAttribsVk
7070
{
71-
Uint32 ResIndex = 0; // Resource index in the signature
72-
Uint32 DescrSet = 0; // Descriptor set index
73-
Uint32 BindingIndex = 0; // Binding index within the descriptor set
74-
Uint32 NumConstants = 0; // Number of 32-bit constants
71+
Uint32 ResIndex = 0; // Resource index in the signature
72+
Uint32 DescrSet = 0; // Descriptor set index
73+
Uint32 BindingIndex = 0; // Binding index within the descriptor set
74+
Uint32 NumConstants = 0; // Number of 32-bit constants
75+
Uint32 SRBCacheOffset = 0; // Offset in the SRB resource cache
7576

7677
// Shared buffer created in the Signature.
7778
// All SRBs reference this same buffer to reduce memory usage.

Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ void PipelineResourceSignatureVkImpl::CreateSetLayouts(const bool IsSerialized)
406406
InlineCBAttribs.DescrSet = pAttribs->DescrSet;
407407
InlineCBAttribs.BindingIndex = pAttribs->BindingIndex;
408408
InlineCBAttribs.NumConstants = ResDesc.ArraySize; // For inline constants, ArraySize is the number of 32-bit constants
409+
InlineCBAttribs.SRBCacheOffset = pAttribs->SRBCacheOffset;
409410

410411
// Create a shared buffer in the Signature for all inline constants.
411412
// All SRBs will reference this same buffer.
@@ -956,8 +957,6 @@ bool PipelineResourceSignatureVkImpl::DvpValidateCommittedResource(const DeviceC
956957

957958
VERIFY_EXPR(SPIRVAttribs.ArraySize <= ResAttribs.ArraySize);
958959

959-
// TODO: verify how this works for push constants
960-
961960
bool BindingsOK = true;
962961
for (Uint32 ArrIndex = 0; ArrIndex < SPIRVAttribs.ArraySize; ++ArrIndex)
963962
{
@@ -1129,18 +1128,15 @@ void PipelineResourceSignatureVkImpl::UpdateInlineConstantBuffers(const ShaderRe
11291128
{
11301129
VERIFY(ResourceCache.GetContentType() == ResourceCacheContentType::SRB,
11311130
"Inline constant buffers can be updated only in SRB resource caches");
1132-
constexpr ResourceCacheContentType CacheType = ResourceCacheContentType::SRB;
11331131
for (Uint32 i = 0; i < m_NumInlineConstantBuffers; ++i)
11341132
{
11351133
const InlineConstantBufferAttribsVk& InlineCBAttr = m_InlineConstantBuffers[i];
11361134
// Skip native push constants - they are handled directly by CommitPushConstants
11371135
if (InlineCBAttr.ResIndex == PushConstantResIndex)
11381136
continue;
11391137

1140-
const Uint32 DataSize = InlineCBAttr.NumConstants * sizeof(Uint32);
1141-
const ResourceAttribs& Attr = GetResourceAttribs(InlineCBAttr.ResIndex);
1142-
const Uint32 CacheOffset = Attr.CacheOffset(CacheType);
1143-
const void* pInlineConstantData = ResourceCache.GetInlineConstantData(Attr.DescrSet, CacheOffset);
1138+
const Uint32 DataSize = InlineCBAttr.NumConstants * sizeof(Uint32);
1139+
const void* pInlineConstantData = ResourceCache.GetInlineConstantData(InlineCBAttr.DescrSet, InlineCBAttr.SRBCacheOffset);
11441140
VERIFY_EXPR(pInlineConstantData != nullptr);
11451141
VERIFY_EXPR(InlineCBAttr.pBuffer);
11461142

@@ -1154,16 +1150,15 @@ void PipelineResourceSignatureVkImpl::UpdateInlineConstantBuffers(const ShaderRe
11541150

11551151
const void* PipelineResourceSignatureVkImpl::GetPushConstantData(const ShaderResourceCacheVk& ResourceCache, Uint32 ResIndex) const
11561152
{
1153+
VERIFY(ResourceCache.GetContentType() == ResourceCacheContentType::SRB,
1154+
"Push constant data can be retrieved only from SRB resource caches");
11571155
// Find the inline constant buffer with the specified resource index
11581156
for (Uint32 i = 0; i < m_NumInlineConstantBuffers; ++i)
11591157
{
11601158
const InlineConstantBufferAttribsVk& InlineCBAttr = m_InlineConstantBuffers[i];
11611159
if (InlineCBAttr.ResIndex == ResIndex)
11621160
{
1163-
const ResourceCacheContentType CacheType = ResourceCache.GetContentType();
1164-
const ResourceAttribs& Attr = GetResourceAttribs(InlineCBAttr.ResIndex);
1165-
const Uint32 CacheOffset = Attr.CacheOffset(CacheType);
1166-
return ResourceCache.GetInlineConstantData(Attr.DescrSet, CacheOffset);
1161+
return ResourceCache.GetInlineConstantData(InlineCBAttr.DescrSet, InlineCBAttr.SRBCacheOffset);
11671162
}
11681163
}
11691164
return nullptr;

0 commit comments

Comments
 (0)