Repository navigation
fix(shader): put the compute wave index in TG_SIZE[11:6] - #5214
Conversation
GCN and RDNA code reads a compute wave's index in its workgroup from TG_SIZE[11:6] (ACO: s_bfe_u32 tg_size, 6 | 6 << 16). The prologue wrote it only at bit 20, so every wave read 0 there and cross-wave reductions such as RADV's radix sort lost the carries of all but wave 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1b7350c to
3124895
Compare
|
Ran this against vkQuake (PPSA99010) with RT shadows on, which builds acceleration structures through the title's RADV port. Setup: Windows 11, RTX 4070 Laptop (driver 32.0.16.1714), WinLibs GCC 15.2.0 r7, Release, On 3 of 3 runs it still stops after 12 presented frames:
The last shader prepared before the stall is the RT compute shader So this PR doesn't change vkQuake's stop here. It may still be needed once the pipeline compiles, but I can't reach that point to check. AI-assisted: yes (Claude Code); all runs were on my machine. |
|
Thanks for testing. That compile stop is the first wall we hit too, before the one this PR fixes. On an RTX 4060 Ti the RADV acceleration-structure compute shaders took 58 s and ~530 s in NVIDIA's compiler. We got past it by letting one run finish those compiles into the pipeline cache ( The next stop was a real GPU hang (Windows TDR / The bug doesn't depend on vkQuake: |
|
@houcineBen Thanks, that worked. I reproduced your path on an RTX 4070 Laptop (driver 32.0.16.1714), Windows 11, WinLibs GCC 15.2.0 r7, Release. Build:
One difference from your description: on this setup the title doesn't reach the acceleration-structure builds without the float-mode part. Without it, AI-assisted: yes (Claude Code); all runs were on my machine. |
…t) (#481) * fix(recompiler): give vertex-path shaders the NGG group info Ported from upstream PR boykopovar#5081 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): put the compute wave index in TG_SIZE[11:6] Ported from upstream PR boykopovar#5214 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): take the 32_AR export alpha from channel 1 as GFX10 does Ported from upstream PR boykopovar#5110 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): order buffer and image memory at s_barrier Ported from upstream PR boykopovar#5117 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): decode GFX10 scratch offsets as one dword Ported from upstream PR boykopovar#5426 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): accept MIMG sampler tuples ending in VCC Ported from upstream PR boykopovar#4996 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(recompiler): name the attribute of an out-of-range interpolation reference Ported from upstream PR boykopovar#5450 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): decode the high-half result of v_interp_p2_f16 Ported from upstream PR boykopovar#5471. The Vop3InterpDecode unit-test hunk is not ported (that test file is not on main); the execution test InterpolationF16 carries the coverage. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): clear the bits of inactive lanes in VALU carry-out and v_div_scale masks Ported from upstream PR boykopovar#5162 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): apply the f32 output modifier and denormal flush to v_cvt_f32_f64 Ported from upstream PR boykopovar#5159 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): update per-invocation LDS without atomics Ported from upstream PR boykopovar#5160. Conflicts resolved against main: kept main's barrier condition for non-LDS shared atomics; the unit-test hunk for SRT read patching (a different upstream change, not on main) is dropped. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): flush ds_add_f32 denormals and NaNs as the hardware does Ported from upstream PR boykopovar#5492 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(shader): run DS src2 lanes one at a time in lane order Ported from upstream PR boykopovar#5498 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(agc): compare NOT_EQUAL unordered, reject TRUNC_COORD point sampling and round the array layer half to even in color compare emulation Ported from upstream PR boykopovar#907 (follow-up to its predecessor). Hand-applied to main's reworked emitter: NOT_EQUAL uses OpFUnordNotEqual, the array layer is clamp(roundEven(z)), and ResourceMaterializer rejects TRUNC_COORD with point filtering. The upstream execution-test rewrite is not ported (it targets a diverged test file). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * chore(shader): bump ShaderDiskCache FormatVersion to 35 The ported DS fixes add MemoryInfo::flushDenormalResults (now encoded in the plan) and new IR opcodes, so cached payloads from format 34 must not load. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(shader): run ported upstream execution tests on Metal through a device shim The upstream execution tests for the ported fixes compile unchanged against a Metal stand-in for the Vulkan test device (guest buffer descriptors are mirrored into shared MTLBuffers). Covers boykopovar#5162 (VALU carry-out masks), boykopovar#5159 (v_cvt_f32_f64 result modes), boykopovar#5492 (ds_add_f32) and boykopovar#5498 (DS src2 lane order). The LdsSrc2 and LdsSrc2Wide tests use device-memory LDS, which the Metal bridge rejects, and are not registered. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(shader): run ported decoder and collector unit tests in the Metal build Registers the upstream tests for boykopovar#4996, boykopovar#5426 and boykopovar#5450 (already on main's tree but not built for Metal) and a high-half decode check for boykopovar#5471. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(shader): check per-invocation LDS updates without atomics on the Metal recompiler Standalone copy of the boykopovar#5160 verifyFunctionLdsUpdates check. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(shader): check the TG_SIZE wave index on Metal Buffer-store variant of the boykopovar#5214 execution test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(shader): run the s_barrier memory-order execution test on Metal Registers boykopovar#5117's upstream test through the device shim. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(shader): draw a 32_AR export on Metal Guest-replay draw for boykopovar#5110: alpha comes from export channel 1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(shader): draw an NGG vertex shader that reads the group info Guest-replay draw for boykopovar#5081. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(shader): reject TRUNC_COORD point sampling in the color compare emulation Recompile-level check for boykopovar#907. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(shader): run the src2 lane-order test without the Metal debug layer Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docs(shader): port upstream debt entries and add the FormatVersion 35 history line Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Checked the |
What
A compute wave with
TG_SIZE_ENfound its index in the workgroup only at bit 20 of the TG_SIZE SGPR. GCN and RDNA code reads it from bits [11:6]: ACO lowersload_subgroup_idtos_bfe_u32 tg_size, 6 | 6 << 16(Mesasrc/amd/compiler/instruction_selection, GFX10/GFX11 compute path). Every wave of such a shader read 0 there, so it took itself for wave 0.The prologue now also writes the wave index to [11:6]. The bit-20 copy, the wave count in [5:0] and bit 31 are unchanged.
Seen on a RADV (Mesa 26.2) build running on AnyPS5: the radix sort's prefix sums across waves lost every carry but wave 0's, the sorted keys were garbage, and the PLOC BVH build that reads them spun forever in its task loop (host GPU hang, Windows TDR /
VK_ERROR_DEVICE_LOST). With the fix the sort matches a CPU sort and PLOC completes, offline from a captured dispatch and in the title.Test:
agc_driver_tg_size_wave_idruns a 256-thread compute group in wave64 and wave32; every thread storess_bfe_u32 TG_SIZE, 0x60006and must readthread / wave size. It fails onmain(every thread reads 0) and passes with the change.Tested
Windows 11, NVIDIA RTX 4060 Ti, MinGW GCC 15.2.
agc_driver_tg_size_wave_id: fails before, passes after.cteston this branch: 1073 passed, 7 skipped (offscreen video-out and an unsupported stencil export), 0 failed.patched_librariesandwindows_fixed_basefailed once under-j8(DLL load error 127 from the shell PATH, 5 s subprocess timeout) and pass when rerun alone.Not verified on PS5 hardware; the source is the ACO lowering above.
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)🤖 Generated with Claude Code