Shaders: declare UAVsAtEveryStage for vertex/geometry programs with UAVs #1977

Closed
github-bot wants to merge 1 commit from gh-pr/1977/head into gh-pr/1977/base
Owner

@⁠Calvix2k on GitHub · 2026-11-25 02:14 UTC · original
Calvix2k:codex/shader-uav-flags-1973 → main · +18 −0 · 1 files · 1 commits · closed without merging

Closes #1973.

Problem

Since cd94d35 the validator rejects 867 vertex programs with "Flags must match usage". The validator recomputes the DXIL shader flags from the module's resources, and a vertex or geometry program here can carry UAVs (root UAVs, or the written-pages/view-mark bitmaps the converter binds for memory writes) without the module declaring UAVsAtEveryStage (shader flag 16). The recomputed flags then differ from the ones in dx.shaderFlags.

Change

crates/victory-shader/src/emit/shader.rs:

  • add flags::UAVS_AT_EVERY_STAGE (1 << 16);
  • after the resource table is built, set it for a program that is not pixel, not compute and not mesh when it has root UAVs or one of the written-pages handles (memory_dirty, view_marks, view_writes);
  • emit the matching SFI0 feature bit 0x4.

This is zed6000's tested patch from #1973, unchanged in behaviour; I only split the comment and rebased it onto main at 940d32f.

Verification

zed6000 on an RX 7900 XTX (940d32f + patch vs 940d32f):

Build Change
+ patch vs 940d32f +867 programs valid, 0 lost
+ patch vs ccfb029 (before cd94d35) 0 gained, 0 lost — back to 24,785

cargo test -p victory-shader --lib: 247 passed, 0 failed there.

On my RX 7800 XT host (Windows 10 19045, driver 32.0.32029.2010) the same command gives 172 passed, 75 failed, and every failure is the same environment limit, not this change: no SM 6.6 hardware device (the device supports SM 0x65 only) / no SM 6.6 warp device (… SM 0x62 only). Windows 10 reports SM 6.5 for this adapter, so the GPU probe suites cannot create a device at all; they fail identically on unpatched main. The CPU-only emission tests (the ones that build and validate the metadata this patch changes) all pass.

  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 1 file ok.

I could not re-run the 867-program count here because it needs a device that accepts the wave64/SM 6.6 modules; that measurement stands on zed6000's run.

**@⁠Calvix2k** on GitHub · 2026-11-25 02:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1977) `Calvix2k:codex/shader-uav-flags-1973` → `main` · +18 −0 · 1 files · 1 commits · closed without merging Closes #1973. ## Problem Since `cd94d35` the validator rejects 867 vertex programs with "Flags must match usage". The validator recomputes the DXIL shader flags from the module's resources, and a vertex or geometry program here can carry UAVs (root UAVs, or the written-pages/view-mark bitmaps the converter binds for memory writes) without the module declaring `UAVsAtEveryStage` (shader flag 16). The recomputed flags then differ from the ones in `dx.shaderFlags`. ## Change `crates/victory-shader/src/emit/shader.rs`: - add `flags::UAVS_AT_EVERY_STAGE` (`1 << 16`); - after the resource table is built, set it for a program that is not pixel, not compute and not mesh when it has root UAVs or one of the written-pages handles (`memory_dirty`, `view_marks`, `view_writes`); - emit the matching `SFI0` feature bit `0x4`. This is zed6000's tested patch from #1973, unchanged in behaviour; I only split the comment and rebased it onto `main` at `940d32f`. ## Verification zed6000 on an RX 7900 XTX (`940d32f` + patch vs `940d32f`): | Build | Change | |---|---| | + patch vs `940d32f` | **+867 programs valid, 0 lost** | | + patch vs `ccfb029` (before `cd94d35`) | 0 gained, 0 lost — back to 24,785 | `cargo test -p victory-shader --lib`: 247 passed, 0 failed there. On my RX 7800 XT host (Windows 10 19045, driver 32.0.32029.2010) the same command gives **172 passed, 75 failed**, and every failure is the same environment limit, not this change: `no SM 6.6 hardware device (the device supports SM 0x65 only)` / `no SM 6.6 warp device (… SM 0x62 only)`. Windows 10 reports SM 6.5 for this adapter, so the GPU probe suites cannot create a device at all; they fail identically on unpatched `main`. The CPU-only emission tests (the ones that build and validate the metadata this patch changes) all pass. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 1 file ok. I could not re-run the 867-program count here because it needs a device that accepts the wave64/SM 6.6 modules; that measurement stands on zed6000's run.
A vertex or geometry program that carries a UAV (root UAVs, or the
written-pages and view-mark bitmaps) now sets DXIL shader flag 16 and the
matching SFI0 feature bit 0x4. The validator recomputes that flag from the
resources and rejected 867 programs on main since cd94d35 with
'Flags must match usage'.

