Shaders: gradient samples with a level clamp, and cube gradients in face space #1280
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1280"
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 nicogunvis-boop on 2026-11-24T17:05:20Z.
What
image_sample_d_cl(explicit gradients plus a level-of-detail clamp) was refused, and most retail uses of it are on cubes, whose gradient samples were refused as well. Example from the title (disassembled locally, registers only):Eight addresses on a cube: two face-space gradients per direction (
ds/dx, dt/dx, ds/dy, dt/dy), the face coordinatess, t, face, then the clamp. This matchesimage_addr_dwords((3, 2)for CUBE plus one forcl).Change (
crates/victory-shader/src/emit/lower.rs)image_sample_d_cllowers through theimage_sample_dpath. The clamp is read after the coordinates (and array slice) and passed assampleGrad's clamp operand, which wasundef.cube_direction(s, t, face)is affine insandton one face (each component is a constant,±(2s-3)or±(2t-3)), socube_direction(s + ds, t + dt, face) - cube_direction(s, t, face)is the exact direction gradient. Those two 3-component gradients go tosampleGradon the cube.a_gradient_sample_with_a_level_clamp_reads_the_clamp_after_the_coordinates(2D) anda_cube_gradient_sample_takes_face_space_gradients(cube), both synthetic. Before the change both are refused.Measured
victory translate --validateon the retail package (Windows 11, dxil.dll from SDK 10.0.26100):image_sample_d_clThe other 4 now stop on "a cross-lane operation outside compute". No other program's outcome changed (25,891 compared). The programs are mostly
PS_DeferredTextured*,PS_MirrorReflection*,PS_TexturedLit*andPS_VoxelizeVisiblity*.cargo test -p victory-shader --lib emit::lower: 13 passed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.Not yet checked in a running world frame. Tested on an RTX 4070. Independent of #1245.
Imported from Marvisak/VIctory. Originally posted by shortselow-byte on 2026-11-24T17:54:45Z.
For triage:
git merge-treeagainst the current heads shows this PR conflicts inemit/lower.rs(the gradient part ofLower::image) with three open PRs:ae0b48e), which now also rewrites howLower::imagereads gradient VGPRs under a16/g16;It merges cleanly with #694, which also lowers
image_sample_d_cl(same"image_sample_d" | "image_sample_d_cl"arm, so git takes one), but both add their own clamp handling.Whichever lands first, the gradient addressing in
Lower::imagewill need one reconciled version.Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T21:12:07Z.
Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the repo toolchain, merged into current
main(ffe310e):cargo test -p victory-shadermainmain+ this PRcargo clippy --all-targets -- -D warnings, with and without--all-features: clean.I didn't test with game data.
Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:36:36Z.
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 gradients are in main (
0b35b7fe,4f57f46f), the cube case as SampleLevel from the face-space gradients.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