startup: support pixel-stage 2D-array image_store and UAV binding #2822

Merged
R0D4X merged 1 commit from upstream-pr/2830 into main 2026-11-26 12:47:41 +00:00
R0D4X commented 2026-11-26 12:40:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-26T12:40:44Z.


Fixes #2742

Root Cause / Motivation

Following the merged compute 2D-array UAV slices (#2744, #2777, #2787), the remaining open part of #2742 was the pixel-stage 2D-array image_store path:

  • tools/startup/gfx2hlsl.py (op_image_store) still refused dim:SQ_RSRC_IMG_2D_ARRAY outside compute stages.
  • src/startup_stubs/d3d12_draw.inl (read_pixel_uav_line and pixel_uav_view) accepted only tex2d manifest lines and D3D12_UAV_DIMENSION_TEXTURE2D views.

Summary

  • Translator (tools/startup/gfx2hlsl.py): Allow dim:SQ_RSRC_IMG_2D_ARRAY in pixel-stage op_image_store (emitting RWTexture2DArray<float4>, uint3(x, y, layer), and uav N tex2da table P O), reusing the existing per-lane exec guard and manifest emission. Pixel d16, 1D/3D/cube dimensions, and partial dmask remain refused.
  • Startup Runtime (src/startup_stubs/d3d12_draw.inl):
    • Extend PixelUav and read_pixel_uav_line to accept tex2da in addition to tex2d (still refusing tex3d, raw buffers, view qualifiers, and channels).
    • Extend pixel_uav_view to validate explicit D3D12_UAV_DIMENSION_TEXTURE2DARRAY views for tex2da (checking MipSlice == 0, PlaneSlice == 0, in-bounds FirstArraySlice/ArraySize, float format with D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE), preserving FirstArraySlice/ArraySize on the created desktop view, and refusing plain 2D or default views for tex2da.
  • Fixtures & Tests (tests/startup_pixel_image_store_check.py, tests/startup_pixel_uav.cpp, tests/startup_pixel_uav_check.py):
    • Add source-built pixel 2D-array image_store programs (relative layers 1 and 3, full and v_cmpx partial EXEC), llvm-mc binary round-trip verification, and refusal checks (2 address registers, pixel d16, 1D/3D/cube).
    • Add a 6-slice, 2-mip R32G32B32A32_FLOAT ALLOW_UNORDERED_ACCESS texture array in startup_pixel_uav.cpp bound through an explicit TEXTURE2DARRAY UAV with FirstArraySlice=1, ArraySize=4 (covering physical slices 1..4).
    • Verify complete fenced readback of all 6 physical slices x 2 mips: relative layers 1 and 3 write only physical slices 2 and 4 at (1, 2) mip 0; exec-on writes slice 2 while exec-off leaves all 6 slices untouched; wrong-layer and dropped-EXEC shader mutations fail readback as expected; plain 2D, default, mip-1, SRV+UAV conflict, no-ALLOW_UNORDERED_ACCESS, and integer-format array views are refused before draw with all 6 slices untouched.

Before / After

  • Before: Pixel-stage image_store ... dim:SQ_RSRC_IMG_2D_ARRAY was refused by gfx2hlsl.py, and d3d12_draw.inl rejected uav N tex2da manifest lines.
  • After: Full-mask FP32 pixel-stage 2D-array image_store translates cleanly and binds tracked TEXTURE2DARRAY UAV views through d3d12_xs.dll with full fenced readback verified on WARP and hardware.

Verification

  • Commit under test: 9a7e98a3 (based on 8c9f168f)
  • Environment: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230, Windows SDK 10.0.26100.0, FXC + DXC 1.9.2602.17
    • WARP: Microsoft Basic Render Driver (1414:008c), driver 10.0.26100.9818
    • Hardware: NVIDIA GeForce RTX 5080 (10de:2c02), driver 32.0.16.2124

Commands and measured results (0 failures, 0 skips):

  • Pure-Python, neighbor, link & bidi checks (git diff --check, startup_pixel_image_store_check.py, startup_compute_image_store_check.py, startup_compute_image_store_d16_check.py, startup_translator_check.py, docs_links_check.py, bidi_controls_check.py): PASS
  • ctest --preset dev --no-tests=error -j 1 -R '^(startup_tools_lint|startup_pixel_image_store_|startup_pixel_uav_|startup_compute_dispatch_array_)' -V: 10/10 passed (50.03 sec, debug layer: on, errors: 0 on WARP and RTX 5080)
  • ctest --preset release --no-tests=error -j 1 -R '^(startup_pixel_image_store_|startup_pixel_uav_|startup_compute_dispatch_array_)' -V: 9/9 passed (56.33 sec, debug layer: on, errors: 0 on WARP and RTX 5080)
  • X2W_PIXEL_UAV_NO_DEBUG=1 ctest --preset release --no-tests=error -j 1 -R '^startup_pixel_uav_' -V: 2/2 passed (27.95 sec, debug layer: absent on WARP and RTX 5080)
  • Live self-mutations (refuse_pixel_array, force_tex2d_kind): 2/2 caught (rc=1) and reverted cleanly.

Evidence Scope

  • Verified locally: pure-Python controls, neighbor/lint/link/bidi checks, dev and release builds and CTests (debug layer enabled and disabled) on WARP and RTX 5080, and tools/disasm_rdna2.py decode of all binary fixture words.
  • Verified in CI (not locally): tests/startup_pixel_image_store_check.py binary llvm-mc-15 in the Ubuntu pixel-binary job (no local llvm-mc installed).

AI-assisted; source-built fixtures only.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6626853133 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2830). Originally posted by [R0D4X](https://github.com/R0D4X) on 2026-11-26T12:40:44Z. --- Fixes #2742 ## Root Cause / Motivation Following the merged compute 2D-array UAV slices (#2744, #2777, #2787), the remaining open part of #2742 was the pixel-stage 2D-array `image_store` path: - `tools/startup/gfx2hlsl.py` (`op_image_store`) still refused `dim:SQ_RSRC_IMG_2D_ARRAY` outside compute stages. - `src/startup_stubs/d3d12_draw.inl` (`read_pixel_uav_line` and `pixel_uav_view`) accepted only `tex2d` manifest lines and `D3D12_UAV_DIMENSION_TEXTURE2D` views. ## Summary - **Translator (`tools/startup/gfx2hlsl.py`):** Allow `dim:SQ_RSRC_IMG_2D_ARRAY` in pixel-stage `op_image_store` (emitting `RWTexture2DArray<float4>`, `uint3(x, y, layer)`, and `uav N tex2da table P O`), reusing the existing per-lane `exec` guard and manifest emission. Pixel `d16`, 1D/3D/cube dimensions, and partial `dmask` remain refused. - **Startup Runtime (`src/startup_stubs/d3d12_draw.inl`):** - Extend `PixelUav` and `read_pixel_uav_line` to accept `tex2da` in addition to `tex2d` (still refusing `tex3d`, raw buffers, view qualifiers, and `channels`). - Extend `pixel_uav_view` to validate explicit `D3D12_UAV_DIMENSION_TEXTURE2DARRAY` views for `tex2da` (checking `MipSlice == 0`, `PlaneSlice == 0`, in-bounds `FirstArraySlice`/`ArraySize`, float format with `D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE`), preserving `FirstArraySlice`/`ArraySize` on the created desktop view, and refusing plain 2D or default views for `tex2da`. - **Fixtures & Tests (`tests/startup_pixel_image_store_check.py`, `tests/startup_pixel_uav.cpp`, `tests/startup_pixel_uav_check.py`):** - Add source-built pixel 2D-array `image_store` programs (relative layers 1 and 3, full and `v_cmpx` partial EXEC), `llvm-mc` binary round-trip verification, and refusal checks (2 address registers, pixel `d16`, 1D/3D/cube). - Add a 6-slice, 2-mip `R32G32B32A32_FLOAT` `ALLOW_UNORDERED_ACCESS` texture array in `startup_pixel_uav.cpp` bound through an explicit `TEXTURE2DARRAY` UAV with `FirstArraySlice=1, ArraySize=4` (covering physical slices `1..4`). - Verify complete fenced readback of all 6 physical slices x 2 mips: relative layers 1 and 3 write only physical slices 2 and 4 at `(1, 2)` mip 0; `exec`-on writes slice 2 while `exec`-off leaves all 6 slices untouched; wrong-layer and dropped-EXEC shader mutations fail readback as expected; plain 2D, default, mip-1, SRV+UAV conflict, no-`ALLOW_UNORDERED_ACCESS`, and integer-format array views are refused before draw with all 6 slices untouched. ## Before / After - **Before:** Pixel-stage `image_store ... dim:SQ_RSRC_IMG_2D_ARRAY` was refused by `gfx2hlsl.py`, and `d3d12_draw.inl` rejected `uav N tex2da` manifest lines. - **After:** Full-mask FP32 pixel-stage 2D-array `image_store` translates cleanly and binds tracked `TEXTURE2DARRAY` UAV views through `d3d12_xs.dll` with full fenced readback verified on WARP and hardware. ## Verification - Commit under test: `9a7e98a3` (based on `8c9f168f`) - Environment: Windows 11 x64 (`10.0.26300.9974`), MSVC `19.44.35230`, Windows SDK `10.0.26100.0`, FXC + DXC `1.9.2602.17` - WARP: `Microsoft Basic Render Driver` (`1414:008c`), driver `10.0.26100.9818` - Hardware: `NVIDIA GeForce RTX 5080` (`10de:2c02`), driver `32.0.16.2124` Commands and measured results (0 failures, 0 skips): - Pure-Python, neighbor, link & bidi checks (`git diff --check`, `startup_pixel_image_store_check.py`, `startup_compute_image_store_check.py`, `startup_compute_image_store_d16_check.py`, `startup_translator_check.py`, `docs_links_check.py`, `bidi_controls_check.py`): **PASS** - `ctest --preset dev --no-tests=error -j 1 -R '^(startup_tools_lint|startup_pixel_image_store_|startup_pixel_uav_|startup_compute_dispatch_array_)' -V`: **10/10 passed** (`50.03 sec`, `debug layer: on, errors: 0` on WARP and RTX 5080) - `ctest --preset release --no-tests=error -j 1 -R '^(startup_pixel_image_store_|startup_pixel_uav_|startup_compute_dispatch_array_)' -V`: **9/9 passed** (`56.33 sec`, `debug layer: on, errors: 0` on WARP and RTX 5080) - `X2W_PIXEL_UAV_NO_DEBUG=1 ctest --preset release --no-tests=error -j 1 -R '^startup_pixel_uav_' -V`: **2/2 passed** (`27.95 sec`, `debug layer: absent` on WARP and RTX 5080) - Live self-mutations (`refuse_pixel_array`, `force_tex2d_kind`): **2/2 caught (`rc=1`)** and reverted cleanly. ## Evidence Scope - Verified locally: pure-Python controls, neighbor/lint/link/bidi checks, `dev` and `release` builds and CTests (debug layer enabled and disabled) on WARP and RTX 5080, and `tools/disasm_rdna2.py` decode of all binary fixture words. - Verified in CI (not locally): `tests/startup_pixel_image_store_check.py binary llvm-mc-15` in the Ubuntu `pixel-binary` job (no local `llvm-mc` installed). AI-assisted; source-built fixtures only.
upstream-sync closed this pull request 2026-11-26 13:03:07 +00:00
tedin7 commented 2026-11-26 13:03:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:47:25Z.

Review: COMMENTED


Review of head 9a7e98a3 against current main (0 behind).

What I checked

  • tools/startup/gfx2hlsl.py: the pixel gate now accepts 2D and 2D-array; 1D/3D/cube, pixel d16 and partial dmask stay refused. Pixel and compute share the array branch, so the uint3(x, y, layer) lowering is the same code already merged in #2744 / #2787.
  • src/startup_stubs/d3d12_draw.inl: tex2da manifest line, the TEXTURE2DARRAY view checks (mip 0, plane 0, slice range with no overflow, float typed-store format) and the plain-2D / default-view refusals for tex2da.
  • Tests: startup_pixel_uav.cpp does a real D3D12 fenced readback of all 6 slices x 2 mips and the python check compares it with a CPU-side expectation (layers 1 and 3 land in physical slices 2 and 4, exec-off leaves all slices untouched). Wrong-layer and dropped-EXEC mutations must fail in that check.
  • Overlap: #2787 (merged) is the compute d16 array path, no shared lines. #2661 (open, pixel sparse dmask) edits the same read_pixel_uav_line / pixel_uav_view region, so whichever merges second will need a keep-both rebase. It is a different slice, not a duplicate.

Commands run locally (Linux)

  • python3 tests/startup_pixel_image_store_check.py: rc 0
  • python3 tests/docs_links_check.py: ok; python3 tests/bidi_controls_check.py: ok; git diff --check origin/main...HEAD: clean
  • Mutation: restored the old compute-only gate in gfx2hlsl.py; startup_pixel_image_store_check.py fails with only 2D images are lowered. Restored afterwards.
  • startup_pixel_uav_check.py needs the built D3D12 fixtures, so I did not run it here. The author's Windows run on this head (WARP and hardware, dev 10/10 and release 9/9) is in the PR body, and the PR's CI "Build and test on Windows" is green.
  • Real-GPU run on a separate card: not available from my side.

No blocking findings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6074372631 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2830#pullrequestreview-6074372631). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T12:47:25Z. **Review:** COMMENTED --- Review of head `9a7e98a3` against current main (0 behind). What I checked - `tools/startup/gfx2hlsl.py`: the pixel gate now accepts 2D and 2D-array; 1D/3D/cube, pixel d16 and partial dmask stay refused. Pixel and compute share the array branch, so the `uint3(x, y, layer)` lowering is the same code already merged in #2744 / #2787. - `src/startup_stubs/d3d12_draw.inl`: `tex2da` manifest line, the TEXTURE2DARRAY view checks (mip 0, plane 0, slice range with no overflow, float typed-store format) and the plain-2D / default-view refusals for `tex2da`. - Tests: `startup_pixel_uav.cpp` does a real D3D12 fenced readback of all 6 slices x 2 mips and the python check compares it with a CPU-side expectation (layers 1 and 3 land in physical slices 2 and 4, exec-off leaves all slices untouched). Wrong-layer and dropped-EXEC mutations must fail in that check. - Overlap: #2787 (merged) is the compute d16 array path, no shared lines. #2661 (open, pixel sparse dmask) edits the same `read_pixel_uav_line` / `pixel_uav_view` region, so whichever merges second will need a keep-both rebase. It is a different slice, not a duplicate. Commands run locally (Linux) - `python3 tests/startup_pixel_image_store_check.py`: rc 0 - `python3 tests/docs_links_check.py`: ok; `python3 tests/bidi_controls_check.py`: ok; `git diff --check origin/main...HEAD`: clean - Mutation: restored the old compute-only gate in `gfx2hlsl.py`; `startup_pixel_image_store_check.py` fails with `only 2D images are lowered`. Restored afterwards. - `startup_pixel_uav_check.py` needs the built D3D12 fixtures, so I did not run it here. The author's Windows run on this head (WARP and hardware, dev 10/10 and release 9/9) is in the PR body, and the PR's CI "Build and test on Windows" is green. - Real-GPU run on a separate card: not available from my side. No blocking findings. AI-assisted; commands listed were executed locally.
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!2822
No description provided.