fix(shader): bind 1D textures to 2D bias, offset and mip-load accesses #23701

Merged
MichonGoddijn231849 merged 2 commits from upstream-pr/23701 into main 2026-11-27 04:10:25 +00:00
MichonGoddijn231849 commented 2026-11-19 13:38:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-11-19T13:38:15Z.


What

A DIM 2D image_sample_b, image_sample_lz_o, image_sample_l_o, image_sample_b_o or image_load_mip through a 1D T# threw image descriptor is incompatible with the static runtime image interface. The 1D mode for 2D accesses through a 1D T# (flatLineCompatible, #2237) took only loads, image_sample_lz, plain image_sample, image_sample_l and image_gather4_lz.

  • ResourceTracker.cpp:
    • a DIM 2D sample whose flags combine bias or offset with only level-zero, LOD, bias and offset also keeps the 1D mode;
    • so does a DIM 2D image_load_mip. The 3D-on-1D mode keeps its mip-less loads. Through a 2D-array view of a 1D T#, only the measured _lz and _l forms are taken, as before.
  • Debt: a new 2D bias, offset and mip-load accesses through a 1D T# entry records the measurement.

No cache format change: flatLineCompatible is an existing field.

Measurement: tools/hw-oracle on gfx1036. The source was a 64-texel, five-level 32_FLOAT 1D T# (texel = level·1000 + x) with clamp and wrap addressing. There were 32 rows per case, with u in [-0.3, 1.3], second coordinates 0, 0.5, 1, 3, -0.25 and 7, biases -1 to 3.5, x and y offsets -8 to 7, and LODs 0 to 3:

access hardware DIM 2D = DIM 1D main DIM 2D branch DIM 2D vs hardware, NVIDIA / AMD
image_sample_lz_o, clamp / wrap 32/32, 32/32 throws 32/32, 32/32 on both
image_sample_l_o, clamp / wrap 32/32, 32/32 throws 32/32, 32/32 on both
image_sample_b, clamp / wrap 32/32, 32/32 throws 0/32, as main's DIM 1D image_sample_b
image_sample_b_o, clamp / wrap 32/32, 32/32 throws 0/32, as main's DIM 1D image_sample_b_o
image_load_mip, x 0 to 70, y 0, 1, 2, 5 and -1, mips 0 to 7 32/32 (y ignored, mips past the last level read 0) throws 32/32 on both

The bias forms take the same path as DIM 1D. Their translated results equal the translated DIM 1D ones on 32/32 rows on both GPUs. Both differ from the hardware in a compute shader only because the translation takes a compute shader's implicit LOD as 0, while the hardware uses the quad derivatives. In a pixel shader the bias works as the test below shows.

Tested

Windows 11 Pro 10.0.26200, MinGW Release build. ctest --test-dir build -R '^agc_driver_image_(plane|volume|sample|gather|one_dimensional)|^agc_shader_memory$|disk_cache' -V with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, on main and on this branch. The GPUs were an NVIDIA GeForce RTX 5080 (610.74) and an AMD Radeon(TM) Graphics iGPU (gfx1036, 32.0.21045.16010).

main NVIDIA main AMD branch NVIDIA branch AMD
Result 31/34 34/34 32/35 35/35
Insert instance layer "VK_LAYER_KHRONOS_validation" 28 28 29 29
was not found but was requested 0 0 0 0
VUID- 0 0 0 0

