startup: zero-extend R8_UINT vertex fetches #1238

Merged
R0Y00 merged 1 commit from upstream-pr/1245 into main 2026-11-24 05:13:40 +00:00
R0Y00 commented 2026-11-24 05:07:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T05:07:01Z.


Refs #870. A startup pipeline refused BUF_FMT_8_UINT. The translator now extracts the addressed byte from its containing dword and returns the missing integer components as (0, 0, 1).

The source-built fixture fetches vertex-buffer slot 1 with stride 3 and offset 1. It checks the manifest, compiles the complete VS, calls its vertex body from a compute wrapper and compares all four raw component bits against the CPU byte reference for 16 independent indices. The other 256 output words must retain their sentinel. Switching the instruction encoding to R8_UNORM on the same input produces the expected mismatch at word 0.

Tested e784374c with the existing Release offscreen_check.exe and Windows SDK 10.0.26100 DXC. From the checkout with those two tools on PATH:

python -B tests/startup_r8_uint_check.py dxc.exe offscreen_check.exe warp
python -B tests/startup_r8_uint_check.py dxc.exe offscreen_check.exe hardware

Windows 11 build 26200.9974. NVIDIA RTX 4060 Laptop 32.0.16.1656 and WARP 10.0.26100.9818 each matched 320/320 words, detected the UNORM control and reported zero debug-layer errors or warnings. The checks also register as startup_r8_uint_warp and startup_r8_uint_hardware for CTest.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6575069828 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1245). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T05:07:01Z. --- Refs #870. A startup pipeline refused `BUF_FMT_8_UINT`. The translator now extracts the addressed byte from its containing dword and returns the missing integer components as `(0, 0, 1)`. The source-built fixture fetches vertex-buffer slot 1 with stride 3 and offset 1. It checks the manifest, compiles the complete VS, calls its vertex body from a compute wrapper and compares all four raw component bits against the CPU byte reference for 16 independent indices. The other 256 output words must retain their sentinel. Switching the instruction encoding to R8_UNORM on the same input produces the expected mismatch at word 0. Tested `e784374c` with the existing Release `offscreen_check.exe` and Windows SDK 10.0.26100 DXC. From the checkout with those two tools on PATH: ```powershell python -B tests/startup_r8_uint_check.py dxc.exe offscreen_check.exe warp python -B tests/startup_r8_uint_check.py dxc.exe offscreen_check.exe hardware ``` Windows 11 build 26200.9974. NVIDIA RTX 4060 Laptop 32.0.16.1656 and WARP 10.0.26100.9818 each matched 320/320 words, detected the UNORM control and reported zero debug-layer errors or warnings. The checks also register as `startup_r8_uint_warp` and `startup_r8_uint_hardware` for CTest.
tedin7 commented 2026-11-24 05:17:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:17:34Z.

Review: COMMENTED


Reviewed commit e784374c (Linux host — Windows offscreen_check build and startup_r8_uint_{warp,hardware} GPU tests were not executed locally).

Code & Edge-Case Audit

  • tools/startup/gfx2hlsl.py:
    • BUF_FMT_8_UINT lowers to w = {0}.Load(a & ~3u) >> ((a & 3u) * 8u); with components ['w & 255u', '0u', '0u', '1u'].
    • Alignment & bounds: unlike ldu() (which also reads (a & ~3u) + 4 when a & 3u != 0), this reads only the single aligned dword a & ~3u, avoiding an out-of-bounds +4 read on tightly sized buffers.
    • Zero-extension: ByteAddressBuffer.Load returns uint, so the right shift is unsigned and w & 255u zero-extends the selected byte to [0, 255] with no sign extension.
    • Missing components: Y, Z, W emit 0u, 0u, 1u (raw integer 1, matching D3D R8_UINT (0, 0, 0, 1) rather than U(1.0)).
  • tests/startup_r8_uint_check.py, CMakeLists.txt, docs/experiments.md:
    • Title-neutral (AGENTS.md compliant).
    • Exercises vertex-buffer slot 1 with stride 3 (ud4) and offset:1 across 16 vertices (covering all a & 3u byte lanes 0..3), reading asuint(body(id).pos) from a compute wrapper to preserve exact integer bits, with R8_UNORM (format_code=1) as a negative control.
    • Minor note: tests/startup_r8_uint_check.py only has a draw entrypoint (no pure-Python mode wired into .github/workflows/windows.yml), though pipeline(5)/pipeline(1) work standalone in Python.

