Shaders: implicit-level samples in compute take their gradients from the quad #1237
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1237"
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 felicienradio on 2026-11-24T16:42:55Z.
<html>
Console compute programs may sample with an implicit level of detail (
image_sample,image_sample_b): the hardware takes the coordinates' coarse derivatives across each quad of lanes. Emitted as DXILsample/sampleBias, these programs fail validation:In compute shaders the gradients are now read from the quad (lane 1 − lane 0 for x, lane 2 − lane 0 for y, through
waveReadLaneAt), as the hardware's coarse derivatives, and passed tosampleGrad. A bias scales them by 2^bias. Pixel and mesh shaders are unchanged; cube samples keep the old path.Affected programs include
CS_SkyMain,scattering_transmittance_system(fog/in-scattering), the ray-traced shadow denoisers, the irradiance cache / light probes, and theCS_RaytracingResolvefamily.Results
victory translate --validateover the title's shaders on Windows (dxil.dll 10.0.26100), on top of #439:Tests
cargo test -p victory-shader --features host: all pass.Independent of the "descriptor read only as data" PR, which unlocks ~490 more
</html>CS_RaytracingResolveprograms that this change then lets validate.Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T17:59:36Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
a3346f9:cargo test -p victory-shaderpasses, 120 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T20:59:31Z.
Context for choosing between this PR and #160, which both change how implicit-level samples are emitted in compute:
maininto the world counts 730 compute programs refused by the validator for exactly this ("features incompatible with the shader stage", among them the G-buffer resolves and the sky): fxceless/victory-gta6, at itssampleLevelfallback inlower.rs. It works around it by sampling level 0 outside pixel shaders, and its comment says gradients from the lanes are the real fix: what this PR does.samplein compute. Its own test lets the validator 1.6 error through (CS_DERIVATIVES, "1.8 takes them") and relies on the driver's compute derivatives. This PR's gradients from quad lanes 1−0 and 2−0 validate at 1.6 instead. The two touch the samesample/sampleBiasemission, so only one approach can be kept.quad_lanepattern (quad q's lanes 2^n texels apart in x and y, so the quad's derivatives pick level n, on a texture whose texels name their level) would check this PR's gradients on the GPU as well.Reading only, nothing run. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by wildheathen on 2026-11-24T23:15:48Z.
#1237 and #1065 compared on the new main
70564ae: the same 735 compute programs, plus pipeline creation on an RTX 5080. I'm not the author of either.Both PRs fix "Function uses features incompatible with the shader stage (cs)", which comes from implicit-LOD
sample/sampleBiasin compute. #1065 keeps the implicit sample and declares validator 1.8 for those programs. #1237 computes coarse gradients from quad lanes 1−0 and 2−0 and callssampleGrad, staying at 1.6.Merging onto
70564ae37f838d: the two hunks @zed6000 and @alessiodeia describe, resolved the same way.a3346f9: one conflict inlower.rs. Main's newhelpers_readsits where #1237 addsquad_gradients. Both are kept, as separate functions.Offline (
translate --validate --listovershaders.rpf, dxil.dll 10.0.26100, compared program by program)70564ae#1065 and #1237 gain exactly the same 735 programs. Per program there's no difference between them on this dump.
Pipeline creation on an RTX 5080 (
--pipelines, driver 32.0.16.2124, 32-lane waves)70564aeE_INVALIDARG) with or without the PR.70564ae. NVIDIA's driver accepts them even thoughdxil.dllrefuses them. So on this card neither PR changes which compute programs run. What changes is that the DXIL is valid, and with #1237, how the level is chosen.A GPU test of the level they pick, which both PRs lack
@upipibi asked on #1237 for a test of whether the gradients pick the right mip. Here's one, written on upstream's
synthetic_testsharness (View::Mipped):image_sample(implicit level, red channel) on a 32×32 texture with 4 levels, where every texel of level n holds (n+1)·1000;70564aeStride::Structured(16)) while the translated shader reads it as a byte-address buffer, and NVIDIA applies the view's stride on top. WithStride::Structuredcreating a raw view instead (towiice's fix), the test above passes on the 5080 for both PRs, and upstream's owngathers_at_a_level_match_the_hardwarepasses too. So on WARP and on NVIDIA, both pick the right level.The test (append to
emit/synthetic_tests.rs)What's left to choose on
No game data, shader bytes or shader names here; counts only.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:19:35Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by ElSeba0811 on 2026-11-25T04:45:21Z.
I've got another case worth checking on the GTX 1070 Ti: a Y-only texture footprint in a 2D thread group. Our 1D tests passed, but this one picked the wrong mip.
We tested the earlier quad-gradient code from #180 (
aa692580ed69e4fa20b8312df55027108fe8d7c7) in our localffe310echeckout. This PR'sa3346f9patch uses the same lane-0/1/2 gradient construction, but I haven't run this exact head. I'm sharing a regression case to check, not claiming your branch failed.The synthetic test builds coordinates from guest x/y/z thread IDs, samples four constant-color mip levels and checks every lane. We used
[64,1,1],[8,8,1]and[8,4,2]groups, with wave32 and wave64.On the old mapping,
[8,8,1], wave32, Y-only got 32 of 64 lanes wrong: all 64 read mip 0, while the upper 32 should have read mip 1.Our local fix emits a 1D host group with the same total threads, then reconstructs guest x/y/z from the flat ID. Dispatch group counts and guest logical dimensions stay the same. The 1D, 2D, 3D and Y-only cases then passed exact checks on both GTX and WARP. Positive/negative bias, sampler LOD bounds, texel offsets and whole-quad EXEC masks passed too. Arbitrarily partially active quads are still outside that coverage.
This is separate from the structured/raw SRV test issue discussed above: our coordinates come from thread IDs, not an input buffer. The local tests are
compute_quad_gradients_select_distinct_mips_on_hardware_and_warpandcompute_quad_gradients_preserve_bias_bounds_offsets_and_whole_quad_exec.The 1D mapping still needs integration review. No world-rendering or FPS claim here, just a case that may catch something the 1D or symmetric tests miss.
AI-assisted with Codex. Synthetic-test details only; no game data attached.
upstream-sync referenced this pull request2026-11-25 10:07:34 +00:00
upstream-sync referenced this pull request2026-11-25 12:03:40 +00:00
upstream-sync referenced this pull request2026-11-25 19:06:15 +00:00
Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-26T03:04:56Z.
I rebased this onto main
63bcca4and opened #2999 on top of it, with your commit kept as is. Two things came up on an RX 6750 XT:[8, 8, 1]group, while the console's quad is four threads of one row. #2999 runs such programs as one host row. Its test reads level 1 on every lane (hardware and WARP), against 3 with this PR alone.a16) the bias was read as f32 instead of the low half's f16.image_addresses_of_16_bits_and_clampsfails with this PR on main and passes with the fix in #2999.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T20:00:14Z.
Independent corroboration from a full-pack validation census (retail shaders.rpf v1.0.2.1, 26 084 programs, dxil.dll SDK 10.0.26100.0):
dx.op.samplex3 amid 133sampleLeveland otherwise stage-legal ops — the implicit-level sample is the only pixel-only op present.Texture2D.Sampleshader gives byte-identical validator text at validator versions 1.6/1.7 and compiles clean at 1.8 — while Gather/SampleCmpLevelZero/SampleLevel controls validate fine at 1.6, matching the read that ops 60/61 are the sole offenders.Full census posted in #1633 (comment-7202054103).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.