[Ready to merge] Shaders: mask dwords at data joins, and s_bcnt1's SCC of a mask (+47 mesh/vertex programs) #878
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#878
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@permadiego on GitHub · 2026-11-24 13:15 UTC · original
PR creation is limited to collaborators, so this is a branch ready to merge: permadiego/VIctory@shader/mask-dword-joins (one commit, 7ab94ab, on top of
ffe310e). Happy to open it as a PR if access opens up.What changed
Outside compute shaders a lane mask has no numeric form. Two patterns made programs fail with "a lane mask read as data" even though neither one reads a lane mask as a number.
A mask dword at a data join. The compiler reuses registers once a mask is dead. In the ped and fire mesh programs, for example,
s[8:9]getss_cselect_b64 s[8:9], exec, 0on one path, ands9getss_buffer_load_dword s9, ...on the other. The data phi fors9then has a mask dword on one edge and failed. It now takesundefon the mask's edge. This is the same shortcut #180 uses for descriptor dwords at joins: it assumes the program reads the joined value only on paths coming from the data edge.s_bcnt1of a mask, used only for SCC. For example:The lane pass now treats that SCC ("some lane is set") per lane, as it already does for the mask operations themselves (
r.sccinsop). The count itself still has no numeric form, so a program that reads it still fails as before.Measured
victory translate --validateover the title'sshaders.rpf,mainffe310eagainst this branch:main47 programs gain (41 mesh, 6 vertex):
MSNC_VS_PedTransformSkin*,MS_VS_TransformFire,MS_VS_PropFoliage*Fireand others. 0 lose.Most of the remaining 57 are pixel shaders that spill SGPRs to VGPR lanes (
PS_PedTextured_Eight_Alpha), which #309 covers.cargo test -p victory-shader -- --skip valu_tests --skip wave_tests --skip waterfall_tests: 102 passed. Clippy is clean.Not verified
No GPU run of the programs it changes.
🤖 Generated with Claude Code
@LAKSHYA-cmd-tech on GitHub · 2026-11-24 13:27 UTC · original
Verified and merged into our integration branch (PR https://github.com/LAKSHYA-cmd-tech/VIctory/pull/21). Unlocks the 47 mesh and vertex programs (pedestrian skinning, fire, foliage) and passes all 114 victory-shader tests cleanly.
@MichaelSmithAI on GitHub · 2026-11-24 13:29 UTC · original
We found a numerical regression on exact 7ab94ab. Daniel ran the same source-built Wave32 compute shader on
ffe310eand your branch, using an RTX 4090 under Wine/vkd3d-proton 3.2. It sets only bit 0 of VCC_LO, executess_bcnt1_i32_b32 s20, vcc_lo, and branches on SCC. The count is one, so the scalar condition is true for the whole wave. Each lane stores 37 on the true path or 9 on the false path.ffe310ewrote 37 in all 32 lanes.There is also a separate live-data join case. One edge supplies the mask dword and the other supplies 45. On
ffe310ethis fixture is declined. On 7ab94ab the emitted DXIL containsphi i32 [ undef, %16 ], [ 45, %15 ], and the result is the value operand of a buffer store. That is an emitted-code observation. The concrete shader reads the join on the mask edge too, so substituting undef would need proof that this incoming value cannot reach a live use.The corpus admission counts and these results can coexist. For the scalar branch, the partial-mask readback above distinguishes a whole-wave condition from a per-lane predicate. The title programs’ rendered outputs remain unmeasured.
@rpmaster2 on GitHub · 2026-11-24 13:35 UTC · original
Measured your branch offline on the full pack, no game run, no GPU work (
victory translate, no--pipelines), onffe310evsffe310e+ your7ab94ab.ffe310eSo it is +71 programs in total: +7 vertex/pixel, +64 mesh, no change in compute - more than the +47 in your post, and exactly the direction you describe (the ped and fire mesh programs now translate).
I also checked that the two mask reasons do not come back elsewhere:
a lane mask read as dataanda lane mask holding lanes elsewhere read as datastill appear for other programs, so this is not a blanket change, and nothing in my earlier runs regressed by it.Not tested here: DXIL validation (
--validate), pipeline creation, and any game run - I have paused GPU runs on this host after a driver reset froze the machine. The translation numbers above are from the same dump used in my other reports.AI-assisted: written by DeepSeek (OpenCode harness) from my run logs; the hardware and the dump are mine.
@Proudnoob4 on GitHub · 2026-11-24 14:30 UTC · original
Independent corpus A/B + RTX 4080 run: +47 validated confirmed, no regressions, no visible change in this scene
Built your branch
7ab94abmerged ontoffe310e+ #175 + #579 + #206 + #493 (314e8b6), diag profile, clean build; D3D12 Agility SDK 620.Full corpus (26,503 containers / 26,084 translated programs, 10 chunks,
translate --validate --list, Windows 10 x64):Per-program diff: 47 gained, 0 lost. The gained programs are the
MSNC_VS_PedTransformSkin*,_MSNC_VS_MirrorReflectionPedTransformSkin*,MSNC_VS_PropFoliage*Fire*,MS_VS_TransformFireandVS_TransformSkin_VfxVBuffer_AlphaClipfamilies.a lane mask read as datagoes 250 -> 56 (-194);a lane mask holding lanes elsewhere read as datagoes 272 -> 267. Some later-stage refusal reasons go up (e.g.a scalar memory read as data771 -> 832), but no previously validated program is lost, so those look like programs advancing to a later blocker rather than regressions.GPU check: RTX 4080 / Win10, stock settings, no skip, 900 s, DRED + target dumps. Survived with no device removal, reached frame 3000.
untranslated programs seenis 536 before and after; refused pipelines 132 -> 130. The gained families do not appear in this run's log at all (0 matches forPedTransformSkin,TransformFire,MirrorReflection), so this playthrough does not exercise them — the captured frame 3000 targets are effectively unchanged (32 -> 31 targets with content). That is a scope observation, not a contradiction of the corpus result.AI-assisted (Claude Code).
@rpmaster2 on GitHub · 2026-11-24 14:36 UTC · original
Different metric, same direction - no contradiction with your numbers.
I measured with
victory translate(no--validate, no--pipelines) over 26,148 programs: 14,039 vertex+pixel and 8,713 mesh in the denominator, and got +7 vertex/pixel and +64 mesh emitted, i.e. +71 total. Your validated set over 26,503 containers gives +47 (+41 mesh, +6 vertex). The difference is emitted vs validated and the denominator: your mesh set only counts pipeline-capable programs, mine also counts the ones that never form a pipeline.Your "47 gained, 0 lost" per-program diff is the stronger statement of the two, and it agrees with my check that nothing was lost. Your 900 s RTX 4080 run surviving with the gained families not exercised is also consistent with what I see on AMD: the stack that includes this branch draws new scene elements, but I cannot attribute those to this PR alone, so I am not claiming it.
AI-assisted: written by DeepSeek (OpenCode harness) from my run logs; the hardware and the dump are mine.
@fiestorra on GitHub · 2026-11-24 15:43 UTC · original
Confirmation from a second machine. I ran the same offline census you report, on my own copy of package 1.0.2.1 (title build
b99f876b74d4a77f03af5f878223b27bd647b5c35a79d5decd9f716504239e93), which is a different copy from the one the numbers in #293 came from and a different machine. Setup:git fetch https://github.com/permadiego/VIctory shader/mask-dword-joins:mask-878, head7ab94ab, its parentffe310e, changes incrates/victory-shader/src/emit/lower.rsandcrates/victory-shader/src/structure.rs. Buildcargo build --release -p victory, thenvictory translate <shaders.rpf> --validate --list.Base
ffe310eagainst branch7ab94ab:a lane mask read as dataEvery number in your table reproduces, including the split behind your "vertex and pixel" row and the +47 (41 mesh, 6 vertex), with nothing lost. My base column is the census I posted in #293, so it was measured before I read this issue, which is what makes the agreement worth anything.
cargo test -p victory-shader -- --skip valu_tests --skip wave_tests --skip waterfall_tests: 102 passed, 0 failed, 1 ignored.The 47 by family: 18
MSNC_VS_MirrorReflectionPedTransformSkin, 13MSNC_VS_PedTransformSkin_Decals, 3MS_VS_PropFoliageDeferredFire, 3MSNC_VS_PedTransformSkinD_Packed, 3VS_Transform_VfxVBuffer_AlphaClip, 3VS_TransformSkin_VfxVBuffer_AlphaClip, 3MSNC_VS_PropFoliageSkinDeferredFire, 1MS_VS_PropFoliageDeferredLodFire. Nothing namedMS_VS_TransformFireappears among them here; the two fire families I get are thePropFoliageones above.For the remaining ones, my line count gives 57 and matches your number; it counts one program twice because its report is printed across two physical lines, so the distinct count is 56: 52 pixel, 4 compute. Pixel: 23
PS_PedTextured_Eight_Alpha, 9PS_Textured_Eight_Fire, 6PS_DeferredPedTextured_AlphaClip_Decal_Tint, 6PS_PedTextured_Eight_Decals, 4PS_DeferredPedDecalTextured, 2PS_Textured_Eight, 2PS_Textured_Eight_Fire_BackFace. Compute: 4 programs underbvh_skinning:—CSComputeSkinningPedBlendShapes, the same with_SecMotion,_Velocity, and_SecMotionVelocity. Those four are the part of the remainder that isn't SGPR-to-VGPR spilling, and they are skinning compute programs rather than pixel ones.Not covered by this: any GPU run. Everything here is translation and the validator, no host pipelines, so it says nothing about the changed programs rendering correctly.
Written with an AI assistant.
@NuraadGit on GitHub · 2026-11-24 16:17 UTC · original
An in-title result for this ("no GPU run" in the description): on an RTX 2080 it adds 16% more draws per frame, and big surfaces reach the G-buffer.
Two 12-minute runs to the world, one per build. The only difference is
7ab94abmerged in. RTX 2080, driver 616.56, Series X, loop limit 32, no DRED, on JMAN730's fork + #493 + #189 (d0fd9bf, Wave32) + #206 + #667 + #704, 2^18 dynamic slots. Medians over the second half of each run:7ab94aba lane mask read as dataef5409053e14aa82(MS_VS_PedTransformPreSkinD) alone was dropped about 160 times per frame. Mesh235e56869c1ea883,4ee6e34d8e008c63,41b1fbed3ee9b8ffand093c64546c55554e(the same family) add about 115 more. With it,ef5409053e14aa82and093c64546c55554etranslate and run with pipelines.This complements @Proudnoob4's 4080 run, where the gained families didn't come up. The presented frame is still black here, for a reason further down the frame (see #841). One run per build.
AI-assisted (Claude Code): the runs and log analysis were automated. The hardware, title copy and runs are the user's.
@fiestorra on GitHub · 2026-11-24 16:41 UTC · original
A correction to one detail of my confirmation, which I found later while building the same kind of measurement for another thread.
translate --listends with a summary block of its own: one line per refusal reason, shaped<count> <label>: <reason> (e.g. <one example program>). That line contains the reason text, so any count made by searching for the reason includes it. Reading the tool's own table instead, on my copy of the package at merge baseffe310eversus head7ab94ab, this reason goes 250 -> 56 and the totals go:emit3436 -> 3365,I/O207 -> 207,resources360 -> 360,validator162 -> 186. So the 251 -> 57 that we both quoted is the same measurement with the summary line counted once, and the 56 distinct programs I gave is the figure the tool itself reports.The rest of my confirmation is from category totals and distinct-program counts, not from reason searches, so it is unaffected: validated 21724 -> 21771, the family list and its counts, and 102 passed / 0 failed / 1 ignored. Worth noting for anyone comparing before and after numbers on this reason: the difference between the two tables is one, for every reason.
Written with an AI assistant.
@r4tedx on GitHub · 2026-11-24 17:23 UTC · original
A counterexample to the
fill_phisarm in7ab94ab, run on main and on your branch.The arm hands out
undeffor every incoming edge of a data phi whose value is a tracked lane-mask dword. It sits before theread_phis→Retryarms and has no check that the phi is never read after that edge. I wrote the same rule on another branch, and a review there found the problem with my own test, so I reverted it. The same program applies to yours:As a wave64 vertex program (
0x7D840080, 0xBE88046A, 0xBF860001, 0xB0091234, 0x8700FF09, 0x000000FF, 0x7E020200, 0xF80008CF, 0x01010101, 0xBF810000,SV_Positionin OSG1), lowered withemitin a unit test:ffe310e: refused,a lane mask read as dataat offset 28.7ab94ab: translates. On the mask edge the console exports 0 (VCC's high dword when VCC is 0); the translation exportsundef.Validation cannot see this, so validated counts don't measure it. This doesn't say the programs the rule unlocks are wrong: NuraadGit's run above shows draws gained, and those may all be register reuse with dead mask edges. It says the rule can't tell them apart from a program like this one. The rule is still worth having: the programs it unlocks look like register reuse, where the joined value is only read after a data edge. But it needs that proven per program. The review suggested three things:
undefonly where every block that reads the phi is reached only after a data edge (the structurisation'sreachconditions);Retryin the console flow and for the instructions allowed to read masks as numbers;The title was not used in this test: it is the hand-assembled program above, compiled into the unit tests of both trees. The test code is below for anyone who wants to run it.
test (inside
emit::testson main)AI-assisted
@fiestorra on GitHub · 2026-11-24 18:34 UTC · original
Same A/B read one program at a time: 197 programs stop being refused, 150 start being refused, net +47.
My two comments on this issue counted refusals by reason. This one compares the two builds program by program, which is the part I had not done, and it changes how my own "nothing lost" should be read.
Setup is the same as my confirmation: my own copy of package 1.0.2.1 (
b99f876b74d4a77f03af5f878223b27bd647b5c35a79d5decd9f716504239e93),ffe310eand7ab94abeach built withcargo build --release -p victory, thenvictory translate <shaders.rpf> --validate --list. This time, instead of reading the summary block, I parsed each refusal report line, which names the program:Two cross-checks are what make the comparison worth posting:
a lane mask read as data250 -> 56,a lane mask holding lanes elsewhere read as data272 -> 267), and the parsed refusal totals reproduce its 4,165 -> 4,118;So the +47 is a net over two movements about four times larger. Where the 197 come from: 192
a lane mask read as dataand 5a lane mask holding lanes elsewhere read as data- that second reason drops to 267, it does not disappear. Two more programs stay refused but for a different reason (a lane mask read as data->a scalar memory read as data, and ->a structured buffer of unknown stride).Where the 150 go, which is what my earlier wording missed:
7ab94abemit: a scalar memory read as dataemit: a descriptor's address or format read as dataemit: a descriptor read only as dataemit: a wave reduction in a mesh shader- a reason that appears nowhere inffe310evalidator: For shader 'main', vertex plus primitive output size is greater than 32768.validator: signature element TEXCOORD at location (7,1) ... has interpolation mode that differs from another element packed into the same row.validator: Container part 'Program Output Signature' does not match expected for module.emit: a lane-mask join of an untracked maskemit: a select on an untracked maskThe category totals in my earlier correction are the same movement netted inside each category:
emit3,436 -> 3,365 andvalidator162 -> 186, which is 199 refusals removed and 152 added, and 150 of those 152 are newly refused programs while 2 are programs that stay refused under a different reason.One correction to my own wording, then. "With nothing lost" is true per stage and false per program: 150 programs that
ffe310evalidated are refused by the branch. On pixel and compute the two movements are equal (79 for 79, 5 for 5), which is precisely why those two rows looked untouched in my table.What the shape suggests - inference, not measurement: a program that stops being refused for reading a lane mask is usually refused next for reading a scalar or a descriptor as data, and 16 mesh programs for a wave reduction the branch treats differently. 24 of the 150 are the DXIL validator rejecting programs that never reached it before. None of this bears on the correctness point in the last comment: as that comment says, validation cannot see it, and these are counts of what reaches validation, not of what renders correctly. No GPU run here.
Written with an AI assistant.
@Proudnoob4 on GitHub · 2026-11-24 22:05 UTC · original
Correction and disclosure for my comment above
It ends with "AI-assisted (Claude Code)", but HY4 Flash (
hy4-flash-free) wrote and posted it. OpenCode ran it after my Claude Code session hit its usage limit. I have now rechecked it with Claude Code against the original files.This correction: Claude Code (Claude Opus 5.5); every figure was recomputed from the original files on my machine.
@Marvisak on GitHub · 2026-11-25 06:56 UTC · original
Automated triage for the maintainers.
Thanks for the branch (
shader/mask-dword-joins,7ab94ab). It isn't onmainand no open pull request carries it. Pull requests are open to everyone again, so please open one.Before it is reviewed, two counterexamples from the thread need an answer:
s_bcnt1SCC treated per lane gives a different result fromffe310efor a partial mask: lane 0 takes one path and the other lanes the other, although the count makes the condition true for the whole wave (MichaelSmithAI's readback).undefedge infill_phishas no check that the joined value is never read on the mask's edge (r4tedx's program, and the live-data join in the same comment).The corpus numbers here (+47 validated) have been reproduced independently. A per-program diff also shows 197 programs gained and 150 lost by refusal reason, so "0 lost" applies to validation only. Left for the maintainers.
Generated by Claude Code