Skip to content

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

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
MichonGoddijn231849:fix-2d-bias-offset-samples-on-1d-tsharp
Nov 27, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
MichonGoddijn231849:fix-2d-bias-offset-samples-on-1d-tsharp

Conversation

@MichonGoddijn231849

@MichonGoddijn231849 MichonGoddijn231849 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

MichonGoddijn231849 and others added 2 commits November 19, 2026 14:34
A DIM 2D image_sample_b, image_sample_lz_o, image_sample_l_o or
image_sample_b_o through a 1D T# threw "image descriptor is
incompatible with the static runtime image interface": the 1D mode of
2D accesses through a 1D T# took only loads, image_sample_lz, plain
image_sample, image_sample_l and image_gather4_lz.

Measured on gfx1036 with the hardware oracle, each of these equals the
DIM 1D form with the same first coordinate, bias, x offset and LOD on
32 of 32 rows with clamp and wrap addressing, whatever the second
coordinate and the y offset hold. They now take the 1D mode. The
translated offset forms match the hardware on every row on NVIDIA and
AMD; the bias forms equal the translated DIM 1D ones, which differ from
the hardware in compute shaders because their implicit LOD is taken
as 0.

agc_driver_image_plane_offset_on_line samples a two-level 1D texture
with DIM 2D image_sample_lz_o and image_sample_l_o, x offsets from -8
to 7, y offsets and second coordinates the result must ignore, and LOD
0 and 1. agc_driver_image_plane_address_on_line_implicit_lod required
the DIM 2D image_sample_b refusal; it now draws that pixel shader with
a bias of 0 and 1 and expects levels 0 and 1 of the first coordinate's
footprint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A DIM 2D image_load_mip through a 1D T# was refused for the same
reason: the 1D mode took only mip-less loads. Measured on gfx1036 with
the hardware oracle, it equals DIM 1D image_load_mip with the same x
and mip on 32 of 32 rows whatever y holds (0, 1, 2, 5 and -1), and a
mip past the last level reads zero. It now takes the 1D mode, which
matches the hardware on every row on NVIDIA and AMD. The 3D-on-1D mode
keeps its mip-less loads.

agc_driver_image_plane_offset_on_line adds a DIM 2D image_load_mip with
x inside and past each level, y from 0 to -1 and mips 0 to 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MichonGoddijn231849 MichonGoddijn231849 changed the title fix(shader): bind 1D textures to 2D bias and offset samples fix(shader): bind 1D textures to 2D bias, offset and mip-load accesses Nov 19, 2026
@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Ran the focused tests with the Khronos validation layer on Linux and an NVIDIA GPU, since CI runs the GPU tests only on lavapipe and the NVIDIA run in the Tested section is on Windows.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 96bfc118f9 merged onto main fbaae8a79d with --no-ff (clean, as 969d1cbb8c). Main baseline is a Release build of fbaae8a79d on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_driver_image_(plane|volume|sample|gather|one_dimensional)|^agc_shader_memory$|disk_cache' -V
main fbaae8a79d this PR
Result 32 of 32 passed 33 of 33 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 28 29
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

Run on the current head, which includes the second commit 96bfc118f9 (2D mip loads through a 1D T#); the first run on 055b54ec76 gave the same counts. agc_driver_image_plane_offset_on_line is new and does not exist on main; it passes on this PR. agc_driver_image_plane_address_on_line_implicit_lod (now drawing the DIM 2D image_sample_b shader with bias 0 and 1) passes. The three tests that fail on the RTX 5080 on Windows on both sides (agc_driver_image_plane_address_on_line, agc_driver_image_sample_lod_clamp, agc_driver_image_sample_lod_clamp_shader_lane) pass here on main and on this PR. agc_shader_memory and the disk_cache tests create no Vulkan device. Every device selected the RTX 4090.

Negative control: with main's ResourceTracker.cpp and the rest of this PR, both agc_driver_image_plane_offset_on_line and agc_driver_image_plane_address_on_line_implicit_lod fail with ShaderRecompiler::Recompile: image descriptor is incompatible with the static runtime image interface: descriptor format 56 decodes to {class 1, dim 1, ...}. With the change restored both pass.

No new VUID- errors; all focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@tablefrogpillow

Copy link
Copy Markdown
Contributor

Ran this PR's tests on AMD hardware under RADV on Linux. The Tested runs used NVIDIA and AMD's Windows driver on gfx1036, and the run above used NVIDIA on Linux, so RADV and GCN5 had not been covered yet.

Setup: head 96bfc118f9 merged onto main 928e3dd808 with --no-ff (clean). Ubuntu 24.04, GCC, Release, Mesa 26.2.6 RADV, Khronos validation layer 1.4.363. Env: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer. The test executables ran directly, once per GPU. The Vega numbers come from the same binaries on a second machine with the same Mesa and layer versions.

GPU agc_driver_image_plane_address_on_line_implicit_lod agc_driver_image_plane_offset_on_line
RX 7900 GRE (NAVI31, gfx1100, RDNA3) pass pass
Ryzen 7800X3D iGPU (RAPHAEL, gfx1036, RDNA2) pass pass
RX Vega 56 (VEGA10, gfx900, GCN5, Wave64) pass pass
  • Every log shows the loader inserting VK_LAYER_KHRONOS_validation and the selected GPU.
  • None logs was not found but was requested, a VUID- line, or any Validation Error/Warning.
  • The tests as they are on main also pass on all three GPUs.
  • Negative control: this branch's test executables, run against main's libSceAgcDriver.prx, fail on all three GPUs with image descriptor is incompatible with the static runtime image interface (both tests). That is the error this PR removes.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Nov 19, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6280 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 6488 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 7642 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 7684 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 9852 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 9897 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 10193 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 13928 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 13929 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 14032 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 14853 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 14944 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 15555 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 18106 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 18107 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 20248 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 20519 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 22424 core/shader/recompiler/Optimization/src/ResourceTracker.cpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Script-hpp

Copy link
Copy Markdown
Contributor

Tested on Intel Arc B390 (Mesa 26.2.7 ANV, Linux 7.2.10), PR head 96bfc118f9 merged into main 8c254da48b, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (layer 1.4.341, the loader log shows it inserted) and VK_LOADER_DEBUG=layer:

  • ctest -R '^(agc_driver_image_plane_address_on_line_implicit_lod|agc_driver_image_plane_offset_on_line)$' -V: 2/2 pass, no VUID- in the log.
  • Control: the two test files alone on main fail on this device with image descriptor is incompatible with the static runtime image interface: descriptor format 56 decodes to {class 1, dim 1, ...}. So the test catches the bug on this device too.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit fea2053 into boykopovar:main Nov 27, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants