shader: preserve complete native frontend cache results #3792
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3792"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-01T22:54:21Z.
Problem
The native frontend cache stored only part of a translated shader. Pixel descriptor metadata, mesh heap metadata and HLSL were not serialized, so a cache hit could return a result that differs from a live translation. The encoder and decoder were separate hand-written field lists, and nothing failed when a cached record gained a member. The graphics cache key also ignored
X2W_MESH57_PARTIAL_ZERO, which lowering reads.Change
static_asserton the field count fails the build whenNativeComputeShadergains a member that the list does not cover.frontend-3. Loose.csirand.pairirentries are regenerated, and prepared compute packs must be rebuilt.X2W_MESH57_PARTIAL_ZEROis read once on first use and is part of the graphics frontend key, so lowering and the cache use the same value.Lowering is not changed; this is serialization and cache keying only.
This conflicts textually with #3522, which changes first-dispatch lookup in the same cache reader. I will rebase after whichever merges first.
Validation
Windows, MSVC,
devpreset, at22f5b1c9e: 8/8 tests passed.native_direct_cache_controlsround-trips a shader with every field populated and checks that malformed payloads are refused.native_direct_cache_key_controlschecks that changing the option gives a separate cache entry. The container check compares cached IR payloads and emitted DXIL byte for byte across cold and warm runs, and the pack checks compare complete cached results with live translations.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-02T04:13:41Z.
Rebased onto
main(0dd65da11).mainreplacedstride_srvswithstride_sources(ComputeStrideSource) and addedshiftandbasetoMeshHeapRead. The shared field list now covers both:stride_sourcesis decoded with a 32-entry limit and ashader_register > 31check, andMeshHeapReadis written and read withshiftandbase. Note that the cache onmainstill does not serializemesh_heap_readsat all, so the two new fields are lost on a cache hit there along with the rest; this PR covers them. The CTest selection from the description passes again with MSVC on the new head.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T05:26:44Z.
Review: COMMENTED
Thanks for rebasing and covering the new stride and heap-read fields. I rebuilt
compile_dxil,native_direct_cache_checkandnative_compute_pack_checkat9a06ec0a. On Windows Debug,ctest --preset dev --no-tests=error -j 2 -R '^native_(direct_cache(_key)?_controls|direct_(container|mesh)|fixed_graphics_psi1|compute_pack(_parts)?|compile_dxil_rekey)$' --output-on-failurepassed 8/8. The merge against maine958b8e8now conflicts in theX2W_NATIVE_SHADER_REVISIONinput list inCMakeLists.txt. Please retainshader_translation_error.hfrom #3799 and all three new cache-identity headers from this PR when rebasing, then rerun the cache and compute-pack refusal checks on the combined head.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-02T06:53:32Z.
Rebased onto
main(f365f125b) after #3791 and #3799 merged; the only conflict was the shader-revision source list inCMakeLists.txt(both header lists kept). On the new head, eight of the nine tests in the CTest selection from the description ran and passed. The ninth,native_compute_pack_refusals(added by #3799), was not run: its executable was not built in that run.Heads-up on an interaction with #3821: it adds
ComputeViewBinding::dynamic_scalar_load, and this PR's cache visitor names every field of that struct in a structured binding. The two merge cleanly as text, but the second one to merge will not compile until the field is added to the visitor and its fixture; I will push that follow-up as soon as the first one lands.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T08:59:14Z.
Review: APPROVED
Confirmed the rebased head keeps
shader_translation_error.hand the three additional cache-identity headers. On7c4de869, Windows Debug,ctest --preset dev --no-tests=error -j 1 -R '^native_(direct_cache(_key)?_controls|direct_(container|mesh)|fixed_graphics_psi1|compute_pack(_parts|_refusals)?|compile_dxil_rekey)$' --output-on-failurepassed 9/9, including the compute-pack refusal test added on main.