Repository navigation
Shaders: 16-bit gradient samples (_g16) and a16 independently, in decoding and lowering (#1116) - #2372
Shaders: 16-bit gradient samples (_g16) and a16 independently, in decoding and lowering (#1116)#2372KainanP wants to merge 4 commits into
Conversation
…ds.rs with 21 tests
On top of the two commits of Marvisak#1209 (`image_addr_dwords` and `Lower::image` read `a16` and `_g16` independently), which map `image_sample_d_g16` only. `Lower::image` now matches a `_g16` opcode by its form without the suffix, so `image_sample_d_cl_g16` lowers as `image_sample_d_cl` does (`sampleGrad` with the clamp) with 16-bit gradients, and the `_cl` and `_o` checks see the form (`image_sample_d_cl_g16` read no clamp). The comparison forms stay refused by name, as `image_sample_c_d` is: SM 6.6 has no `SampleCmpGrad`. The refusal of `a16` gradients of 1D and 3D images is stale once `a16` no longer packs gradients; `_g16` gradients start a VGPR per direction (`grad_regs`), as in LLVM's GFX10 assembler tests (`gfx10_asm_mimg.s`: 3D `image_sample_d_g16` takes 7 VGPRs, 3D `image_sample_d` with a16 8). `gradient_samples_of_16_bits` lowers `image_sample_d` and `_d_cl`, with and without `_g16` and `a16` (2D), validates them with `dxil.dll` and samples a 64x16 texture whose texel holds its level and position on the hardware adapter and WARP, with gradients that give level 3.25 (level 4 or 5.25 if they were read with the wrong width or halves swapped); 3D forms are translated and validated, `image_sample_c_d_g16` must be refused. On `main` it fails: the `_g16` forms are refused and `image_sample_d` with a16 reads 4000 for 3066. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I ran the 3D gradient cases on PR head
As a sensitivity check, I deliberately made the 3D The regression can be cherry-picked onto this PR. Test commit git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr2372-volume-readback
git cherry-pick 2996b2763f590bb4c1ffabe7c929b402fbe309ca
cargo test --locked -p victory-shader --lib emit::valu_tests::gradient_samples_of_16_bits -- --exact --nocaptureThe test ran with synthetic shaders and textures. Cube sampling and in-game behavior remain open. AI-assisted with Codex. |
(cherry picked from commit 2996b27)
|
@steven-seagull27 thanks — the 3D readbacks were the part this PR couldn't run (the test host had no volume view). Your commit is now on the branch as AI use: Claude Code (Claude Opus 5.5). |
|
Thanks for integrating the volume test and checking it on the 4060. I cherry-picked the cube test onto your updated head
On +X the unclamped sample returned 2162 (mip 2, texel 2,5). On −Z with minimum LOD 3 it returned 53065 (mip 3, texel 1,2). As a sensitivity check on the earlier head The uninstrumented cube and volume regressions both passed together on the updated head. Cube test commit git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr2372-cube-readback
git cherry-pick 65ce74a19e68649a9d3b6c75f215499437940d8a
cargo test --locked -p victory-shader --lib emit::valu_tests::cube_gradients_of_16_bits -- --exact --nocaptureThis covers synthetic cube samples with an isotropic point sampler and zero LOD bias. |
|
Automated triage for the maintainers. Merge candidate. Makes Notes for the maintainer: the branch carries #1209's two commits (with their author), including its ~1,100-line CI: Generated by Claude Code |
|
Independent Windows verification (software WARP only, no hardware GPU in the final runs)
Results:
Diff review of Environment notes: the Windows SDK 10.0.19041 Verified by Claude Code (Claude Sonnet 5.5), an AI assistant, on behalf of a maintainer. |
|
I reproduced the mip-query regression noted in the closing review of #1209. 2d45b56 is one commit directly on The same synthetic Windows/WARP fixture reads dimensions from an 8×4 texture with three mips. On The fixture also passes on upstream Please retain the follow-up's Git author if you cherry-pick. If you fold this fix or test into another commit, please include: Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com AI-assisted with Codex. Synthetic texture and shader. |
|
I checked @andrewpozdnakov7-jpg’s mip-query fix on RTX 5080 (621.40), Windows WARP (10.0.26100.10068), and WARP 1.0.22. I used an 8×4 texture with three mip levels and added high-half patterns at level 0 as well as levels 1 and 2. Each build also ran the existing 2D and volume tests and our six-face cube regression.
All three adapters agreed. Unpacked and zero-padded controls passed on the PR head. For packed a16 operands AI-assisted with Codex. Synthetic textures and shaders. |
Fixes #1116.
This builds on #1209 and puts both halves of #1116 in one PR, as the triage comment on the issue asked. The first two commits are #1209's (
e32b53e,351a162) cherry-picked unchanged, with @geiyiliyabumo kept as author. The third commit is mine. If #1209 lands first, this PR shrinks to that one commit.Problem
On RDNA2,
a16and the_g16opcodes are independent.a16packs the coordinates and the LOD/clamp two per VGPR._g16packs the derivatives two per VGPR, and each direction starts a new VGPR. LLVM's GFX10 assembler tests (llvm/test/MC/AMDGPU/gfx10_asm_mimg.s, llvmorg-20.1.8) show this. For 2D,image_sample_d … a16takesv[0:4](5 VGPRs) andimage_sample_d_g16takes[v0, v2, v4, v5](4). For 3D,image_sample_d … a16takes 8 andimage_sample_d_g16takes[v0, v2, v3, v5, v6, v7, v8](7).On
main(940d32f):image_addr_dwordspacks gradients whenevera16is set and never for_g16.Lower::imagereads gradients as f16 undera16. Animage_sample_dwith a16 and 32-bit gradients samples the wrong level and the wrong texel (measured below: 4000 instead of 3066)._g16sample is refused by name.a16gradients of 1D and 3D images are refused.Change
image_addr_dwordspacks gradients only for_g16.Lower::imagereads the offset, bias and compare words whole, gradients byg16, and coordinates and LOD/clamp bya16. It mapsimage_sample_d_g16.crates/victory-shader/src/emit/lower.rs, +14 −11):_g16opcode is matched by its name without the suffix, soimage_sample_d_cl_g16lowers the wayimage_sample_d_cldoes (sampleGradwith the clamp). Before, its_clcheck looked at the full name, so the clamp was never read._ocheck also uses that name, so_o_g16forms work once an_ogradient form is lowered (Shaders: lower image_gather4_c_lz(_o) and offset sample variants #1687)._g16ones start a VGPR per direction (grad_regs).image_sample_c_d_g16, …) stay refused by name, asimage_sample_c_dalready is: SM 6.6 has noSampleCmpGrad.Tests
New test
emit::valu_tests::gradient_samples_of_16_bits, using hand-encoded MIMG words (encoding cross-checked against the LLVM test file above):image_sample_d,_d_cl,_d_g16and_d_cl_g16on a 2D texture, each with and without a16 (8 programs). Each is lowered, validated withdxil.dll, and run on the hardware adapter and on WARP.1000n + 64y + x. The sampler is point.image_sample_dwith a16,_d_g16, and_d_g16with a16 are translated and validated only, because the test host has no 3D view.image_sample_c_d_g16must be refused.lower_cs32is split so thattry_lower_cs32returns the lowering error. There are no other test-helper changes.Per-case results (RTX 4060 and WARP give the same values):
mainimage_sample_dimage_sample_da16image_sample_d_g16(± a16)image_sample_d_climage_sample_d_cla16image_sample_d_cl_g16(± a16)_da16 /_d_g16a16_d_g16The test fails on
main(image_sample_d_g16 is not supported) and on #1209 alone (image_sample_d_cl_g16 is not supported).Validation
Windows 11, Rust 1.98.1, RTX 4060 (default adapter) and WARP,
dxil.dllfrom SDK 10.0.26100.0.main940d32fcargo test --workspace --locked --no-fail-fast(RTX)VICTORY_WARP=1 cargo test --workspace --locked --no-fail-fastcargo test --workspace --all-features --locked --no-fail-fastcargo clippy --workspace --all-targets --locked -- -D warnings(and--all-features)cargo xtask policyThe +22 tests are #1209's 21
fields.rstests and the new one. The failures are the same tests onmainon this machine, so they come before this change:victory-gpudynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views(the NVIDIA heap-size cap, #1835), and on RTXstride_tests::a_heap_buffer_read_by_element_takes_the_views_stride,stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerosandsynthetic_tests::gathers_at_a_level_match_the_hardware. Under WARP the last one fails together withpermutes_read_the_lane_named_and_zero_from_lanes_left_out, which are hardware-only checks.Not measured
fields.rshalf alone. Avictory translate --validatecount before and after would show whether any programs use_g16or a16 gradients. If someone with a dump can run it, that would help._g16: the reads come from Shaders: fix GFX10 independent a16/g16 gradient dword packing in fields.rs with 21 tests #1209 and are not covered by a GPU test here.image_sample_cd*_g16(0xE8–0xEF): not in the decoder's opcode table.image_sample_cditself is not lowered either.AI use
The change, the test and this description were written with Claude Code (Claude Opus 5.5). All results above come from runs on my machine. No game data was used.
🤖 Generated with Claude Code