Skip to content

Commit 17b7af5

Browse files
committed
Fix ImmutableSamplers2 test when no resources provided in PRS Desc.
1 parent 617b449 commit 17b7af5

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,16 @@ void DeviceContextVkImpl::CommitShaderResources(IShaderResourceBinding* pShaderR
647647

648648
const Uint32 SRBIndex = pResBindingVkImpl->GetBindingIndex();
649649
const PipelineResourceSignatureVkImpl* pSignature = pResBindingVkImpl->GetSignature();
650-
ResourceBindInfo& BindInfo = GetBindInfo(pResBindingVkImpl->GetPipelineType());
650+
651+
// Use PSO's pipeline type as fallback when PRS has no resources and thus PIPELINE_TYPE_INVALID
652+
PIPELINE_TYPE SrbPipelineType = pResBindingVkImpl->GetPipelineType();
653+
if (SrbPipelineType == PIPELINE_TYPE_INVALID)
654+
{
655+
VERIFY_EXPR(m_pPipelineState != nullptr);
656+
SrbPipelineType = m_pPipelineState->GetDesc().PipelineType;
657+
}
658+
659+
ResourceBindInfo& BindInfo = GetBindInfo(SrbPipelineType);
651660
ResourceBindInfo::DescriptorSetInfo& SetInfo = BindInfo.SetInfo[SRBIndex];
652661

653662
// Always bind the SRB, even if it has no descriptor sets (e.g., only push constants)

Tests/DiligentCoreAPITest/src/PipelineResourceSignatureTest.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -771,14 +771,6 @@ TEST_F(PipelineResourceSignatureTest, ImmutableSamplers2)
771771
PipelineResourceSignatureDesc Desc;
772772
Desc.Name = "ImmutableSamplers2 - PRS3";
773773
Desc.BindingIndex = 3;
774-
775-
//Note that PipelineTypeFromShaderStages() will return PIPELINE_TYPE_INVALID if we leave Desc.Resources empty,
776-
//which will lead to PIPELINE_TYPE_INVALID from CmmoitShaderResources() -> pResBindingVkImpl->GetPipelineType()
777-
//and causing assert or crash essentially.
778-
const PipelineResourceDesc PlaceholderResource[] = {
779-
{SHADER_TYPE_VERTEX, "Placeholder", 1, SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, SHADER_RESOURCE_VARIABLE_TYPE_STATIC}};
780-
Desc.Resources = PlaceholderResource;
781-
Desc.NumResources = _countof(PlaceholderResource);
782774
pDevice->CreatePipelineResourceSignature(Desc, &pSignature3);
783775
ASSERT_NE(pSignature3, nullptr);
784776
}

0 commit comments

Comments
 (0)