Patch by zed6000, reported and measured in #1973.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:50:31 +00:00
github-bot closed this pull request 2026-11-26 04:50:31 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-25 02:15 UTC · original

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

**@⁠DesertGamer** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1977#issuecomment-7150500888) ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 02:36 UTC · original

Offline measurement on a retail dump: +867, 0 lost, the same set as #1989

I merged head e3cefe5 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs).

Build Validated Change Lost
main 940d32f 23,918
this PR 24,785 +867 0
#1989 (0f11320), for comparison 24,785 +867 0

All 867 failed with "Flags must match usage" on main. All of them are vertex programs, and this PR and #1989 restore exactly the same 867 programs. So on this data, either PR fixes the cd94d35 regression (#1973, #1987) completely. Review can pick between them on code and tests alone. I also bisected the regression independently to cd94d35 (868 programs at that commit, 0 at its parent).

AI-assisted (Claude Code). No shader names or data are included, per the asset policy.

**@⁠sinan-cmyk** on GitHub · 2026-11-25 02:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1977#issuecomment-7150945662) ### Offline measurement on a retail dump: +867, 0 lost, the same set as #1989 I merged head e3cefe5 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). | Build | Validated | Change | Lost | |---|---|---|---| | `main` 940d32f | 23,918 | | | | this PR | 24,785 | **+867** | **0** | | #1989 (0f11320), for comparison | 24,785 | +867 | 0 | All 867 failed with "Flags must match usage" on `main`. All of them are vertex programs, and **this PR and #1989 restore exactly the same 867 programs**. So on this data, either PR fixes the cd94d35 regression (#1973, #1987) completely. Review can pick between them on code and tests alone. I also bisected the regression independently to cd94d35 (868 programs at that commit, 0 at its parent). AI-assisted (Claude Code). No shader names or data are included, per the asset policy.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 02:38 UTC · original

Closing this in favour of #1989 (@⁠BastienRodz), which is the same flag fix but strictly better, and it is green and mergeable:

  • Mesh shaders. @⁠Dathinel's fixture shows this branch still fails the mesh case (Flags must match usage, declared 0x40000010, expected 0x40010010): my vertex_like excludes mesh (self.mesh.is_none()), because I took zed6000's condition as-is. #1989's graphics && !self.pixel includes mesh and passes all six fixture cases. Changing only the predicate here would fix it, but then the two PRs are the same PR.
  • Regression test. #1989 adds vertex_uav_writes_declare_uavs_at_every_stage, which parses the ShaderFlags word out of dx.entryPoints and asserts bit 16 and the clear case. Mine relied on the hardware census only.

The corpus numbers from #1973 apply to both: +867 validated, 0 lost over 25,889 programs on main 940d32f, confirmed independently by @⁠sinan-cmyk in #1977 and by zed6000. Nothing is lost by closing this one — the code is the same two bits, and #1989 covers one more stage.

For #1989: view_marks and view_writes are created together in mark_view_write, so omitting view_marks.is_some() from the condition is fine as it stands.

**@⁠Calvix2k** on GitHub · 2026-11-25 02:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/1977#issuecomment-7150993634) Closing this in favour of #1989 (@⁠BastienRodz), which is the same flag fix but strictly better, and it is green and mergeable: - **Mesh shaders.** @⁠Dathinel's fixture shows this branch still fails the mesh case (`Flags must match usage`, declared `0x40000010`, expected `0x40010010`): my `vertex_like` excludes mesh (`self.mesh.is_none()`), because I took zed6000's condition as-is. #1989's `graphics && !self.pixel` includes mesh and passes all six fixture cases. Changing only the predicate here would fix it, but then the two PRs are the same PR. - **Regression test.** #1989 adds `vertex_uav_writes_declare_uavs_at_every_stage`, which parses the `ShaderFlags` word out of `dx.entryPoints` and asserts bit 16 and the clear case. Mine relied on the hardware census only. The corpus numbers from #1973 apply to both: `+867 validated, 0 lost` over 25,889 programs on `main 940d32f`, confirmed independently by @⁠sinan-cmyk in #1977 and by zed6000. Nothing is lost by closing this one — the code is the same two bits, and #1989 covers one more stage. For #1989: `view_marks` and `view_writes` are created together in `mark_view_write`, so omitting `view_marks.is_some()` from the condition is fine as it stands.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1977
No description provided.