Repository navigation
Shaders: support image_sample_d_cl and image_gather4_l lowering (#293, #653) - #694
LAKSHYA-cmd-tech wants to merge 1 commit into
Conversation
catminou4
left a comment
There was a problem hiding this comment.
cargo test -p victory-shader --locked on macOS 26 arm64, rustc 1.98.1, head c169328: 57 passed, 0 failed (+1 vs main — the new lowering coverage runs ungated). Approving.
|
A review note from reading the diff at 1. 2. 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 Nothing was run for this note; the title was not used. AI-assisted. |
|
I ran the same generated mip texture on With 32 lanes requesting mip 0, 1 or 2, The 2D I also checked 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. |
|
Measured on the full retail shader pack (26,503 containers) with
Windows 11, dxil.dll from SDK 10.0.26100. |
c169328 to
88f55ef
Compare
|
Measured offline against main AI-assisted. |
88f55ef to
0beec4d
Compare
Halfect
left a comment
There was a problem hiding this comment.
A merge-compile note on current head 0beec4d, verified locally. The correctness questions raised above (gather level, cube gradients, _b_cl bias operand) are separate and still stand; this is only about building against current main.
main commit 6638098 (merged with #566) changed victory_shader::resource::track to take a fourth argument, lanes: Option<&Structured> — tracked for open PRs in #801, which lists this PR among the mergeable ones affected. GitHub shows no text conflict, so nothing looks wrong until CI or a merger runs the tests:
git merge --no-edit 0beec4d # onto main ffe310e — merges cleanly
cargo check --locked -p victory-shader --tests
error[E0061]: this function takes 4 arguments but 3 arguments were supplied
--> crates/victory-shader/src/emit/lower.rs:7471
| let res = resource::track(&p, &native.layout, native.stage).unwrap();
--> crates/victory-shader/src/emit/lower.rs:7516
| let res = resource::track(&p, &native_cs.layout, native_cs.stage).unwrap();
Both are the new calls in image_sample_d_cl_and_gather4_l_translate. Since the test computes st after track and exercises no per-lane descriptors, passing None keeps the old behavior:
let res = resource::track(&p, &native.layout, native.stage, None).unwrap();With that one change at both call sites, the merged tree compiles and the new test passes (cargo test --locked -p victory-shader --lib image_sample_d_cl_and_gather4_l_translate: 1 passed, Windows, rustc 1.98.1). Same fix two of my own PRs needed today (#655, #683).
Verified CPU-only; no game files, no GPU run.
The LOD form of a gather stopped its program. DXIL gathers from level 0 and has no LOD operand, so the console's LOD is not read: exact for the level-0 gathers titles make of shadow maps and G-buffers. From upstream JMAN730#694 (0beec4d, JMAN730#293, JMAN730#653); its image_sample_cl / image_sample_b_cl / image_sample_d_cl halves are already in this tree. The test also covers image_sample_d_cl. (cherry picked from commit 0beec4d) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Verified offline against the whole shader corpus (26,084 programs, 4070 SUPER / Windows 10)Applied
Both target classes are gone and 16 more compute programs reach DXIL. Two things worth knowing
Repro: |
…, Marvisak#956, Marvisak#587 and this branch's own changes
makeDouble from the register pair, then fptrunc; declares double precision (ShaderFlags bit 2, SFI0 0x1). Inline constants read as a 64-bit operand are doubles (floats) or sign-extended integers, and abs and neg act on the high half's sign bit. From upstream PR Marvisak#978 (c8c117a), hand-ported: image_sample_d_cl was in already (JMAN730#694); the double-precision flag is bit 2, not bit 0 (DisableOptimizations), and inline float constants are encoded as doubles. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
A real run of the title refuses 31 shaders with 'an address in an SGPR that is no root parameter', but that message is wrong for most of them: the parameter exists and the address came from its second or later dword. The message now says which case it is - a root descriptor's high half, a root constant past the first dword, a descriptor heap index, a parameter's later dword, or genuinely no parameter - so the next run decides the fix instead of requiring a guess. Diagnostics only: no lowering behaviour changes. docs/world-load-diagnosis.md records what the run achieved, the ranked refusals, and why Marvisak#694's image_gather4_l change was not taken.
A real run of the title refuses 31 shaders with 'an address in an SGPR that is no root parameter', but that message is wrong for most of them: the parameter exists and the address came from its second or later dword. The message now says which case it is - a root descriptor's high half, a root constant past the first dword, a descriptor heap index, a parameter's later dword, or genuinely no parameter - so the next run decides the fix instead of requiring a guess. Diagnostics only: no lowering behaviour changes. docs/world-load-diagnosis.md records what the run achieved, the ranked refusals, and why Marvisak#694's image_gather4_l change was not taken.
- the net change of Marvisak#705 on current main - tests of this and of Marvisak#694 pass the lane structure argument resource::track now takes
|
Merged onto Checked with CI's steps (both clippy runs with |
|
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. Gather picks one channel per instruction. The dmask names which one, so the call is For reference on the second point, our own lowering's shaping: (AI-assisted write-up, checked against our own lowering.) Context: failure measurements in #1481. |
|
DXIL Which programs use them, on the retail shaders ( A version that reads the named level, written from scratch on Measured:
Not tested: the title with this branch (on this card 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. |
|
Automated triage for the maintainers. Closing because this change is already in 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. |
|
Follow-up to my comment above: AI use: Claude Code; checked by mrejecutor. |
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.