The three NVIDIA failures are the same on both sides: agc_driver_image_plane_address_on_line (linear mip blending, see #6221), agc_driver_image_sample_lod_clamp and agc_driver_image_sample_lod_clamp_shader_lane.

  • New agc_driver_image_plane_offset_on_line (compute):
    • DIM 2D image_sample_lz_o and image_sample_l_o through a two-level 16-texel 1D texture;
    • x offsets from -8 to 7, with y offsets and second coordinates the result must ignore;
    • LOD 0 and 1 for _l_o;
    • a DIM 2D image_load_mip with x inside and past each level, y from 0 to -1 and mips 0 to 3;
    • passes on both GPUs.
  • agc_driver_image_plane_address_on_line_implicit_lod (pixel shader) used to require the DIM 2D image_sample_b refusal. It now draws that shader with a bias of 0 and of 1 at one texel per pixel and expects levels 0 and 1 of the first coordinate's footprint. Passes on both GPUs.
  • Negative checks:
    • with main's ResourceTracker.cpp, the new test fails on both GPUs with the refusal;
    • with only the mip-load condition removed, it fails on its image_load_mip.
  • An intermediate version kept the old refusal check, and agc_driver_image_plane_address_on_line_implicit_lod failed with image_sample_b 2d on a 1D texture was not refused. That is the check this change replaces.

tools/pr_overlap.py could not compare ResourceTracker.cpp with the PRs that conflict with main; none of their diffs touches the flatLine conditions. My open #23644 and #23519 edit other conditions a few lines above. Not tested on a PS5.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5080, driver 610.74, Windows 11 Pro 10.0.26200; AMD Radeon(TM) Graphics (RDNA2 iGPU, gfx1036), driver 32.0.21045.16010, Windows 11 Pro 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5395969866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23701). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-11-19T13:38:15Z. --- ### What A DIM 2D `image_sample_b`, `image_sample_lz_o`, `image_sample_l_o`, `image_sample_b_o` or `image_load_mip` through a 1D T# threw `image descriptor is incompatible with the static runtime image interface`. The 1D mode for 2D accesses through a 1D T# (`flatLineCompatible`, #2237) took only loads, `image_sample_lz`, plain `image_sample`, `image_sample_l` and `image_gather4_lz`. - **`ResourceTracker.cpp`:** - a DIM 2D sample whose flags combine bias or offset with only level-zero, LOD, bias and offset also keeps the 1D mode; - so does a DIM 2D `image_load_mip`. The 3D-on-1D mode keeps its mip-less loads. Through a 2D-array view of a 1D T#, only the measured `_lz` and `_l` forms are taken, as before. - **Debt:** a new `2D bias, offset and mip-load accesses through a 1D T#` entry records the measurement. No cache format change: `flatLineCompatible` is an existing field. **Measurement:** `tools/hw-oracle` on gfx1036. The source was a 64-texel, five-level 32_FLOAT 1D T# (texel = level·1000 + x) with clamp and wrap addressing. There were 32 rows per case, with u in [-0.3, 1.3], second coordinates 0, 0.5, 1, 3, -0.25 and 7, biases -1 to 3.5, x and y offsets -8 to 7, and LODs 0 to 3: | access | hardware DIM 2D = DIM 1D | `main` DIM 2D | branch DIM 2D vs hardware, NVIDIA / AMD | | --- | --- | --- | --- | | `image_sample_lz_o`, clamp / wrap | 32/32, 32/32 | throws | 32/32, 32/32 on both | | `image_sample_l_o`, clamp / wrap | 32/32, 32/32 | throws | 32/32, 32/32 on both | | `image_sample_b`, clamp / wrap | 32/32, 32/32 | throws | 0/32, as `main`'s DIM 1D `image_sample_b` | | `image_sample_b_o`, clamp / wrap | 32/32, 32/32 | throws | 0/32, as `main`'s DIM 1D `image_sample_b_o` | | `image_load_mip`, x 0 to 70, y 0, 1, 2, 5 and -1, mips 0 to 7 | 32/32 (y ignored, mips past the last level read 0) | throws | 32/32 on both | The bias forms take the same path as DIM 1D. Their translated results equal the translated DIM 1D ones on 32/32 rows on both GPUs. Both differ from the hardware in a compute shader only because the translation takes a compute shader's implicit LOD as 0, while the hardware uses the quad derivatives. In a pixel shader the bias works as the test below shows. ### Tested Windows 11 Pro 10.0.26200, MinGW Release build. `ctest --test-dir build -R '^agc_driver_image_(plane|volume|sample|gather|one_dimensional)|^agc_shader_memory$|disk_cache' -V` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer`, on `main` and on this branch. The GPUs were an NVIDIA GeForce RTX 5080 (610.74) and an AMD Radeon(TM) Graphics iGPU (gfx1036, 32.0.21045.16010). | | `main` NVIDIA | `main` AMD | branch NVIDIA | branch AMD | | --- | --- | --- | --- | --- | | Result | 31/34 | 34/34 | 32/35 | 35/35 | | `Insert instance layer "VK_LAYER_KHRONOS_validation"` | 28 | 28 | 29 | 29 | | `was not found but was requested` | 0 | 0 | 0 | 0 | | `VUID-` | 0 | 0 | 0 | 0 | The three NVIDIA failures are the same on both sides: `agc_driver_image_plane_address_on_line` (linear mip blending, see #6221), `agc_driver_image_sample_lod_clamp` and `agc_driver_image_sample_lod_clamp_shader_lane`. - New `agc_driver_image_plane_offset_on_line` (compute): - DIM 2D `image_sample_lz_o` and `image_sample_l_o` through a two-level 16-texel 1D texture; - x offsets from -8 to 7, with y offsets and second coordinates the result must ignore; - LOD 0 and 1 for `_l_o`; - a DIM 2D `image_load_mip` with x inside and past each level, y from 0 to -1 and mips 0 to 3; - passes on both GPUs. - `agc_driver_image_plane_address_on_line_implicit_lod` (pixel shader) used to require the DIM 2D `image_sample_b` refusal. It now draws that shader with a bias of 0 and of 1 at one texel per pixel and expects levels 0 and 1 of the first coordinate's footprint. Passes on both GPUs. - Negative checks: - with `main`'s `ResourceTracker.cpp`, the new test fails on both GPUs with the refusal; - with only the mip-load condition removed, it fails on its `image_load_mip`. - An intermediate version kept the old refusal check, and `agc_driver_image_plane_address_on_line_implicit_lod` failed with `image_sample_b 2d on a 1D texture was not refused`. That is the check this change replaces. `tools/pr_overlap.py` could not compare `ResourceTracker.cpp` with the PRs that conflict with `main`; none of their diffs touches the `flatLine` conditions. My open #23644 and #23519 edit other conditions a few lines above. Not tested on a PS5. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 5080, driver 610.74, Windows 11 Pro 10.0.26200; AMD Radeon(TM) Graphics (RDNA2 iGPU, gfx1036), driver 32.0.21045.16010, Windows 11 Pro 10.0.26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-21 07:40:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:40:37Z.

Review: APPROVED


Reviewed — looks good

The reviewed change at head 96bfc118f9f90027235713ebd89c6a7cae82666d is internally consistent in the changed compatibility logic and tests; no checks were run during this review.

What I ran

No commands or tests were run. I inspected the prepared diff and the changed files at the pinned head.

Results

Check Result Note
Source review passed Four changed files read
Tests not run Author-reported results only

Findings

Blocking

None.

Non-blocking

None.

Not verified

The hardware measurements and test results described by the author were not independently verified. Build and test execution were not performed. All four changed files listed in the manifest were read; no changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003889656 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23701#pullrequestreview-6003889656). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:40:37Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change at head `96bfc118f9f90027235713ebd89c6a7cae82666d` is internally consistent in the changed compatibility logic and tests; no checks were run during this review. ## What I ran No commands or tests were run. I inspected the prepared diff and the changed files at the pinned head. ## Results | Check | Result | Note | | --- | --- | --- | | Source review | passed | Four changed files read | | Tests | not run | Author-reported results only | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The hardware measurements and test results described by the author were not independently verified. Build and test execution were not performed. All four changed files listed in the manifest were read; no changed files were excluded. ## To get this to a good state Nothing is required.
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!23701
No description provided.