shader: lower float loads and stores in the SPIR-V address window #1340
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1347"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:50:51Z.
What
The SPIR-V address-window adapter now lowers 32-bit float accesses through a physical pointer:
OpConvertUToPtr %_ptr_PSB_float,OpAccessChaininto a%rt_floatarray (%_ptr_PSB_arrf, stride 4), and a plainOpLoad %floatorOpStoreof a float (no memory operand orAligned 4). It copies the signed-integer pattern: each access runs in a branch taken only for an aligned, in-window address whose index addition does not wrap. A load is anOpBitcast %floatof the loaded heap word, and a store is anOpBitcast %uintof the value. Outside the branch a load yields bit pattern zero (0.0) and a store changes nothing. A bit-cast keeps every bit, including a NaN payload and the sign of a zero.Every existing form and error message is unchanged. Still refused: atomics,
Volatile, another alignment, half and double pointers, a multi-index access chain, a float access through an unsigned pointer (all with the existing messages). The lowered output for every existing fixture is byte-identical to origin/main.Also added:
tests/spirv_window/address_float.{spvasm,py}, a--spirv-address-window-floatreadback inreadback.cppandoffscreen_check.cpp, the CMake entry next to the other address-window tests, and a paragraph indocs/experiments.md.Why
Float loads and stores are the next scalar form after unsigned, signed and 64-bit integers, and a module that touches float data through a physical address could not be lowered at all.
Tested with
Windows (not run by the author):
The same name with
_hardwareruns on a real adapter. It does the D3D12 readback of 11 cases against a CPU model, then 7 mutations that must each diverge at a predicted case and word.Linux (run by the author, Debian spirv-tools and spirv-cross):
python3 -B tests/spirv_window/address_float.py spirv-as spirv-val spirv-cross: validation of source, lowered and mutated modules, shape checks, HLSL check, 11 rejection cases, a mixed unsigned and float module, and a Python model whose predicted first-divergence word for each of the 7 mutations is checked.tests/spirv_window/check.pyandaddress_signed.py,tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check.readback.cppwas compiled on its own and agrees word for word with the Python model on all 11 cases.Not run: DXC, WARP, hardware, or the Windows build, so
readback.cppandoffscreen_check.cppwere not compiled in the real build. Whether a compiled shader keeps a NaN payload on a given GPU is measured only by the readback. SPIRV-Cross 2021.01.15 (the Ubuntu CI version) was not available locally; the HLSL check only countsasuint(and.Store(and looks forasfloat(, which both spellings should satisfy.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:57:09Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
b27f4eed77c27f9c3b92d71b5c6ed867e50b8eaf:--preset dev):cmake --build --preset dev --target offscreen_check -- -j 6):5.13s(configure1.54s)ctest --preset dev -R '^spirv_address_window_float_warp$' --no-tests=error --output-on-failure): 1/1 passed (1.39s)/O2(--preset release):cmake --build --preset release --target offscreen_check -- -j 6):3.84s(configure1.58s)ctest --preset release -R '^spirv_address_window_float_warp$' --no-tests=error --output-on-failure): 1/1 passed (1.38s)Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:57:22Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
b27f4eeℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.