fix(shader): compare through 2D image_sample_c on 1D T#s #5456

Merged
billythemenace2 merged 1 commit from upstream-pr/5456 into main 2026-10-14 20:48:28 +00:00
billythemenace2 commented 2026-10-13 20:08:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-13T20:08:51Z.


What

A depth-compare sample with DIM 2D through a 1D T# (image_sample_c_lz, or plain image_sample_c) now reads the 1D view, the same way #2237 handles image_sample_lz and image_sample through that pair. Before this change the shader got no 1D runtime mode, and the first draw with a 1D T# threw image descriptor is incompatible with the static runtime image interface: descriptor format 7 decodes to {class 1, dim 1, ...}; modes: {class 1, dim 3, ...}.

The change is in ResourceTracker: the compare flag no longer stops an ImageSampleRaw from being flatLineCompatible. Only comparisons the runtime does natively (32_FLOAT, 16_UNORM) reach the 1D view. Comparisons it emulates for other color formats have no 1D mode, so they still throw. The technical debt entry for 2D accesses through a 1D T# is updated to match.

Hardware semantics, measured on RDNA1 (gfx1010, AMD Radeon RX 5700 XT) with the tools/hw-oracle template (template.s unchanged). The kernels were assembled with the Windows driver's amd_comgr_2.dll and launched with its HIP runtime (amdhip64_6.dll). Float modes were IEEE off, DX10 clamp on, denormals preserved and round to nearest even, in wave32 and in wave64 with byte-identical results.

  • T#: 1D, 8 texels, 32_FLOAT and 16_UNORM, linear; also with HEIGHT = 3. S#: point and bilinear filters; wrap, clamp-last-texel and opaque-white border; LESS and GEQUAL compare functions.
  • Rows: u at texel centres 0, 3 and 7, plus u = 1.25 and -0.25; v in {0, 0.5, 1, 1.5, -0.25, 3}; references between every pair of texel values.
  • Result: image_sample_c_lz, image_sample_c and image_sample_c_l (LOD 0) with DIM 2D (ref, u, v) equal the DIM 1D comparison with (ref, u) on every row. v is ignored, including v = 3 and -0.25 under border addressing, and bilinear blends only along u.
  • Implicit LOD: on a 64-texel, 7-mip 32_FLOAT T#, image_sample_c in 2x2 compute quads takes its LOD from u alone. Steps of 1, 4 and 16 texels per lane select mips 0, 2 and 4. v steps of 16, 32 and 64 texels per lane change nothing.
  • As a check of the Windows host, it reproduces the Ubuntu ROCm (gfx1010) measurement from #5375 for image_sample_lz and image_load on 1D T#s.

The measurement tables are attached.
measurement-results-3d-compare-on-1d.md

