shader: set the 64-UAV-slot DXIL flag when a module declares more than 8 UAVs #3272

Manually merged
github merged 1 commit from github-bot/gh-3270 into gh-pr/3270/base 2026-11-28 03:48:20 +00:00 AGit
Owner

@⁠Not-Saii on GitHub · 2026-11-28 03:33 UTC · original
Not-Saii:shader/uav-slots-flag → main · +64 −1 · 3 files · 1 commits · merged 2026-11-28 03:45 UTC

Refs #3226

DXC sets shader flag 0x8000 (64 UAV slots) when a module's declared UAV ranges add up to more than 8 slots, and the DXIL validator refuses a module whose declared flags differ:

error: Flags must match usage.
note: Flags declared=1572880, actual=1605648
Validation failed.

The direct emitter never set that bit. DxilModule::finish_compute (src/dxil_module.h) now sums the UAV range sizes of its resource records and sets the flag above 8. Every direct compute and graphics module goes through this function, so the fix is in one place.

Test

New native_uav_slots_controls (tests/native_uav_slots_check.py): two source-built compute containers store to 8 and 9 buffer descriptors read from one descriptor table. Both must compile and validate, and compile_dxil must report 8 and 9 UAV bindings.

  • Negative control: the 8-UAV case must compile without the flag. Setting the flag unconditionally would fail it.
  • Before this change (Debug compile_dxil at c827d8ba + 3ea1a79f): 8 UAVs compile; 9 UAVs fail with Flags must match usage, declared=524304, actual=557072 (0x80010 vs 0x88010).
cmake --preset release
cmake --build --preset release --target compile_dxil
ctest --preset release --no-tests=error -R '^native_uav_slots_controls$' -V

Result at 5b0bfdc0 (on main 0fe4cebc), Windows 11 build 26300, DXC from Windows SDK 10.0.26100: 1/1 Passed (8 UAVs: compiled and validated, 9 UAVs: compiled and validated). The branch was then rebased onto main 5033d2d3 without conflicts (no upstream change to src/dxil_module.h). The test and census were not rerun after the rebase.

The fixture declares only single-slot UAVs, so the range-size sum for UAV arrays has no fixture of its own.

Start-up cohort (counts only)

compile_dxil gfx1013-direct-cs@36 --requests over the 878 untranslated compute requests from #3226, Release build:

compiled refused
c827d8ba + 3ea1a79f (Debug) 160 718
5b0bfdc0 (Release) 216 662
  • All 36 shaders that failed with Flags must match usage now compile. That error appears 0 times in the new run.
  • None of the 160 earlier compiles were lost. The other 20 gains come from the three compute commits merged between the two bases (#3246, #3247, #3257).
  • The 36 declare 9 (2), 10 (33) or 16 (1) UAV bindings. None of them gets a runtime manifest: the compute manifest allows 8 UAVs (src/direct_compute_cache.cpp). This change gives them valid DXIL but no dispatchable translation.

No GPU was used. This is a validation-only change.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠Not-Saii** on GitHub · 2026-11-28 03:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3270) `Not-Saii:shader/uav-slots-flag` → `main` · +64 −1 · 3 files · 1 commits · merged 2026-11-28 03:45 UTC Refs #3226 DXC sets shader flag `0x8000` (64 UAV slots) when a module's declared UAV ranges add up to more than 8 slots, and the DXIL validator refuses a module whose declared flags differ: ``` error: Flags must match usage. note: Flags declared=1572880, actual=1605648 Validation failed. ``` The direct emitter never set that bit. `DxilModule::finish_compute` (`src/dxil_module.h`) now sums the UAV range sizes of its resource records and sets the flag above 8. Every direct compute and graphics module goes through this function, so the fix is in one place. ## Test New `native_uav_slots_controls` (`tests/native_uav_slots_check.py`): two source-built compute containers store to 8 and 9 buffer descriptors read from one descriptor table. Both must compile and validate, and `compile_dxil` must report 8 and 9 UAV bindings. - Negative control: the 8-UAV case must compile without the flag. Setting the flag unconditionally would fail it. - Before this change (Debug `compile_dxil` at `c827d8ba` + `3ea1a79f`): 8 UAVs compile; 9 UAVs fail with `Flags must match usage`, `declared=524304, actual=557072` (`0x80010` vs `0x88010`). ```powershell cmake --preset release cmake --build --preset release --target compile_dxil ctest --preset release --no-tests=error -R '^native_uav_slots_controls$' -V ``` Result at `5b0bfdc0` (on `main` `0fe4cebc`), Windows 11 build 26300, DXC from Windows SDK 10.0.26100: `1/1 Passed` (`8 UAVs: compiled and validated`, `9 UAVs: compiled and validated`). The branch was then rebased onto `main` `5033d2d3` without conflicts (no upstream change to `src/dxil_module.h`). The test and census were not rerun after the rebase. The fixture declares only single-slot UAVs, so the range-size sum for UAV arrays has no fixture of its own. ## Start-up cohort (counts only) `compile_dxil gfx1013-direct-cs@36 --requests` over the 878 untranslated compute requests from #3226, Release build: | | compiled | refused | |---|---:|---:| | `c827d8ba` + `3ea1a79f` (Debug) | 160 | 718 | | `5b0bfdc0` (Release) | 216 | 662 | - All 36 shaders that failed with `Flags must match usage` now compile. That error appears 0 times in the new run. - None of the 160 earlier compiles were lost. The other 20 gains come from the three compute commits merged between the two bases (#3246, #3247, #3257). - The 36 declare 9 (2), 10 (33) or 16 (1) UAV bindings. None of them gets a runtime manifest: the compute manifest allows 8 UAVs (`src/direct_compute_cache.cpp`). This change gives them valid DXIL but no dispatchable translation. No GPU was used. This is a validation-only change. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DXC sets shader flag 0x8000 when the declared UAV ranges add up to more
than 8 slots, and the validator refuses a module whose declared flags
differ ("Flags must match usage"). DxilModule::finish_compute now sums the
UAV range sizes of its resource records and sets the flag, so it covers
every direct compute and graphics module.

