shader: lower gfx1013 D16 image stores to RGBA16 FLOAT #2099

Merged
Jess-Doit merged 1 commit from upstream-pr/2106 into main 2026-11-25 00:49:38 +00:00
Jess-Doit commented 2026-11-25 00:26:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T00:26:47Z.


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).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6594274380 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2106). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-25T00:26:47Z. --- 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](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content) 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. ```powershell . .\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](https://www.nuget.org/packages/libLLVM.runtime.win-x64/15.0.0) ```powershell $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 ``` ```bash 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).
upstream-sync closed this pull request 2026-11-25 01:01:42 +00:00
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
R0Y00/Xbox2Windows!2099
No description provided.