Skip to content

fix(shader): share wave64 VGPRs past the private ones between the two halves - #7410

Open
wachi35676 wants to merge 2 commits into
boykopovar:mainfrom
wachi35676:fix/shader-wave-shared-vgprs
Open

wachi35676 wants to merge 2 commits into
boykopovar:mainfrom
wachi35676:fix/shader-wave-shared-vgprs

Conversation

@wachi35676

@wachi35676 wachi35676 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

On GFX10, a wave64 program can declare wave-shared VGPRs (RDNA2 ISA 3.6.5): COMPUTE_PGM_RSRC3.SHARED_VGPR_CNT blocks of eight VGPRs placed after the (COMPUTE_PGM_RSRC1.VGPRS + 1) * 4 private ones. Lane N and lane N + 32 share one copy of each.

  • ACO uses them to swap the halves of a wave64 (emit_permlane64_shared_vgpr) and to emulate a wave-wide ds_bpermute_b32 (emit_bpermute_shared_vgpr).
  • The flash-attention reductions of llama.cpp's Vulkan backend end with that swap.
  • The recompiler kept these VGPRs private, so each half read its own stale copy and lost the other half's partial sums.
  • In PS5LM Plus (PPSA99581) this gave garbage with -fa on -ctk q8_0 -ctv q8_0, and slightly wrong text in other configurations.

Changes:

  • The driver decodes RSRC1.VGPRS and RSRC3.SHARED_VGPR_CNT for compute dispatches into ShaderComputeStageInfo. Both are part of the cache key, the dispatch key (0x228) and request serialization (version 50).
  • A VALU write to a shared VGPR also updates lane N ^ 32's copy, through a new HalfSwapU32 IR op.
    • When both halves write, the high half wins, because a wave64 VALU instruction issues its low half first (ISA 4.2.1 Table 9, 6.2.4).
    • In SPIR-V the partner is the other half in the same invocation, a subgroup shuffle (64-lane subgroups), or the workgroup exchange (spanned waves).
  • A non-VALU write to a shared VGPR, such as ACO's ds_bpermute_b32, is modeled while an immediate s_mov_b32, s_mov_b64 or s_bfm_b64 earlier in the block has left one half of EXEC empty, as ACO does. With both halves possibly active the ISA gives no order, so it throws.
  • These also throw: a VALU instruction that reads the shared VGPR it writes, v_writelane_b32, relative VGPR writes in such a program, wave32 programs with shared VGPRs, and host subgroups narrower than 32 lanes.
  • RADV also sets SHARED_VGPR_CNT in SPI_SHADER_PGM_RSRC2 for graphics stages. Graphics stages are not modeled, so a draw whose program sets it throws. No graphics program set it in Dusklight, flycast, Porpoise, PSSwanStation, PS5LM, Prospero Win, ProsperoAI or ProsperoLight.
  • The remaining gaps are recorded in docs/dev/debt/shader.md.

Sources:

  • AMD RDNA2 ISA 3.6.5, 4.2.1 (Table 9) and 6.2.4, and the GPR_ALLOC table (VGPR_SHARED_SIZE in units of 8).
  • Mesa be738ab0ea44cbddee6f0dcbd3cd9d16d98118ed:
    • src/amd/compiler/aco_lower_to_hw_instr.cpp: emit_permlane64_shared_vgpr, emit_bpermute_shared_vgpr and copy_constant_sgpr.
    • src/amd/vulkan/radv_shader.c: S_00B848_VGPRS((num_vgprs - 1) / 4) for wave64, S_00B8A0_SHARED_VGPR_CNT(num_shared_vgprs / 8), and the RSRC2 SHARED_VGPR_CNT of the graphics stages.
    • src/amd/registers/gfx10.json: field positions.
  • Not measured on hardware.

Tested

