Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/mimg-sampler-vcc-4991
Oct 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/mimg-sampler-vcc-4991

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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 Shader: MIMG sampler tuple s104/s105/VCC is refused (PPSA99902 conditional startup) #4991 (decoder refusal only; title not rerun)
  • GPUs tested: none
  • AI-assisted: yes

@Amoenus

Amoenus commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

@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 fix(libc): hand out the unwind cursor table through a _nid_no_patch export #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.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

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

xXPBSXx commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

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).

@oneandonlydean
oneandonlydean merged commit 3e485ed into boykopovar:main Oct 14, 2026
7 of 8 checks passed
@xXPBSXx

xXPBSXx commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

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).

RINNECODER added a commit to RINNECODER/AnyPS5 that referenced this pull request Oct 14, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shader: MIMG sampler tuple s104/s105/VCC is refused (PPSA99902 conditional startup)

4 participants