fix(agc): keep each set's image table writes in its own draw snapshot… #6537
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6537"
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 AnthonyClemens on 2026-10-15T19:21:27Z.
What
The vertex and fragment image tables both use
ImageTableBinding(260), one in set 0 and one in set 1.PrepareDrawBindingsmatched the recorded descriptor writes to their bindings by binding number alone. So the set 0 table also took the fragment table's writes:This change also matches each write against the set it was first recorded for.
Found on Resident Evil 2 (PPSA04288). In the first scene, two RE Engine pixel shaders that sample through image tables in both stages caused GPU page faults, a TDR and device loss. The validation layer reported
VUID-VkWriteDescriptorSet-dstArrayElement-00321(832 descriptors written into a variable count of 831). The faulting addresses are an image descriptor's words read as a buffer descriptor: the base address >> 8, with format bits on top.The recorder test device now enables the descriptor indexing features that image tables need, when the GPU supports them. A new test,
drawSnapshotTableSetTests, builds a draw with a 1-element vertex table and a 2-element fragment table, and checks that the snapshot writes 1 table descriptor into its set 0 and 2 into its set 1. Without the fix it gets 3 and 0.Tested
Windows 11 (26200), MinGW-w64 GCC 15.2.0, Release.
agc_driver_recorder_tests --draw-descriptors-only: the new test fails on main and passes with the change (1.4 s).ctest -R ^agc_: 594 of 598 pass.agc_driver_quad_pixel_mask,agc_driver_store_over_untracked,agc_driver_layered_volume_vertex_no_gpl.agc_driver_gpu_indirect_arguments_misaligned_writer_aheaddoesn't compile with this toolchain ("requested alignment '65536' exceeds object file maximum 8192"), on main too.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 repositoryImported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-15T20:25:20Z.
Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2), with
9800f3ab9merged into main44df21632.drawSnapshotTableSetTestsis only called from the--draw-descriptors-onlymode and the no-argument run ofagc_driver_recorder_tests, and no CTest entry runs either. Soctestnever executes it: all 39 registeredagc_driver_recorder_testsentries pass both with and without the change.Run directly:
agc_driver_recorder_tests --draw-descriptors-onlypasses (Draw descriptor writes and snapshot overrides passed; image tables are available on lavapipe, so it isn't skipped).ShaderResources.cpp: it fails withAGC graphics: the draw snapshot wrote the wrong number of image table descriptors into the vertex set(exit 139).Registering a test for
--draw-descriptors-onlyinlibSceAgcDriver/CMakeLists.txtwould let CI see it.drawDescriptorWriteTestsin the same mode isn't registered on main either.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-15T22:09:52Z.
Confirming on Linux with an NVIDIA GPU. We hit the same validation message in 007 First Light and found the same two-line change independently.
agc_driver_recorder_tests --draw-descriptors-onlyholds on the RTX 3080 too, with this commit cherry-picked ontomainfa9365ca7:main'sShaderResources.cppit fails with the same message and exit 139.main4186f06a9plus local changes the title needs to get there:VUID-VkWriteDescriptorSet-dstArrayElement-00321reports 339 descriptors written at binding 260 into a variable count of 332, until the layer's limit of 10 reports. That holds for the base alone (to frame 201) and with #6567's change (to frame 260).VK_ERROR_DEVICE_LOST). The kernel logged NVRM Xid 31, an MMU fault on a texture-unit read (GPCCLIENT_T1_5,FAULT_PDE,ACCESS_TYPE_VIRT_READ);#6567 (mine) fixes a separate cause of the same message:
AllocateRewrittencould hand a draw a recycled set allocated for a smaller table. It merges cleanly with this PR.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-16T10:24:06Z.
Demon's Souls (PPSA01342) on Windows: on our stack, every run without this PR and #6567 crashed (6 of 6). With both, 2 of 4 runs reached our 3000 s limit. The other two ended on failures we haven't tied to either PR. Every "with" run has both this PR and #6567 cherry-picked (patch-identical to
9800f3ab9and 544e7afb3), so these runs can't tell the two fixes apart.Setup: Windows Server 2025 (26100), RTX 3060, NVIDIA 591.86, MinGW-w64 GCC 15.2.0, Release. Stack:
maina5e2a80c6+ #6412, #5870 (merged since), #6280, #6320, #5987, #6553, the first three commits of #6481, and a local file-backed SPIR-V store. The same scripted menu inputs were used every run.Without either PR, all six runs died:
APS5_PIPELINED_DRAWS=0VulkanDevice::PrepareDispatchAPS5_NO_PIPELINE_CACHE=1APS5_ADDRESS_COPY_MAX_MIB=1024nvoglv64.dllWith both:
VK_ERROR_OUT_OF_DEVICE_MEMORY); #6481's newest commit now faults such an entry insteadVK_ERROR_DEVICE_LOSTinvkWaitForFences; still looking into itlibSceAgcDriverreturn address isShaderResources::PrepareDrawBindings+0x1df9. That is just after the function's onlyvkUpdateDescriptorSetscall. This PR changes which set each write in that call goes to, and #6567's cause also writes through that call. fma-rc's guard-page fault on Linux (Demon's Souls PPSA01341, on #6567) is at the same call. There, #6567 alone got through the scene wheremainfaulted.vkWaitForFencesVK_ERROR_DEVICE_LOSTas main6-c02. It's left out of the table because that extra code was active.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-16T21:15:42Z.
This looks like it also fixes an NVIDIA driver crash in Ghost of Yōtei (PPSA26344) during loading, around frames 795–812. RTX 4090, driver 617.42, Windows 11.
Without this PR, three runs crashed the same way: run179 (an older main), run182 and run183 (
main82ddae75b). All three used a cold shader cache, and the crash came at frames 795–812:The address read is two small dwords. Symbolized against the build that ran (run179), the driver's caller is
recordDrawatGraphics/src/Draw.cpp, line 1812 in that tree: thevkCmdBindDescriptorSetsof the fragment set (RuntimeAbi::FragmentDescriptorSet). That fits what you describe, where set 1's image table is never written and set 0's writes spill into the next set in the pool. The samewhileloop that matches writes by binding number alone is in both trees.With this PR's two commits cherry-picked onto the same
main-based tree:Not a clean A/B: the crash didn't happen on every run without the fix either (a cold run of an older tree with a different shader setting got through frame 897), so two runs past the range is good evidence, not proof.
Imported from boykopovar/AnyPS5. Originally posted by marco-scheffler on 2026-10-17T14:09:20Z.
Linux NVIDIA data point: Ubuntu 24.04.4, RTX 4000 SFF Ada Generation, driver 595.99.02, GCC 13.3.0, Release. This PR at
2132abc69merged ontomainc9e6c45de, fullcteston the RTX (ANYPS5_GPU=RTX, Xvfb with-DANYPS5_VIDEO_OUT_TEST_DRIVER=x11): no new failures. The only failures,video_out_flip_eop{,_main,_aftergpu}(#6616) andagc_driver_{f16_fma,fma_mix_f16}_denormal_modes, fail the same way on thatmain(0/5 serial with and without this PR).