graphics: avoid uvec4 specialization-constant selects in the GPU tiler shaders #795
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!795
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/795/head"
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?
@DenizSAHIN570 on GitHub · 2026-09-23 20:26 UTC · original
DenizSAHIN570:fix/gpu-tiler-vec-spec-selects→main· +30 −12 · 3 files · 1 commits · closed without mergingSummary
gpu_tiler_standard64_3d.inc,gpu_tiler_prt.compandgpu_tiler_prt_3d.compchoose their per-element-size bit positions with a ternary chain betweenuvec4constants on theELEMENT_BYTESspecialization constantstandard64_3d_extent()already uses in that fileProblem
GpuTilerCpuParityfails on my machine (Radeon RX 9070 XT, RADV / Mesa 26.2.2, GFX1201):The shader's address math is identical to the CPU reference (
Gen5Standard64KBVolumeOffsetInBlock, SOURCES row{4,4,4,5}for 1-byte elements), so it is not a formula disagreement. What I found:(x >> 3) & 1would give, as if the fourth shift constant were 3 instead of 5. This matches the pattern of bad bytes exactly (x 8..15 wrong, 16..23 correct, 24..39 wrong).-V --target-env vulkan1.3 -Os) compiles the ternary chain toOpSpecConstantOp Selectwith a scalar bool condition anduvec4operands (legal in SPIR-V 1.4+). The constants in the module are correct.I could not identify where the wrong value is produced (constant folding in the driver's SPIR-V front end, the shader compiler, or something else), and I did not find a matching report in Mesa's tracker, so I am not claiming it is a Mesa bug. The construct is easy to avoid, and that is what this PR does.
Change
Each vector ternary chain becomes a small helper (
standard64_3d_shifts(),prt_shifts(),prt_3d_shifts()) with early returns, plus a short comment. 3 files, +30/-12. Values are the same as before.Validation
kyty_emulatorandshader_recompiler_compute_testsboth build against current main (569ec04)OpSpecConstantOp Selectcount goes from 4 / 4 / 8 (standard64_3d / prt / prt_3d) to 0 / 0 / 0GpuTilerCpuParityon unmodified main: fails as above (and at family 5 once only the 3D shader is fixed). With this change:ok (330 cases, 236 format/mode pairs).image format does not support required usage: format=129, because this GPU does not support D24_UNORM_S8_UINT. So the full compute suite still cannot complete here, and validation for this change is the tiler test plus the SPIR-V check above.ShaderRecompilerComputeTests.cppis the only test source that exercises the tiler..incfile.Limits and what would help
AI assistance
An AI coding assistant was used for this change: to help analyse the failing test, to draft the change, and to draft this description. I ran the builds and test runs above in my own environment and checked their output, and I reviewed the complete diff. All communication on this PR comes from me.
standard64_3d, prt and prt_3d pick their per-element-size bit positions with a ternary chain between uvec4 constants on the ELEMENT_BYTES specialization constant. glslang compiles that to OpSpecConstantOp Select with a scalar condition and uvec4 operands. On RADV (Mesa 26.2.2, RX 9070 XT) the fourth component comes out wrong for 1-byte elements, so 64 KB 3D and PRT tiling reads and writes the wrong bytes. GpuTilerCpuParity fails there ("detile bytes family=4 bpe=1: first mismatch at 8"), while the shader's address math matches the CPU reference exactly. Return the shift constants from early-return helpers instead, the same pattern standard64_3d_extent() already uses. The values are unchanged. The compiled SPIR-V no longer contains a vector-typed OpSpecConstantOp Select. GpuTilerCpuParity passes with this change on the same GPU (330 cases, 236 format/mode pairs).@coderabbitai[bot] on GitHub · 2026-09-23 20:28 UTC · original
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
02dc6d58-49a5-4b95-9ea9-371a993fe48d📥 Commits
Reviewing files that changed from the base of the PR and between
569ec04d1aande73ebd60f4.📒 Files selected for processing (3)
src/graphics/host_gpu/shaders/gpu_tiler_prt.compsrc/graphics/host_gpu/shaders/gpu_tiler_prt_3d.compsrc/graphics/host_gpu/shaders/gpu_tiler_standard64_3d.incIncluded review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough
The PRT, PRT 3D, and standard64 3D shader paths now use helper functions to select shift vectors for
ELEMENT_BYTESvalues 1, 2, 4, and 8, with the existing fallback for other values. The offset calculations remain unchanged. Comments document a reported specialization-constant select miscompilation.Merge Risk: ⚪ Minimal · up to
e73ebNo merge-blocking issue is evident in the shader change; it is ready for normal checks.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Comment
@coderabbitai helpto get the list of available commands.@MuteRex on GitHub · 2026-10-21 13:42 UTC · original
Retested on current main (
4644c52, 2026-10-21) on a second RDNA4 card, and this is still needed. I'm asking for it to be reopened.Hardware: RX 9060 XT (RADV GFX1200), Mesa 26.0.8, Ubuntu 26.04, kernel 7.0.0-38. That's a different chip and an older Mesa than the 9070 XT / GFX1201 / Mesa 26.2.2 in the PR description.
gpu_tilerfails on main with exactly the error from the PR description:gpu_tiler4644c524644c52+ #9304644c52+ #930 + this PRThe diff still applies cleanly to current main. Nothing else regressed: the full suite went from 6 failures to 5, and the remaining ones are unrelated (
shader_recompiler_compute/BoundedRecordBufferAccess32, plus 4 emulator CLI tests that only show "Not Run" because I builtkyty_testswithout the emulator).I also ran a source build with this PR applied in Resident Evil 2 (PPSA04288) for a while and saw no tiler-related problems. That game's main issue on AMD is a separate GPU hang (#1396).
Logs for all three runs are attached.
AI assistance (Claude) was used to run the suites and summarise the logs. I ran the tests on my own hardware and reviewed the results.
kytyps5-rdna4-pr-tests.zip
Pull request closed