fix(shader): read explicit-LOD 2D samples through 1D T#s as measured #5583

Merged
mitul72 merged 1 commit from upstream-pr/5583 into main 2026-10-14 23:34:16 +00:00
mitul72 commented 2026-10-14 00:16:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mitul72 on 2026-10-14T00:16:42Z.


What

A 2D image_sample_l through a 1D T# now takes the 1D runtime mode, as image_sample_lz already does, instead of failing the runtime image interface.

Source: hardware measurement on RDNA2 (gfx1036) with tools/hw-oracle, against the same sample with DIM 1D. u inside, on and past the edges; v of 0, 0.5, 1, -0.25 and 3; LOD -1 to 6 on a 5-level R32_FLOAT texture; point, linear and linear-mip filtering; wrap, clamp and border addressing; HEIGHT or DEPTH 3. All 4725 rows matched: the 1D T# decides the addressing and v is ignored. docs/dev/debt/shader.md is updated accordingly.

Test: ImagePlaneAddressOnLine samples a 5-level 1D T# with distinct mip contents at LODs -1 to 6 (fractional included) under point filtering with wrap and clamp and linear-mip filtering with wrap, clamp and border. Each result must equal the same image_sample_l with DIM 1D bit for bit; point results must also be the expected texel of the expected level, linear-mip results the blend of the two selected levels.

Tested

Linux, RX 9060 XT (RADV GFX12, local Mesa). Full ctest passes except agc_driver_tessellation, which segfaults inside RADV while linking pipeline libraries on unmodified upstream 703aa8f63 as well.