New test native_uav_slots_controls: two source-built compute containers
store to 8 and 9 buffer descriptors from one table. Both must compile and
validate, and compile_dxil must report 8 and 9 UAV bindings. The 8-UAV
case is the negative control (the flag must stay clear); the 9-UAV case
fails validation before this change (declared 0x80010, actual 0x88010).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 03:36:14 +00:00
github-bot changed target branch from main to gh-pr/3270/base 2026-11-28 03:48:19 +00:00
github manually merged commit 95ee41a759 into gh-pr/3270/base 2026-11-28 03:48:20 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-28 03:45 UTC · original · approved these changes

Independently reviewed 95ee41a7, integration tree 42153a0d on main a166a753. The emitter declares validator 1.6 or later. Summing UAV range sizes at that validator boundary agrees with DXC's module flag collector.

Debug and Release /O2 each passed the eight-versus-nine individual-UAV validation fixture:

ctest --test-dir <build> --no-tests=error -R '^native_uav_slots_controls$' --output-on-failure

A temporary source-built emitter probe also checked a single declared array range. Eight elements left flag 0x8000 clear and nine set it. Windows 11 26200.9974, MSVC x64, SDK/DXC 10.0.26100.0. This verification covers DXIL validation and flag emission. The existing eight-UAV runtime manifest limit still applies to the cohort.

**@⁠R0Y00** on GitHub · 2026-11-28 03:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3270#pullrequestreview-6095532731) · **approved these changes** Independently reviewed `95ee41a7`, integration tree `42153a0d` on main `a166a753`. The emitter declares validator 1.6 or later. Summing UAV range sizes at that validator boundary agrees with [DXC's module flag collector](https://github.com/microsoft/DirectXShaderCompiler/blob/main/lib/DXIL/DxilModule.cpp). Debug and Release /O2 each passed the eight-versus-nine individual-UAV validation fixture: ```powershell ctest --test-dir <build> --no-tests=error -R '^native_uav_slots_controls$' --output-on-failure ``` A temporary source-built emitter probe also checked a single declared array range. Eight elements left flag `0x8000` clear and nine set it. Windows 11 26200.9974, MSVC x64, SDK/DXC 10.0.26100.0. This verification covers DXIL validation and flag emission. The existing eight-UAV runtime manifest limit still applies to the cohort.
This discussion has been locked. Commenting is limited to contributors.
No description provided.