fix(shader): accept MIMG sampler tuples ending in VCC #4996

Merged
MarcZX10 merged 1 commit from upstream-pr/4996 into main 2026-10-14 01:34:27 +00:00
MarcZX10 commented 2026-10-13 07:36:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:36:59Z.


What

Closes #4991.

The MIMG decoder rejects sampler base s104 because it checks sampler + 4 > 106. On gfx10, the aligned four-dword sampler tuple at s104 consists of s104, s105, VCC_LO, and VCC_HI. LLVM models this explicitly as SGPR104_128 / SReg_128 (see register definitions and gfx10 MIMG sampler operands). The existing descriptor read path maps the upper two components to the VCC halves.

Allow the exact s104 sampler base while keeping s108 and later bases rejected. Add a regression using the reported synthetic instruction words; it verifies ImageSample decode and sampler resource index 26, plus rejection of base s108.

The issue's title observation came from a private native-MSAA integration; this PR claims only the decoder boundary and synthetic translation regression. It does not claim title progression or hardware validation.

Tested

  • Linux, Release/Ninja after rebasing onto upstream/main 6d7b87370: built image_sample_gather_tests; ctest --test-dir /tmp/AnyPS5-4991-build -R '^image_sample_gather$' --output-on-failure passed (1/1).
  • python3 tools/check_conventions.py --base upstream/main --head HEAD: passed.
  • git diff --check: passed.
  • Not tested on a console or GPU; title not rerun.

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; no silent stubs added
  • No notes, investigation files or images added to the repository
  • No new third-party code or dependencies
  • Generic behavior, not specific to one title
  • Depends on: none
  • Unblocks: PPSA99902 #4991 (decoder refusal only; title not rerun)
  • GPUs tested: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4839963358 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4996). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T07:36:59Z. --- ### What Closes #4991. The MIMG decoder rejects sampler base s104 because it checks `sampler + 4 > 106`. On gfx10, the aligned four-dword sampler tuple at s104 consists of s104, s105, VCC_LO, and VCC_HI. LLVM models this explicitly as `SGPR104_128` / `SReg_128` (see [register definitions](https://github.com/llvm/llvm-project/blob/d8219b47422f7322db252ad29ca8ea87993fb433/llvm/lib/Target/AMDGPU/SIRegisterInfo.td#L452) and [gfx10 MIMG sampler operands](https://github.com/llvm/llvm-project/blob/d8219b47422f7322db252ad29ca8ea87993fb433/llvm/lib/Target/AMDGPU/MIMGInstructions.td#L1379)). The existing descriptor read path maps the upper two components to the VCC halves. Allow the exact s104 sampler base while keeping s108 and later bases rejected. Add a regression using the reported synthetic instruction words; it verifies ImageSample decode and sampler resource index 26, plus rejection of base s108. The issue's title observation came from a private native-MSAA integration; this PR claims only the decoder boundary and synthetic translation regression. It does not claim title progression or hardware validation. ### Tested - Linux, Release/Ninja after rebasing onto upstream/main `6d7b87370`: built `image_sample_gather_tests`; `ctest --test-dir /tmp/AnyPS5-4991-build -R '^image_sample_gather$' --output-on-failure` passed (1/1). - `python3 tools/check_conventions.py --base upstream/main --head HEAD`: passed. - `git diff --check`: passed. - Not tested on a console or GPU; title not rerun. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation files or images added to the repository - [x] No new third-party code or dependencies - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA99902 #4991 (decoder refusal only; title not rerun) - [x] GPUs tested: none - [x] AI-assisted: yes
Amoenus commented 2026-10-13 08:40:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-13T08:40:00Z.