Tested

  • Windows 11, AMD Radeon RX 5700 XT, Adrenalin 32.0.21045.5002, MinGW GCC 15.2.0. The full build is clean.
  • New test agc_driver_image_plane_compare_on_line (image_sample_c_lz and image_sample_c with DIM 2D on a 16-texel 16_UNORM 1D T#, eight different v values) passes. Without the ResourceTracker change it fails with the error above.
  • ctest -R ^agc_: the same tests fail with and without this change. Those tests also fail on unchanged main (dacd78525) on this machine, including agc_driver_image_plane_address_on_line and agc_driver_image_plane_address_on_line_implicit_lod. No test changes result.
  • python3 tools/check_conventions.py --base origin/main passes.
  • PPSA06888 used to stop at this throw on the first draw with the 1x1 16_UNORM 1D T# (02638c00 00700000 00000000 81800924 ...). With this change, on top of #4474 and #5375, it gets to the menu with music and then stops at a separate, unrelated MSAA error.

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 (#5375 edits the neighbouring lines in ResourceTracker.cpp, which merge cleanly, and adds a debt entry next to the one changed here; whichever PR merges second needs a rebase of that line in docs/dev/debt/shader.md)
  • Unblocks: PPSA06888 #5382
  • GPUs tested: AMD Radeon RX 5700 XT (gfx1010), Adrenalin 32.0.21045.5002, Windows 11
  • AI-assisted: yes. Claude wrote the change, the test and the measurement kernels; I reviewed it and ran the measurements and tests on my machine.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4848839719 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5456). Originally posted by [billythemenace2](https://github.com/billythemenace2) on 2026-10-13T20:08:51Z. --- ### What A depth-compare sample with DIM 2D through a 1D T# (`image_sample_c_lz`, or plain `image_sample_c`) now reads the 1D view, the same way #2237 handles `image_sample_lz` and `image_sample` through that pair. Before this change the shader got no 1D runtime mode, and the first draw with a 1D T# threw `image descriptor is incompatible with the static runtime image interface: descriptor format 7 decodes to {class 1, dim 1, ...}; modes: {class 1, dim 3, ...}`. The change is in `ResourceTracker`: the compare flag no longer stops an `ImageSampleRaw` from being `flatLineCompatible`. Only comparisons the runtime does natively (32_FLOAT, 16_UNORM) reach the 1D view. Comparisons it emulates for other color formats have no 1D mode, so they still throw. The technical debt entry for 2D accesses through a 1D T# is updated to match. Hardware semantics, measured on RDNA1 (gfx1010, AMD Radeon RX 5700 XT) with the `tools/hw-oracle` template (`template.s` unchanged). The kernels were assembled with the Windows driver's `amd_comgr_2.dll` and launched with its HIP runtime (`amdhip64_6.dll`). Float modes were IEEE off, DX10 clamp on, denormals preserved and round to nearest even, in wave32 and in wave64 with byte-identical results. - T#: 1D, 8 texels, 32_FLOAT and 16_UNORM, linear; also with HEIGHT = 3. S#: point and bilinear filters; wrap, clamp-last-texel and opaque-white border; LESS and GEQUAL compare functions. - Rows: u at texel centres 0, 3 and 7, plus u = 1.25 and -0.25; v in {0, 0.5, 1, 1.5, -0.25, 3}; references between every pair of texel values. - Result: `image_sample_c_lz`, `image_sample_c` and `image_sample_c_l` (LOD 0) with DIM 2D (ref, u, v) equal the DIM 1D comparison with (ref, u) on every row. v is ignored, including v = 3 and -0.25 under border addressing, and bilinear blends only along u. - Implicit LOD: on a 64-texel, 7-mip 32_FLOAT T#, `image_sample_c` in 2x2 compute quads takes its LOD from u alone. Steps of 1, 4 and 16 texels per lane select mips 0, 2 and 4. v steps of 16, 32 and 64 texels per lane change nothing. - As a check of the Windows host, it reproduces the Ubuntu ROCm (gfx1010) measurement from #5375 for `image_sample_lz` and `image_load` on 1D T#s. The measurement tables are attached. [measurement-results-3d-compare-on-1d.md](https://github.com/user-attachments/files/33404556/measurement-results-3d-compare-on-1d.md) ### Tested - Windows 11, AMD Radeon RX 5700 XT, Adrenalin 32.0.21045.5002, MinGW GCC 15.2.0. The full build is clean. - New test `agc_driver_image_plane_compare_on_line` (`image_sample_c_lz` and `image_sample_c` with DIM 2D on a 16-texel 16_UNORM 1D T#, eight different v values) passes. Without the `ResourceTracker` change it fails with the error above. - `ctest -R ^agc_`: the same tests fail with and without this change. Those tests also fail on unchanged `main` (dacd78525) on this machine, including `agc_driver_image_plane_address_on_line` and `agc_driver_image_plane_address_on_line_implicit_lod`. No test changes result. - `python3 tools/check_conventions.py --base origin/main` passes. - PPSA06888 used to stop at this throw on the first draw with the 1x1 16_UNORM 1D T# (`02638c00 00700000 00000000 81800924 ...`). With this change, on top of #4474 and #5375, it gets to the menu with music and then stops at a separate, unrelated MSAA error. ### 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 (#5375 edits the neighbouring lines in `ResourceTracker.cpp`, which merge cleanly, and adds a debt entry next to the one changed here; whichever PR merges second needs a rebase of that line in `docs/dev/debt/shader.md`) - [x] Unblocks: PPSA06888 #5382 - [x] GPUs tested: AMD Radeon RX 5700 XT (gfx1010), Adrenalin 32.0.21045.5002, Windows 11 - [x] AI-assisted: yes. Claude wrote the change, the test and the measurement kernels; I reviewed it and ran the measurements and tests on my machine.
KauaSantos702 commented 2026-10-14 13:37:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by KauaSantos702 on 2026-10-14T13:37:55Z.


NVIDIA run at this head (7bce94920), adding a vendor to the AMD results in the body: no agc_* test fails.

  • NVIDIA GeForce RTX 5070 (Blackwell), driver 32.0.16.1714, Windows 11
  • WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON
  • ctest -R '^agc_' -j2: 484 tests, 483 passed, 0 failed, 1 skipped. The skipped test is agc_driver_stencil_ref_export, because the device lacks VK_EXT_shader_stencil_export; it is also skipped on main.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169670680 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5456#issuecomment-6169670680). Originally posted by [KauaSantos702](https://github.com/KauaSantos702) on 2026-10-14T13:37:55Z. --- NVIDIA run at this head (`7bce94920`), adding a vendor to the AMD results in the body: no `agc_*` test fails. - NVIDIA GeForce RTX 5070 (Blackwell), driver 32.0.16.1714, Windows 11 - WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON` - `ctest -R '^agc_' -j2`: 484 tests, 483 passed, 0 failed, 1 skipped. The skipped test is `agc_driver_stencil_ref_export`, because the device lacks `VK_EXT_shader_stencil_export`; it is also skipped on `main`.
jotitadev commented 2026-10-14 17:18:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T17:18:35Z.


Run on an Apple GPU, since the PR was tested only on the RX 5700 XT.

GPUs tested: Apple M2 Max, MoltenVK 1.4.2 (Vulkan 1.4.357), macOS 27.2, x86-64 under Rosetta

main does not run the GPU tests on macOS yet, so I tested on macos-port at b7eb6b6b (mugurc/AnyPS5) with this PR's diff applied, not on main. Release build, LunarG Vulkan SDK 1.4.363.0. The suite is ctest -R agc -E 'flip|display|lds_atomics64' -j1 --timeout 30. Without the PR, 22 tests fail on this branch, all of them known macOS failures listed in #1. Head 7bce94920. The diff applies cleanly, except docs/.

  • agc_driver_image_plane_compare_on_line passes. With only the new test added to the unchanged branch, it fails with image descriptor is incompatible with the static runtime image interface: descriptor format 7 decodes to {class 1, dim 1, ...}, so the 1D compare path runs on this device. MoltenVK normally backs 1D images with 2D textures (its texture1DAs2D setting).
  • Suite: the same 22 failures with and without the PR. None are new and none are fixed.
  • agc_driver_image_plane_address_on_line and agc_driver_image_plane_address_on_line_implicit_lod pass here with and without the PR. The description says they fail on the 5700 XT.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174105303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5456#issuecomment-6174105303). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-14T17:18:35Z. --- Run on an Apple GPU, since the PR was tested only on the RX 5700 XT. GPUs tested: Apple M2 Max, MoltenVK 1.4.2 (Vulkan 1.4.357), macOS 27.2, x86-64 under Rosetta `main` does not run the GPU tests on macOS yet, so I tested on `macos-port` at `b7eb6b6b` (mugurc/AnyPS5) with this PR's diff applied, not on `main`. Release build, LunarG Vulkan SDK 1.4.363.0. The suite is `ctest -R agc -E 'flip|display|lds_atomics64' -j1 --timeout 30`. Without the PR, 22 tests fail on this branch, all of them known macOS failures listed in #1. Head `7bce94920`. The diff applies cleanly, except `docs/`. - `agc_driver_image_plane_compare_on_line` passes. With only the new test added to the unchanged branch, it fails with `image descriptor is incompatible with the static runtime image interface: descriptor format 7 decodes to {class 1, dim 1, ...}`, so the 1D compare path runs on this device. MoltenVK normally backs 1D images with 2D textures (its `texture1DAs2D` setting). - Suite: the same 22 failures with and without the PR. None are new and none are fixed. - `agc_driver_image_plane_address_on_line` and `agc_driver_image_plane_address_on_line_implicit_lod` pass here with and without the PR. The description says they fail on the 5700 XT. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
adriadam10 commented 2026-10-14 19:58:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T19:58:21Z.


Checked on the HW oracle (gfx1035, IEEE off, DX10 clamp on): image_sample_c_lz, image_sample_c and image_sample_c_l with DIM 2D on a 1D T# equal the DIM 1D comparison bit for bit over 63504 rows (32_FLOAT and 16_UNORM, HEIGHT 1 and 3, point/bilinear, wrap/clamp/border, several compare functions, v in {0, 0.5, 1, 1.5, -0.25, 3}), matching your gfx1010 measurements. The new test fails without the ResourceTracker change and passes with it.

Rebased onto main: the only conflict was the 2D-through-1D line in docs/dev/debt/shader.md (#5375 edited it); kept main's text and added your comparison sentence. Tests on the rebased tree: only agc_driver_tessellation fails, as on main. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6177128743 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5456#issuecomment-6177128743). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T19:58:21Z. --- Checked on the HW oracle (gfx1035, IEEE off, DX10 clamp on): `image_sample_c_lz`, `image_sample_c` and `image_sample_c_l` with DIM 2D on a 1D T# equal the DIM 1D comparison bit for bit over 63504 rows (32_FLOAT and 16_UNORM, HEIGHT 1 and 3, point/bilinear, wrap/clamp/border, several compare functions, v in {0, 0.5, 1, 1.5, -0.25, 3}), matching your gfx1010 measurements. The new test fails without the `ResourceTracker` change and passes with it. Rebased onto main: the only conflict was the 2D-through-1D line in `docs/dev/debt/shader.md` (#5375 edited it); kept main's text and added your comparison sentence. Tests on the rebased tree: only `agc_driver_tessellation` fails, as on main. Merging once the full Build is green.
github-actions[bot] commented 2026-10-14 20:17:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T20:17:14Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#5841 core/shader/recompiler/Optimization/src/ResourceTracker.cpp L1509-1510
docs/dev/debt/shader.md L71
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6177490323 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5456#issuecomment-6177490323). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T20:17:14Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5841 | `core/shader/recompiler/Optimization/src/ResourceTracker.cpp` [L1509-1510](https://github.com/boykopovar/AnyPS5/blob/03f49fcf2e90a765551a1d7f36fbde4b5409300b/core/shader/recompiler/Optimization/src/ResourceTracker.cpp#L1509-L1510)<br>`docs/dev/debt/shader.md` [L71](https://github.com/boykopovar/AnyPS5/blob/03f49fcf2e90a765551a1d7f36fbde4b5409300b/docs/dev/debt/shader.md#L71) | | |
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!5456
No description provided.