Shaders: cube samples with gradients, and image_sample_d_cl #563
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/563"
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?
Imported from Marvisak/VIctory. Originally posted by SAitken91 on 2026-11-24T04:57:31Z.
image_sample_d_clwas refused by name (27 programs in shaders.rpf, includingPS_DeferredTextured). Behind it, every one of those programs also hit a cube sample with explicit gradients, refused as "a cube sample with texel coordinates, gradients or a level query". Both now translate tosampleGrad.Change
cube_gradientturns the face gradients into the direction's gradients through the face's linear part ofcube_direction(u = 2s − 3, v = 2t − 3; the major axis doesn't move). This mirrors the existing table term by term._cl. The level-of-detail clamp follows the coordinates and is passed assampleGrad's clamp, which was undef before.Results
victory translate --validate shaders.rpf: vertex/pixel validated 12172 → 12197. Both errors are gone from the list. The other 2 of the 27 stop at unrelated cases.Testing
cargo test -p victory-shader: 69 passed. Clippy and rustfmt are clean.cube_directionbeing affine per face, but no draw has been checked. A differential test (needsVICTORY_CONSOLE_DXC) would confirm it.This is independent of #539 and #554.
Written with the help of Claude (AI).
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by KoLolX3 on 2026-11-24T05:32:31Z.
Check on Linux, not Windows: pass. Head
10ac6ceacmerged ontomaind2a4bae1f(clean merge).core,formats,game,loader,pe,pipeline,shader): PR92 passed, 7 failed,main92 passed, 7 failed.cargo xwin check --workspace --target x86_64-pc-windows-msvc, coversvictory-gpu,victory-hleand the app): PR ok,mainok.main168.mainhere as well (not this PR): 7 tests invictory-loaderandvictory-pethat parse their own test binary as a PE image, which is an ELF file on Linux.victory-gpu/victory-hletests and the game itself.On: AMD Ryzen 7 5700, 62 GB RAM, Artix Linux 7.3.4-artix1-2, rustc 1.98.1 (the repo's pinned toolchain), cargo-xwin 0.24.1. No game data. Automated check only: the code itself was not reviewed.
Imported from Marvisak/VIctory. Originally posted by iurysf on 2026-11-24T06:17:12Z.
Tested offline against main
d2a4baewithvictory translate --list --validateover the title'sshaders.rpf+ executable (26,096 programs), dxil.dll 1.9.2602.17:AI-assisted.
Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T07:32:14Z.
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.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T09:37:26Z.
Review: APPROVED
Tested
10ac6ceon Windows 11, RTX 5070, MSVC: the workspace passes (195 outsidevictory-shader;victory-shader --libwith--test-threads=1: 69).victory translate <title exe> --validate --pipelinesgives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines. None of the 12 has cube gradients or_cl.cube_gradientagainstcube_directionterm by term. Eachu = 2s − 3/v = 2t − 3entry becomes2·ds/2·dtwith the same sign, and the ±1 major-axis entries become 0. That is the Jacobian of the face-to-direction map._clreads the clamp right after the coordinates, which matches the MIMG address order (gradients, coordinates, clamp), and is passed assampleGrad's clamp.No issues found.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T10:19:31Z.
Independent check of head
10ac6ce, read on its own base and built merged ontomainffe310e(clean merge). I read the comments above first; @mercuryVM already checkedcube_gradientagainstcube_directionterm by term and I get the same. This adds the references for the two hardware claims and what is still untested.References
IntrinsicsAMDGPU.td(release/18.x, line 640):AMDGPUDimCube : AMDGPUDimProps<0x3, "cube", "CUBE", ["s", "t"], ["face"]>. Gradients are per coordinate name, not per slice name, so a cube has two per direction and the coordinates start at address 4, as the PR has it. With the clamp that is 4 + 3 + 1 = 8 addresses, the count reported for the title's samples on #318.ac_nir_lower_tex.c(mesa-24.0.0,prepare_cube_coords, lines 107-147): with derivatives,scandtcare multiplied by1 / |ma|first, the derivatives are converted "to 2D derivatives" of those same quotients, and only then is 1.5 added. So the hardware's gradients are of the face coordinates s and t in [1, 2], andu = 2s - 3givesdu = 2 ds. The PR's factor of two and its zero for the major axis are the exact inverse for a direction whose major component is +-1, which is whatcube_directionproduces.AMDGPUDimProfile.AddrArgs, lines 739-746: the extra arguments, the gradients, the coordinates and slice, thenLodClampMip, which isclampfor the_clsamples), andsampleGrad's last operand is the minimum-LOD clamp, so passing it there is the same quantity.Limits I see, none new defects of this PR
image_sample_d_cltakes the pathimage_sample_dhas onmain, where witha16the gradients are read as packed 16-bit halves. @r4tedx's note on #318 (LLVM'sgfx10_asm_mimg.s: gradients stay 32-bit unless the opcode is a_g16one) applies to both names. The title's_clsamples are reported as not a16, so this is latent, but_clwitha16now translates where it was refused by name.cube_gradientcompares the face to 0..5 ascube_directiondoes, so the existing shortcut (the face operand of a cube array adds 8 x the slice) covers gradients too.image_sample_d_cl_oand the comparison forms are still refused by name.Not tested by anything in this PR. It adds no test, and no test on
mainsamples a cube with gradients, so the suite result below only says nothing else moved. #160 has the same rule (also calledcube_gradient) with a GPU test for it,cube_gradients_are_the_face_coordinatesin itsimage_tests.rs, on a cube whose faces and levels each hold their own value. The two PRs edit the samematcharm and cannot both land as they are; if this one goes first, that test is the one to carry over. I did not port it: it needs #160's fixture.Suite. NVIDIA RTX 3070, driver 616.56, Windows 11, Rust 1.98.1, SDK 10.0.26100
dxil.dllvalidating,cargo test -p victory-shader -- --test-threads=1:mainffe310e+ this PR, 120 passed, 0 failed, 1 ignored (the bitcode benchmark).Not checked: the title (no game files here), AMD hardware, any sampled result.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-24T17:23:52Z.
Heads-up: this PR and #1004 both edit the cube-sample refusal in
emit/lower.rsand conflict with each other. Merged together only texel coordinates are still refused; that resolution is in the bundle #1319 (clippy and tests pass). AI-assisted (Claude Code); no game data.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:25:01Z.
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 cube samples with gradients are in main (
0b35b7fe,4f57f46f), the cube case done as SampleLevel from the face-space gradients because SampleGrad on a cube cannot reproduce them (diff_tests::cube_gradients_pick_the_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.
upstream-sync referenced this pull request2026-11-25 02:06:02 +00:00
Pull request closed