@MarcZX100 Independently checked unchanged #4996 head 3e238ff11d03beedfc9b224f6c749fd2a4f393ab, on Windows 11 Enterprise 26200 / WinLibs GCC 15.2r7 / Release, with RTX 5080 (NVIDIA610.62) and AMD Radeon (32.0.21036.18):

  • Full build/libraries, conventions and test registration pass. Eight relevant groups x5 pass on each GPU, without selected skips, including image_sample_gather.
  • Full NVIDIA suite: 1029 passed /3 failed /8 skipped of1040, max23.309s, parallel2/30s timeout. All three residuals (patched_libraries, agc_driver_bda_span_reads, agc_driver_pixel_interlock) reproduce on exact parent-main6d7b8737 and after restoring/rebuilding the unchanged PR head. This is not a full-green claim. The loader failure matches already-merged #5014; I have not retested that correction in this build.

Additional tests are preserved in our fork commit, directly on top of your unchanged head, with no additional production change:

  • A native recompiled image_sample_lz fixture writes the sampler into s104/s105/VCC_LO/VCC_HI and checks bilinear filtering plus a nonzero white-border high word, wave32 and wave64, all64 lanes/components. Nine relevant groups x5 pass on both GPUs with this supplement, shader cache disabled.
  • Zeroing only the VCC_LO read fails the filtering result (0 instead of0.25); zeroing only VCC_HI fails the white-border result (0 instead of1). Both temporary mutations are restored byte-for-byte and the full build/libraries rebuilt before passing repeats.
  • Supplemental CPU checks verify the four IR component reads for sample, gather and get-lod, and the exact range exception for all encoded sampler bases108..124. The same CPU/native fixture fails at the descriptor guard on unchanged main6d before the fix.

Please feel free to use the supplemental tests and debt entry from that commit. Your sampler >104 predicate is equivalent to our tested sampler +4 >108 because decoded bases are multiples of4. Raw gfx1013/gfx1036 execution remains unmeasured; the native evidence above is for AnyPS5's recompilation. The native fixture covers sample-lz, while gather/get-lod coverage here is CPU IR only. The conditional integration now passes full build/libraries/checkers,26 relevant groups x5 on both GPUs, and full NVIDIA1037/0/8 of1045 (max23.804s). Its exact124-module frozen profile loads x5; only AGC differs from42a,123 other modules are byte-identical, and AGC named imports match. The guarded comparison is complete: prior42a stopped at MIMG descriptor register range overflow after807.203s/59readbacks; the credited-fix profile stops at MTBUF resource descriptor register range overflow after792.920s/59readbacks, with no MIMG range exception logged. Both exit0xC0000409 without the1080s timeout and send the same six300ms pulses (consumption unlogged). The new run also logs GPU submissions36322/36323 not reaching36321 in10s and fence error0xFFFFFFFC before the MTBUF exception; their cause remains untraced, as in the earlier uninstrumented42a run. Protected originals/executable, exact baseline runtime/guest, saved user data, all59 archived readback hashes and source cleanliness are independently rechecked after restoration. This is a changed decoder frontier on a conditional integration, not unchanged-main startup, raw hardware equivalence, gameplay, rendering accuracy, FPS or a speed improvement. MTBUF instruction fields are not captured yet, so no new missing-capability claim or issue follows solely from this refusal. No duplicate fix PR from us.

AI-assisted validation, tests and reporting: Codex; author responsible.

