dxil: emit InnerCoverage, ShadingRate, MeshDerivatives, and 64UAVs flags in graphics shaders #2451

Open
github-bot wants to merge 1 commit from github-bot/gh-2451 into main AGit
Owner

@⁠Decodere on GitHub · 2026-11-25 19:24 UTC · original
Decodere:fix-dxil-graphics-flags → main · +145 −2 · 2 files · 1 commits · open

Emit four DXIL shader-flag and SFI0 feature bits in Shader::try_finish_graphics that dxil.dll requires when the corresponding graphics features are used: InnerCoverage, ShadingRate, DerivativesInMeshAndAmpShaders, and 64UAVs. Part of #1401. Part of #1833.

What is in it

  • crates/xcl/src/gpu/dxil/graphics.rs (Shader::try_finish_graphics):
    • Count static UAV bindings (self.bindings with ResClass::Uav) and emit 64UAVs (flags |= 1 << 15, sfi0 |= 0x8) across vertex, pixel, and mesh shaders whenever more than 8 static UAVs are bound (while preserving UavsAtEveryStage 1 << 16 / 0x4 for vertex shaders with any static UAV).
    • Emit ShadingRate (flags |= 1 << 24, sfi0 |= 0x8_0000) when Stage::Vertex outputs or Stage::Pixel inputs contain SemKind::ShadingRate (excluding Stage::Mesh primitive outputs, matching DXC).
    • Scan surviving post-optimize() instructions on Stage::Pixel and Stage::Mesh to emit InnerCoverage (flags |= 1 << 10, sfi0 |= 0x400) when dx.op.innerCoverage. (op 92) survives, and DerivativesInMeshAndAmpShaders (flags |= 1 << 29, sfi0 |= 0x100_0000) when mesh derivative or implicit-LOD ops (dx.op.unary. ops 83..=86, dx.op.sample. op 60, dx.op.sampleBias. op 61, dx.op.sampleCmp. op 64, dx.op.calculateLOD. op 81) survive; eliminated calls in unreachable blocks and dead-code-eliminated derivatives do not emit spurious flags.
  • crates/xcl/src/gpu/dxil/graphics_tests.rs:
    • Added four CPU/DXC-validated unit tests (ps_inner_coverage_sets_flag_only_when_live, shading_rate_sets_flag_for_vs_and_ps_but_not_ms, ms_derivatives_and_implicit_lod_set_flag_but_explicit_lod_does_not, graphics_64_uavs_flag_tracks_static_uav_count) asserting validate::validate, exact SFI0 values, disassembly metadata flags, and negative guards (unreachable inner coverage, mesh primitive shading rate, explicit sample_level and DCE'd mesh derivative, 8 static UAVs, and a single UAV at register u8).

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 4060 8 GB (driver 621.14, 32-lane waves), Intel Core i5-11400F, Windows 11 Home build 26200, Rust 1.100.0, DXC / dxil.dll 1.9.2609.5, release build.
  • Failing-first before the graphics.rs fix (on origin/main 943043e): all 4 new tests failed (0 passed, 4 failed on missing SFI0 bits).
  • Targeted cargo test --release -p xcl --lib -- gpu::dxil::graphics::tests:: --nocapture:
    • RTX 4060: 29 passed, 0 failed, 0 ignored (0.28 s, 0 skipped).
    • XCL_ADAPTER=warp: 29 passed, 0 failed, 0 ignored (0.03 s; 0 skipped on the 4 new tests, 2 pre-existing draw tests skipped: no wave64).
  • cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture (RTX 4060): 1367 passed, 0 failed, 46 ignored across 24 test binaries (184/184 gpu::dxil::* passed; 29 pre-existing SKIPPED GPU/environment checks: 21 no wave64, 3 per-lane wave32 refused, 3 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in gpu::dxil::graphics::tests).

Regression run
main:

xcl-smoke v1
commit: 2898511af1c038a2ef809719e9b6f89e5675c422
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1535 (PresentX 1536)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13996 MB

PR:

xcl-smoke v1
commit: 2e6e6ab8d6d8e453947020d777ca335630d85940
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1532 (PresentX 1532)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14013 MB

Not tested

  • Native wave64 GPU execution on wave64 hardware and D3D12 debug-layer tests requiring d3d12SDKLayers.dll.
  • Live runtime rendering of titles executing hardware VRS, conservative inner coverage, or mesh-shader implicit-LOD draws beyond DXC 1.9 validation and the 60 s title smoke test.

AI use

  • Google Antigravity (Gemini 4 Neon) implemented the flag emission in graphics.rs, wrote the DXC-validated tests in graphics_tests.rs, ran the test/smoke suites, and drafted this PR description.
**@⁠Decodere** on GitHub · 2026-11-25 19:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2451) `Decodere:fix-dxil-graphics-flags` → `main` · +145 −2 · 2 files · 1 commits · open Emit four DXIL shader-flag and `SFI0` feature bits in `Shader::try_finish_graphics` that `dxil.dll` requires when the corresponding graphics features are used: `InnerCoverage`, `ShadingRate`, `DerivativesInMeshAndAmpShaders`, and `64UAVs`. Part of #1401. Part of #1833. **What is in it** - `crates/xcl/src/gpu/dxil/graphics.rs` (`Shader::try_finish_graphics`): - Count static UAV bindings (`self.bindings` with `ResClass::Uav`) and emit `64UAVs` (`flags |= 1 << 15`, `sfi0 |= 0x8`) across vertex, pixel, and mesh shaders whenever more than 8 static UAVs are bound (while preserving `UavsAtEveryStage` `1 << 16` / `0x4` for vertex shaders with any static UAV). - Emit `ShadingRate` (`flags |= 1 << 24`, `sfi0 |= 0x8_0000`) when `Stage::Vertex` outputs or `Stage::Pixel` inputs contain `SemKind::ShadingRate` (excluding `Stage::Mesh` primitive outputs, matching DXC). - Scan surviving post-`optimize()` instructions on `Stage::Pixel` and `Stage::Mesh` to emit `InnerCoverage` (`flags |= 1 << 10`, `sfi0 |= 0x400`) when `dx.op.innerCoverage.` (op 92) survives, and `DerivativesInMeshAndAmpShaders` (`flags |= 1 << 29`, `sfi0 |= 0x100_0000`) when mesh derivative or implicit-LOD ops (`dx.op.unary.` ops `83..=86`, `dx.op.sample.` op `60`, `dx.op.sampleBias.` op `61`, `dx.op.sampleCmp.` op `64`, `dx.op.calculateLOD.` op `81`) survive; eliminated calls in unreachable blocks and dead-code-eliminated derivatives do not emit spurious flags. - `crates/xcl/src/gpu/dxil/graphics_tests.rs`: - Added four CPU/DXC-validated unit tests (`ps_inner_coverage_sets_flag_only_when_live`, `shading_rate_sets_flag_for_vs_and_ps_but_not_ms`, `ms_derivatives_and_implicit_lod_set_flag_but_explicit_lod_does_not`, `graphics_64_uavs_flag_tracks_static_uav_count`) asserting `validate::validate`, exact `SFI0` values, disassembly metadata flags, and negative guards (unreachable inner coverage, mesh primitive shading rate, explicit `sample_level` and DCE'd mesh derivative, 8 static UAVs, and a single UAV at register `u8`). **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 4060 8 GB (driver 621.14, 32-lane waves), Intel Core i5-11400F, Windows 11 Home build 26200, Rust 1.100.0, DXC / `dxil.dll` 1.9.2609.5, release build. - Failing-first before the `graphics.rs` fix (on `origin/main` `943043e`): all 4 new tests failed (`0 passed, 4 failed` on missing `SFI0` bits). - Targeted `cargo test --release -p xcl --lib -- gpu::dxil::graphics::tests:: --nocapture`: - RTX 4060: `29 passed, 0 failed, 0 ignored` (`0.28 s`, `0` skipped). - `XCL_ADAPTER=warp`: `29 passed, 0 failed, 0 ignored` (`0.03 s`; `0` skipped on the 4 new tests, `2` pre-existing draw tests skipped: `no wave64`). - `cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture` (RTX 4060): `1367 passed, 0 failed, 46 ignored` across `24` test binaries (`184/184` `gpu::dxil::*` passed; `29` pre-existing `SKIPPED` GPU/environment checks: `21` no wave64, `3` per-lane wave32 refused, `3` no D3D12 debug layer, `1` no heap windows, `1` cannot disable driver cache; `0` skipped in `gpu::dxil::graphics::tests`). **Regression run** main: ``` xcl-smoke v1 commit: 2898511af1c038a2ef809719e9b6f89e5675c422 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1535 (PresentX 1536) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13996 MB ``` PR: ``` xcl-smoke v1 commit: 2e6e6ab8d6d8e453947020d777ca335630d85940 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1532 (PresentX 1532) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14013 MB ``` **Not tested** - Native wave64 GPU execution on wave64 hardware and D3D12 debug-layer tests requiring `d3d12SDKLayers.dll`. - Live runtime rendering of titles executing hardware VRS, conservative inner coverage, or mesh-shader implicit-LOD draws beyond DXC 1.9 validation and the 60 s title smoke test. **AI use** - Google Antigravity (Gemini 4 Neon) implemented the flag emission in `graphics.rs`, wrote the DXC-validated tests in `graphics_tests.rs`, ran the test/smoke suites, and drafted this PR description.
Shader::try_finish_graphics previously omitted four DXIL shader/SFI0 flag
bits required by dxil.dll when the corresponding graphics features are
present:

