Repository navigation
Shaders: a vertex program writing through views declares UAVs at every stage - #1989
BastienRodz wants to merge 1 commit into
Conversation
…y stage Commit cd94d35 emits a raw root UAV for the view-write bitmap whenever a shader built with Options::view_marks writes through an unordered buffer view, including vertex programs. DXIL requires any non-pixel, non-compute shader with declared UAVs to set the UAVsAtEveryStage shader flag (bit 16) and the matching SFI0 feature bit (0x4); without them, dxil.dll rejects the module with 'Flags must match usage.' (Marvisak#1973). Add flags::UAVS_AT_EVERY_STAGE (1 << 16), set it in Shader::finish for non-pixel, non-compute stages (vertex, geometry, and mesh, matching DXC's valver < 1.8 rule since we emit dx.valver 1.6) when dx.resources declares any UAV, map it to SFI0 bit 0x4, and add a synthetic unit test covering vertex, mesh, pixel, and compute stages. Fixes Marvisak#1973. Co-Authored-By: Gemini 4 Neon <noreply@google.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VIctory V2: community PRs, merged and testedOpen 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). 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: Unofficial community fork of Marvisak/VIctory, GPL-3.0. |
|
Confirmed on the title's shaders, as asked in #1973. Head
No program is left with "Flags must match usage". |
|
Confirming this as the one to merge for #1973 (I closed my #1977 in its favour after @Dathinel's mesh fixture showed my stage predicate still failed the mesh case and yours passes it). The corpus result applies to this head too: zed6000 and @sinan-cmyk both measured |
Restore validator compatibility after the marked-write copy-back update. Keep the original fix and regression coverage. Verified the expected pre-fix failure, Linux shader tests, and Windows MSVC test compilation.
|
Independent native Windows validation of
This verifies the focused synthetic cases, including mesh and the pixel/compute controls. No game files or title corpus were used. AI-assisted (OpenAI Codex). |
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.
145 passed / 0 failed / 2 ignored. Vertex program writing through views declares UAVs at every stage (+1 test). Duplicate/overlap with #1977 — maintainer should pick one; this one covers the 'writing through views' case explicitly.
|
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at AI-assisted (Claude Code). |
|
An independent full-corpus run of this PR: offline
So it clears exactly the 867 that
Not tested: the title on the GPU with these programs (this laptop can't reach the world). AI use: Claude Code (Claude Opus 5.5) built both trees, ran the corpus and wrote this; the results are from the runs described. No game data: counts only. |
|
Independent corpus run on AMD / Windows 10, same archive as the other reports (
+867 validated, 0 lost — the same delta zed6000 measured on an RX 7900 XTX and @sinan-cmyk on a retail NVIDIA machine, now reproduced on an RX 7800 XT with the SDK 10.0.26100.0 validator ( The mesh case Dathinel found is also covered: the corpus has 71 mesh programs failing |
…s, in every stage, head 0f11320) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…842 programs gained offline; known NVIDIA risks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Merge candidate. This fixes #1973 and #1987, a regression from I checked that the PR's Generated by Claude Code |
What's wrong
Since
cd94d35("GPU: shaders mark the pages they write through views; copy-backs compare only those"), translated shaders built withemit::Options::view_marksdeclare the view-write bitmap (u1inMEMORY_SPACE, a raw root UAV indx.resources) whenever they store or perform atomics through unordered buffer views. That includes vertex programs.DXIL requires any non-pixel, non-compute shader that declares UAVs to set the
UAVsAtEveryStageshader flag and the matchingSFI0feature bit. Becausevictory-shaderdid not set either bit, the DXIL validator recomputed the flags from the module and rejected those vertex modules withFlags must match usage.(#1973, 867 vertex programs in the reporter's offline check withdxil.dll1.8.2502).What the fix does
flags::UAVS_AT_EVERY_STAGE = 1 << 16incrates/victory-shader/src/emit/shader.rs, matchingm_UAVsAtEveryStageat bit 16 in DXC'sinclude/dxc/DXIL/DxilShaderFlags.h(lines 264-265).Shader::finish, setsflags::UAVS_AT_EVERY_STAGEwhenever the stage is neither pixel nor compute (graphics && !self.pixel, covering vertex, geometry, and mesh shaders) anddx.resourcesdeclares any UAV (!self.root_uavs.is_empty() || self.memory_dirty.is_some() || self.view_writes.is_some()). This matches DXC'sDxilModule::CollectShaderFlagsForModuleinlib/DXIL/DxilModule.cpp(lines 318-350): becausevictory-shaderdeclaresdx.valver(1, 6)(< 1.8), DXC setsUAVsAtEveryStagewheneverNumUAVs && !(SM->IsCS() || SM->IsPS()).flags::UAVS_AT_EVERY_STAGEto0x4in theSFI0feature word, matchingShaderFeatureInfo_UAVsAtEveryStage = 0x0004in DXC'sinclude/dxc/DXIL/DxilConstants.h(line 2276) andShaderFlags::GetFeatureInfoinlib/DXIL/DxilShaderFlags.cpp(lines 85-86).emit::tests::vertex_uav_writes_declare_uavs_at_every_stage) checkingSFI0, the serializeddx.entryPointsshader flags, anddxil.dllvalidation (when available) for vertex and mesh programs withview_marks, vertex programs without declared UAVs, and pixel and compute programs withview_marks.Tests
origin/main(940d32f): the new unit test failed before the fix with:assertion left != right failed: VS SFI0 0x2000000: missing UAVsAtEveryStagex86_64-pc-windows-msvc, tests under Wine, no SM 6.6 device / nodxil.dll):cargo xwin test -p victory-shader --target x86_64-pc-windows-msvc -- --test-threads=1: 173 passed, 75 failed, 3 ignored (vs 172 passed, 75 failed, 3 ignored onorigin/main; only difference is the new test passing, and all 75 failures are the same SM 6.6 device tests under Wine).cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: pass.cargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings: pass.cargo xtask policy: pass (182 files ok).windows-latest(which hasdxil.dll) with the upstream CI's commands, everything passes;victory-shader248 passed, 0 failed, including the new test: https://github.com/BastienRodz/VIctory/actions/runs/45532795156On the title's shaders (@zed6000, comment):
translate --validateover the retail shader pack with dxil.dll 1.8.2502 gives 23,918 validated onmain940d32fand 24,785 with this PR, +867 and 0 lost. That is identical, program by program, toccfb029beforecd94d35, and no program is left with "Flags must match usage".Fixes #1973. Same report: #1987.
No game data used. AI-assisted: implemented with Gemini 4 Neon, reviewed and verified with Claude Code.
🤖 Generated with Claude Code