Skip to content

shader: lower gfx1013 same-texel image loads through the UAV - #2136

Merged
R0Y00 merged 3 commits into
R0Y00:mainfrom
Jess-Doit:shader/gfx1013-image-uav-load
Nov 25, 2026
Merged

R0Y00 merged 3 commits into
R0Y00:mainfrom
Jess-Doit:shader/gfx1013-image-uav-load

Conversation

@Jess-Doit

Copy link
Copy Markdown
Contributor

Refs #1545.

Change

Lower one full-mask gfx1013 2D image_load from the store's mip-zero R32G32B32A32_FLOAT descriptor to asuint(outputData[uint2(x, y)]) on RWTexture2D<float4> at u0. The translator checks the descriptor provenance, requires the load before the store, and matches both coordinate VGPR numbers and tracked values. The destination must use dispatch X/Y with local Z size 1. The caller supplies a single Z dispatch group. Loaded words become available after s_waitcnt vmcnt(0).

The fixture uses the same RGBA32 FLOAT UAV for load and store and skips with exit 77 without TypedUAVLoadAdditionalFormats or the required typed-load and typed-store format bits. D3D12 typed UAV loads

Tests

The shader rotates RGBA to GBAR in 16 unique mip-zero texels over two X groups. The independent CPU reference compares all 1,344 words in three mips, including 1,280 untouched sentinels. The pure-Python checks pin the declaration, read, store and their order. LLVM 15 reassembles the recorded words, disassembles both image instructions and verifies the synthetic container CLI translation. The existing explicit-mip SRV fixture also passed its binary round trip.

Control Result
Drop the UAV read and use zero 64 mismatches on each adapter. First at mip 0, word 0, expected 3f800001, actual 00000000.
Read the neighbour then restore X Rejected. Image UAV load and store must use the same coordinate VGPRs and values.
Read identical coordinates from a different VGPR pair Rejected by the same coordinate check.
Share a destination or use local Z size 2 Rejected. Image UAV load/store requires unique dispatch X/Y coordinates and local Z size 1.
Place the load after the store Image UAV load must precede the image store.
Add a second UAV load or remove the store Only one image UAV load is supported or Expected at least one observable store.
Consume the loaded value without the VM wait Vector load result used or overwritten before s_waitcnt vmcnt(0).
Sparse mask, nonzero UAV mip or A16 Rejected with the full-DMASK or full-width mip-zero diagnostic.
D16, array or 3D Unsupported compute instruction.
Explicit mip through the UAV image_load_mip requires a separate SRV.
Alias the SRV descriptor or use the UAV's SGPRs for an SRV load Rejected by the overlapping descriptor or descriptor provenance check.

Verification

Tested commit 62b0c31105069e6bf0614bd6391857a793e49204 on Windows 10 22H2, build 19045.6456, with DXC 1.9.2602.17 and LLVM 15.0.7 llvm-mc. The GTX 1060 6GB used driver 32.0.15.6094. In-box WARP used Microsoft Basic Render Driver 10.0.19041.5794. The D3D12 debug layer was enabled and reported zero warnings and errors for the fixture and its control on both adapters.

Preset GTX 1060 pass WARP pass Docs pass Fail Capability skip
Debug (dev) 15 15 1 0 0
Release (release) 15 15 1 0 0

Set VULKAN_SDK to the Vulkan SDK 1.4.363.0 installation. Use a Python environment with requirements-dev.txt installed.

. .\tools\dev.ps1
$env:XBOX2WINDOWS_ADAPTER = '1060'
$env:X2W_D3D12_DEBUG = '1'
$python = (Resolve-Path .\out\pe-env\Scripts\python.exe).Path
$filter = '^compute_store_aot_(gfx1013_.*(image|mimg)|mimg_)|^docs_links$'
foreach ($preset in 'dev','release') {
    cmake --preset $preset "-DINTAKE_PYTHON=$python"
    cmake --build --preset $preset --target offscreen_check -j 2
    ctest --preset $preset --no-tests=error -j 1 -V -R $filter
}
& $python -B tests/compute_mimg_image_uav_load_check.py

The local binary checks used LLVM 15.0.7 for assembly, llvm-objcopy to extract .text and libLLVM 15.0.0 to disassemble. The Windows DLL can be extracted to out/libLLVM-15.dll. LLVMSharp Windows runtime package

