Repository navigation
Recompiler: image_sample_*_g16 reads 16-bit gradients, packed in halves - #436
sennecools wants to merge 1 commit into
Conversation
The _g16 sampling forms carry their derivatives as 16-bit halves: the dx and dy groups each start a dword (2D: dsdx|dtdx, dsdy|dtdy; 3D: dsdx|dtdx, drdx|pad, dsdy|dtdy, drdy|pad). XCL read them as 32-bit floats, so the gradients were garbage and the coordinates and every later address component were read from the wrong VGPRs. Tests: sample_d_g16_reads_packed_half_gradients (2D and 3D address layout in the HLSL) and gpu_sample_d_g16_coordinates_follow_packed_gradients (2D sample_d_g16 on the GPU, decoy coordinates where 32-bit gradients would put them). AI-assisted (Claude Code)
|
Independent RTX 3060 check of Tested on a GeForce RTX 3060 12 GB (610.88), Intel i5-8400, Windows 11 Home 26200.9974, Rust 1.100.0 x86_64-pc-windows-msvc, MSVC 14.44.35230, and DXC 1.9.2602.17 (SDK 10.0.26100), debug.
The baseline failed both the generated HLSL check and GPU readback. For lane 0, the GPU returned Not tested: full workspace, retail titles, or other GPU adapters in this run. AI use: OpenAI Codex (GPT-6) ran the tests locally and drafted this report from the actual results. |
|
Test run on AMD RDNA4 – commit Tested
Not tested
Run and report: Claude Code (Claude Opus 5.5). |
|
Test report on AMD RDNA3: RX 7800 XT (16 GB), driver 32.0.32015.7029, Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug build. No retail data was used. Tested: the PR head
Not tested: a regression run on a title, a release build, and the head merged onto current AI use: Claude Code ran the commands and drafted this comment; the runs are real runs on the hardware above. |
|
Independent RTX 4070 SUPER (Ada, wave32 only) check of Tested on a GeForce RTX 4070 SUPER 12 GB, driver 617.42 (32.0.16.1742), AMD Ryzen 7 5700X3D, 32 GB, Windows 11 Pro build 26300, Rust 1.100.0
Not tested: release build, retail titles / AI use: Claude Code (Claude Opus 5.5) ran the builds and tests on this machine and drafted this report from their output. |
|
Review: the layout matches LLVM's GFX10 codegen for One gap: AI-assisted review (Claude Code, Claude Opus 5.5). |
|
The direct DXIL path has the same bug:
Related: #1797 ( (Written with Claude Code, Claude Opus 5.5, from reading the code at |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
The
_g16sampling forms carry their derivatives as 16-bit halves, and the dx and dy groups each start a dword (2D: dsdx|dtdx, dsdy|dtdy; 3D: dsdx|dtdx, drdx|pad, dsdy|dtdy, drdy|pad). XCL read them as 32-bit floats. That made the gradients wrong and moved the coordinates, and every address component after them, onto the wrong VGPRs. No issue covers this.The retail title I ran uses none of these opcodes: an
xcl shaderscensus of its pack found 0 instructions of all 16IMAGE_SAMPLE_*_G16variants. This is a correctness fix for titles that do use them.What is in it
crates/xcl/src/gpu/recomp/emit.rs:_g16gradients are laid out as 16-bit halves, each group starting a dwordcrates/xcl/src/gpu/recomp/tests.rs: two new testssample_d_g16_reads_packed_half_gradientschecks the HLSL addresses for 2D and 3Dgpu_sample_d_g16_coordinates_follow_packed_gradientsruns a 2Dimage_sample_d_g16on the GPU, with decoy coordinates where 32-bit gradients would put themTested
cargo test --workspace -- --test-threads=4(debug): 668 passed, 0 failed, 41 ignored. No SKIPPED tests, and both new tests pass.emit.rschange reverted,cargo test -p xcl --lib g16: 0 passed, 2 failed (both new tests).cargo build --release -p xclfor the regression runRegression run
The retail title, 120 s, offline, release build. The
gpu:line comes from smoke.ps1, which picked the virtual display adapter; the real GPU is the one above.main:
this PR:
Not tested
_g16instructions in its pack), so the regression run only shows that nothing else broke._cl,_oandcvariants have no test of their own.AI use