Recompiler: pixel comparison samples apply their LOD bias #345
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/349"
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 Kalmarv on 2026-11-24T00:07:24Z.
Pixel-shader
image_sample_c_b*now applies the instruction’s LOD bias to depth comparisons. With point mip filtering, +1 selects the coarser mip and −1 the finer mip. This overlaps #247 inemit.rsand builds directly on main.What is in it
crates/xcl/src/gpu/recomp/emit.rs— Scalesddx(coord)andddy(coord)byexp2(bias). Atps_6_6,QuadReadAcrossXandQuadReadAcrossYonSV_Positionidentify the pixel in the quad. An unrolled four-iteration loop usesQuadReadLaneAtfor the coordinate and both derivatives, then issues one nativeSampleCmpper iteration. Each pixel selects its own result.crates/xcl/src/gpu/recomp/tests.rs— six 16×16 raster draws check positive, negative and per-pixel bias, the zero-offset form, zero bias and a minimum-LOD clamp against two opposite depth checkerboards with point mip filtering.Tested
7d1c008isfe3011d's two commits squashed into one, with the same tree (git diff fe3011d 7d1c008is empty).cargo test --workspace -- --test-threads=4on7d1c008merged ontomain9e3831e(a clean merge,389c343): 777 passed, 0 failed, 41 ignored (thexcllibrary: 728 passed, 21 ignored). SKIPPED:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64), andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows;main's own test).fe3011d1b16don18c105af8692. The bias and flat integer selector raster tests both passed (2 passed, 0 failed).cargo build --workspacepassed.cargo test --workspace -- --test-threads=4returned 690 passed, 0 failed, 41 ignored. GPU tests reporting SKIPPED within the pass count:gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64).cccc2c3890efon an RTX 5070 Ti (610.74), SDK DXC 1.7,ps_6_6: the targeted raster test passed. The full workspace returned 652 passed, 0 failed, 40 ignored; two native-wave64 tests reported SKIPPED within the pass count. All six bias cases passed on the full-screen triangle and the partial quads along the diagonal.d25aea141589on9ab7d763197c.cargo build --workspacepassed.cargo test --workspace -- --test-threads=4returned 652 passed, 0 failed, 40 ignored. GPU tests reporting SKIPPED (included in Cargo’s pass count):gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64).9ab7d763197cwith only the tests added failed four of six draw cases. The two controls passed on base, and all six passed on this head.a60db9f3e5f2: two checks passed. Both offset forms read the expected texel at mip 1 with a nonzero offset. SDK DXC compiled 20 opcode and view combinations.CreateReservedResourcereturnedE_OUTOFMEMORYingpu_sparse_vram_descriptors_buffers_and_xmem. Three sparse windows had zero GPU addresses, then pipeline creation returnedDXGI_ERROR_DEVICE_REMOVED.d25aea1merged ontomain7ebf1b8. The new test passes, and withemit.rsfrommainfails in four of its six cases. Their whole suite stopped in the #344 hang in 4 of 4 runs; with #443 merged too: 679 passed, 0 failed, 41 ignored.main9ab7d76and the head tested in that report: 918 and 913 frames, no crash or device removal (https://github.com/ivall/xcl/pull/349#issuecomment-7119194735).Regression run
Our own runs, one after the other on the machine under Tested (RTX 5070 Ti), release builds, no uncommitted changes:
mainat18c105a(this PR's base), then this PR's head7d1c008. 1276 / 1246 frames (102 %), peak commit 26598 / 27160 MB (98 %); no device removal and no crash on either run.main:
PR:
Not tested
AI use
18c105aand its runs, and this description7d1c008🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by nullmarsh on 2026-11-24T00:19:39Z.
AMD run, since Not tested says no AMD driver has compiled these quad operations yet:
d25aea1merged ontomaina6f5f7a(clean merge): pass on RDNA4, and the new test fails without theemit.rschange.Tested
.\scripts\test.ps1: 677 passed, 0 failed, 41 ignored; noSKIPPEDGPU tests.XCL_REQUIRE_GPU=wave64,mesh cargo test -p xcl --lib gpu_ps_compare_mip:gpu_ps_compare_mip_biaspasses.emit.rsback onmain. The test fails withIMAGE_SAMPLE_C_B, scale 0.125, slope 0: pixel (0,0): 0 instead of 1 from mip 1, plus the_C_B_CL,_C_B_Oand slope 0.5 cases.sample_cmp_gradis identical, so git merges it cleanly): both compare-mip tests pass.Not tested
smoke.ps1); cube and array sampling on hardware; NVIDIA.AI use
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T00:22:30Z.
Thanks for testing on the RX 9060 XT and checking the negative control where reverting just the emitter change brought back all four mip-selection failures.
🤖 GPT-6.2 Astra
Imported from ivall/xcl. Originally posted by throny on 2026-11-24T01:16:16Z.
NVIDIA RTX 40 run of
d25aea1onmain7ebf1b8(clean merge): the new test passes and fails without theemit.rschange. The whole suite did not finish on this tree here, for a reason that is not this PR (below).Tested
stable-x86_64-pc-windows-msvc, debug; DXC 1.9.2602.17 (Windows SDK 10.0.26100.0); noXCL_SAMPLE_*cargo test --workspace -- --test-threads=4onmain+ this PR: stopped in the lib tests in 4 of 4 runs (basesa6f5f7a,2997c9atwice,7ebf1b8), in the #344 deadlock (gpu_uma_import_check_at_initand three other GPU tests running for over 60 seconds; the same stop happens here on trees without this PR, stacks in my report on #443).gpu_ps_compare_mip_biashad passed before the stop each time.16fc79d) merged in as well: 679 passed, 0 failed, 41 ignored,gpu_ps_compare_mip_biasok (one run).SKIPPEDon this adapter:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)emit.rsfrommain:gpu_ps_compare_mip_biasfails in four of its six cases (IMAGE_SAMPLE_C_B+1,_C_B_CL−1,_C_B_O+1 and the per-pixel slope case); the two controls pass.13d8a1f): the two branches merge without a conflict although both addsample_cmp_gradandcheck_ps_depth_mip(one copy of each results), andcargo test -p xcl --lib gpu_ps_compare_miponmain+ #350 + #349 passes both tests.Reviewed (read the whole diff)
qevery pixel of the quad computescoord[q] + (its position − q's position) · gradient[q], so the implicit derivativesSampleCmpsees are pixelq's scaled ones, and each pixel keeps the result of its own iteration (delta 0, its own coordinate).xi.xcl_posis always a member ofXclIn.Not tested
scripts/smoke.ps1) on a title, no shader-pack run (XCL_SAMPLE_RPF), wave64 hardware, cube and array forms (the test draws 2D only).AI use
Imported from ivall/xcl. Originally posted by QemmHD on 2026-11-24T01:18:19Z.
Review: scaling
ddx/ddybyexp2(bias)adds the bias to log2 of the footprint, and the quad construction reproduces those derivatives exactly. Two points (same as on #350):emit.rs:2191-2196: offsets for comparison samples still use level0u, so_c_b_o/_c_b_cl_owith a non-zero offset move by mip-0 texels while the bias selects mip ≥ 1. The test's_Orows use offset 0; a note on the #247 dependency, or a non-zero-offset row after #247, would cover it.QuadReadLaneAtandSampleCmpdepend on here) aren't exercised; an edge through quads would cover that.AI-assisted review (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.
Imported from ivall/xcl. Originally posted by CuteBooty on 2026-11-24T01:32:05Z.
Regression run on a retail title for
d25aea1, which the description lists as pending: pass (no device removal, no crash, frames and peak commit level withmain).Tested
scripts\smoke.ps1 -Game <folder> -Seconds 60on the PR's head as it is and onmain9ab7d76, the commit it is based on, each built from a clean checkout of its commit.main) and 911 frames (PR), also with no device removal or crash. Themainblock is one run, shared with my reports on #348 and #350.memory:line: 6311 MB local / 4619 MB non-local (main), 6311 MB local / 4619 MB non-local (PR).main:
PR:
Not tested
AI use: Claude Code with Claude Fable 5.2 made the runs with me present and wrote this comment.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T02:26:14Z.
Thanks for checking the mip calculation and the triangle coverage.
The standalone head uses mip-0 texel units for both offset forms, and its two offset rows pass zero. I added that dependency to the PR body draft. With #247 at
a60db9f, a syntheticIMAGE_SAMPLE_C_B_Odraw with a +1 X offset read the expected neighbor at mip 1.The full-screen triangle left the helper-lane case uncovered. The test now keeps that draw and adds a diagonal that leaves one or three covered pixels in each edge quad. The bias fixture now enters whole-quad mode (
S_WQM_B64 EXEC, EXEC) before computing texture coordinates so helper pixels supply the screen derivatives. It checks the depth comparison for all 96 covered pixels and the clear value for the other 160.Tested
PR head
cccc2c3890efon an RTX 5070 Ti (610.74), SDK DXC 1.7,ps_6_6: the targeted raster test passed. The full workspace returned 652 passed, 0 failed, 40 ignored; two native-wave64 tests reported SKIPPED within the pass count.Not tested
AMD on this follow-up. Our title smoke pair on this head is in the description; the title doesn't show whether it reaches these sampling forms.
🤖 GPT-6.2 Astra
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T07:42:12Z.
Independent native D3D12 check of
fe3011don RTX 3080 Ti / 621.35, Windows 11 build 26300, DXC 1.8.2502.11 and Rust 1.99.1 MSVC, release.All six bias cases matched the expected pixel values on both the full-screen and partial-quad triangles. The flat integer selector control passed too. The offset variants in this fixture use zero offsets. Two stock tests passed, with zero failures, ignores or skips.
Commands used
XCL_ADAPTER=3080 Tiandcargo test --locked --offline --release -p xcl --lib <filter> -- --test-threads=1 --nocapture, withgpu_ps_compare_mip_biasandgpu_ps_p0_reads_flat_integer_selectors.AI use: Codex (GPT-6, exact variant unavailable) ran the tests and drafted this report.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T17:50:38Z.
Squashed into one commit (
7d1c008, the same tree as before) as CONTRIBUTING asks; the smoke pair for it is queued.A note for the merge order with #247: this PR makes the PS
SampleCmptake the bias, and #247 moves a comparison offset by the mip that sample reads. With both in a tree, one line in #247's offset code has to take the bias too, orgpu_image_sample_c_b_d_offset_moves_by_the_mip_readfails (sample_c_b_o, PS: pixel (0,0) = 0). We have that line ready and tested (62f93a3; with it the test passes, and main + all eleven of our open PRs + both follow-ups pass the whole suite, 815 passed, 0 failed). Whichever of the two lands second, we push it there.AI use: Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T14:29:05Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-26T22:48:20Z.
Tested
Independent run at clean PR head
7d1c008da9127bde6076023cd3856a92dbb04c40on Intel Arc A770 (driver 32.0.101.9175), Ryzen 7 3800X, Windows 11 x64 26200.9974, Rust/Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5, debug test profile.Prebuilt with
cargo test --locked -p xcl --lib --no-run --message-format=jsonoutside the GPU mutex. Ran<test-exe> gpu::recomp::tests::gpu_ps_compare_mip_bias --exact --nocapture --test-threads=1under the Arc mutex withXCL_ADAPTER=A770.1 passed, 0 failed, 0 ignored and 0 GPU skips (1.29 s). All six bias cases matched expected mip-dependent readback across both triangle geometries, including the per-pixel slope and min-LOD clamp.
Not tested
Nonzero texel offsets, cube or array views, performance, the workspace suite and retail smoke.
AI use
T3 Code / Codex (gpt-6.2-sol) ran the original verification and summarized the saved results.
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-27T17:57:48Z.
NVIDIA and AMD full-suite run, to go with the reports above by JJAutoCompare, since none of them names a GPU. Tested exact head
7d1c008d(on its base18c105a).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace --no-fail-fast -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 690 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.gpu_ps_compare_mip_bias.XCL_ADAPTER=radeon),cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 690 passed, 0 failed, 41 ignored, no skips.--skipleaves out tests that fail on main6089122atoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-27T18:00:59Z.
Tested on AMD / Linux:
7d1c008d(RX 9070 16 GB, RDNA4, Mesa 26.3.1 RADV; Ryzen 5 9600X, 32 GB; CachyOS; Proton Experimentalexperimental-11.0-20261112with vkd3d-proton masterec207194plus a local patch dropping thelpVtblchecks of command allocators and lists; DXC 1.9.2609.5; Rust 1.96.0,x86_64-pc-windows-gnudebug build, tests run under Wine)The head as it is (not merged onto current
main), with its base18c105afthe same session as the baseline.Tests (
XCL_REQUIRE_GPU=wave64)cargo test -p xcl --lib -- gpu_ps_compare_mip_bias --test-threads=1: 1 passed, 0 failed, 0 ignored (on the GPU, wave64).cargo test --workspace --no-fail-fast -- --test-threads=4with--skip compositor_blends_ui_plane_over_scene_plane --skip failed_restore_stops_before_importing_an_unbacked_window --skip grooming_leaves_a_window_under_1_gib_only_its_hole(the first loses the RADV device here, the other two run out of memory under Wine): lib 645 passed, 5 failed, 21 ignored; base18c105aflib (same flags): 644 passed, 5 failed, 21 ignored, the same 5. The other binaries fail the same 3 tests as onmainhere (e2e,pls_quota,predication_e2e).Not tested
AI use
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T14:26:46Z.
merge-check claim
head:
7d1c008da9Imported from ivall/xcl. Originally posted by throny on 2026-11-28T14:40:10Z.
merge-check
base:
b937fbabhead:
7d1c008da9merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2141 passed, 1 failed, 48 ignored (26 SKIPPED lines). The one failure is gpu::dxil::msaa_tests::direct_msaa_loads_precede_get_dimensions, which main itself has at
b937fbab(#3093); base alone: 2140 passed, 1 failed, 48 ignored.review: no blocking finding. The new arm takes pixel-shader comparison samples with a bias and does not overlap the arm #350 adds for gradients; a three-way merge of the two PRs on main's files has no conflict and keeps one copy of the helpers both add. Open and not new to this PR: the forms with an offset still move the coordinate by mip-0 texels, which waits on #247 (open); whichever of the two lands second needs the one-line fix named in the thread. The earlier point about a partial quad in the test is answered: the test draws one now.
performance: this one costs frame time by design: every pixel-shader comparison sample with a bias becomes four SampleCmp calls plus quad reads instead of one. Titles that filter shadows with biased comparison samples pay it; nobody has measured how much. It changes a translator source: every tester re-translates all shaders once.
verdict: safe to merge (correctness; the cost deserves a title measurement, together with #350)
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T17:48:12Z.
Focused GPU finding on #349 head
7d1c008: the bias path scalesddx/ddycorrectly, but then adds the scaled derivatives to the original coordinate to make a quad forSampleCmp. At U = 12,582,913, binary32 spacing is 1, so adding or subtracting 0.25 returns U. The texture operation sees a zero horizontal derivative and selects mip 0. The instruction's originaldU/dx = 2with bias-3requires an effective derivative of 0.25, or two texels on the eight-wide base mip, selecting mip 1.On Windows 11 build 26300, RTX 3080 Ti / 621.35, DXC 1.8.2502.11, the attached synthetic depth-checkerboard test failed 0/1 on the unchanged head: full-screen pixel (0,0) returned 1 instead of the mip-1 value 0. Changing only the coordinate constant to 0.5 made the same biased test pass 1/1; the PR's existing
gpu_ps_compare_mip_biasalso passed 1/1. As a diagnostic control, replacing only the new bias arm with ordinarySampleCmpmade the large-coordinate test pass, but that drops bias semantics and is not a proposed fix. Command for each run:cargo test --offline --locked -j 4 -p xcl --lib <test-filter> -- --nocapture --test-threads=1; no skip was printed. I did not run the full suite, title smoke, or a corrected production implementation for this finding.This is the bias counterpart of the explicit-gradient boundary reported on #350. A correction must preserve the bias-scaled footprint independently of a large coordinate while preserving clamp, wrap, mirror, border, cube and array behavior. Simply clamping or wrapping every coordinate is not equivalent for all sampler modes. Please keep this regression alongside the existing small-coordinate cases before treating the four-sample SM 6.6 path as complete.
AI use: Codex (GPT-6.2 Sol) traced the emitter, wrote and ran the synthetic GPU fixture and controls, and drafted this report; Codex (GPT-6.2 Astra) independently checked the related comparison-gradient boundary and SM 6.6 constraints.
Test-only regression diff (head 0/1; small-coordinate control 1/1)
Imported from ivall/xcl. Originally posted by johnbf8x on 2026-11-30T02:10:59Z.
merge-check claim
head:
7d1c008da9Imported from ivall/xcl. Originally posted by johnbf8x on 2026-11-30T02:30:17Z.
merge-check
base:
9335bc0d86head:
7d1c008da9merge: clean (git merge --no-commit --no-ff onto origin/main in a detached worktree; the merged tree was tested uncommitted)
build: cargo build --workspace -> ok (the PR merged and main alike, each in its own target dir)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> main and PR the same: 137 passed, 2 failed, 20 ignored outside the lib; the lib binary ends abnormally on both (0x80004005), so no lib total. SKIPPED: 28 on both (22 no wave64, 3 f16/f32 per-lane forms refused, 2 no heap windows, 1 no D3D12 debug layer). Failing: e2e test_title_draws_with_a_root_signature_under_the_debug_layer and test_title_runs_under_the_debug_layer_with_dred (no D3D12 debug layer on this PC), both fail on main too. The lib in parts: hle::d3d12x::list_x alone on 1 thread 113 passed on both; the rest on 4 threads, 0 failed before the process ends on both (PR 1741 ok, main 1739 ok). Next to the change, on 1 thread: gpu::recomp::tests:: PR 216 passed, 0 failed, 18 ignored; main 215 passed, 0 failed, 18 ignored. The new gpu_ps_compare_mip_bias passes 4 of 4 runs on the PR; the PR's tests.rs alone applied on main fails it in 4 of its 6 cases (C_B, C_B_CL, C_B_O with slope 0, and C_B with slope 0.5; the bias-0 control and the C_B_CL_O case agree on main)
review: none blocking, after reading the whole diff (emit.rs, tests.rs). The new arm only takes pixel-shader comparison samples with a bias (after the LZ / non-PS arm); the derivatives are of the coordinate before the texel offset (of the direction for cubes), scaled by exp2(bias). The test draws a partial quad and checks every pixel against a checkerboard in opposite phases per mip, so a neighbour's coordinate and a wrong mip are told apart. As the first check says: the forms with an offset still move by mip-0 texels until #247 (open, also emit.rs) lands, and whichever of the two lands second needs the follow-up named there. Not run with a title
performance: costs frame time by design, not measured here: each pixel-shader comparison sample with a bias becomes four SampleCmp calls plus quad reads instead of one, so titles that filter shadows with biased comparison samples pay it. It changes a translator source, so every tester re-translates all shaders once
verdict: safe to merge (correctness; the shader cost still wants a measurement in a title)
hardware / tool and model: NVIDIA GeForce RTX 3070 Ti 8 GB (driver 621.40), Intel Core i7-12700K, Windows 10 Pro 19045, rustc 1.100.0 / Claude Code, Claude Opus 5.5