Checks Run (Linux / Python / LLVM-19)

  • git diff --check origin/main...HEAD: pass (0 issues)
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: pass (16 Markdown files, 280 links)
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: pass (1049 files)
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py: pass
  • Python translation check on tests/startup_r8_uint_check.py (pipeline(5) and pipeline(1)): pass (verified r0.Load(a & ~3u) >> ((a & 3u) * 8u) and w & 255u, 0u, 0u, 1u)
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/startup_sampler_heap_check.py: pass
  • LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so /root/.local/share/x2w-rev-venv/bin/python -B tests/compute_store_check.py binary /usr/bin/llvm-mc-19 /usr/bin/llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: pass (exit 0)
  • Windows build and ctest -R '^startup_r8_uint_(warp|hardware)$': not run locally.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034084543 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1245#pullrequestreview-6034084543). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:17:34Z. **Review:** COMMENTED --- Reviewed commit `e784374c` (Linux host — Windows `offscreen_check` build and `startup_r8_uint_{warp,hardware}` GPU tests were not executed locally). ### Code & Edge-Case Audit - `tools/startup/gfx2hlsl.py`: - `BUF_FMT_8_UINT` lowers to `w = {0}.Load(a & ~3u) >> ((a & 3u) * 8u);` with components `['w & 255u', '0u', '0u', '1u']`. - **Alignment & bounds**: unlike `ldu()` (which also reads `(a & ~3u) + 4` when `a & 3u != 0`), this reads only the single aligned dword `a & ~3u`, avoiding an out-of-bounds `+4` read on tightly sized buffers. - **Zero-extension**: `ByteAddressBuffer.Load` returns `uint`, so the right shift is unsigned and `w & 255u` zero-extends the selected byte to `[0, 255]` with no sign extension. - **Missing components**: Y, Z, W emit `0u`, `0u`, `1u` (raw integer `1`, matching D3D `R8_UINT` `(0, 0, 0, 1)` rather than `U(1.0)`). - `tests/startup_r8_uint_check.py`, `CMakeLists.txt`, `docs/experiments.md`: - Title-neutral (`AGENTS.md` compliant). - Exercises vertex-buffer slot 1 with stride 3 (`ud4`) and `offset:1` across 16 vertices (covering all `a & 3u` byte lanes `0..3`), reading `asuint(body(id).pos)` from a compute wrapper to preserve exact integer bits, with `R8_UNORM` (`format_code=1`) as a negative control. - Minor note: `tests/startup_r8_uint_check.py` only has a `draw` entrypoint (no pure-Python mode wired into `.github/workflows/windows.yml`), though `pipeline(5)`/`pipeline(1)` work standalone in Python. ### Checks Run (Linux / Python / LLVM-19) - `git diff --check origin/main...HEAD`: pass (0 issues) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: pass (16 Markdown files, 280 links) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: pass (1049 files) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py`: pass - Python translation check on `tests/startup_r8_uint_check.py` (`pipeline(5)` and `pipeline(1)`): pass (verified `r0.Load(a & ~3u) >> ((a & 3u) * 8u)` and `w & 255u`, `0u`, `0u`, `1u`) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/startup_sampler_heap_check.py`: pass - `LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so /root/.local/share/x2w-rev-venv/bin/python -B tests/compute_store_check.py binary /usr/bin/llvm-mc-19 /usr/bin/llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: pass (exit 0) - Windows build and `ctest -R '^startup_r8_uint_(warp|hardware)$'`: not run locally.
upstream-sync closed this pull request 2026-11-24 06:47:14 +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!1238
No description provided.