Shaders: a vertex program writing through views declares UAVs at every stage #1987
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1989"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T02:27:42Z.
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
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:56:50Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,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.
Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-25T02:28:23Z.
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.
Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-25T02:34:16Z.
Confirmed on the title's shaders, as asked in #1973. Head
0f11320, merged onto main940d32f(a clean merge), measured withvictory translate --validate --listovershaders.rpf(1.0.2.1, dxil.dll 1.8.2502) and compared program by program:940d32f940d32f+ this PRccfb029, beforecd94d35No program is left with "Flags must match usage".
cargo test -p victory-shader --libgives 248 passed and 0 failed on an RX 7900 XTX (RDNA3). Your version also flags mesh programs with UAVs, which my patch in #1973 didn't; on this data both give the same result. Offline counts only; no program names or data.Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T02:38:49Z.
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
main 940d32f23,918 → 24,785 validated (+867, 0 lost) on 25,889 programs with the same two bits. I ran this branch's test locally on Windows 10 / RX 7800 XT:vertex_uav_writes_declare_uavs_at_every_stagepasses, and the mesh finding above is the reason to prefer it over mine.Imported from Marvisak/VIctory. Originally posted by BaggyALPHA on 2026-11-25T02:53:53Z.
Independent native Windows validation of
0f11320on upstream940d32f. I made validator loading mandatory in the local synthetic test so a skipped validator could not produce a pass.vertex_uav_writes_declare_uavs_at_every_stagevalidated with both official DXC 1.7 and 1.8. The SFI0 anddx.entryPointsassertions passed as well.Flags must match usage. It passed again with the PR's metadata.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).
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T03:00:15Z.
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
0f11320.victory-shader: 245 passed, 3 failed, 3 ignored. The 3 are #1744's NVIDIA failures onmain(the twostride_testsheap-buffer reads andgathers_at_a_level_match_the_hardware). Same asmainon this hardware. Not run: a title.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-25T03:17:55Z.
An independent full-corpus run of this PR: offline
victory translate --validateover the title 1.0.2.1's shader pack, release builds, Windows 11 26300. The validator is the SDK10.0.26100.0\x64\dxil.dll, which on this machine is DXC 1.9.2602 (serviced;IDxcVersionInforeports 1.9). This PR (0f11320) is a fast-forward ofmain940d32f.Flags must match usagemain940d32fSo it clears exactly the 867 that
cd94d35broke (#1973, #1987). Nothing moves elsewhere: the remaining compute (735, "incompatible with the shader stage", the derivative case of #1065) and mesh (71, output size over 32,768) refusals are the same programs on both builds. This also confirms the result with a 1.9 validator; the numbers in #1987 were from 1.8.cargo test -p victory-shader --lib --locked: 240 passed, 8 failed. The 8 are the same hardware-only ones that fail on plainmainon the Intel Iris Xe the tests use here (BVH 1-ULP, dot products, 64-bit image atomics, wave size, heap cap).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.
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T03:32:35Z.
Independent corpus run on AMD / Windows 10, same archive as the other reports (
shaders.rpf, 1.0.2.1, 411,695,600 bytes),victory translate … --validate --list --jobs 10, release builds:Flags must match usagemain940d32f0f11320+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 (
dxil.dll1.7, i.e. the onedefault_pathpicks on this machine). The 1.7 PSV false failures (#1945) are in both runs at the same rate, so they do not affect the delta.The mesh case Dathinel found is also covered: the corpus has 71 mesh programs failing
vertex plus primitive output size is greater than 32768in both runs — unrelated — and no mesh program appears among the 867.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:26:37Z.
Automated triage for the maintainers.
Merge candidate.
This fixes #1973 and #1987, a regression from
cd94d35. Vertex programs that now declare the view-write bitmap UAV were rejected with "Flags must match usage". The fix is inShader::finish(emit/shader.rs). It sets shader flag bit 16 (UAVS_AT_EVERY_STAGE) and SFI0 feature0x4for non-pixel, non-compute stages that declare a UAV.I checked that the PR's
has_uavscondition is the same one thatfinishuses onmainto build the UAV list indx.resources(root_uavs/memory_dirty/view_writes), so the flag follows exactly what is declared. Including mesh stages matches DXC's pre-1.8 rule, which the PR cites with source references. Several independent corpus runs in the thread report +867 validated programs and 0 lost, with validators 1.7, 1.8 and 1.9, with no program left with the error. CI (check) passes. The competing #1977 was closed in favour of this PR.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T15:34:29Z.
Superseded by
a1a2077on main ("vertex, geometry and mesh programs with UAVs say so in their flags"), which sets ShaderFlags bit 16 and SFI0 0x4 for the same case. Closing. Thanks to everyone who ran the corpus on this one.Pull request closed