Shaders: derive TYPED_UAV_LOADS and ROVs flags from surviving calls #2608
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2610"
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 fuzeofficlal on 2026-11-25T16:46:43Z.
Summary
Shader::finishreconciles module shader flags fromModule::uses()so instructions dropped by dead-code elimination or constant-branch folding do not leave stale feature flags behind.TYPED_UAV_LOADSandROVSwere still set imperatively during lowering and were not reconciled against surviving instructions.When a typed UAV
bufferLoad.f32ortextureLoad.f32has an unused result (dropped by DCE) or sits in an unreachable constant branch,TYPED_UAV_LOADS(1 << 13) remained set in the module flags, causing the Windows SDK DXIL validator (dxil.dll) to reject the shader withFlags must match usage. Likewise,ROVSremained set if every ROV-annotated handle was dropped.Changes
crates/victory-shader/src/emit/bitcode.rs:Uses::typed_uav_loadsandUses::rovs.Module::resource_props0to readprops0from adx.op.annotateHandlecall and deriverovs(props0 & 0x2000 != 0) andtyped_uav_loads(survivingdx.op.bufferLoad.*/dx.op.textureLoad.*on a typed UAV handleprops0 & 0x1000 != 0 && (1..=10).contains(&(props0 & 0xFF))) inModule::uses().crates/victory-shader/src/emit/shader.rs:flags::TYPED_UAV_LOADSandflags::ROVSfromusesinShader::finish.typed_uav_load_flags_follow_dcecovering dead vs. live typed UAVbufferLoad.f32andtextureLoad.f32with and without surviving stores and ROV annotations, validated throughdxil.dll.crates/victory-shader/src/emit/lower.rs:self.s.flags |= flags::TYPED_UAV_LOADS/flags::ROVSwrites and readself.s.m.uses().rovsfor test reporting.Verification
Flags must match usage. Flags declared=8192, actual=0.cargo test -p victory-shader --lib emit::shader::testsandpops— pass (dxil.dllvalidation passes across all buffer/texture/ROV/store/read combinations).cargo clippy -p victory-shader --all-targets -- -D warnings— pass (0 warnings).cargo xtask policy— pass (184 files ok).Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T17:15:48Z.
WARP verification of
0f19565merged cleanly ontoorigin/main13f91ca(detached checkout).Environment: Windows 11. No physical GPU device was created:
VICTORY_WARP=1,VICTORY_D3D12_WARP=1,cargo -j 4, separateCARGO_TARGET_DIR.dxil.dllwas present (Windows Kits 10.0.26100.0 x64), so the validator insidetyped_uav_load_flags_follow_dceactually ran.Adapter audit:
Host::newinemit/host.rsis the only path invictory-shaderthat enumerates adapters or callsD3D12CreateDevice. It readsVICTORY_WARP=1even when called asHost::new(false), so no executed test touched a hardware adapter.Commands and results:
cargo clippy -j 4 -p victory-shader --all-targets: clean.cargo test -j 4 -p victory-shader --lib typed_uav_load_flags: 1 passed.cargo test -j 4 -p victory-shader --lib: 268 passed, 3 failed, 3 ignored.origin/mainunder the same WARP setup: 267 passed, 3 failed, 3 ignored. The same 3 fail on both:synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_numberandpermutes_read_the_lane_named_and_zero_from_lanes_left_out("no pipeline for a wave of 32"), andgathers_at_a_level_match_the_hardware. They compare against hardware behaviour WARP does not reproduce, so they are unrelated to this PR.(flags::TYPED_UAV_LOADS, ...)/(flags::ROVS, ...)entries from the flag derivation makes the new test fail.Review notes: no bugs found. The flags are now derived from the instructions that survive DCE (
Uses), matching the "Flags must match usage" validator rule. The0x1000/0x2000props checks and the(1..=10)kind range look consistent with howhandle()builds them. No sibling PR overlap found inemit/.Not tested: hardware-adapter results (the 3 failures above are WARP-only limits), a physical GPU, or a retail title.
Independent review and WARP verification by Claude Code (Claude Sonnet 5.5), an AI. No game files, dumps or retail data were used.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:51:00Z.
Reviewed:
resource_props0correctly digs the props aggregate out ofdx.op.annotateHandle— bit 0x2000 ROV and bit 0x1000 TYPED_UAV_LOADS (gated on a resource-kind range) match the DXIL resource-properties layout, and reading the annotation directly for loads is the right call since lowering builds the handle's index first. Deriving the flags from surviving calls rather than declared usage is the validator-safe direction. CI green.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:21:06Z.
Automated triage for the maintainers.
This moves
TYPED_UAV_LOADSandROVSfrom imperative sets inLower(crates/victory-shader/src/emit/lower.rs) into theModule::usesreconciliation inShader::finish, deriving them from survivingdx.op.annotateHandle/bufferLoad/textureLoadcalls via the newModule::resource_props0(crates/victory-shader/src/emit/bitcode.rs), so a load dropped by DCE no longer leaves a flag the validator rejects. I checked that main still sets these flags imperatively, that the UAV bit (0x1000), ROV bit (0x2000) and typed kind range 1..=10 match how lowering builds props0, and that the new test runs the cases throughdxil.dll. One small note: the check ignores the component count in props1, which is fine while lowering always declares four channels (0x409). CI:checkpassing.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T05:15:20Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (withdxil.dllvalidator and WARP):TYPED_UAV_LOADSandROVSfromModule::uses()after DCE (by inspecting livedx.op.annotateHandleanddx.op.{bufferLoad,textureLoad}.*instructions) matches how the other DXIL shader flags are computed and prevents validator"Flags must match usage"rejections when lowering emits an ROV annotation or typed UAV load that DCE later drops.cargo test -p victory-shader emit::shader::tests: 2 passed, 0 failed (typed_uav_load_flags_follow_dcevalidated viadxil.dllacross buffer/texture/ROV/store/read cases).cargo test -p victory-shader emit::bitcode::tests: 12 passed, 0 failed.VICTORY_WARP=1 cargo test -p victory-shader emit::memory_tests: 5 passed, 0 failed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.