Recompiler: decode packed G16 gradients in direct DXIL #2838
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2838"
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 ivall/xcl. Originally posted by CryingLaughing on 2026-11-26T17:21:20Z.
Direct DXIL read each
IMAGE_SAMPLE_*_G16gradient as a 32-bit float. That also moved the coordinates to the wrong VGPRs. This fixes the direct path identified in the #436 review. #436 covers HLSL.What is in it
gpu/dxil/lower_image.rs, decode the gradients as packed 16-bit values, with each derivative group starting on a dword boundary.SAMPLE_Dcontrols. A pixel test gives both layouts the same coordinates, then verifies that a nonzero upper-half gradient selects mip 1 and zero selects mip 0. The fixtures call direct DXIL explicitly.Tested
ef36b7dfe3eeb0a5c872dc667d6cdfc1d20033c9on main8b957bec6f82495aec940944c6bf47faa02db590. Windows 11 25H2 build 26200.9974, Core i5-13600K, RTX 4080 driver 621.01, Rust 1.100.0 x64 MSVC, DXC 1.8.2502.11, debug.cargo build --workspace --locked -j 2passed. WithXCL_ADAPTER=4080,cargo test --workspace --locked -j 2 --no-fail-fast -- --test-threads=4 --show-outputreported 1,449 passed, 0 failed, 47 ignored across 38 harnesses. The pass count includes 29 capability skips and 10 unset optional sample notices.Regression run
Matched retail smoke is pending.
Not tested
Imported from ivall/xcl. Originally posted by MatyEjsr on 2026-11-26T17:43:21Z.
Independent verification and source audit of PR #2838 at head
ef36b7dfe3eeb0a5c872dc667d6cdfc1d20033c9(merge-basemain8b957bec6f82495aec940944c6bf47faa02db590) on Windows 11 + NVIDIA GeForce RTX 3090.Source & Triage Notes
crates/xcl/src/gpu/dxil/lower_image.rs(Lw::mimg) setsg16 = mods.contains(&"g16")and pushes(16, component == 0)for each of the two derivative directions (dx,dy), matchingmimg_address_dwordsincrates/xcl/src/gpu/rdna2.rs((GRADIENTS[dim] / 2).next_multiple_of(2)) across 1D/1DArray (2 dwords), 2D/Cube/2DArray (2 dwords), and 3D (4 dwords), and matching the companion HLSL fix in open PR #436 (emit.rsonmainstill treats gradients as 32-bit).i_bodykeeps(h, !a16 || (grad_n != 0 && k == 0))so body coordinates start on a dword boundary even withA16=1and oddgrad_n. BothUNORM=1(mimg_unorm_sample) andCD_*_G16opcodes share thisshape/poslayout.mainand no duplicate open PRs ornvidia-devoverlap.PR descriptioncurrently fails because the description is missing the pairedxcl-smoke v1regression blocks and the required**AI use**section.Tested
32.0.16.1742, wave32), 31.4 GB RAM,rustc 1.100.0(0ef1bc386 2026-11-09,stable-x86_64-pc-windows-msvc), DXC1.9.2602.17(dxcompiler/dxil, Windows SDK10.0.26100.0), Windows Developer Mode ON, debug & release builds.cargo build --workspace -j 8passed in 17.98s (0 warnings in touched files).cargo test -p xcl --lib -- direct_sample_grad_g16_widens_packed_gradients gpu_direct_sample_grad_g16_uses_packed_coordinate_slots gpu_direct_sample_grad_g16_nonzero_half_selects_mip --test-threads=1 --nocapture: 3 passed, 0 failed, 0 ignored, 0 SKIPPED (0.37s).XCL_DIRECT_DXIL=1):cargo test -p xcl --lib -- gpu_direct_sample_grad_g16 gpu_images_sample_load_store_atomic --test-threads=1 --nocapture: 3 passed, 0 failed, 0 ignored, 0 SKIPPED (0.31s).cargo test --workspace -j 8 --no-fail-fast -- --test-threads=8 --show-output: Cargo reported 1,449 passed, 0 failed, 47 ignored across 38 harnesses (xcllib: 1,321 passed, 0 failed, 27 ignored in 28.37s). Within those passes, 28SKIPPEDcapability lines occurred across 17 tests (not counted as coverage: 15 wave64 / refused per-lane subcases across 6lower_dxil::tests, 8 wave64-only GPU tests,heap_window_out_of_memory_falls_back_to_the_switch_formwithno heap windows,uploads_start_from_each_subresources_statewithno D3D12 debug layer, andthe title under the debug layerdred: true/falsewithno d3d12SDKLayers.dll) plus 10 unsetXCL_SAMPLE_*notices.cargo build --release -p xcl -j 8passed in 40.92s;scripts/smoke.ps1 -Seconds 60 -Title c1cc91a4onef36b7dftimed out before guest launch because basemain8b957becstarted full-pack 26,503-shader startup preparation and exceededsmoke.ps1's default 120s startup timeout.Not tested
smoke.ps1regression run (main8b957becvsef36b7df), AMD / Intel GPUs, native wave64 execution, D3D12 debug layer tests, heap-window OOM fallback, Linux / Wine, and optionalXCL_SAMPLE_*tests (unset).AI use
lower_image.rsagainst RDNA2 ISA layout and companion PR #436, checked PR metadata/checks, ran debug/release builds, targeted/full workspace tests, and drafted/audited this verification report.Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T17:58:59Z.
AMD run (listed as untested), with an RTX 3060 in the same PC: the new tests pass on both, and nothing else changes from
main.Tested: pass, head
ef36b7dapplied onmain8b957be, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17, card picked withXCL_ADAPTER.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4 --nocapture,mainand this PR one after the other on each card:main708 passed, 2 failed, 6 SKIPPED; this PR 711 passed, 2 failed, 6 SKIPPED. The 2 failures arefuzz_validate_and_gpu_1and_3, the AMD fuzz seeds in #2115, the same onmain.main710 passed, 0 failed, 24 SKIPPED; this PR 713 passed, 0 failed, 24 SKIPPED.On both cards the only result changes are the three new tests, all ok:
direct_sample_grad_g16_widens_packed_gradients,gpu_direct_sample_grad_g16_uses_packed_coordinate_slotsandgpu_direct_sample_grad_g16_nonzero_half_selects_mip. The SKIPPED sets are the same as onmain.On native wave64: the two new GPU tests build their kernel with
direct_kernel_full(.., false)(wave64: false), so they run as wave32 on the RX 9070 XT too and don't cover a G16 sample in a 64-lane wave. The other native wave64 cases ingpu::run on this card and are unchanged.Not tested: a G16 sample in wave64, retail titles, release, Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-26T18:00:58Z.
RX 9070 / Linux-Wine verification of head
ef36b7dfe3eeb0a5c872dc667d6cdfc1d20033c9against main8b957bec6f82495aec940944c6bf47faa02db590. The three original regressions reproduce on main and pass on the PR. Additional native-wave64 coordinate checks and both halves/directions of packed pixel gradients also pass on the PR.This adds Linux/Wine and explicit native-wave64 sampling to the Windows RX 9070 XT report above.
Tested
RX 9070 (RADV GFX1201), Mesa
26.3.1-arch3.5, Ryzen 7 7700, CachyOS kernel7.3.0-5-cachyos, GE-Proton11-12 / Wine 11.0 Staging, native d3d12/d3d12core/dxgi, vkd3d-proton8293130ebe370b1+(local asserts-disabled build), DXC1.9.2602.17, Rust1.97.1, releasex86_64-pc-windows-gnu.Separate source copies and targets, built with
cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run. Main received the same upstream test block. Both copies had identical test-only readback/IR observations; original assertions were retained. Production bytes were checked against the pinned sources after reversing those observations.direct_sample_grad_g16 --nocapture --test-threads=1direct_sample_grad_g16 --nocapture --test-threads=4workflow_gpu_g16 --nocapture --test-threads=1, three fresh processes per sourceAll 10 harness invocations had 0 ignored and 0 capability skips. The main failures were the expected IR/layout/pixel assertions, with no device removal or unexpected execution failure.
The added
workflow_gpu_g16checks reused the original small, owned fixtures:SAMPLE_D, G16 2D, G16 2D array with A16, and G16 3D with A16. The captured DXIL has the explicit 64-lane wave property. Every PR lane returned the expected(x, y, z, 1)texel. Main retained the ordinary control and failed the G16 coordinate cases in every repetition.Across original and added checks, there were 40 sampling dispatches and 56 pixel draws, including 24 native-wave64 dispatches. A separate verifier recomputed 8,192 coordinate words and 3,584 pixel words from the saved readbacks and the fixture's texel/gradient values. The PR had 0 mismatched words; main had 2,048 coordinate and 736 pixel mismatches. The ordinary
SAMPLE_Dshader containers stayed byte-identical between sources and repetitions for each control case.Environment:
XCL_ADAPTER=AMD Radeon RX 9070,XCL_REQUIRE_GPU=wave64,XCL_NETWORK=0,XCL_DIRECT_DXIL=1,XCL_DXC_THREADS=1, native DLL overrides and private enabled cache directories. The fixtures explicitly call the direct translator.Not tested
Full workspace suite, retail data, smoke runs, HLSL G16 fixes, other image dimensions or opcode variants, native Windows, other GPUs, or title performance/FPS. Native wave64 coverage here is for the compute sampling kernels; the pixel draws do not establish a physical graphics wave size. These fixture results are not an independent console-ISA conformance result.
AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the change, prepared the additional fixtures and observations, built and ran both sources, independently checked source bytes, DXIL metadata and captured GPU values, and wrote this report. Publication authorized by the account owner.
Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-26T19:24:06Z.
I compared parent
8b957becand PR headef36b7dfon an RTX 3080 using the Wave32 Direct DXIL path. I uploaded a two-layer texture with two mip levels and distinct colors for each layer and mip, then ran the same six draws on both revisions. Reading back the colors made it possible to identify which mip each draw actually sampled.With packed 16-bit gradients, the parent sampled mip 0 in all 32 samples where mip 1 was expected. The PR returned the expected mip-1 colors in all 32 samples, including the correct green or yellow for each layer. The zero-gradient and full-width-gradient controls passed on both revisions. An independent repeat on the PR head reproduced the result with zero skips.
I used Codex GPT-6.2 Sol for the GPU fixture and comparison, and a separate GPT-6.2 Sol agent for independent verification. Codex GPT-6.2 Astra wrote this comment.
I reviewed and approved this comment before posting.
Pull request closed