Update (2026-10-15): our retained native fixture is now upstreamed for review in #6422, independently extracted on main940 as a test-only change. Fresh Windows NVIDIA/AMD runs pass50/50 per GPU across initial/restored phases;30 separate fault-control runs detect the old bound or a missing sampler word. The new PR maintains exact pins and scope. The historical conditional replay's saved-user-data restoration wording above is subject to the active-root correction in #3036. AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141700669 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4996#issuecomment-6141700669). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-13T08:40:00Z. --- @MarcZX100 Independently checked **unchanged #4996 head `3e238ff11d03beedfc9b224f6c749fd2a4f393ab`**, on Windows 11 Enterprise 26200 / WinLibs GCC 15.2r7 / Release, with RTX 5080 (NVIDIA610.62) and AMD Radeon (32.0.21036.18): - Full build/libraries, conventions and test registration pass. Eight relevant groups x5 pass on each GPU, without selected skips, including `image_sample_gather`. - Full NVIDIA suite: **1029 passed /3 failed /8 skipped of1040**, max23.309s, parallel2/30s timeout. All three residuals (`patched_libraries`, `agc_driver_bda_span_reads`, `agc_driver_pixel_interlock`) reproduce on exact parent-main6d7b8737 and after restoring/rebuilding the unchanged PR head. This is not a full-green claim. The loader failure matches already-merged #5014; I have not retested that correction in this build. Additional tests are preserved in [our fork commit](https://github.com/Amoenus/AnyPS5/commit/6884fab479437624037a089c1d3c8e7885c66f17), directly on top of your unchanged head, **with no additional production change**: - A native recompiled `image_sample_lz` fixture writes the sampler into s104/s105/VCC_LO/VCC_HI and checks bilinear filtering plus a nonzero white-border high word, wave32 and wave64, all64 lanes/components. Nine relevant groups x5 pass on both GPUs with this supplement, shader cache disabled. - Zeroing only the VCC_LO read fails the filtering result (0 instead of0.25); zeroing only VCC_HI fails the white-border result (0 instead of1). Both temporary mutations are restored byte-for-byte and the full build/libraries rebuilt before passing repeats. - Supplemental CPU checks verify the four IR component reads for sample, gather and get-lod, and the exact range exception for all encoded sampler bases108..124. The same CPU/native fixture fails at the descriptor guard on unchanged main6d before the fix. Please feel free to use the supplemental tests and debt entry from that commit. Your `sampler >104` predicate is equivalent to our tested `sampler +4 >108` because decoded bases are multiples of4. Raw gfx1013/gfx1036 execution remains unmeasured; the native evidence above is for AnyPS5's recompilation. The native fixture covers sample-lz, while gather/get-lod coverage here is CPU IR only. The [conditional integration](https://github.com/Amoenus/AnyPS5/commit/30a9b4afc4946421e8912a35b3c82b5369af5e3f) now passes full build/libraries/checkers,26 relevant groups x5 on both GPUs, and full NVIDIA1037/0/8 of1045 (max23.804s). Its exact124-module frozen profile loads x5; only AGC differs from42a,123 other modules are byte-identical, and AGC named imports match. The guarded comparison is complete: prior42a stopped at `MIMG descriptor register range overflow` after807.203s/59readbacks; the credited-fix profile stops at `MTBUF resource descriptor register range overflow` after792.920s/59readbacks, with no MIMG range exception logged. Both exit0xC0000409 without the1080s timeout and send the same six300ms pulses (consumption unlogged). The new run also logs GPU submissions36322/36323 not reaching36321 in10s and fence error0xFFFFFFFC before the MTBUF exception; their cause remains untraced, as in the earlier uninstrumented42a run. Protected originals/executable, exact baseline runtime/guest, saved user data, all59 archived readback hashes and source cleanliness are independently rechecked after restoration. This is a changed decoder frontier on a conditional integration, not unchanged-main startup, raw hardware equivalence, gameplay, rendering accuracy, FPS or a speed improvement. MTBUF instruction fields are not captured yet, so no new missing-capability claim or issue follows solely from this refusal. No duplicate fix PR from us. AI-assisted validation, tests and reporting: Codex; author responsible. <!-- codex-vcc-native-upstream-v1 --> Update (2026-10-15): our retained native fixture is now upstreamed for review in [#6422](https://github.com/boykopovar/AnyPS5/pull/6422), independently extracted on main940 as a test-only change. Fresh Windows NVIDIA/AMD runs pass50/50 per GPU across initial/restored phases;30 separate fault-control runs detect the old bound or a missing sampler word. The new PR maintains exact pins and scope. The historical conditional replay's saved-user-data restoration wording above is subject to the active-root correction in #3036. AI-assisted: Codex. <!-- /codex-vcc-native-upstream-v1 -->
MarcZX10 commented 2026-10-13 10:18:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T10:18:37Z.


