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!694
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/694/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?
@LAKSHYA-cmd-tech on GitHub · 2026-11-24 06:57 UTC · original
LAKSHYA-cmd-tech:fix/image-sample-d-cl-and-gather4-l→main· +118 −7 · 1 files · 1 commits · closed without merging## What
Resolves two frequent shader conversion failures during world load identified in #293 (~103 dropped draws/dispatches per frame) and #653:
image_sample_d_cl:
image_gather4_l and image_gather4_l_o:
Tests
No game data used.
@r4tedx on GitHub · 2026-11-24 07:03 UTC · original
A review note from reading the diff at
c169328, with two facts about the title's shaders that testers measured for #160, which lowers the same two instructions. I have not built or run this PR.1.
image_gather4_lreads level 0. The change addsimage_gather4_landimage_gather4_l_oto the arm that emitstextureGather(opcode 73), next to the_lzforms.textureGatherhas no level operand, and I see nothing in the diff that uses the level, so a gather at level 2 would return level 0's texels. That matters here: over the retail shaders, none of the 12image_gather4_lprograms has a level the translator can prove is 0 (EduAzevedo on #160). #360 had the same gap and its author deferred it. In #160 a gather at a run-time level becomes four samples at the footprint's texel centres at that level, so the sampler's address mode and level range still apply; a level known to be 0 stays a real gather.2.
image_sample_d_clon a cube. The clamp is read atfirst + grads + coords, and the gradient count is not changed. Everyimage_sample_d_clin the title is on a cube, with eight address registers and no a16: two gradients per direction (the face coordinates'), then the three coordinates and the clamp (EduAzevedo).mainexpects three gradients per direction on a cube and runs past the operand list. #318 lowered_d_clwithout that cube rule and the count of refused programs did not move: 27 atimage_sample_d_clbecame 27 atan image address(nullmarsh on #318). From reading only, I expect the same here.A smaller point: the new test checks that the two programs lower, not what they compute. A GPU test with a mipmapped texture whose levels hold different values would have caught the first point.
Where #160 stands, for whoever decides between them: on the title's shaders 23 of the 27
image_sample_d_clprograms and all 12image_gather4_lprograms translate and validate, nothing that translated onmainis lost, and in the title #293's top G-buffer pixel shader7bdefdfde461f6e3runs with it (nullmarsh). Those are the linked testers' measurements, not mine.Nothing was run for this note; the title was not used. AI-assisted.
@fuzeofficlal on GitHub · 2026-11-24 07:23 UTC · original
I ran the same generated mip texture on
c169328and #160 at25e917b, on the default D3D12 adapter and WARP.With 32 lanes requesting mip 0, 1 or 2,
image_gather4_lon this PR matched 11/32 lanes on each backend. All 21 requests for mips 1 and 2 missed, and the representative lanes for both returned the mip-0 tuple. Both controls (image_sample_landimage_gather4_lz) matched 32/32. The same gather matched 32/32 on #160 on each backend.The 2D
image_sample_d_clcase on this PR correctly selected minimum LODs 0, 1 and 2 per lane. The eight-address cube case from #160's synthetic test stopped atan image addresson this PR. On #160 it ran and matched the expected face and mip on both backends.I also checked
image_sample_b_clwith a zero bias and minimum LOD 2. The plain_bcontrol matched 32/32, while_b_clmatched 0/32. Counting the bias address for both SampleBias forms infirst(usize::from(op == 61)in place of the exactimage_sample_bname check) restored 32/32 on both. #160 already passed that case as well.These results favor using #160 for the overlapping gather and cube paths. If the sampling clamp changes are split out here, the bias-address fix above preserves the coordinate and clamp operand positions.
@slint6614-dev on GitHub · 2026-11-24 07:32 UTC · original
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate, against maind2a4bae(emitted / validated):cargo test -p victory-shaderimage_gather4_l(12 refusals, all compute): cleared by #694, #160 and #136; the 12 programs then validate.image_sample_d_cl(27 refusals): cleared by #694, #563 and #160, but only #563 (cube gradients) turns 25 of them into validated pixel programs; with #694 they stop on another reason.Windows 11, dxil.dll from SDK 10.0.26100.
@iurysf on GitHub · 2026-11-24 08:27 UTC · original
Measured offline against main
c2e7254withvictory translate --list --validateover the title'sshaders.rpf+ executable (26,096 programs), dxil.dll 1.9.2602.17, comparing outcomes program by program: failures 3,734 -> 3,722 (−12). All 12 "image_gather4_l" refusals now emit and validate, and there are no regressions. On this corpus, the 27 "image_sample_d_cl" refusals are not among those fixed here; #563 clears those (27 -> 0, see my comment there).AI-assisted.
@bittertea0323 on GitHub · 2026-11-24 14:22 UTC · original
Verified offline against the whole shader corpus (26,084 programs, 4070 SUPER / Windows 10)
Applied
0beec4dcleanly onffe310e+ local diag changes, then ran the offline batch over thetitle's shader container dump (26,503 containers, 26,084 programs, same file both runs):
emit: image_sample_d_clemit: image_gather4_lemit: a cross-lane operation outside computeBoth target classes are gone and 16 more compute programs reach DXIL. Two things worth knowing
before merge:
sample_d_clprograms did not become emittable — the VS+PS count is unchanged — sothey carry a second failure class as well. The counter dropping is not the same as those
programs emitting.
a cross-lane operation outside computewent 46 → 48: a new failure rather than areshuffle of the existing ones. Small, but worth a look.
Repro:
cargo build --release -p victorythenvictory translate <container dump>; both runsused the same container file on the same host. The rest of the failure table is unchanged from
baseline (
translate-baselinein our notes), so nothing else moved.@alexdeliu on GitHub · 2026-11-24 17:47 UTC · original
Merged onto
main@ffe310eb, this PR (efd02d56) no longer compiles its tests.crates/victory-shader/src/emit/lower.rs:7471(andlower.rs:7516) callsresource::trackwith 3 arguments. Since6638098cit takes a 4th,lanes: Option<&Structured>; main's tests passSome(&st)withlet st = structure::structure(&p).unwrap();.Checked with CI's steps (both clippy runs with
-D warnings,cargo test --workspace) on Windows 11, AMD RX 9070. Every open PR: https://gist.github.com/alexdeliu/ef9ef0ebc1776ff104b5aa8eaea18e87@MoonYueya on GitHub · 2026-11-24 18:20 UTC · original
This PR covers the two instructions our own 303-failure window flagged most often in class E, so we are not going to re-describe them — you have the lowering. Two things from our side that the PR description does not mention, in case they are useful for the follow-on cases:
Parse the modifiers as a set, not as part of the opcode name.
l,lz,oandclare orthogonal to the gather/sample family, which is what makesimage_gather4_landimage_sample_d_clfall out of the opcode table in the first place — they are not missing opcodes, they are unparsed suffixes. Structuring the check as "family + modifier set" also picks upimage_gather4_l_o(level and offset) andimage_sample_cl/image_sample_b_clfor free, which the PR body does not name.Gather picks one channel per instruction. The dmask names which one, so the call is
GatherRed/GatherGreen/GatherBlue/GatherAlpha, andGatherCmp*when a comparison sampler is bound. A dmask that does not name exactly one channel is worth refusing explicitly rather than picking one.For reference on the second point, our own lowering's shaping:
has_cl / has_o / has_l / has_lzcome out of a singlemodssplit, and the LOD is0uwhenlzis present, the address whenlis present, and computed from derivatives otherwise (pixel stage only). That ordering matters —lzhas to win overl, and both have to win over the implicit-derivative path.(AI-assisted write-up, checked against our own lowering.)
Context: failure measurements in #1481.
@MrEjecutor on GitHub · 2026-11-24 21:10 UTC · original
image_gather4_lhere gathers at level 0, but the title names a level; a version that reads it, with a GPU test, is on a branchDXIL
TextureGather(opcode 73) has no level operand: it always reads mip 0. With this PR,image_gather4_l/image_gather4_l_otranslate, but they read level 0 wherever the console program asks for level n.Which programs use them, on the retail shaders (
victory translate --listonmainffe310e): 17 compute programs are refused onimage_gather4_ltoday, 11 inmeshlet_culling(CS_BatchCullMeshlets,CS_BatchCullPreSkinnedMeshlets,CS_BatchCullBatchCSMeshletsand their_Prev/_ParaboloidShadowsvariants) and 6 inwater_micro_geom_renderer(patch generation and culling). According to thefxceless/victory-gta6fork (the one that renders the lit world on NVIDIA, #1528), the meshlet culling reads its depth pyramid this way: a 4x4 block at the meshlet's level, as oneimage_gather4_land threeimage_gather4_l_o. Read at level 0, "most of the world was culled against the wrong depths", in the fork's words.A version that reads the named level, written from scratch on
main: https://github.com/MrEjecutor/VIctory/tree/gather4-l-level (one commit,4f44097, onffe310e). For 2D textures it reads the 2x2 footprint at the named level with fourtextureLoads in gather order, the offset in texels of that level; cube, array and 16-bit forms stay refused. Shortcuts, marked in the code: the level is rounded and clamped to the texture's levels, and texels past the edge are clamped whatever the sampler says.Measured:
translate --validateover the retail shaders: no program refused onimage_gather4_lany more; all ofmeshlet_cullingvalidates; compute validated 1,417 → 1,433 of 2,582.gather_level_tests.rs, on an RTX 5060 Ti and on WARP): six gathers at levels 1 and 2 of an 8x8 texture, with and without offsets and at the edge, return the expected texels. With the level forced to 0 the test fails on its first case.cargo test -p victory-shader: 122 passed (Rust 1.100).cargo xtask policy: ok. Clippy with warnings denied is clean on the change (1.100 flags one existing loop inlower.rs:678, unrelated).Not tested: the title with this branch (on this card
mainalone still hangs in the world, see #747); AMD; the water programs' output.If it is useful, it can replace the two gather arms here, or be cherry-picked on its own.
AI use: written with Codex (gpt-6-luna) and Claude Code (Claude Opus 5.5); checked and measured by mrejecutor. The analysis that pointed at the level is fxceless's; no code was taken from their fork.
@Marvisak on GitHub · 2026-11-25 00:27 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.image_sample_d_cl and image_gather4_l/_l_o are both lowered in main (emit/lower.rs image(), gather_at_level).
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
@MrEjecutor on GitHub · 2026-11-25 00:43 UTC · original
Follow-up to my comment above:
mainat70564aenow lowersimage_gather4_l/image_gather4_l_oitself and loads the four texels from the named level (gather_at_levelinemit/lower.rs, with the sampler's border and a level proven whole, which my version did not handle). So thegather4-l-levelbranch I pointed to is superseded and I am not proposing it.AI use: Claude Code; checked by mrejecutor.
Pull request closed