Repository navigation
Conversation
|
Review (head 4270faa, diff read, not a merge-check):
Suggested verdict: not yet (share the code, use the test runner, split). (Review written with Claude Code, Claude Opus 5.5.) |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 4270faa2: 3 finding(s). 2 are inline. These are on lines outside the diff:
crates/xcl/src/gpu/dxil/lower_image.rs:1944: Only DIM 1|5 are rerouted. image_sample_c_l on 1D (0), 1DArray (4) and Cube (3) still reaches the (Some(z),..) if has_lz || !ps arm and the implicit sampleCmp arm, so their explicit LOD is still dropped. A compute IMAGE_SAMPLE_C_L DIM=3 with lod=2 still lowers to sampleCmpLevelZero and reads mip 0, and in a PS it uses derivative LOD. That's the bug this PR fixes, left in place for the remaining dims.
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| let loaded = lw.s.texture_load(tex, Some(mip_i), &load_coords, &[]); | ||
| let is_b = lw.lor(bx, by); | ||
| let val = lw.sel(is_b, border_val, loaded[0]); | ||
| lw.apply_depth_compare(cmp_ref, val, cmp_func) |
There was a problem hiding this comment.
Not certain about this one: the emulated compare passes the raw cmp_ref to apply_depth_compare without clamping it to [0,1] for UNORM depth views. The hardware SampleCmp path this replaces (and, as far as I know, D3D/RDNA2 comparison filtering) clamps the reference for UNORM formats. A D24/D16 shadow map with cmp_ref=1.02, texel=1.0 and LESS_EQUAL then gives 0 (shadowed) instead of 1 (lit) for receivers past the far plane.
| let m0 = lw.sel(mip_none, m0_none, m0_sel); | ||
| let m1 = lw.sel(mip_linear, m1_lin, m0); | ||
|
|
||
| let is_mag = lw.fcmp(Pred::FOLe, l_raw, zf); |
There was a problem hiding this comment.
Not certain about this one: mag-vs-min XY filtering is decided from l_raw (lod + bias, before the S# MIN/MAX_LOD and T# MIN_LOD clamps), while the mip is picked from the clamped LOD. With XY_MAG=point, XY_MIN=bilinear, MIN_LOD=1.0 and lod=-1.0, mip 1 is read (minified) but the point filter is used, so PCF edges come out hard.
In Direct DXIL (
crates/xcl/src/gpu/dxil/lower_image.rs), explicit-LOD comparison samples (IMAGE_SAMPLE_C_LandIMAGE_SAMPLE_C_L_O) dropped the explicit LOD operand:!ps), they lowered todx.op.sampleCmpLevelZero, always reading mip 0 regardless of the requested LOD.ps), they lowered to implicit-LODdx.op.sampleCmp, computing screen-space derivatives instead of honoring the explicit LOD.Because XCL emits SM 6.6 DXIL (before SM 6.7's
SampleCmpLevel), 2D and 2DArrayimage_sample_c_l/image_sample_c_l_ocan be lowered cleanly in SM 6.6 via mip-leveltextureLoad+apply_depth_compare, matching the existingmimg_gather4_lodapproach.What is in it
crates/xcl/src/gpu/dxil/lower_image.rs:sample_cmp_mipandmimg_sample_cmp_lod, and route 2D / 2DArrayimage_sample_c_landimage_sample_c_l_o(base.starts_with("sample") && has_c && has_l && matches!(dim, 1 | 5)) through them inmimg.LOD_BIAS,[MIN_LOD, MAX_LOD], T#MIN_LOD,MIP_FILTER(none,pointwith RDNA2 half-up0.501953125,lineartwo-mip trilinear blend),XY_MAG_FILTER/XY_MIN_FILTER(1-tap point vs 2x2 bilinear PCF), RDNA2 address modes, border color,UNORM=1/FORCE_UNORMALIZED,A16/D16, static samplers, and signed 6-bit texel offsets.sample_cmp_lod_tests:sample_cmp_lod_variants_translate_validate_and_avoid_implicit_or_lz_cmp: verifies 2D/2DArrayIMAGE_SAMPLE_C_L/IMAGE_SAMPLE_C_L_O(compute and pixel,UNORM=1,A16/D16) validate withdxil.dlland lower viagetDimensions+textureLoadinstead ofsampleCmpLevelZero/sampleCmp.gpu_sample_cmp_lod_reads_explicit_mip_and_filters: real 2-mipTexture2D<float>GPU dispatch verifying explicitlod=1.0vslod=0.0,lod=0.5linear mip blending, 2x2 bilinear PCF on a checkerboard mip 1, S#LOD_BIAS=+1.0, andIMAGE_SAMPLE_C_L_Otexel offset (guarded viawave64_supported/wave32_supportedso no-GPU CI skips cleanly).Tested
32.0.16.1074),rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9 (1.9.2609).dx.op.sampleCmpLevelZero; GPU test returned0.0from mip 0 instead of1.0from mip 1 forlod=1.0).cargo test -p xcl --lib -- gpu::dxil::lower_image::): 8 passed, 0 failed (0.61s), including all 2-mip GPU assertions on RTX 5070 Ti.cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::withXCL_DXC_DIRset to DXC 1.9): 2601 passed, 0 failed, 49 ignored, 9 filtered (426.1s).SKIPPEDlines in workspace run (27 total): 21no wave64(RTX 5070 Ti is wave32), 3 wave32 per-lane#1426(V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32), 2no heap windows(defaultXCL_HEAP_WINDOWSoff), 1no build ahead(XCL_PSO_PRECOMPILEoff).cargo build --release -p xcl -j 4) succeeded and passed the paired 150 s title smoke below.Regression run
main (
f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):PR (
4270faa28b06ea7b6c9ad2d8e463051a16899173):Not tested
uma_driver::tests::andtest_title_runs_and_game_folder_is_untouched(filtered out of the workspace test run).IMAGE_SAMPLE_C_Lon 1D / 1DArray / Cube dimensions, and the HLSL fallback path (recomp/emit.rs, which is kept unchanged in this Direct DXIL PR).AI use