Thanks for the independent validation and for documenting the exact parent-main controls and remaining failures. The NVIDIA and AMD repeats, plus the isolated VCC_LO/VCC_HI mutations, are especially useful evidence for the sampler tuple handling. I’ll keep the PR’s claim scoped to the paths you exercised; I understand this does not establish raw gfx1013/gfx1036 equivalence or title gameplay.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6143377450 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4996#issuecomment-6143377450). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T10:18:37Z. --- Thanks for the independent validation and for documenting the exact parent-main controls and remaining failures. The NVIDIA and AMD repeats, plus the isolated VCC_LO/VCC_HI mutations, are especially useful evidence for the sampler tuple handling. I’ll keep the PR’s claim scoped to the paths you exercised; I understand this does not establish raw gfx1013/gfx1036 equivalence or title gameplay.
xXPBSXx commented 2026-10-14 00:24:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T00:24:40Z.


Windows test of #4996: Windows 10 (19045), MinGW-w64 GCC 15.2, Release, ninja -j 4, ctest called directly, GPU selected by the execution tests: NVIDIA GeForce RTX 4080 SUPER (Selected GPU log line). Tree: main feddf7f4c + merge of PR head 3e238ff11d03beedfc9b224f6c749fd2a4f393ab (local merge 1e384354f).
agc_driver_image_gather_one_dimensional, agc_driver_image_gather_one_dimensional_array, agc_driver_image_packed_horizontal_gather, image_sample_gather: exit code 0, 3 of 3 runs each (12 of 12). Logs: rtx4996_*_N.log.
Not tested: that the new test (ImageSampleGather.cpp) fails without the change (no baseline run), the AMD GPU (present, not selected), other ctest targets, Linux, a title run (PPSA99902).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158068768 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4996#issuecomment-6158068768). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-14T00:24:40Z. --- Windows test of #4996: Windows 10 (19045), MinGW-w64 GCC 15.2, Release, `ninja -j 4`, ctest called directly, GPU selected by the execution tests: NVIDIA GeForce RTX 4080 SUPER (`Selected GPU` log line). Tree: `main` `feddf7f4c` + merge of PR head `3e238ff11d03beedfc9b224f6c749fd2a4f393ab` (local merge `1e384354f`). `agc_driver_image_gather_one_dimensional`, `agc_driver_image_gather_one_dimensional_array`, `agc_driver_image_packed_horizontal_gather`, `image_sample_gather`: exit code 0, 3 of 3 runs each (12 of 12). Logs: `rtx4996_*_N.log`. Not tested: that the new test (`ImageSampleGather.cpp`) fails without the change (no baseline run), the AMD GPU (present, not selected), other ctest targets, Linux, a title run (PPSA99902). AI-assisted (Claude Code).
xXPBSXx commented 2026-10-14 01:50:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T01:50:13Z.


Correction to my Windows test above: I wrote that the GPU was shown by a Selected GPU log line, but that line was not in the ctest logs of those runs (ctest without -V does not print the output of passing tests). A later interactive run of agc_driver_image_gather_one_dimensional with ctest -V showed Selected GPU name=NVIDIA GeForce RTX 4080 SUPER; I did not keep a log of that run, and the other three targets were not re-run with -V.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159089085 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4996#issuecomment-6159089085). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-14T01:50:13Z. --- Correction to my Windows test above: I wrote that the GPU was shown by a `Selected GPU` log line, but that line was not in the ctest logs of those runs (ctest without `-V` does not print the output of passing tests). A later interactive run of `agc_driver_image_gather_one_dimensional` with `ctest -V` showed `Selected GPU name=NVIDIA GeForce RTX 4080 SUPER`; I did not keep a log of that run, and the other three targets were not re-run with `-V`. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4996
No description provided.