Shaders: derive TYPED_UAV_LOADS and ROVs flags from surviving calls #2610
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2610
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@fuzeofficlal on GitHub · 2026-11-25 16:46 UTC · original
fuzeofficlal:fix/shader-dce-typed-uav-loads-flag→main· +93 −7 · 3 files · 1 commits · openSummary
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).@oni-swr on GitHub · 2026-11-25 17:15 UTC · original
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.
@kotekompotek on GitHub · 2026-11-25 17:51 UTC · original
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.@Marvisak on GitHub · 2026-11-25 23:21 UTC · original
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
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.