Skip to content

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

Closed
Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/shader-uav-flags-1973
Closed

Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/shader-uav-flags-1973

Conversation

@Calvix2k

Copy link
Copy Markdown
Contributor

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 Marvisak#1973.
@DesertGamer

Copy link
Copy Markdown

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.

@sinan-cmyk

Copy link
Copy Markdown

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.

@Calvix2k

Copy link
Copy Markdown
Contributor Author

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

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.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. UAVsAtEveryStage declared for vertex/geometry programs with UAVs. Note: overlaps with #1989 (same UAVsAtEveryStage declaration, 2 files vs 1) — whichever lands second must reconcile; both pass independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

main: 867 vertex programs fail validation ("Flags must match usage") since cd94d35

4 participants