Shaders: quad reads at a triangle edge without the console's compiler #3583
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3583"
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 kilolimaVI on 2026-11-27T19:02:31Z.
flow_testsanddiff_testsdraw the derivative, quad-read and level-of-detail cases (including the triangle-edge ones from4015a18) from console-compiled HLSL, so they need the console SDK'sdxc.exe, and most contributors' machines skip them silently. This adds hand-assembled versions that run anywhere.Quad reads (
emit/quad_read_tests.rs)quad_reads_at_a_triangle_edge_reach_helpers_and_killed_pixels: each pixel computes a key from its position and reads its x, y and diagonal neighbours' keys with DPPquad_perm([1,0,3,2],[2,3,0,1],[3,2,1,0]), as the console compiler takesddx_fine/ddy_fineandQuadReadAcross*. Drawn as a triangle whose edge crosses quads (16x16):v_cmpxof the killed lanes,s_andn2of the live mask,s_cbranch_scc0to a null export,s_wqmof the live mask). Killed pixels stay helpers: their neighbours read their keys, and they must not be written.Levels of detail (
emit/lod_tests.rs)levels_of_detail_at_a_triangle_edge_and_after_a_discard:image_get_lodof coordinates linear in the pixel position (u = 0.3 x,v = 0.11 yon a 16x16 texture, so log2(4.8) = 2.2630 everywhere), next to the same edge and after the same discard, so the helper lanes must compute the coordinates the derivatives take. Tolerance 0.02 of a level.Results at main
63bcca4Both in wave32 and wave64, on the hardware adapter and WARP:
(Before
4015a18the edge case is where an RX 6700 XT read 0 from helpers.)Only the two new files and their
modlines; no change in behaviour. Clippy clean with default and all features.AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by pickles976 on 2026-11-27T19:31:31Z.
Verified exact production/test head
c7661dd85con a physical RTX 4060 Laptop under Linux/Wine. This is the updated triangle-edge LOD head, not earlier2169264.Linux 6.17, i7-13620H/16 GiB, RTX 4060 Laptop 8 GiB/NVIDIA 590.48.1, Wine 11.0, diagnostic-relaxed-vtable vkd3d-proton 2576c0b4adfae4a+ (not stock certification), DXVK NVIDIA masking disabled. Local edits are test-only: mandatory SDK DXIL validator and non-software NVIDIA/dedicated-VRAM checks, removal of duplicate Wine-WARP legs, full coverage counters, and explicit finite-value checks for both LOD outputs (NaN must not pass tolerance comparisons). Owner instructions and expected values unchanged.
cargo-victory-wine.sh test -p victory-shader --features host --lib triangle_edge -- --nocapture --test-threads=1
2/2 pass, zero ignored, 1.39 s after fresh intended-worktree compilation 5.90 s. Both quad-neighbour and LOD tests execute wave32/wave64 x edge/discard: 8 hardware draws, 10 mandatory shader validations, 2048 pixel slots inspected. Each test has 136 drawn pixels per edge case and 104 per discard case, 480 drawn pixels total, zero wrong. Quad checks 2464 scalar components; LOD checks 1984 (4448 combined). LOD expected unclamped 2.2630, actual 2.2656 in all four cases within the owner's 0.02 tolerance; clamped output 0.
Evidence: .compat-runtime/logs/verify-verify-victory3583-triangle-edge-20261127T192814Z/{console.log,result.json,command.json,resources.jsonl}. Sampled GPU peak147 MiB, available RAM minimum11227 MiB, disk minimum12.145 GiB; guards unchanged.
These are synthetic helper/discard/derivative pixel oracles, not native 64-lane hardware, WARP coverage, a matched-parent regression result, or retail rendering/FPS proof. No production lowering modified and no title launched.
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T19:40:45Z.
Thanks, the RTX 4060 numbers are a useful pair with the 780M: NVIDIA rounds the level up to 580/256 (2.2656), RDNA3 down to 579/256 (2.2617), both inside the 0.02 tolerance. And you're right that a NaN compared false and passed; the LOD test now also requires both levels to be finite.
AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T19:48:25Z.
Added a third test,
gather_tests::gathers_take_the_footprint_at_the_coordinate:image_gather4_lzatt = x + dtexels over a 16x16 texture whose texels hold their index. At d 0.25 and 0.75 the footprint must start atfloor(t); just below a boundary (d = -1/1024) it only reports which way the host rounds.So RDNA3 snaps the coordinate to 8 fractional bits as the console's hardware does, and WARP doesn't: near texel boundaries a gather (
GatherRed,GatherCmpfor PCF) takes different texels on the two. @pickles976 if you have a minute, the NVIDIA number for the -1/1024 row would complete the picture:cargo test -p victory-shader --lib gathers_take_the_footprint -- --nocaptureAI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T19:51:43Z.
Added
gather_tests: lookups att = x + dtexels over a 16x16 texture whose texels hold their index, withimage_gather4_lz(footprint at floor(t)) andimage_sample_lzwith a point sampler (texel at floor(t)). At d 0.25 and 0.75 every host must take floor(t); just below a boundary (d = -1/1024) the test only reports which way the host rounds.The exact cases are 0 wrong on both. So RDNA3 snaps a gather's coordinate more coarsely than a point sample's (it rounds up from 1/1024 below), and WARP doesn't: near texel boundaries a gather (
GatherRed,GatherCmpfor PCF) takes different texels on the two, while point samples agree. @pickles976 if you have a minute, the NVIDIA row would complete the picture:cargo test -p victory-shader --lib -- gathers_take_the_footprint point_samples_take_the_texel --nocapture --test-threads=1AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T21:17:35Z.
Follow-up for the gather numbers: #3613 fixes the boundary case this PR's
gather_testsreports. It moves the first-level gather coordinate to the middle of the console's footprint (same rule asgather_first), and the test now requires the console's result on every host.On the 780M + WARP: before, WARP took the footprint one texel back at 1/1024 and at the 1/512 tie below an edge; after, both hosts are 256/256 in all six cases.
@pickles976 if you still have the 4060 set up, the most useful run is on #3613's branch:
cargo test -p victory-shader --lib -- gather_tests --nocaptureThe
gather d ...lines show which way NVIDIA goes before and after.AI-assisted (Claude).
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.