Astro Bot (PPSA21567): without this change the title throws this refusal before the crash-site hub on main + #454.

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 (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none. Overlaps #5456 (compare samples through 1D T#s) and #5375 (3D accesses through 1D T#s) on adjacent lines of ResourceTracker.cpp and the docs/dev/debt/shader.md entry. The behaviours are independent: explicit LOD is its own condition and only feeds flatLineCompatible, so it widens neither #5375's 3D path nor #5456's compare path. Whichever merges later combines the conditions and appends its sentence to the entry.
  • Unblocks: PPSA21567 #357
  • GPUs tested: AMD Radeon RX 9060 XT (RADV GFX12, local Mesa build), Linux
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4851138873 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5583). Originally posted by [mitul72](https://github.com/mitul72) on 2026-10-14T00:16:42Z. --- ### What A 2D `image_sample_l` through a 1D T# now takes the 1D runtime mode, as `image_sample_lz` already does, instead of failing the runtime image interface. Source: hardware measurement on RDNA2 (gfx1036) with `tools/hw-oracle`, against the same sample with DIM 1D. u inside, on and past the edges; v of 0, 0.5, 1, -0.25 and 3; LOD -1 to 6 on a 5-level R32_FLOAT texture; point, linear and linear-mip filtering; wrap, clamp and border addressing; HEIGHT or DEPTH 3. All 4725 rows matched: the 1D T# decides the addressing and v is ignored. `docs/dev/debt/shader.md` is updated accordingly. Test: `ImagePlaneAddressOnLine` samples a 5-level 1D T# with distinct mip contents at LODs -1 to 6 (fractional included) under point filtering with wrap and clamp and linear-mip filtering with wrap, clamp and border. Each result must equal the same `image_sample_l` with DIM 1D bit for bit; point results must also be the expected texel of the expected level, linear-mip results the blend of the two selected levels. ### Tested Linux, RX 9060 XT (RADV GFX12, local Mesa). Full `ctest` passes except `agc_driver_tessellation`, which segfaults inside RADV while linking pipeline libraries on unmodified upstream 703aa8f63 as well. Astro Bot (PPSA21567): without this change the title throws this refusal before the crash-site hub on `main` + #454. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none. Overlaps #5456 (compare samples through 1D T#s) and #5375 (3D accesses through 1D T#s) on adjacent lines of `ResourceTracker.cpp` and the `docs/dev/debt/shader.md` entry. The behaviours are independent: explicit LOD is its own condition and only feeds `flatLineCompatible`, so it widens neither #5375's 3D path nor #5456's compare path. Whichever merges later combines the conditions and appends its sentence to the entry. - [x] Unblocks: PPSA21567 #357 - [x] GPUs tested: AMD Radeon RX 9060 XT (RADV GFX12, local Mesa build), Linux - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tibzejoker commented 2026-10-14 08:30:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-14T08:30:03Z.


Runs for this PR at head a98b06534. Windows 11, MinGW-w64 GCC 15.2.0 Release, two GPUs in one machine: Intel UHD Graphics 770 (driver 32.0.101.6129, picked with ANYPS5_GPU=Intel) and RTX 4090 (NVIDIA 616.92).

  • The tests built from this PR's changed test files (agc_driver_image_plane_address_on_line) pass on both GPUs.
  • ctest -R "agc_driver|agc_masked|agc_shader" -j4: no failures on either GPU. Intel: 387 tests, 28 skipped. NVIDIA: 387 tests, 1 skipped (agc_driver_stencil_ref_export). The skips are the same as on main with each GPU. On the UHD 770 they are features it doesn't support: f64, 64-bit and float atomics, mesh shaders, fp16 interpolation and dot, shader clock.

No difference between the two GPUs.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6164224406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5583#issuecomment-6164224406). Originally posted by [tibzejoker](https://github.com/tibzejoker) on 2026-10-14T08:30:03Z. --- Runs for this PR at head `a98b06534`. Windows 11, MinGW-w64 GCC 15.2.0 Release, two GPUs in one machine: Intel UHD Graphics 770 (driver 32.0.101.6129, picked with `ANYPS5_GPU=Intel`) and RTX 4090 (NVIDIA 616.92). - The tests built from this PR's changed test files (`agc_driver_image_plane_address_on_line`) pass on both GPUs. - `ctest -R "agc_driver|agc_masked|agc_shader" -j4`: no failures on either GPU. Intel: 387 tests, 28 skipped. NVIDIA: 387 tests, 1 skipped (`agc_driver_stencil_ref_export`). The skips are the same as on `main` with each GPU. On the UHD 770 they are features it doesn't support: f64, 64-bit and float atomics, mesh shaders, fp16 interpolation and dot, shader clock. No difference between the two GPUs. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-14 22:16:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T22:16:21Z.


@mitul72 I rebased this onto main and combined the condition and the debt entry with #5375 and #5456 (lineSampleFlags kept, explicit LOD feeds only flatLineCompatible): oneandonlydean/AnyPS5@e52e140f5c, branch rebase/5583-sample-through-1d. The branch here doesn't take maintainer pushes, so could you reset it to that commit? Tests pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6179707065 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5583#issuecomment-6179707065). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T22:16:21Z. --- @mitul72 I rebased this onto main and combined the condition and the debt entry with #5375 and #5456 (`lineSampleFlags` kept, explicit LOD feeds only `flatLineCompatible`): [oneandonlydean/AnyPS5@e52e140f5c](https://github.com/oneandonlydean/AnyPS5/commit/e52e140f5cd7396093e79f701b051d0bf36d890b), branch `rebase/5583-sample-through-1d`. The branch here doesn't take maintainer pushes, so could you reset it to that commit? Tests pass.
frankea commented 2026-10-15 04:04:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-15T04:04:02Z.


The merged commit e52e140f5 fails its own new linear-mip check on NVIDIA, deterministically. Windows 11 10.0.26200, RTX 4090 (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 r7, Release, BUILD_TESTING=ON:

AGC graphics: image_sample_l 2d on a 1D texture with linear filtering, linear mips, clamp to edge, u -0.200000, v 0.250000, LOD 1.250000: thread 12 blends the levels to 67.501945, expected 60.000000
  • main at e52e140f5 itself: agc_driver_image_plane_address_on_line fails 3 of 3. Its parent 4808d9c20 passes (two builds on it today, with #5851 and with #6060's earlier head, neither touching the shader recompiler). Current main a077a88df fails 8 of 8, same message, with #6060 or #6168 merged as well.
  • The per-component bit-for-bit comparison against image_sample_l with DIM 1D passes for that thread, so both paths agree on this driver; it is the blend expectation 10 + 40 * LOD that the GPU does not meet at LOD 1.25 with u past the edge under clamp-to-edge. 67.5 corresponds to a blend weight of 0.4375 instead of 0.25.
  • @tibzejoker's run above of this PR's head a98b06534 passed on an RTX 4090 with the same driver, 616.92, so the difference is between that head and the rebased combination with #5375 and #5456 that landed, or in what those two changed underneath.

The other threads of the same case are not reported since Require stops at the first. I can run a variant that prints every thread's blend if that helps narrow it, or test a candidate commit on this box.

Tested with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6184129595 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5583#issuecomment-6184129595). Originally posted by [frankea](https://github.com/frankea) on 2026-10-15T04:04:02Z. --- The merged commit `e52e140f5` fails its own new linear-mip check on NVIDIA, deterministically. Windows 11 10.0.26200, RTX 4090 (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`: ``` AGC graphics: image_sample_l 2d on a 1D texture with linear filtering, linear mips, clamp to edge, u -0.200000, v 0.250000, LOD 1.250000: thread 12 blends the levels to 67.501945, expected 60.000000 ``` - `main` at `e52e140f5` itself: `agc_driver_image_plane_address_on_line` fails 3 of 3. Its parent `4808d9c20` passes (two builds on it today, with #5851 and with #6060's earlier head, neither touching the shader recompiler). Current `main` `a077a88df` fails 8 of 8, same message, with #6060 or #6168 merged as well. - The per-component bit-for-bit comparison against `image_sample_l` with DIM 1D passes for that thread, so both paths agree on this driver; it is the blend expectation `10 + 40 * LOD` that the GPU does not meet at LOD 1.25 with u past the edge under clamp-to-edge. 67.5 corresponds to a blend weight of 0.4375 instead of 0.25. - @tibzejoker's run above of this PR's head `a98b06534` passed on an RTX 4090 with the same driver, 616.92, so the difference is between that head and the rebased combination with #5375 and #5456 that landed, or in what those two changed underneath. The other threads of the same case are not reported since `Require` stops at the first. I can run a variant that prints every thread's blend if that helps narrow it, or test a candidate commit on this box. Tested with AI assistance (Claude Code).
mitul72 commented 2026-10-15 04:50:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mitul72 on 2026-10-15T04:50:48Z.


Thanks for the detailed report. The bit-for-bit comparison against image_sample_l DIM 1D passing on the 4090 shows the 1D path itself is right: both return the same blend there. The absolute 10 + 40 * LOD check assumed AMD's linear-mip weights, which a host driver doesn't have to match. #6221 drops that check for the linear-mip cases and keeps the DIM-1D comparison and the point-sampling checks. A run of it on your box would be welcome.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6184679172 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5583#issuecomment-6184679172). Originally posted by [mitul72](https://github.com/mitul72) on 2026-10-15T04:50:48Z. --- Thanks for the detailed report. The bit-for-bit comparison against `image_sample_l` DIM 1D passing on the 4090 shows the 1D path itself is right: both return the same blend there. The absolute `10 + 40 * LOD` check assumed AMD's linear-mip weights, which a host driver doesn't have to match. #6221 drops that check for the linear-mip cases and keeps the DIM-1D comparison and the point-sampling checks. A run of it on your box would be welcome.
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!5583
No description provided.