Windows 11, WinLibs GCC 15.2, full build:

  • ctest -R "agc_|shader|recompiler|guest_|request_serializer" -E video_out (GPU tests on): 1163/1163 passed.
  • ctest -R "^(libkernel|kernel|nid|patched_libraries|file_streams|libc)" -E "agc_|video_out": 12/12 passed.

After the rebase onto main 3a40945 (serializer version 50): clean full Windows build. request_serializer, agc_shader_memory, agc_driver_wave_shared_vgprs and the wider serializer, dispatch, subgroup, masked-select, stencil and shader-cache set pass 40/40 on NVIDIA and on AMD. ctest -R ^agc_ on NVIDIA: 1122/1122.

Linux (WSL Ubuntu 24.04, GCC 13.3): libSceAgcDriver plus the recompiler, serializer and AGC driver tests pass. agc_driver_wave_shared_vgprs skips on llvmpipe (subgroup size 8).

New tests:

  • agc_driver_wave_shared_vgprs runs ACO's half swap, an exec-masked low-half write and ACO's wave64 bpermute sequence word for word, and checks the rejections.
    • On main's sources it fails with lane 0 read 0x00000000, expected lane 32's 0x00201020, or with lane 6 read 0x00000000, expected lane 33's 0x00211021 for the bpermute part only.
    • With this change it passes on both GPUs, also with spanned waves.
  • agc_driver_prepared_unregistered_graphics checks that a graphics stage with SHARED_VGPR_CNT is rejected.
  • agc_driver_graphics covers decoding RSRC1/RSRC3 and serialization.
  • request_serializer replays a version 49 compute request, which has no wave-shared VGPR words. If the reader reads those words from version 37 as before, it fails with RequestSerializer: truncated data.

PS5LM Plus 0.8.4 (PPSA99581) with Qwen2.5-0.5B-Instruct q4_k_m (Apache-2.0), prompt "The capital of France is", 16 tokens, temperature 0. The title is fixed on NVIDIA (RTX 5070 Ti):

  • main, -fa on -ctk q8_0 -ctv q8_0: orntymology. In the 19th-arthury.10 (3/3).
  • This PR: Paris. It is the largest city in Europe and the second largest in the world (3/3), the CPU backend's exact answer.
  • -fa on with f16 K/V, and -fa off, now give the same answer. Before, they gave Paris. It is the largest city in the world by population… and Paris. It is located in the south of France….

On the AMD Radeon iGPU the title is still garbage in every configuration, -fa off included, both before and after this change; that is a separate bug. Only the replay of the captured flash-attention dispatch is correct there: its max relative error against a numpy reference went from 0.99 to 0.031.

An independent review checked:

  • the EXEC-half tracker, including cross-block state, every EXEC writer and the inline-constant sign extension;
  • the graphics register fields;
  • the ACO sequences, word for word;
  • negative controls for each part.

