Repository navigation
Recompiler: pixel comparison samples apply their LOD bias - #349
Conversation
|
AMD run, since Not tested says no AMD driver has compiled these quad operations yet: Tested
Not tested
AI use
|
|
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 |
|
NVIDIA RTX 40 run of Tested
Reviewed (read the whole diff)
Not tested
AI use
|
|
Review: scaling
AI-assisted review (Claude Code, Claude Opus 5.5). |
|
Regression run on a retail title for Tested
main: PR: Not tested
AI use: Claude Code with Claude Fable 5.2 made the runs with me present and wrote this comment. |
|
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 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 ( Tested PR head 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 |
cccc2c3 to
fe3011d
Compare
|
Independent native D3D12 check of 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 AI use: Codex (GPT-6, exact variant unavailable) ran the tests and drafted this report. |
SM 6.6 has no comparison sample that takes a bias, so a pixel shader's image_sample_c_b* selected its mip from the unbiased screen derivatives. The derivatives are now scaled by 2^bias, and SampleCmp runs once for each pixel of the quad (QuadReadLaneAt) with that pixel's footprint; each pixel keeps its own result. A lane's own coordinate is used unchanged on an axis it does not move along, so a non-finite derivative cannot turn it into NaN. The test draws a full-screen triangle and one whose edge leaves partial quads. Assisted-by: Codex (GPT-6.2 Astra) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fe3011d to
7d1c008
Compare
|
Squashed into one commit ( A note for the merge order with #247: this PR makes the PS AI use: Claude Code (Claude Opus 5.5) |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Tested Independent run at clean PR head Prebuilt with 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. |
|
NVIDIA and AMD full-suite run, to go with the reports above by JJAutoCompare, since none of them names a GPU. Tested exact head Tested
Not tested
AI use
|
|
Tested on AMD / Linux: The head as it is (not merged onto current Tests (
Not tested
AI use
|
|
merge-check claim |
|
merge-check |
|
Focused GPU finding on #349 head 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 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)diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index e7edaf96..e38245be 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -1991,6 +1991,27 @@ fn gpu_ps_compare_mip_bias() {
assert!(failures.is_empty(), "{}", failures.join("\n"));
}
+#[test]
+fn gpu_ps_compare_bias_keeps_lod_at_large_clamped_coordinate() {
+ if !gpu_ready() {
+ return;
+ }
+ let ps = prog(&[
+ ("S_WQM_B64", "ENC_SOP1", &[("SDST", 126), ("SSRC0", 126)], None),
+ ("V_MOV_B32", "ENC_VOP1", &[("VDST", 8), ("SRC0", 255)], Some((-3.0f32).to_bits())),
+ ("V_MOV_B32", "ENC_VOP1", &[("VDST", 9), ("SRC0", 240)], None),
+ ("V_MUL_F32", "ENC_VOP2", &[("VDST", 10), ("SRC0", 255), ("VSRC1", 2)], Some(2.0f32.to_bits())),
+ ("V_ADD_F32", "ENC_VOP2", &[("VDST", 10), ("SRC0", 255), ("VSRC1", 10)], Some(12_582_912.0f32.to_bits())),
+ ("V_MUL_F32", "ENC_VOP2", &[("VDST", 11), ("SRC0", 255), ("VSRC1", 3)], Some(0.125f32.to_bits())),
+ ("IMAGE_SAMPLE_C_B", "ENC_MIMG", &[("VDATA", 20), ("VADDR", 8), ("SRSRC", 4), ("SSAMP", 6), ("DMASK", 1), ("DIM", 1)], None),
+ ("EXP", "ENC_EXP", &[("TGT", 0), ("EN", 1), ("VSRC0", 20), ("DONE", 1), ("VM", 1)], None),
+ ]);
+ check_ps_depth_mip_expected(&ps, |_, y| {
+ let v = (((y as f32 + 0.5) * 0.125 * 4.0) as u32).min(3);
+ ((3 + v + 1) % 2) as f32
+ }).unwrap();
+}
/// Draw console wave64 VS + PS (`vs` None: position and COLOR passed through; `ps` None:
@@ -2040,6 +2061,15 @@ fn draw_console_views(
/// Both depth mips contain a checkerboard, in opposite phases. Check the comparison result at
/// each pixel so that selecting a neighbor's coordinates is distinguishable from selecting its mip.
fn check_ps_depth_mip(ps: &[u8], coord_scale: f32, mip_at: impl Fn(usize) -> u32) -> Result<(), String> {
+ check_ps_depth_mip_expected(ps, |x, y| {
+ let mip = mip_at(x);
+ let size = 8u32 >> mip;
+ let texel = |p: usize| (((p as f32 + 0.5) * coord_scale * size as f32) as u32).min(size - 1);
+ ((texel(x) + texel(y) + mip) % 2) as f32
+ })
+}
+
+fn check_ps_depth_mip_expected(ps: &[u8], expected_at: impl Fn(usize, usize) -> f32) -> Result<(), String> {
use windows::Win32::Graphics::Direct3D12::*;
@@ -2076,13 +2106,10 @@ fn check_ps_depth_mip(ps: &[u8], coord_scale: f32, mip_at: impl Fn(usize) -> u32
let pixels = draw_console_views(None, Some(ps), &tri, &sgprs, std::slice::from_ref(&tex), &samplers);
for (i, pixel) in pixels.iter().enumerate() {
let (x, y) = (i % 16, i / 16);
- let mip = mip_at(x);
- let size = 8u32 >> mip;
- let texel = |p: usize| (((p as f32 + 0.5) * coord_scale * size as f32) as u32).min(size - 1);
let covered = (x as f32 + 0.5) * height + (y as f32 + 0.5) * width < width * height;
- let expected = if covered { ((texel(x) + texel(y) + mip) % 2) as f32 } else { -1.0 };
+ let expected = if covered { expected_at(x, y) } else { -1.0 };
if pixel[0] != expected {
- return Err(format!("{width}x{height} triangle, pixel ({x},{y}): {} instead of {expected} at mip {mip}", pixel[0]));
+ return Err(format!("{width}x{height} triangle, pixel ({x},{y}): {} instead of {expected}", pixel[0]));
} |
|
merge-check claim |
|
merge-check |
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 D3D12.X: replacing the sparse state deadlocks when the old state still holds placed buffers #344 hang in 4 of 4 runs; with D3D12.X: the sparse state is replaced outside its lock #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 (Recompiler: pixel comparison samples apply their LOD bias #349 (comment)).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