Skip to content

shader: lower gfx1013 1D float image stores and mip loads - #2056

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
Jess-Doit:shader/compute-image-1d
Nov 25, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
Jess-Doit:shader/compute-image-1d

Conversation

@Jess-Doit

Copy link
Copy Markdown
Contributor

Refs #1545. Stacked on #1649 (at a9fb1792): this PR also shows #1649’s commits until #1649 merges, and the change here is only 3e27abf6. It stays a draft until then; I’ll rebase onto main once #1649 lands.

Change

Lower gfx1013 full-mask R32G32B32A32_FLOAT 1D stores to RWTexture1D<float4> at u0. Lower explicit-mip reads from a separate descriptor to Texture1D<float4> at t0, with Load(int2(x, mip)). The caller declares the UAV and SRV dimensions independently. RDNA 2 specifies one address VGPR for the store and two for the load (§8.2.3, Table 42). LLVM 15 accepted both forms and rejected the wrong address widths. AMD RDNA 2 ISA

The compute fixture adds a distinct 1D case flag and uses the existing footprint-based upload and readback path.

Tests

The source-built shader copies all four channels from source mips 1 and 2 into eight unique texels of destination mip 0. The CPU reference compares all 224 destination words across mips of widths 32, 16 and 8, including 192 sentinels. The LLVM check reassembles the recorded bytes, disassembles the MIMG instructions, and compares the container CLI output against the HLSL from the assembly text.

Control Result
Force the source mip to zero 32 mismatches on each adapter. First at mip 0, word 0, expected 3f100000, actual 3f000000.
Shift destination X by one 36 mismatches on each adapter. First at mip 0, word 0, expected 3f100000, actual sentinel bf000000.
Sparse store or load mask Rejected with the operation's requires full DMASK 0xf diagnostic.
D16, 1D arrays, or 1D atomics Rejected as Unsupported compute instruction, identifying the instruction.
A16, plain image_load, or image_store_mip Rejected as an unsupported image load or store target.
Store with extra address VGPR or load missing its mip VGPR Rejected as an unsupported image target. LLVM 15 reports image address size does not match dim and a16.
Same descriptor, overlapping descriptors, or absent separate SRV Rejected by the descriptor or binding check.
Wrong UAV or SRV dimension, gfx1030, or UINT binding Rejected by the corresponding view or gfx1013 RGBA32 FLOAT binding check.
Omit vmcnt(0) Rejected for consuming the load before the wait.

Verification

Tested commit 3e27abf675945f30785477f3b457e7f92eabbe87 on Windows 10 22H2, build 19045.6456, using DXC 1.9.2602.17. 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 reported zero warnings and errors for the 1D fixture and its controls 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_float_store_1d_check.py

The local binary checks used LLVM 15.0.7 for assembly, llvm-objcopy to extract .text, and libLLVM 15.0.0 from the LLVMSharp NuGet runtime for disassembly. 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
foreach ($suite in 'float_store_1d','float_store','float_store_layers') {
    & $python -B "tests/compute_mimg_NAME_check.py".Replace('NAME', $suite) --binary $mc $objcopy --llvm $library
}
python3 -B tests/compute_mimg_float_store_1d_check.py --binary llvm-mc-15 llvm-objcopy-15 --llvm libLLVM-15.so.1

Limits

The 1D profile requires full masks, full-width addresses and data, and a separate read-only SRV for explicit mips. The fixture exercises in-bounds coordinates and normal binary32 values on desktop D3D12. Console out-of-bounds behavior, special floating-point values, and arbitrary resource formats are outside the measurement.

I reran it at 3e27abf6 on the same machine: 31/31 in dev and 31/31 in release (GTX 1060 and WARP, debug layer on, no skips), plus the LLVM 15 --binary checks of the 1D, 2D and layers fixtures.

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

@Jess-Doit

Copy link
Copy Markdown
Contributor Author

Kept in step: d9d5ce8b merges the new #1649 head, which already includes current main. The CLI's lower() call forwards both image_srv_dimension and main's load_format_constant. On GTX 1060 + WARP: 12 passed, 0 failed, 0 skipped. LLVM 15 fixture checks, docs links and bidi also pass.

Status: still a draft that depends on #1649. I'll rebase it onto main and mark it ready once #1649 merges.

@Jess-Doit
Jess-Doit force-pushed the shader/compute-image-1d branch from d9d5ce8 to 0300282 Compare November 25, 2026 17:08
@Jess-Doit

Copy link
Copy Markdown
Contributor Author

Rebased onto the refreshed #1649 (9ae3d2ed, on main 7092683a) and force-pushed: head is now 03002826.

One behaviour change from the rebase: main's same-texel UAV load path (#2136) now applies only to 2D views. Before, a plain 1D image_load would enter it and be refused later, as an unverified descriptor. Now it gets the existing full-width refusal, which is what this PR's control expects. The UAV-load docs already describe that path as 2D-only.

Tests on Windows 10 build 19045, dev preset, GTX 1060 6GB (driver 32.0.15.6094) and in-box WARP 10.0.19041.

  • compute_store_aot_gfx1013_image_: 12 of 12.
  • Pure-Python: the 1D, layers, UAV load, D16 and heap-store checks pass.

This stays a draft until #1649 merges.

@Jess-Doit
Jess-Doit force-pushed the shader/compute-image-1d branch from 0300282 to 84e3682 Compare November 25, 2026 20:41
@Jess-Doit

Copy link
Copy Markdown
Contributor Author

Moved onto the rebased #1649 (fab79c8e, on main 5123cc6d) and force-pushed: head is now 84e36821. There were no conflicts.

Tests: ctest -R "mimg|image_store|image_load|1d" on GTX 1060 + WARP: 45 of 46 pass. The one failure, startup_image_load_d16_warp, fails on main on this host too.

Still a draft until #1649 merges. Ready for more review.

Full-mask R32G32B32A32_FLOAT image_store into a 1D UAV view and
full-mask image_load_mip from a separate 1D SRV, declared with
--image-uav-dimension 1d and --image-srv-dimension 1d, lower to
RWTexture1D<float4> and Texture1D<float4>.Load(int2(x, mip)). The
same-texel UAV load path stays 2D: a plain image_load of another
dimension is refused as before.

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

Copy link
Copy Markdown
Contributor Author

#1649 is merged, so this is rebased onto current main (0104f763) as one commit and force-pushed: head is now ce50e406. There were no conflicts. It now contains only the 1D change, and I'm marking it ready for review.

Tests on Windows 10 19045, GTX 1060 + WARP:

  • ctest -R "mimg|image_store|image_load|1d": 48 of 49 pass.
  • The one failure, startup_image_load_d16_warp, fails on main on this host too.
  • All zero-argument *_controls in tests/compute_store_check.py pass, and so do the 1D translation controls.

Ready for more review.

@Jess-Doit
Jess-Doit force-pushed the shader/compute-image-1d branch from 84e3682 to ce50e40 Compare November 25, 2026 21:52
@Jess-Doit
Jess-Doit marked this pull request as ready for review November 25, 2026 21:52
@R0Y00
R0Y00 merged commit adc2fd9 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.

2 participants