perf(shader): index ValidateProgram by value and block id #470
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/470"
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 adriadam10 on 2026-10-03T16:28:44Z.
What
ValidateProgramruns twice per recompile (end ofTranslateand inSpirvEmitter::Emit) and looked up every instruction and block instd::unordered_maps keyed by pointer. Value and block ids are dense per program (nextValueId/nextBlockId), soblockIndicesandinstructionPositionsare now an index by id that stores the pointer next to the position. A node whose slot holds another pointer (a foreign value or block whose id collides with a local one) goes to a fallback map, so foreign definitions, duplicates and positions are detected exactly as before. No validation check is removed or changed.Measured with callgrind/perf on compute shaders assembled with
llvm-mc -mcpu=gfx1030(ALU chains with a branch every 40 instructions, results stored, plus two loop shaders with phis), oneRecompileeach, cache off:ValidateProgrambeforeperf statover 100 recompiles of the 1754-word shader: 3445–3484M cycles before, 2997–3230M after (-7 to -13 %). The rest ofValidateProgramis the per-instruction checks themselves.Tested
agc_driver_pixel_helper_lanes, which fails the same way onmainon this machine.compileVariantoutput, temporary logging not included).agc_validate_programtest: a valid program, use before definition, a duplicated instruction, a foreign definition with a local id, and two values with the same id in one block (in order and out of order). It passes onmainand on this branch.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)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T05:46:05Z.
Thanks, indexing by id is a nice win and the validator still catches the same cases. The branch now conflicts with main in core/libs/prx/libSceAgcDriver/CMakeLists.txt (the agc_dcc_key_sharing_tests block from #466 landed where you add agc_validate_program_tests); a rebase should be all it needs.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T06:19:38Z.
Thanks! Rebased onto current main; the CMakeLists.txt conflict was only placement, so
agc_validate_program_testsnow sits after theagc_dcc_key_sharing_testsblock from #466. Both tests pass locally.