A regression run of Dusklight, flycast, Porpoise, PSSwanStation, PS5LM, Prospero Win, ProsperoAI and ProsperoLight (60 s each) showed no new errors.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA99581 (PS5LM Plus (PPSA99581) #5601)
  • GPUs tested: NVIDIA GeForce RTX 5070 Ti (617.42) and AMD Radeon Graphics (Ryzen 5 9600X iGPU, 32.0.21042.62), Windows 11; llvmpipe (LLVM 20.1.2) on WSL Ubuntu 24.04, where the new GPU test skips
  • AI-assisted: yes

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 1896 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4287 core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp
PR 5021 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
docs/dev/debt/shader.md
PR 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 5609 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/Recompiler.hpp
PR 6146 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp
core/shader/recompiler/Recompiler.hpp
PR 6194 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6235 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/shader.md
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/shader.md
PR 6290 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
docs/dev/debt/shader.md
PR 6416 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 6481 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6751 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6858 core/shader/recompiler/Recompiler.cpp
PR 6924 core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 6970 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/Recompiler.hpp
PR 7085 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/shader.md
PR 7223 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 7256 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7392 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
docs/dev/debt/shader.md
PR 7395 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 7522 core/shader/recompiler/Recompiler.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Deserialize.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 7668 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 7689 core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/StencilReplay.cpp
PR 8004 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/shader.md
PR 8212 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8246 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8458 docs/dev/debt/shader.md
PR 8939 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 9020 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/shader.md
PR 9183 docs/dev/debt/shader.md
PR 9335 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/shader.md
PR 9356 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/shader.md
PR 9457 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 9489 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Deserialize.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 9604 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9633 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 9671 docs/dev/debt/shader.md
PR 9675 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9700 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9712 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9748 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/shader.md
PR 9749 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 9790 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 9852 core/shader/recompiler/Recompiler.hpp
PR 9875 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9889 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp
core/shader/recompiler/Translation/src/MemoryInstructions/MemoryResourceHelpers.cpp
docs/dev/debt/shader.md
PR 9895 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9897 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 9915 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9969 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 10000 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.hpp
docs/dev/debt/shader.md
PR 10049 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/Recompiler.hpp
PR 10103 core/libs/prx/libSceAgcDriver/tests/execution/PreparedUnregisteredGraphics.cpp
PR 10141 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Deserialize.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 10233 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderInputState.cpp
PR 10351 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/StencilReplay.cpp
PR 10359 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/Translation/include/Translation/InstructionTranslator.hpp
core/shader/recompiler/Translation/src/InstructionTranslator.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 10472 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10489 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.hpp
docs/dev/debt/shader.md
PR 10556 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 10652 core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
docs/dev/debt/shader.md
PR 10757 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 10779 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10867 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cpp
docs/dev/debt/shader.md
PR 11265 core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrOpcode.hpp
core/shader/recompiler/IntermediateRepresentation/src/IrOpcode.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterInstructions.hpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
core/shader/recompiler/Translation/include/Translation/InstructionTranslator.hpp
core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp
core/shader/recompiler/Translation/src/InstructionTranslator.cpp
PR 11351 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 11483 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/shader.md
PR 11490 core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp
core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 11557 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/shader.md
PR 11566 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 11825 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 11998 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 12002 core/shader/recompiler/IntermediateRepresentation/src/IrOpcode.cpp
PR 12066 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 12125 core/shader/recompiler/Translation/src/InstructionTranslator.cpp
PR 12132 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 12316 docs/dev/debt/shader.md
PR 12324 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
PR 12458 core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp
core/shader/recompiler/Translation/src/ControlFlowInstructions.cpp
docs/dev/debt/shader.md
PR 12548 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrOpcode.hpp
core/shader/recompiler/IntermediateRepresentation/src/IrOpcode.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterInstructions.hpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp
docs/dev/debt/shader.md
PR 12662 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/shader.md
PR 12764 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
docs/dev/debt/shader.md
PR 12790 core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 12828 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 12840 core/shader/recompiler/Recompiler.cpp
PR 12855 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 12944 core/shader/recompiler/IntermediateRepresentation/src/IrOpcode.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cpp
docs/dev/debt/shader.md
PR 12980 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/shader.md
PR 13276 core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
PR 13855 core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Deserialize.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Deserialize.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 13991 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14032 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 14068 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
docs/dev/debt/shader.md
PR 14072 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
docs/dev/debt/shader.md
PR 14076 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14081 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 14085 docs/dev/debt/shader.md
PR 14212 docs/dev/debt/shader.md
PR 14217 core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
docs/dev/debt/shader.md
PR 14218 core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterInstructions.hpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
docs/dev/debt/shader.md
PR 14243 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.hpp
PR 14247 docs/dev/debt/shader.md
PR 14265 core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 14266 core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Recompiler.hpp
PR 14341 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 14367 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 14377 docs/dev/debt/shader.md
PR 14473 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14561 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 14621 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14627 docs/dev/debt/shader.md
PR 14628 docs/dev/debt/shader.md
PR 14633 docs/dev/debt/shader.md
PR 14636 core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 14692 docs/dev/debt/shader.md
PR 14708 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
core/shader/recompiler/Translation/include/Translation/InstructionTranslator.hpp
core/shader/recompiler/Translation/src/ControlFlowInstructions.cpp
core/shader/recompiler/Translation/src/DispatchInstructions.cpp
core/shader/recompiler/Translation/src/InstructionTranslator.cpp
core/shader/recompiler/Translation/src/MemoryInstructions/MemoryResourceHelpers.cpp
PR 14793 docs/dev/debt/shader.md
PR 14795 docs/dev/debt/shader.md
PR 14821 core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp
core/shader/recompiler/Translation/src/InstructionTranslator.cpp
core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp
docs/dev/debt/shader.md
PR 14830 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 14853 core/shader/recompiler/Recompiler.cpp
docs/dev/debt/shader.md
PR 14871 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
docs/dev/debt/shader.md
PR 14880 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/Recompiler.cpp
PR 14888 docs/dev/debt/shader.md
PR 14892 core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp
core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp
PR 14900 docs/dev/debt/shader.md
PR 14904 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 14909 docs/dev/debt/shader.md
PR 14913 docs/dev/debt/shader.md
PR 14944 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* unblocks title Names a title ID on the Unblocks line needs rebase Conflicts with main, rebase needed labels Oct 18, 2026
@wachi35676
wachi35676 force-pushed the fix/shader-wave-shared-vgprs branch from 70e15b4 to d662988 Compare October 18, 2026 23:16
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@klosixgaming-arch

Copy link
Copy Markdown
Contributor

Tested on Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce RTX 5090 (driver 617.42), Ryzen 9 9950X3D. Head d662988bf merged onto current main (a373e85); the merge is clean.

agc_driver_wave_shared_vgprs, agc_driver_prepared_unregistered_graphics, agc_driver_graphics, agc_shader_memory, agc_shader_bindless and request_serializer all pass (6 of 6).

A note for other Windows testers: in a build folder under a long path (mine was a workspace path of about 150 characters) the build of agc_driver_prepared_unregistered_graphics_tests stopped with fatal error: opening dependency file ...PreparedUnregisteredGraphics.cpp.obj.d: No such file or directory. That is the Windows path-length limit, not this PR; the same tree built fine from a short build directory.

I did not run the new test against main without the fix, did not run PS5LM Plus (PPSA99581), and did not review the 28-file change (the HalfSwapU32 op, request version 33 and the cache key changes); this is a test report only, not an approval.

AI-assisted: yes. Written with AI assistance and reviewed by me.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@wachi35676
wachi35676 force-pushed the fix/shader-wave-shared-vgprs branch from d662988 to e68ea55 Compare October 19, 2026 01:43
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@wachi35676
wachi35676 force-pushed the fix/shader-wave-shared-vgprs branch from e68ea55 to 455d68f Compare October 19, 2026 04:24
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@wachi35676

Copy link
Copy Markdown
Contributor Author

Rebased onto main 3ddbc4acc to resolve the conflict with #4650. #4650 took request serialization version 35 for its depth-range remap fields, so the shared VGPR fields now read from version 36. RequestSerializer writes 36 and accepts up to 36, and the test literals moved with it. The rest of the change is the same.

  • Windows 11 (WinLibs GCC 15.2.0, full build): the related subset (agc|shader|spirv|recomp|serial|wave) passes 779/779 on an RTX 5070 Ti. agc_driver_wave_shared_vgprs, request_serializer and agc_shader_memory also pass on the AMD RDNA2 iGPU (ANYPS5_GPU=AMD).
  • WSL Ubuntu 24.04 (GCC 13.3, llvmpipe): request_serializer and agc_shader_memory pass. The same 17 of 771 subset tests fail with and without this PR, because WSL lacks userfaultfd write protection ("require watched guest memory").

AI-assisted: yes (Claude Code); results above were run on this machine.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@wachi35676
wachi35676 force-pushed the fix/shader-wave-shared-vgprs branch from 455d68f to 39b3e27 Compare October 19, 2026 06:49
@wachi35676

Copy link
Copy Markdown
Contributor Author

Rebased again, onto main 46f27623c. The f32 flush-to-zero change took request serialization version 36, so the shared VGPR fields now read from version 37. TranslationContext and InstructionTranslator keep both setters. The rest of the change is the same.

  • Windows 11 (WinLibs GCC 15.2.0, full build), RTX 5070 Ti: the agc|shader|spirv|recomp|serial|wave subset passes 779 of 782.
    • agc_driver_store_pending_identity passes 3 of 3 when run on its own.
    • agc_driver_storage_file_write is intermittent: 1 of 3 here, and 1 of 3 on an unmodified main build.
    • shader_cache_runtime_sources reaches its 180 s timeout with or without this PR while other builds load the machine.
  • AMD RDNA2 iGPU (ANYPS5_GPU=AMD): agc_driver_wave_shared_vgprs, request_serializer and agc_shader_memory pass.
  • WSL Ubuntu 24.04 (GCC 13.3, llvmpipe): request_serializer and agc_shader_memory pass. Failing here are the 17 that fail on main in WSL (no userfaultfd write protection), plus shader_cache_runtime_sources (a nested CMake configure exceeds 15 s under load). agc_driver_storage_file_write also failed in the full run and passes on its own.

AI-assisted: yes (Claude Code); results above were run on this machine.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main cleanly (authorship unchanged).

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; full suite green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7410
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 07b75d57b.

@blawesom

Copy link
Copy Markdown
Contributor

One note on the handoff: an earlier full-suite run (on a stale build-tree state) showed agc_shader_memory and agc_driver_bda_span_reads failing — both pass on the rebuilt branch and on clean main (solo and in-suite), so those were stale-binary artifacts, not this PR. The handoff stands: head 07b75d57b, green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766, #7784).

@wachi35676

Copy link
Copy Markdown
Contributor Author

@blawesom thanks for rebasing it and for the RX 9070 XT run. I compared 07b75d57b with the current head 39b3e272a, which was rebased onto 46f27623c earlier today: the added and removed lines of the patch are identical, so your base is the only difference. GitHub still reports this branch as mergeable, so I've left the head at 39b3e272a. I'll rebase again if a conflict appears.

AI-assisted: yes (Claude Code); results above were run on this machine.

@LeandroLP23

Copy link
Copy Markdown
Contributor

PS5LM Plus on an RDNA 3.5 iGPU: with this PR it gives the CPU backend's exact answer in all three configurations. Here the title isn't garbage on AMD.

AMD Radeon 860M (1002:1114, wave64 subgroups), driver 32.0.13058.8001, Windows 11, WinLibs GCC 15.2.0, Release. main f78675a, alone and with 39b3e27 merged. PS5LM Plus 0.8.4 (catalog zip, SHA-256 checked), Qwen2.5-0.5B-Instruct q4_k_m from Qwen's Hugging Face repo. app-args.txt holds the planner's arguments (-ngl 999 -c 4096 -b 256 -ub 64 -np 1 ...) with only the -fa/-ctk/-ctv part changed. Prompt "The capital of France is", n_predict 16, temperature 0, over HTTP on 8081. Three runs per cell, in the same run folder:

Configuration main This PR
-fa on -ctk q8_0 -ctv q8_0 orntymology. In the 19th-arthury.10 (2 of 3; the first run stopped, see below) Paris. It is the largest city in Europe and the second largest in the world (3 of 3)
-fa on (f16 K/V) Paris. It is the largest city in the world by population. It is also (3 of 3) Paris. It is the largest city in Europe and the second largest in the world (3 of 3)
-fa off Paris. It is the largest city in Europe and the second largest in the world (2 of 3) same (2 of 3)

This is the same pattern you measured on the RTX 5070 Ti, with one difference: on this GPU main's -fa off already gave the exact answer. The garbage you see on the RDNA 2 iGPU in every configuration doesn't happen here, so whatever causes it is specific to that GPU or its driver.

The new tests (agc_driver_wave_shared_vgprs, agc_driver_prepared_unregistered_graphics, agc_driver_graphics, agc_shader_memory, request_serializer) pass 3 of 3 on this head with ANYPS5_NO_SHADER_CACHE=1.

A separate stop, not from this PR. In three cases, the first run of a configuration on a fresh build stopped about 11 s after start, before the server answered: main q8_0, and -fa off on both trees. llama.cpp logs ggml_vulkan: device lost on Vulkan0, from waitForFences / waitSemaphores with a UINT64_MAX timeout, and AnyPS5 logs no error. The second and third runs of the same configuration, with the shader cache from the first, answered normally. That looks like the title's Vulkan driver giving up on a wait while AnyPS5 is still building pipelines, as in #6118, but I haven't traced it.

AI-assisted: yes (Claude Code)

@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@adriadam10
adriadam10 force-pushed the fix/shader-wave-shared-vgprs branch from 39b3e27 to 5cea227 Compare October 19, 2026 16:13
@DavidAmsellem

Copy link
Copy Markdown
Contributor

Second AMD-on-Linux (RADV) run, this time on RDNA3, after @blawesom's RX 9070 XT (RDNA4). Merged onto main dbac9fa15 (clean merge), built in full and compared with the same main, on the same machine.

AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.

Full suite (ANYPS5_REQUIRE_VULKAN=1 ctest -j8): 1639/1641 with this PR, against 1638/1640 on main. The failures are the same two on both, so this PR adds none: agc_driver_image_table_vouched_lookups (#7766, fixed by #7916) and agc_driver_guest_memory_lifetime (#7784).

The new agc_driver_wave_shared_vgprs runs here and passes (its only skip is the subgroup-size check, which RADV's 64-lane subgroups clear), so RADV covers the test that llvmpipe skips. No other test is skipped or removed compared with main.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

@DavidAmsellem

Copy link
Copy Markdown
Contributor

First AMD-on-Linux (RADV) run of this PR. Merged onto main dbac9fa15 (clean merge), built in full and compared with the same main, on the same machine.

AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.

Full suite (ANYPS5_REQUIRE_VULKAN=1 ctest -j8) at 9033a683a: 1639/1641 with this PR, against 1638/1640 on main. The two failures are the same on both, so this PR adds none: agc_driver_image_table_vouched_lookups (#7766, fixed by #7916) and agc_driver_guest_memory_lifetime (#7784).

The PR's new ctest entry, agc_driver_wave_shared_vgprs, runs and passes here. No other ctest entry is added, skipped or removed compared with main.

This checks correctness only; I did not measure performance.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@wachi35676
wachi35676 force-pushed the fix/shader-wave-shared-vgprs branch from a165137 to 691c101 Compare October 21, 2026 12:14
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 21, 2026
@wachi35676

Copy link
Copy Markdown
Contributor Author

Rebased onto main 3e91c8edf, keeping @adriadam10's commit. main now writes request serialization version 42, so the shared VGPR fields read from version 43. The test literals moved with them, and the serializer commit's message lists the versions taken. Head 691c10187.

Windows 11, WinLibs GCC 15.2.0:

  • RTX 5070 Ti: the agc|shader|spirv|recomp|serial|wave subset passes 882 of 886. The four are:
  • AMD RDNA2 iGPU: agc_driver_wave_shared_vgprs, request_serializer, agc_shader_memory and agc_driver_graphics pass, 15 of 15.

Thanks @DavidAmsellem for the RX 7900 XT RADV run.

AI-assisted: yes (Claude Code); results above were run on this machine.

@wachi35676

Copy link
Copy Markdown
Contributor Author

Rebased onto main 2f506ca (now a3fe509). main writes request serialization version 46 now: 42 sample order, 43 point list, 44 fused exact arithmetic, 45 pixel function LDS buffer, 46 target merge. This branch therefore moves to version 47, and the two wave-shared VGPR words are read only from 47.

AI-assisted: yes (Claude Code); results above were run on this machine.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@wachi35676

Copy link
Copy Markdown
Contributor Author

One more PS5LM Plus (PPSA99581) case this PR fixes, with a different model and a longer prompt: the flash-attention path with f16 K/V (the app's default -fa on -ctk f16 -ctv f16 -b 256 -ub 64), once the prompt is longer than a few tokens.

Model: SmolLM2-360M-Instruct q8_0 from HuggingFaceTB's GGUF repo (Apache-2.0), from /mnt/usb0/PS5LM/models. Requests go to the app's llama-server on port 8081 from the host: /completion, temperature 0, 24 tokens. Windows 11, Ryzen 5 9600X, RTX 5070 Ti (driver 621.01), WinLibs GCC 15.2.0, Release. These runs set APS5_SPANNED_WAVE=1, because without it the first use of the largest kernel (650,954 SPIR-V words, 11.3 s to build) trips the app's 10 s fence wait on a cold cache (radv/ps5: the GPU has not reached submission 561 (at 548) in 10 s, then ggml_vulkan: device lost on Vulkan0). That is a separate issue.

prompt this PR's base 2f506caca this PR a3fe509d5
The capital of France is (5 tokens) Paris.\n\nParis is the capital of France. … same
Write one sentence about the sea: \n\nThe sea is a vast and mysterious place, full of secrets and wonders waiting to be discovered. same
List three colors of the rainbow, separated by commas: (11 tokens) side line line - - - - - - - - - … \n\n* Blue\n* Green\n* Red\n\nYour response should contain at least 3 …
the same request again (prompt cache hit, 1 token evaluated) ...\n ...\n Shore... Shore... Shore... Zilililililil identical to the first answer
  • The PR column holds in 3 of 3 server runs, and the repeated request returns the same text each time.
  • The base column is one run on 2f506caca. The same garbage text comes on main aeff26bd9 in 3 of 3 runs: NVIDIA with spanning, NVIDIA without it (with a warm pipeline journal), and the AMD Radeon iGPU (gfx1036, ANYPS5_GPU=AMD).
  • On the AMD Radeon iGPU (gfx1036) with this PR, without spanning (64-lane subgroups), one run gives the same three answers as NVIDIA, and the repeated request matches the first. So with this model and configuration the iGPU no longer gives garbage; I haven't tried your Qwen2.5 q4_k_m configuration there.

AI-assisted: yes (Claude Code); results above were run on this machine.

wachi35676 and others added 2 commits October 28, 2026 16:14
… halves

A wave64 compute program declares COMPUTE_PGM_RSRC3.SHARED_VGPR_CNT
blocks of eight wave-shared VGPRs right after its
(COMPUTE_PGM_RSRC1.VGPRS + 1) * 4 private ones (RDNA2 ISA 3.6.5): lane N
and lane N + 32 read and write one copy. ACO swaps the halves of a wave64
through two of them on GFX10 (emit_permlane64_shared_vgpr) and emulates a
wave-wide ds_bpermute_b32 with them (emit_bpermute_shared_vgpr). The
flash-attention reductions of llama.cpp's Vulkan backend reach the swap.
The recompiler kept these VGPRs private, so each half read its own stale
copy and the upper half's partial sums were dropped.

The driver now decodes both fields into ShaderComputeStageInfo (request
serialization version 37, cache key and dispatch key included). A VALU
write to a shared VGPR also updates the partner lane's copy through a new
HalfSwapU32 exchange, the high half winning when both halves write, as a
wave64 VALU instruction issues its low half first (ISA 4.2.1 Table 9,
6.2.4). A non-VALU write, such as ACO's ds_bpermute_b32 into a shared
VGPR, is modeled while an immediate EXEC write earlier in the block has
left one half of EXEC empty; with both halves possibly active the ISA
gives no order and it throws, as do a VALU instruction that reads the
shared VGPR it writes, v_writelane_b32, relative VGPR writes in such a
program, and a draw whose SPI_SHADER_PGM_RSRC2.SHARED_VGPR_CNT is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ion version 50

main now writes request serialization version 49 (37 stencil operation
value export, 38 mesh barycentric flag, 39 merged hull flag, 41
DenormPreserve 32, 42 sample order, 43 point list, 44 fused exact
arithmetic, 45 pixel function LDS buffer, 46 target merge, 47 two-sample
alpha-to-coverage dither, 48 fragment barycentric builtins, 49 depth
export among them), so a compute request of version 49 or older written
by main would be read with the two shared VGPR words it does not have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JKJicKPXaPdKfXumezyTiE
@wachi35676
wachi35676 force-pushed the fix/shader-wave-shared-vgprs branch from a3fe509 to 48fb6f0 Compare October 28, 2026 11:35
@wachi35676

Copy link
Copy Markdown
Contributor Author

Rebased onto main 3a40945 (now 48fb6f0). main writes request serialization version 49 now: 47 two-sample alpha-to-coverage dither, 48 fragment barycentric builtins, 49 depth export. This branch moves to 50 and reads the two wave-shared VGPR words only from 50.

  • Resolved conflicts:
    • StencilReplay.cpp: main's new ballot cases are kept, with HalfSwapU32 added to the opcode list next to BpermuteU32 as before.
    • TranslationContext.hpp and InstructionTranslator.cpp: both setters are kept.
  • The compute replay case now uses a version 49 request. With the reader taking the two words from 37 as before, it fails with RequestSerializer: truncated data.
  • Windows 11, WinLibs GCC 15.2: clean full build. The serializer, shader-memory, wave-shared VGPR, dispatch, subgroup, masked-select, stencil and shader-cache set passes 40/40 on the RTX 5070 Ti and on the AMD RDNA2 iGPU. ctest -R ^agc_ on NVIDIA: 1122/1122. The only failure on the first run was agc_shader_memory checking for version 49; that check now expects 50.
  • check_conventions.py passes.

AI-assisted: yes (Claude Code); results above were run on this machine.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 48fb6f0 merged onto main 73f4f7e · tested 2026-10-31 16:12 UTC · 26 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,354 passed · 5 failed (0 new, 4 also fail on main, 1 unstable on main) · 48 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,407 of 3,072 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (888 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_bda_device 55.5 s, ⚠️ agc_driver_graphics_maps_fallback 31.9 s, ⚠️ agc_driver_graphics 30.3 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_submit_progress: failed in 7 of the last 10 main runs
Failing on main too (4, not counted against this PR)
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (1, not in the main baseline's validation pass)
agc_driver_wave_shared_vgprs
Validation IDs already present on main (3 IDs in 392 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (392 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, and 384 more
VUID-vkCmdCopyImage-srcImage-01548 (12 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_sampling, and 4 more
VUID-vkCmdCopyImage-srcImage-01551 (12 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_sampling, and 4 more
Skipped (48)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_msaa_dcc_compared_import_2: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_4: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_8: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or plat
Reproduce
git fetch origin 48fb6f0c67ab3e0d80cc1eb820448aff27697050 73f4f7e06e4f210a8c6570e335fd654dc0a86134
git checkout 73f4f7e06e4f210a8c6570e335fd654dc0a86134 && git merge --no-ff 48fb6f0c67ab3e0d80cc1eb820448aff27697050
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs needs rebase Conflicts with main, rebase needed shader core/shader unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants