Skip to content

RenderStateCache: reuse archived pipelines with non-default SRB granularity or context mask - #822

Open
hzqst wants to merge 2 commits into
DiligentGraphics:masterfrom
hzqst:fix-vk-unpackinfo-upstream
Open

hzqst wants to merge 2 commits into
DiligentGraphics:masterfrom
hzqst:fix-vk-unpackinfo-upstream

Conversation

@hzqst

@hzqst hzqst commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A pipeline created with a non-default SRBAllocationGranularity or ImmediateContextMask was never reused from a loaded render state cache. Every lookup logged:

Description of pipeline state '...' does not match the description of the pipeline unpacked from the cache. This may be the result of a hash conflict, though the probability of this should be virtually zero.

The cache then created the pipeline again, so a stored cache did not help these pipelines. Any pipeline that may run on several immediate contexts is affected. There are two causes:

  1. The device object archive does not store PipelineStateDesc::SRBAllocationGranularity and ImmediateContextMask (PSOSerializer.cpp: // skip SRBAllocationGranularity, // skip ImmediateContextMask). The dearchiver takes them from PipelineStateUnpackInfo instead. RenderStateCacheImpl::CreatePipelineStateInternal did not fill these two fields, so they stayed at their defaults.
  2. PipelineStateBase clears the bits of ImmediateContextMask that have no command queue on the device (m_Desc.ImmediateContextMask &= DeviceQueuesMask). Even with the right unpack info, the unpacked pipeline can hold a subset of the requested mask, and it was compared with the create info as is.

Fix

  • Copy SRBAllocationGranularity and ImmediateContextMask from the create info into UnpackInfo.
  • Before comparing descriptions, reduce the requested mask to the bits the unpacked pipeline kept. All other fields are still compared exactly.

Test

New test RenderStateCacheTest.ArchivedPSOKeepsDescription:

  1. Creates a compute pipeline with SRBAllocationGranularity = 4 and ImmediateContextMask = ~0 (not the default on any device, and always reduced by the device).
  2. Writes the cache and loads it into a new cache.
  3. Expects the pipeline to be found there, with the requested description and the mask reduced to the device's immediate contexts.

Results (NVIDIA GeForce RTX 5060, Windows, x64 Debug):

  • With neither commit, the test fails on Vulkan, D3D12, D3D11 and GL. With only the first commit, it still fails on all four.
  • With both commits, all RenderStateCacheTest.* tests pass or skip as before on all four.

…y and context mask

Archives do not store PipelineStateDesc::SRBAllocationGranularity and
ImmediateContextMask; the dearchiver takes them from PipelineStateUnpackInfo.
RenderStateCacheImpl left both at their defaults, so a pipeline created with
other values never matched the one unpacked from a loaded cache: the cache
logged a description mismatch and created the pipeline again.

Add RenderStateCacheTest.ArchivedPSOKeepsDescription, which fails on Vulkan,
D3D12, D3D11 and GL without the fix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…acked pipeline

PipelineStateBase clears the bits of ImmediateContextMask that have no command
queue on the device. A pipeline unpacked from the cache therefore may hold a
subset of the requested mask, and comparing its description with the create
info reported a mismatch and created the pipeline again. Compare with the
requested mask reduced to the bits the pipeline kept.

ArchivedPSOKeepsDescription now requests every context bit, so it covers the
reduced mask on any device; it fails on Vulkan, D3D12, D3D11 and GL with only
the previous commit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@hzqst hzqst changed the title RenderStateCache: unpack archived pipelines with their SRB granularity and context mask RenderStateCache: reuse archived pipelines with non-default SRB granularity or context mask Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant