Shaders: a vertex shader that declares a UAV says so in its flags and SFI0 (fixes #1987) #2016
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!2016
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2016/head"
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?
@fiestorra on GitHub · 2026-11-25 03:07 UTC · original
fiestorra:fix/vertex-uav-flag→main· +66 −28 · 1 files · 2 commits · closed without mergingFixed: the missing bit was "UAVs at every shader stage" (16) plus its feature bit (0x4), and the corpus is back to 24,785
The sentence I was missing last round was in the validator's own message, which
translatewas throwing away:actual - declared = 65536 = 1 << 16, on every one of the 868. Bit 16 of the shader flags is documented inDXIL.rstas "UAVs at every shader stage — set when a vertex, hull, domain, or geometry shader declares one or more UAVs". The write marking put a UAV into vertex programs that never had one, and the emitter never set the flag.Declaring the flag alone is not enough: the validator then compares the container's
SFI0with the module's flags, and the next error isContainer part 'Feature Info' does not match expected for module. DXC'sDxilShaderFlags::GetFeatureInfomaps bit 16 toShaderFeatureInfo_UAVsAtEveryStage = 0x0004, so that bit goes with it.Three measured steps over the same local 1.0.2.1 archive (26,503 containers), validator SDK 10.0.26100
dxil.dll1.9:Flags must match usageFeature Infomain940d32f)0x424,785 is the count the parent commit
ccfb029had, so the 868VfxVBuffervertex programs are back to validating and nothing else moved.Two things came with it, because without them this would not have been findable:
translate --validatekeeps the validator'snote:line, appended to the error it already reported. The old line said "Flags must match usage" and nothing else; the note says which flag, which is the difference between four rounds of guessing and a one-line fix.SFI0mapping moved out offinishintofeature_info, with a test that pins every bit against DXC's values (STENCIL_REF0x200,TYPED_UAV_LOADS0x800,UAVS_AT_EVERY_STAGE0x4,ROVS0x1000,WAVE_OPS0x4000,INT640x8000,ATOMIC64_TYPED0x400000,RESOURCE_HEAP0x2000000,SAMPLER_HEAP0x4000000,ATOMIC64_HEAP0x10000000). That pair is what broke here, and a table is cheaper to check than a chain ofifs in a 900-line function.Recipe:
cargo test -p victory-shader --locked --lib248 passed, 3 ignored;cargo test --workspace --locked26 suites with the one failuremainalso has in a session without a desktop (lifecycle::tests::showing_a_title_window_shows_its_stand_in);clippy --workspace --all-targetswith and without--all-featuresclean under-D warnings;rustfmt --checkwith the same two hunksmainalready has inshader.rsand no others (I reverted the two unrelated lines rustfmt wanted to reflow, so the diff carries no formatting churn).What this does not do: it does not make the marking cheaper or change what it marks — the flag is a declaration of what the module already does. And it does not touch the 735 programs refused for "entry function performs some operation that is incompatible with the shader stage" or the 195 with "an address in an SGPR that is no root parameter"; those are separate families with their own causes.
No game data is involved: flag values, counts and error text.
Written with an AI assistant.
The write marking added on 2026-11-25 puts a UAV into programs that never had one, and the validator recomputes the shader flags from what a module declares: a vertex shader holding a UAV must carry ShaderFlags bit 16 ("UAVs at every shader stage", DXIL.rst) or it is refused with "Flags must match usage". Declaring the module flag is not enough on its own - the feature part has to agree, or the next error is "Container part 'Feature Info' does not match expected for module" - so the SFI0 bit 0x4 (ShaderFeatureInfo_UAVsAtEveryStage) goes with it. The flags-to-feature mapping moves out of `finish` into `feature_info`, which is what makes the pair testable, and a test pins every bit against DXC's values. Measured on the offline census over a local 1.0.2.1 shader archive (26,503 containers), validator = SDK 10.0.26100 dxil.dll 1.9: before Flags must match usage 871, validated 23,918 flags Feature Info instead of it 867, validated 23,918 both neither 0, validated 24,785 i.e. the 868 VfxVBuffer vertex programs thatcd94d35cost (#1987) validate again, and the corpus is back to the parent commit's count. `translate --validate` also keeps the validator's `note:` line now, because "Flags must match usage" comes with "note: Flags declared=..., actual=..." and that pair is what identifies the missing bit; without it the reason was one line that said nothing about which flag.The write marking added on 2026-11-25 puts a UAV into programs that never had one, and the validator recomputes the shader flags from what a module declares: a vertex shader holding a UAV must carry ShaderFlags bit 16 ("UAVs at every shader stage", DXIL.rst) or it is refused with "Flags must match usage". Declaring the module flag is not enough on its own - the feature part has to agree, or the next error is "Container part 'Feature Info' does not match expected for module" - so the SFI0 bit 0x4 (ShaderFeatureInfo_UAVsAtEveryStage) goes with it. The flags-to-feature mapping moves out of `finish` into `feature_info`, which is what makes the pair testable, and a test pins every bit against DXC's values. Measured on the offline census over a local 1.0.2.1 shader archive (26,503 containers), validator = SDK 10.0.26100 dxil.dll 1.9: before Flags must match usage 871, validated 23,918 flags Feature Info instead of it 867, validated 23,918 both neither 0, validated 24,785 i.e. the 868 VfxVBuffer vertex programs thatcd94d35cost (#1987) validate again, and the corpus is back to the parent commit's count. The reporting side of that fix (keeping the validator's `note:` line) is #1767's, which is where it belongs: this change is only what the modules declare.@Yoshi-233 on GitHub · 2026-11-25 03:17 UTC · original
I reproduced the flags mismatch with a small synthetic vertex shader on native Linux, independently of the title corpus. I supplied an
SV_Positionoutput signature and ran the publicemit_withpath with a descriptor-tablebuffer_store_dwordand write marking enabled. Linuxdxv(DXC build3f85295c) rejected the base output at940d32fwith:At
3d6a54fthe same input validated. ItsSFI0changed from0x02000000to0x02000004.I checked eight combinations in total: vertex/compute × with/without the buffer store × write marking on/off. The other seven containers were byte-for-byte identical between revisions and passed
dxvon both. That includes the vertex shader with the same store and write marking off, and the compute shader with marking on. All eight passed on the PR. This checks translation and validator acceptance; there was no GPU dispatch or game input.@upipibi on GitHub · 2026-11-25 03:20 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
3d6a54f.victory-shader: 245 passed, 3 failed, 3 ignored; the newthe_feature_bits_follow_the_shader_flagspasses. 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).
@Dathinel on GitHub · 2026-11-25 03:24 UTC · original
I compared this head (
3d6a54f) with #1989 (0f11320) using the same Windows SDK 10.0.26100.0 x64 validator. Both fix the marked vertex case. Four synthetic cases distinguish them:The three new cases are emitter tests. Starting from the copy-through vertex shader and rectangle geometry shader in
emit/rect.rs, emit oneatomicBinOp.i32(OR, byte offset 0, value 1) through eitherview_writes_handle()ormemory_dirty_handle(), then validate the finished container. All three report flags declared0x10, actual0x10010. The same stages without a UAV validate, as do the pixel controls with either binding.Changing only the predicate in this branch to #1989's stage and binding conditions made all nine emitter cases and all six cases of the earlier stage fixture validate. The missing conditions are geometry/mesh stages and the
memory_dirtybinding. The CLI change that retains the validator's diagnostic note is separate and could be reviewed on its own.These are validator results for synthetic shaders. They do not measure how often these cases occur in a title. AI-assisted.
@AgneyaK on GitHub · 2026-11-25 03:37 UTC · original
A full-corpus run, so reviewers can compare this with #1989, which fixes the same regression (#1987). Offline
translate --validateover the title 1.0.2.1's shader pack, release build, Windows 11 26300, validator DXC 1.9.2602 (the serviced SDK10.0.26100.0copy here).Flags must match usagemain940d32f3d6a54f)0f11320)The same counts and the same remaining refusals (735 compute, 71 mesh) as #1989. On this corpus the two are interchangeable; the difference is in the code (stage predicate, mesh handling, tests).
AI use: Claude Code (Claude Opus 5.5) ran the builds and wrote this; counts only, no game data.
@Calvix2k on GitHub · 2026-11-25 03:37 UTC · original
Two things before this lands, because there are now two open PRs for the same bit (#1989 and this one):
1. Mesh shaders are still missed. Your condition keeps
&& self.mesh.is_none(), so a mesh program that declares the view-write UAV does not get the flag. Dathinel's fixture on940d32f(Windows SDK 10.0.26100 validator, the same engine as the corpus run):Flags declared=0x40000010, expected0x40010010)graphics && !self.pixel(dropmesh.is_none();graphicsisthreads.is_none() || mesh.is_some()) makes all six of their cases pass. I hit the same trap in #1977 — that is why I closed it in favour of #1989.2. The
feature_infotable is worth keeping. Mapping the flags to theirSFI0bits in one place instead of the chain ofifarms is the better shape, andtranslate.rsprinting the validator'sdeclared/actualnote is what let you find this at all. I would keep both even if the flag condition ends up identical to #1989's.Corpus confirmation from this machine, for the body:
940d32f23,918 validated / 868Flags must match usage; the fix makes it 24,785 / 0 (+867, 0 lost), RX 7800 XT, Windows 10, SDKdxil.dll1.7.@fiestorra on GitHub · 2026-11-25 05:03 UTC · original
Trimmed back to the fix itself: the note handling moved to #1767, and the queue is conflict-free
This pull request no longer touches
apps/victory/src/translate.rs. The validator'snote:line — which is what made #1987 solvable — is now kept byvalidator_reasonin #1767, which is where the reason-building lives, and my comment there has the detail:So what is left here is only what the modules declare: the shader flags for a vertex program that holds a UAV, the
SFI0feature bit that has to agree with it, and thefeature_infotable with its test. The measured effect is unchanged (871 → 0 onFlags must match usage, 23,918 → 24,785 validated, the parent commit's count).The point of trimming it: keeping the note here as well made #1767 and this conflict in
translate.rsin either merge order, for two lines of duplicated code. With it there and not here, I re-ran the merge of all seventeen of my open pull requests ontomain940d32fand every one merges cleanly, in any order I tried — which is the state I wanted the queue in.Re-checked after the change:
cargo test -p victory-shader --locked --lib248 passed, 3 ignored;clippy --workspace --all-targetswith and without--all-featuresclean under-D warnings;rustfmt --checkonshader.rsshows the same 2 hunksmainalready has and no others.No game data is involved: flag values, counts and file names.
Written with an AI assistant.
@Calvix2k on GitHub · 2026-11-25 05:15 UTC · original
The trimmed head still has
&& self.mesh.is_none()in the flag condition, so the mesh case from Dathinel's fixture still fails:Flags declared=0x40000010, expected0x40010010)graphicsis alreadythreads.is_none() || mesh.is_some(), so dropping that one clause is the whole change:if graphics && !self.pixel && has_uavs. If there is a reason mesh programs should stay out — a validator limitation or a mesh pipeline that refuses the flag — please say so and I will stop bringing it up; otherwise it is the last correctness gap in this fix, and #2027 inherits it because its branch is stacked on this commit.Not blocking the nicer
feature_infotable: that part is good and I hope it lands either here or in #1767.@Marvisak on GitHub · 2026-11-25 09:17 UTC · original
Automated triage for the maintainers.
Proposed close.
This duplicates open PR #1989, which fixes the same regression (#1987) more completely and merges cleanly. Both set
UAVS_AT_EVERY_STAGE(bit 16) and the matchingSFI0bit 0x4 incrates/victory-shader/src/emit/shader.rs(Shader::finish). The difference is the condition. This head's condition excludes mesh and geometry stages (self.mesh.is_none() && self.gs.is_none()) and does not count thememory_dirtybinding. #1989 usesgraphics && !self.pixel && has_uavs, withmemory_dirtyincluded. Dathinel's and Calvix2k's validator runs on this PR show the mesh, geometry and dirty-bitmap cases still rejected here (Flags declared=0x40000010, expected0x40010010) and passing with #1989. On the title corpus both give the same counts.The
feature_infotable and its test are a reasonable cleanup. They could come back as a small follow-up on top of #1989 once it lands.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.
CI: passing (
check).Generated by Claude Code
@fiestorra on GitHub · 2026-11-25 22:46 UTC · original
Closing: main already has this, test included
Main's
a1a2077("Shaders: vertex, geometry and mesh programs with UAVs say so in their flags") setsflags::UAVS_EVERY_STAGEfor exactly the programs this branch covered, and carries the same test name (uavs_outside_pixel_and_compute_programs_are_declared). Rebasing this branch on top of it leaves an empty diff, so there is nothing to review here.What I keep from it: the measurement that made it worth doing (5,046 programs refused with "Flags must match usage", 26 more mesh and vertex programs that only use UAVs from the heap and must not be declared). If that count is still useful to whoever touches the marking next, it is in the branch's history.
Written with an AI assistant.
Pull request closed