fix(agc): read a merged program's vertex tables past its hidden user words #3738
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3738"
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 Mouad-Scriptz-0 on 2026-10-11T16:13:29Z.
What
DecodeVertexStageInforeads a vertex program's vertex buffer and attribute tables from the user-SGPR words the AGC header names (PtrVertexBufferTable,PtrVertexAttribDescTable, counted from the first user SGPR). For a merged program on the geometry path,DecodeGraphicsProgramsinserts the eight hidden user words of the merged layout at the front ofuserData(initializeMerged,firstUserSgpr0), so those reads landed inside the hidden words and found zeros, and the draw threwnull vertex buffer table address. The recompiler already maps the registers correctly (EmbeddedVertexFetchAnalyzeraddskEmbeddedFetchRegisterShift= 8), which is why only the host-side table reads were wrong.DecodeVertexStageInfotakeshiddenUserWords(default 0) and adds it to the two table reads and their bounds checks only;fetchBufferRegandfetchAttribRegstay the header's registers.8 - firstUserSgpr(Draw.cpp, and both static-ABI calls inShaderRegistry.cpp, wherefirstUseris already 0 for mesh programs and the plan's user count already includes the eight words).agc_driver_graphicsgains a header with tables at registers 4 and 6: the merged layout (eight hidden words, tables at words 12-15) decodes its resource and reports registers 4 and 6, the same layout with no hidden-word offset fails on the null table, and the plain layout still decodes.Title: Killzone: Liberation (PPSA11142 01.000.004) stopped on its first PSP frame with this message (registers in #3622); with this change the draw decodes and the vertex program compiles. Closes #3622.
#1077 changes the same
DecodeVertexStageInfocalls for an unrelated layered-target feature; the conflict is a one-line argument merge on each call.Tested
Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, Intel Arc Meteor Lake iGPU), this commit onmaina11c8f7f:agc_driver_graphicsandagc_driver_pm4pass;ctest -j4 --timeout 180without the sevenagc_driver_*tests that fail the same way on a cleanmainbuild on this iGPU (f64_fma_subnormals,vop1_float_unary,vopc_compare,prepared_shaders,prepared_shaders_indirect,prepared_shaders_uncached,prepared_shaders_debug): 824/825, the one failure (agc_driver_emulated_color_compare, an ANV sRGB sampling limit) failing identically on cleanmain;tools/check_conventions.py --base origin/mainandgit diff --checkpass. Killzone: Liberation runs past the stop (Linux). Not tested on Windows.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:56:42Z.
Checked the three call sites (
Draw.cpp, both inShaderRegistry.cpp) againstDecodeGraphicsPrograms/initializeMergedandkEmbeddedFetchRegisterShift: the offset8 - firstUserSgpris 8 for merged programs and 0 otherwise. Built and ran the AgcDriver tests onmain+ this PR (384/384,agc_driver_graphicsincluded); the new test needs the new parameter, so it cannot pass without the change. Merging.Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-11T23:53:23Z.
Confirmed on High on Life (PPSA15388 v01.120.000, Unreal Engine 4). Once #2261 routed its registered NGG culling programs to the mesh path, the run stopped right after the first level loaded with
raised from
DecodeVertexStageInfoinDriver::draw. The address is the program's V# read as the table pointer, eight words too early, with its stride (16) left in bit 52. With this commit cherry-picked the stop is gone (2 runs), and the title continues into the level.Tested and written by Claude (AI assistant) on a contributor's machine.