- InnerCoverage (1 << 10 / SFI0 0x400) for pixel shaders with a surviving
  post-optimize dx.op.innerCoverage (op 92) call.
- ShadingRate (1 << 24 / SFI0 0x8_0000) for vertex outputs and pixel inputs
  carrying SemKind::ShadingRate (not mesh primitive outputs).
- DerivativesInMeshAndAmpShaders (1 << 29 / SFI0 0x100_0000) for mesh
  shaders with surviving post-optimize derivatives or implicit-LOD ops
  (unary 83..=86, sample 60, sampleBias 61, sampleCmp 64, calculateLOD 81).
- 64UAVs (1 << 15 / SFI0 0x8) across vertex, pixel, and mesh stages when
  more than 8 static UAV bindings are declared.

Scan surviving post-optimize instructions for inner coverage and mesh
derivatives so eliminated calls in unreachable blocks or DCE'd derivatives
do not leave spurious flags, and add DXC-validated unit tests covering each
flag and its negative guards.

Part of #1401
Part of #1833

Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:31:20 +00:00
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-25 19:41 UTC · original

Independent AMD RDNA4 (native wave64) test report on exact head 2e6e6ab8d6d8e453947020d777ca335630d85940 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1365 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All gpu::dxil::graphics_tests and native wave64 GPU tests ran and passed.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 2e6e6ab8d6d8e453947020d777ca335630d85940
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1544 (PresentX 1544)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14013 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
**@⁠emirduran707** on GitHub · 2026-11-25 19:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/2451#issuecomment-7172633564) Independent AMD RDNA4 (native wave64) test report on exact head `2e6e6ab8d6d8e453947020d777ca335630d85940` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1365 passed, 2 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). All `gpu::dxil::graphics_tests` and native wave64 GPU tests ran and passed. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599) are pre-existing on unmodified `main` on this GPU. **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release) ``` xcl-smoke v1 commit: 2e6e6ab8d6d8e453947020d777ca335630d85940 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1544 (PresentX 1544) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14013 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - D3D12 debug layer; Intel GPUs. **AI use** - Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 20:02 UTC · original

gpu_ suite (cold cache): 160 passed / 4 failed, no crashes. The four are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, depth-buffer state refusal, and gpu_promoted_uav_clear_values_pass_create_committed_resource (report); none caused by this PR.

**@⁠SlopTart** on GitHub · 2026-11-25 20:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/2451#issuecomment-7173111173) `gpu_` suite (cold cache): 160 passed / 4 failed, no crashes. The four are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, depth-buffer state refusal, and `gpu_promoted_uav_clear_values_pass_create_committed_resource` ([report](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2280)); none caused by this PR.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 20:21 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 20:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/2451#issuecomment-7173561729) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2451/head:github-bot/gh-2451'
git switch 'github-bot/gh-2451'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2451'
git switch 'github-bot/gh-2451'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2451'
git switch 'github-bot/gh-2451'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2451'
git switch 'main'
git merge --squash 'github-bot/gh-2451'
git switch 'main'
git merge --ff-only 'github-bot/gh-2451'
git switch 'main'
git merge 'github-bot/gh-2451'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.