Shaders: cube samples with gradients, and image_sample_d_cl #563
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!563
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/563/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?
@SAitken91 on GitHub · 2026-11-24 04:57 UTC · original
SAitken91:shader/cube-gradients-and-sample-d-cl→main· +57 −7 · 1 files · 1 commits · closed without mergingimage_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
@KoLolX3 on GitHub · 2026-11-24 05:32 UTC · original
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.
@iurysf on GitHub · 2026-11-24 06:17 UTC · original
Tested offline against main
d2a4baewithvictory translate --list --validateover the title'sshaders.rpf+ executable (26,096 programs), dxil.dll 1.9.2602.17:AI-assisted.
@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.
@upipibi on GitHub · 2026-11-24 10:19 UTC · original
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).
@MamaLeVrai on GitHub · 2026-11-24 17:23 UTC · original
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.@Marvisak on GitHub · 2026-11-25 00:25 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 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.
Pull request closed