Skip to content

Commit 11b5918

Browse files
committed
Fix bad SRBCacheOffset.
1 parent 333c3d1 commit 11b5918

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void PipelineResourceSignatureVkImpl::CreateSetLayouts(const bool IsSerialized)
350350
DescrSetValue,
351351
pVkImmutableSamplers != nullptr,
352352
IsPushConstant,
353-
CacheGroupOffsets[CacheGroup],
353+
IsPushConstant ? ~0u : CacheGroupOffsets[CacheGroup], // SRBCacheOffset - push constants don't use it
354354
ResDesc.VarType == SHADER_RESOURCE_VARIABLE_TYPE_STATIC ? StaticCacheOffset : ~0u //
355355
};
356356
}
@@ -367,8 +367,8 @@ void PipelineResourceSignatureVkImpl::CreateSetLayouts(const bool IsSerialized)
367367
"Deserialized descriptor set (", pAttribs->DescrSet, ") is invalid: ", DSMapping[SetId], " is expected.");
368368
DEV_CHECK_ERR(pAttribs->IsImmutableSamplerAssigned() == (pVkImmutableSamplers != nullptr), "Immutable sampler flag is invalid");
369369
DEV_CHECK_ERR(pAttribs->IsPushConstantBuffer() == IsPushConstant, "Push constant flag is invalid");
370-
DEV_CHECK_ERR(pAttribs->SRBCacheOffset == CacheGroupOffsets[CacheGroup],
371-
"SRB cache offset (", pAttribs->SRBCacheOffset, ") is invalid: ", CacheGroupOffsets[CacheGroup], " is expected.");
370+
DEV_CHECK_ERR(pAttribs->SRBCacheOffset == (IsPushConstant ? ~0u : CacheGroupOffsets[CacheGroup]),
371+
"SRB cache offset (", pAttribs->SRBCacheOffset, ") is invalid: ", (IsPushConstant ? ~0u : CacheGroupOffsets[CacheGroup]), " is expected.");
372372
DEV_CHECK_ERR(pAttribs->StaticCacheOffset == (ResDesc.VarType == SHADER_RESOURCE_VARIABLE_TYPE_STATIC ? StaticCacheOffset : ~0u),
373373
"Static cache offset is invalid.");
374374
}
@@ -868,6 +868,11 @@ void PipelineResourceSignatureVkImpl::CopyStaticResources(ShaderResourceCacheVk&
868868
if (!HasDescriptorSet(DESCRIPTOR_SET_ID_STATIC_MUTABLE) || m_pStaticResCache == nullptr)
869869
return;
870870

871+
// If static cache has no descriptor sets (e.g., only push constants),
872+
// there's nothing to copy from the descriptor set.
873+
if (m_pStaticResCache->GetNumDescriptorSets() == 0)
874+
return;
875+
871876
// SrcResourceCache contains only static resources.
872877
// In case of SRB, DstResourceCache contains static, mutable and dynamic resources.
873878
// In case of Signature, DstResourceCache contains only static resources.
@@ -1008,6 +1013,14 @@ void PipelineResourceSignatureVkImpl::CommitDynamicResources(const ShaderResourc
10081013
{
10091014
const PipelineResourceAttribsType& Attr = GetResourceAttribs(ResIdx);
10101015
const PipelineResourceDesc& ResDesc = GetResourceDesc(ResIdx);
1016+
1017+
// Push constants don't use descriptor sets, skip them
1018+
if (Attr.IsPushConstantBuffer())
1019+
{
1020+
++ResIdx;
1021+
continue;
1022+
}
1023+
10111024
const Uint32 CacheOffset = Attr.CacheOffset(CacheType);
10121025
// For inline constants, GetArraySize() returns 1 (actual array size for cache),
10131026
// while ArraySize contains the number of 32-bit constants

Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,7 @@ PipelineResourceSignatureDescWrapper PipelineStateVkImpl::GetDefaultResourceSign
690690
PipelineResourceDesc& Res = const_cast<PipelineResourceDesc&>(SignDesc.Get().Resources[i]);
691691
if ((Res.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) != 0)
692692
{
693-
//TODO: making first inline constant a push constant will lead to assert on CreateSetLayouts
694-
//Res.Flags |= PIPELINE_RESOURCE_FLAG_VULKAN_PUSH_CONSTANT;
693+
Res.Flags |= PIPELINE_RESOURCE_FLAG_VULKAN_PUSH_CONSTANT;
695694
break;
696695
}
697696
}

0 commit comments

Comments
 (0)