fix(shader): store image channels by RDNA2's DST_SEL rule for the format #19096
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19096"
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 angrysandhill on 2026-11-12T19:09:33Z.
What
StoreTexelfilled each texel channel of animage_storefrom the lowest data slot whose DST_SEL named that channel, and stored DST_SEL 0 and 1 as 0. #18595 measured that RDNA2 instead picks the channels by a fixed rule per channel count, and recorded it in the shader debt list. This change implements that rule.Where the old mapping is wrong:
0xfffor 8_8_8_8_UNORM,0x7ffor SNORM, 1.0, or 1); the recompiler stored 0.The usual X,Y,0,1 (two channels), X,0,0,1 (one channel), and X,Y,Z,W and Z,Y,X,W (four channels) already agreed and still do.
The rule, with absent DMASK components read as 0:
The change:
StoreChannelClassgives a format's channel count, and whether it is an integer format, for every non-packed format with one, two or four 8-, 16- or 32-bit channels. Every other format gets 0.StoreChannelsBase), set from descriptor word 1 next to the store-quantize words.StoreTexel: reads the data slots and DST_SEL once, then applies the rule for class 1, 2 or 4. Class 0 keeps the old mapping.StoreTexelentries become one, for what is left.Tested
Setup: Windows 10 Home 22H2 (10.0.19045), AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (driver 32.0.21045.16010), WinLibs GCC 15.2.0 r7 UCRT, Release,
BUILD_TESTING=ON, onmain334615bb34.RDNA2 measurement (hardware oracle, HIP), the probe from #18595: lane 0 stores one texel per (DST_SEL, DMASK) with 32-bit data, over all 1296 DST_SEL tuples (0, 1, X, Y, Z, W) and 15 DMASKs.
0xff,0xffff,0x7f,0x7fff,0x3c00,0x3f800000or 1.Tests:
agc_driver_image_store_dst_sel: 12 formats × 14 DST_SEL tuples × DMASK 0xF and 0x5. The expected texels are RDNA2's, from the measurement.QuantizeStoreTexel.0x19where RDNA2 stores0x1a(reported below).image store dst_sel tests passed (compute shader, specialized module; pixel shader, registration module).334615bb34(the test kept), it fails:image_store DST_SEL Z,Y,X,W dmask 0x0000000f of 8_UNORM (compute shader, specialized module): texel 0 channel 0 is 0x000000cf, expected 0x000000d9.image_store DST_SEL Z,Y,X,W dmask 0x0000000f of 8_UNORM (pixel shader, registration module): texel 0 channel 0 is 0x000000cf, expected 0x000000d9.image_store DST_SEL Z,Y,X,W dmask 0x0000000f of 8_UNORM (compute shader, specialized module): texel 0 channel 0 is 0x000000cf, expected 0x000000d9.image_store DST_SEL X,Y,Z,1 dmask 0x0000000f of 8_8_8_8_UINT (compute shader, specialized module): texel 0 channel 3 is 0x000000ff, expected 0x00000001.^(agc_|shader|vector_), 4 at a time: 1,652 tests; 1,650 pass. The two failures:agc_driver_sample_order_grid_referencefails onmainon this card too (#18229; #9503 fixes it).ImageStore*and pixel-store test passes.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1, one at a time): the new test and the 11 existing image-store and pixel-store tests (^agc_driver_(image_store_.*|pixel_float16_store|image_xor_swizzle_volume)$) pass. The layer is inserted in each, with noVUID-line.registrationWordLimitof 200,000 on this device.Overlap (
tools/pr_overlap.py --branch, and conflict-hunk counts for the PRs that already conflict withmain):static_asserton the same two lines ofDescriptorBindingBuilder.cpp.main): gains one conflict hunk each inDescriptorBindingBuilder.cppandPipelineSpecialization.hpp, at the neighbouringstatic_assertand constant.StoreTexel.Not measured: the PS5's gfx1013, D16 stores, and packed formats.
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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T04:34:11Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and included tests support the stated RDNA2 channel selection behavior.
What I ran
Inspected head
f3ddf2d93805a0ee12e1465259f10c872cdcedfeusingrepo_read.py. No commands or tests were run by me; hardware and test runs described in the PR are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read all changed files listed in the manifest:
core/libs/prx/libSceAgcDriver/tests/execution/ImageStoreDstSel.cpp,core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp,core/shader/recompiler/PipelineSpecialization.hpp,core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvBufferFormat.hpp,core/shader/recompiler/SpirvBackend/src/SpirvBufferFormat.cpp,core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp, anddocs/dev/debt/shader.md. No changed files were excluded. I did not independently run the tests or verify hardware behavior on RDNA2 or PS5 gfx1013; the stated measurements and test results are author-reported.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T08:28:15Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: the channel classifier must exclude scaled formats, which currently receive incorrect channel values.
What I ran
Reviewed head
e38caf48e0beb6805a53940c7703d6655f5ab44ausingrepo_read.pyto read the prepared review metadata, diff, and relevant source at the pinned head. No build or tests were run.Results
Findings
Blocking
core/shader/recompiler/SpirvBackend/src/SpirvBufferFormat.cpp:279classifies onlyUintandSintas integer; all other accepted types return a non-integer class at lines 283–286.GetFormatInfoalso recognizesUscaledandSscaledformats (for example,Format8UScaledandFormat8SScaled). Consequently those formats receive a channel class, andMeasuredStoreChannelstreats them like float/normalized formats: DST_SEL constant 1 becomes the float bit pattern0x3f800000instead of an integer 1 (core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp:1204-1208). Restrict the classifier to the measured UNORM, SNORM, UINT, SINT, and FLOAT types, or handle scaled formats according to their actual store representation.Non-blocking
None.
Sources
Not verified
No build, test suite, or hardware validation was run. Read the prepared description, commits, manifest, diff, the complete new test source and its CMake fragment, and relevant classifier, descriptor binding, SPIR-V module, and image-emitter code. No changed files were excluded by the manifest; unrelated repository files and code outside the targeted context were not read.
To get this to a good state
Exclude scaled formats from the new channel class or implement their correct constant conversion, then rerun the image-store DST_SEL tests and relevant recompiler checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T09:58:33Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed shader path and its coverage look consistent with the stated RDNA2 channel-selection rules; execution checks were not run in this review.
What I ran
ee3f56cf6a1ff71ddf67751ac653f50754ab88d3and the prepared diff; no merged-preview check was run.DescriptorBindingBuilder.cpp,PipelineSpecialization.hpp,SpirvBufferFormat.hpp,SpirvEmitterState.hpp,SpirvBufferFormat.cpp,SpirvImageEmitter.cpp, andshader.md. No changed files were excluded.Results
Negative control
The author reports that the new test fails with the previous recompiler, with registration modules forced to the old mapping, and with the specialization constant set to 0. These controls were not run in this review.
Findings
Blocking
None.
Non-blocking
Not verified
To get this to a good state
Nothing is required. Optional: retain the author-reported hardware and test results with the PR for reviewers who cannot reproduce them.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T09:13:24Z.
Review: COMMENTED
Actionable comments posted: 2
ce0eea32-b66a-4de2-ab97-f9183ccf5968Reviewing files that changed from the base of the PR and between
4cb7752e50and28c0dd9799.core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_store_dst_sel_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/ImageStoreDstSel.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/PipelineSpecialization.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvBufferFormat.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppcore/shader/recompiler/SpirvBackend/src/SpirvBufferFormat.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppdocs/dev/debt/shader.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T09:44:52Z.
Review: COMMENTED
Reviewed — comments
The shader change is plausibly supported by the described RDNA2 measurements, but the new test’s CMake registration does not show how its executable is built, leaving test integration unverified.
What I ran
Reviewed head
6b03a9e31bafebe63af5035b28f1a46a43d1236a; base ismain. Read the prepared description, commits, manifest, diff, and all nine changed files listed in the manifest. Inspected the store-channel selection, format classification, specialization setup, and test registration in repository context. No build or test command was run.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_store_dst_sel_tests.cmake:5registersagc_driver_image_store_dst_sel_tests, but repository searches found no other reference that builds or links this executable. Please confirm that another registration mechanism includesImageStoreDstSel.cpp; if none does, add the executable to the test build so these CTest cases can run.Not verified
files.jsonwas not available as a review-folder document.To get this to a good state
Nothing is required. Optional: confirm and document the test executable’s build registration, or add it if absent.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:17:12Z.
Review: COMMENTED
The trial merge onto
a1b75b0947was clean. I checked howStoreChannelsBaseis bounded against neighboring specialization ranges and how the store rule reaches both specialized and registration modules. Please preserve coverage for the same two-channel and constant-one cases in both module paths, since the former reads a specialization constant and the latter derives the class from the runtime format. Local paired Vulkan validation is pending.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.