fix(shader): read a buffer V#'s presence at run time instead of specializing it #9957
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9957"
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 boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-23T00:05:14Z.
What
A buffer V#'s presence (
dwords[2] != 0 && (dwords[0] != 0 || (dwords[1] & 0xffff) != 0)) was supplied as specialization constantBufferBase + i*BufferWords + 2from the dispatch's V# snapshot, andbuildSpecializedModuleturns supplied specializations into literal constants. The same guest program therefore compiled to two SPIR-V modules, one where the buffer was bound and one where it was still null, with differentRecompileResult::Identity()and no VkPipelineCache hit between them; which one a dispatch got depended on timing.PPSA26344 has eight compute programs of 1.2–1.45M SPIR-V words reached in both states; every new state cost a 54–320 s NVIDIA pipeline compile, and pipeline journal replay of the other state did not help.
descriptor()in SpirvRuntimeBuffer.cpp now computes presence from the V#'s words at run time, as the registration-module path already does; the formatted-buffer helper takes it from its existingvalidparameter, andDescriptorBindingBuilderno longer suppliesBufferBase + 2. The GuardedMemoryLoads fixture now encodes validity in the V# words instead of the specialization. ShaderDiskCache FormatVersion is bumped because generated SPIR-V changes.Tested
Ubuntu 26.10, Ryzen 9 5950X, RTX 3080 Ti 12 GB, NVIDIA 615.71.09. PPSA26344 02.002.000 title-scene load (with a separate blend change applied locally to get past its earlier stop).
BufferBase+2: 1 vs 0) and 20OpLogicalAndfolding it. Warm run: pipelines over 100k words took 1,221 s in the first 15 min because 5 journal-replayed giants were rebuilt at 54–70 s each.tools/select_tests.py, 1143 selected): 1140 pass; the same 3 failures (agc_driver_sample_order,agc_driver_sample_order_grid_reference,agc_driver_sample_order_recipe_depth_locations) occur on main895f47f4eeon this machine.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationon main and on this change: the same 3 failures and identical VUID sets (four pre-existing kinds), no new validation errors.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Related: #639 added registration-time modules, which already read presence from the V# at run time; this brings the dispatch-time specialization path in line.
Conflicts with #7484 only in the GuardedMemoryLoads test fixture (
emitLoad/AccessTracesignatures); whichever lands second needs a small fixture rebase.AI-assisted. Tested by me on my own machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T00:06:43Z.
Review: APPROVED
I reviewed the exact head 5106dae4ce37c9217addcf6d63bf744953d236d3. The change removes dispatch-time buffer-presence specialization from the cache identity and derives it from the descriptor words at runtime. The specialized GCN path masks the high-base word before testing its low 16 bits, and the formatted-buffer helper now receives validity from its existing runtime parameter. The GuardedMemoryLoads fixture encodes descriptor validity in the V# words, and the shader disk-cache format is bumped. I found no correctness issue in those paths.\n\nLocal checks run: and All conventions checks passed. both pass. I did not run the local GPU test suite because no usable build tree is available and the root filesystem is full. I inspected the reported same-machine NVIDIA baseline/change results: the author reports 1,140/1,143 selected tests passing on both, the same three existing sample-order failures and identical pre-existing VUID sets, plus matching warm capture hashes across eight large programs. Hosted relinker/product build jobs are policy-skipped for this PR, so I am relying on the author-provided runtime report for GPU validation.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T00:27:39Z.
Review: APPROVED
Reviewed the four-file change and the reported same-machine main/change Vulkan validation runs. The dispatch-time path now derives buffer presence from V# words at run time; the formatted-buffer path uses the existing runtime parameter, and the disk-cache version is bumped for the SPIR-V change. The fixture now encodes validity in descriptor words rather than specialization, matching the production behavior. The author reports the same three known test failures and VUID set on main and the change, with no new validation errors; required intake/conventions checks pass. Approved at head 5106dae4ce37c9217addcf6d63bf744953d236d3.