Skip to content

shader: lower gfx1013 D16 image stores to RGBA16 FLOAT - #2106

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
Jess-Doit:shader/gfx1013-image-store-d16
Nov 25, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
Jess-Doit:shader/gfx1013-image-store-d16

Conversation

@Jess-Doit

Copy link
Copy Markdown
Contributor

Refs #1545.

Overlap: #1649 and #2056 (open) change the same gfx1013 image rules in tools/compute_store_aot.py and the texture-case flags in tests/compute_check.cpp. This PR uses flag bit 22, #2056 uses bit 23 and #1649 adds bit 31, so they do not collide. Whichever lands later rebases.

Change

Lower gfx1013 full-mask 2D D16 image_store to RWTexture2D<float4> at u0 when the caller declares an R16G16B16A16_FLOAT UAV at mip zero. Widen the low and high halves of VDATA followed by the low and high halves of VDATA+1 with f16tof32. The typed UAV narrows the four components back to binary16. RDNA 2 ISA §§8.2.1 and 8.2.5

An independent LLVM 15 AMDGPU codegen probe with halves 3c01 c002 4003 b004 placed c0023c01 and b0044003 in the two consecutive store VGPRs. LLVM 15.0.7 llvm-mc rejected one-, three- and four-register full-mask D16 stores with image data size does not match dmask, d16 and tfe.

Tests

The source-built compute fixture writes 16 unique texels at mip zero. It compares all 1,344 raw binary16 halves across all three destination mips, including 1,280 untouched sentinels. The written values include positive and negative normals, subnormals of both signs, and both signed zeros. The translation checks pin the view, register, four half conversions and store index. The binary checks reassemble the recorded bytes and verify the synthetic container CLI output for the new and existing float-store fixtures.

Control Result
Swap the halves of VDATA 32 mismatches on each adapter. First at mip 0, half 0, expected 3c00, actual c000.
Swap VDATA and VDATA+1 64 mismatches on each adapter. First at mip 0, half 0, expected 3c00, actual 0000.
Sparse D16 mask D16 image_store requires full DMASK 0xf.
Wrong-width or out-of-range data tuple D16 image_store requires exactly two consecutive data VGPRs.
D16 load, A16 plus D16, or explicit-mip store D16 requires a 2D image_store with full-width coordinates and implicit mip zero.
Non-2D D16 store or D16 atomic Unsupported compute instruction with the rejected form.
D16 store with RGBA32 FLOAT D16 image_store requires a gfx1013 RGBA16 FLOAT UAV.
Full-width store with RGBA16 FLOAT RGBA16 FLOAT image UAV requires a D16 image_store.
gfx1030 with RGBA16 FLOAT RGBA16 FLOAT requires a gfx1013 D16 image store UAV.
Bind a nonzero mip Image store mip does not match the UAV view.

Verification

Tested commit c3ce6f66f59ff87b34eaf81aeee1a4a2574f8870 on Windows 10 22H2, build 19045.6456, with 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 was enabled on both adapters and reported zero warnings and errors for the D16 fixture and both controls in Debug and Release.

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_d16_check.py

The local binary checks used LLVM 15.0.7 for assembly, llvm-objcopy for .text extraction, and libLLVM 15.0.0 for disassembly and the independent codegen probe. 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_float_store_d16_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_float_store_d16_check.py --binary llvm-mc-15 llvm-objcopy-15 --llvm libLLVM-15.so.1

Limits

The profile is restricted to full-mask 2D stores at mip zero with full-width coordinates and an RGBA16 FLOAT UAV. The measurements cover selected finite binary16 values and in-bounds addresses on desktop D3D12. NaN payloads, infinities and native console execution are outside the measurement.

I reran it at c3ce6f66 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 D16, 2D and image atomics fixtures.

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

@R0Y00
R0Y00 merged commit 84ce294 into R0Y00:main Nov 25, 2026
5 checks passed
Jess-Doit added a commit to Jess-Doit/Xbox2Windows that referenced this pull request Nov 25, 2026
Conflicts with R0Y00#2106 (D16 image stores):
* tools/compute_store_aot.py: the image pattern takes both the dimension
  group and d16; RGBA16 FLOAT setup precedes the view-dimension checks;
  the UAV type uses float_image with the dimension table. A d16 store to
  an array or volume keeps R0Y00#2106's "Unsupported compute instruction"
  refusal.
* tests/compute_check.cpp: both flags (bit 22 RGBA16 FLOAT, bits 31/30
  array and volume), main's per-format texel size, and the per-subresource
  readback with main's 16-bit half comparison.
* README, docs, CMake and workflow keep both entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jess-Doit added a commit to Jess-Doit/Xbox2Windows that referenced this pull request Nov 25, 2026
…e-1d

With R0Y00#2106 (D16 stores) now in the base: the image pattern takes 1D, the
layered dimensions and d16; a d16 store to any dimension other than 2D,
1D included, keeps R0Y00#2106's 'Unsupported compute instruction' refusal; the
harness keeps the 1D flag (bit 23) and the RGBA16 FLOAT flag (bit 22) with
main's per-format texel size and this branch's 1D height. README, docs,
CMake and workflow keep both entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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