$mc = (Get-Command llvm-mc -CommandType Application).Source
$objcopy = (Get-Command llvm-objcopy -CommandType Application).Source
$library = (Resolve-Path .\out\libLLVM-15.dll).Path
& $python -B tests/compute_mimg_image_uav_load_check.py --binary $mc $objcopy --llvm $library
& $python -B tests/compute_mimg_float_store_check.py --binary $mc $objcopy --llvm $library
python3 -B tests/compute_mimg_image_uav_load_check.py --binary llvm-mc-15 llvm-objcopy-15 --llvm libLLVM-15.so.1

Limits

The supported launch covers one Z plane and in-bounds, unaliased texels. The measurements cover normal binary32 words on desktop D3D12. Special floating-point values, native console execution and inter-thread ordering are outside the measurement.

After merging main at 5581b4b0 (which brought #2106's D16 stores into the same rules, at head daec8615), I reran the image selection: 33/33 in dev and 33/33 in release on the GTX 1060 and WARP, debug layer on, no skips. The LLVM 15 --binary checks of this fixture and of the D16, 2D and image-atomic fixtures pass too.

Caller contract the translator cannot check: the dispatch must have a single Z group, because the translator proves unique destinations from the dispatch X and Y IDs within one Z plane.

AI-assisted (Codex, driven with Claude Code; Claude Code reviewed the change, merged main and reran the checks).

Jess-Doit and others added 2 commits November 24, 2026 16:34
Conflicts with R0Y00#2106 (D16 image stores): the D16 and RGBA16 FLOAT checks
and the same-texel UAV load checks now form one chain; the store keeps
the UAV coordinate check and R0Y00#2106's two-VGPR data count; the compute
harness keeps both case flags (bit 21 UAV load, bit 22 RGBA16 FLOAT)
and R0Y00#2106's per-format texel size; docs, README, CMake and workflow
keep both entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of head daec8615816d4c8886318462ef3cace66ecdaa17 (comment only).

Scope read: tools/compute_store_aot.py (UAV-load branch, address pairing, Z/X/Y uniqueness guard), tests/compute_mimg_image_uav_load.s, tests/compute_check.cpp (new selector bit 21 plus UAV_TYPED_LOAD requirement), CMake test registration, Windows workflow entry.

Commands run locally (Linux):

  • git diff --stat origin/main...HEAD: 8 files, +282/-14.
  • python3 tests/compute_mimg_image_uav_load_check.py: "Same-texel UAV load translation controls passed".
  • python3 tests/docs_links_check.py: passed (399 links).
  • python3 tests/bidi_controls_check.py: passed.
  • git diff --check origin/main...HEAD: clean.
  • --binary llvm-mc-15 ... mode: not run. llvm-mc-15 and libLLVM-15.so.1 are not installed on this host. CI job "Assemble and translate gfx1013 fixtures" passed, and so did Windows build/test.
  • No separate Win2025 run by me. The PR's own Windows CI is green.

Mutations (both reverted with git checkout -- .):

  1. Dropped the dims[2] != 1 condition. Killed: "Expected rejection: Image UAV load/store requires unique dispatch X/Y coordinates and local Z size 1".
  2. Disabled the load/store coordinate equality check. Killed: "Expected rejection: Image UAV load and store must use the same coordinate VGPRs and values".

Checks: CI green (Linux checks, fixtures, Windows). Title is neutral. No model names in the diff. Mergeable state was reported as UNKNOWN when I looked.

Findings

  • P1: none.
  • P2: none.
  • nit (tools/compute_store_aot.py, UAV-load branch): a lone UAV load with no later store is accepted and lowered. That is harmless, since it is a read-only access. But the Z-size/uniqueness guard only runs when a store pairs with it. A short docstring line saying so, or a rejection test for it, would pin the intent.
  • nit: the docstring says "one Z group" is a caller contract. It is not enforced in the translator, only in the fixture. This is documented, so I am noting it only.

Semantics look right. A same-texel read before the write is race-free when X/Y are injective and Z is a single plane. Ordering is enforced ("must precede the store"). image_load_mip without a separate SRV is now rejected.

AI-assisted; commands listed were executed locally.

@Jess-Doit

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the two mutations.

On the nits:

  • Lone UAV load with no store. That case is already rejected. With image_output set, u0 is the image UAV, so a program whose only access is the load has no observable store. The control at tests/compute_mimg_image_uav_load_check.py:60 removes the image_store from the fixture and expects Expected at least one observable store. So the uniqueness guard never needs to run for an unpaired load, because no translation is produced.
  • One Z group as a caller contract. Right. The translator only sees the shader, and the number of Z groups is chosen at dispatch time, so it cannot check it. It does enforce the parts it can see: local Z size 1 and coordinates equal to dispatch thread X/Y. The docstring states the rest as the caller's requirement, and the harness dispatches (2, 1, 1).

No code change for either, so the head stays daec8615.

Status: ready to merge from our side. CI is green on the current head.

@Jess-Doit

Copy link
Copy Markdown
Contributor Author

Merged current main (681d01f5) at b6dc5726 to clear the conflict. Only CMakeLists.txt conflicted: main's form-coverage environment is kept, along with both typed-UAV-load registrations. Re-run on Windows 10 19045 with the debug layer on (0 D3D12 warnings or errors): GTX 1060 + WARP, 10 passed, 0 failed, 0 skipped. compute_store_check.py binary (LLVM 15), docs links, bidi and git diff --check also pass. The texture-case flag bits are unchanged.

Status: ready to merge from our side.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review of head b6dc5726d8c812aadc1473f0c83eefdfa8a584d1 (comment only).

What changed since my last review (daec8615): only a merge of upstream main. The PR's own diff is unchanged: git diff --stat origin/main...HEAD is still 8 files, +282/-14. The earlier read of the UAV-load branch, fixture and selector bit therefore still applies.

Commands run locally (Linux):

  • python3 tests/compute_mimg_image_uav_load_check.py: "Same-texel UAV load translation controls passed".
  • python3 tests/docs_links_check.py: passed (18 files, 407 links).
  • python3 tests/bidi_controls_check.py: passed (1484 files).
  • git diff --check origin/main...HEAD: clean.
  • gh pr checks 2136: Linux checks, fixture assemble/translate and Windows build/test all pass. The /O2 job and chart publish were skipped.
  • gh pr view: MERGEABLE, title neutral, no model names in the diff.
  • --binary llvm-mc-15 mode not run locally (tool not installed here). The CI fixture job covers it.
  • No separate Win2025 run by me. The PR's Windows CI is green.

Mutation (reverted with git checkout -- .): removed the dims[2] != 1 condition on the UAV-load path in tools/compute_store_aot.py (line 2235). Killed with "Expected rejection: Image UAV load/store requires unique dispatch X/Y coordinates and local Z size 1".

Findings

  • P1: none.
  • P2: none.
  • nit (unchanged from last review): a lone UAV load with no store is accepted, and the Z/X/Y guard only runs when a store pairs with it. This is harmless (read-only). A docstring line would pin the intent.

AI-assisted; commands listed were executed locally.

@legacy-code-archaeologist

Copy link
Copy Markdown
Contributor

Ran head b6dc5726 on three more adapters, Maxwell and Gen9 included. All pass. Windows 11 build 26100, debug layer unavailable.

Test Adapter Driver Translated drop UAV read control
compute_store_aot_gfx1013_image_uav_load_warp Microsoft Basic Render Driver 10.0.26100.8972 1344 words, 0 mismatches 64 mismatches (detected)
..._hardware (XBOX2WINDOWS_ADAPTER=Quadro) NVIDIA Quadro M1000M 32.0.15.7371 1344 words, 0 mismatches 64 mismatches (detected)
..._hardware (XBOX2WINDOWS_ADAPTER=Intel) Intel HD Graphics 530 31.0.101.2111 1344 words, 0 mismatches 64 mismatches (detected)

The translation controls passed on each run. Typed UAV loads of the format used here work on both older GPUs.

AI-assisted.

@stan495 stan495 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.

Verified head b6dc5726 on Windows x64 (dev preset, MSVC 19.44.35228.0, SDK/DXC 10.0.26100.0):

  • python -B tests/compute_mimg_image_uav_load_check.py -> passed
  • cmake --build --preset dev --target offscreen_check -> succeeded
  • ctest --preset dev --no-tests=error -R '^compute_store_aot_gfx1013_image_uav_load_' -V -> 2/2 passed (compute_store_aot_gfx1013_image_uav_load_hardware, compute_store_aot_gfx1013_image_uav_load_warp; groups=2 view_mip=0 compared_words=1344 mismatches=0, drop UAV read failed as expected with 64 mismatches, debug_errors=0 debug_warnings=0)
    • Hardware: AMD Radeon RX 7900 XTX (vendor=1002 device=744c, driver 32.0.32029.2010)
    • WARP: Microsoft Basic Render Driver (vendor=1414 device=008c, driver 10.0.26100.9818)

Verdict: Approved at b6dc5726.

@R0Y00
R0Y00 merged commit 161af38 into R0Y00:main Nov 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants