Repository navigation
dxil: emulate explicit-LOD gather4_l(_o) and support UNORM=1 non-cube sampling - #1951
Conversation
|
Checked on an RTX 3070 (Ampere, driver 616.56, Windows 11, debug build) at The batch run is clean:
The last row comes from Overlap: #1812 (brothernog, open and mergeable) already does explicit-LOD AI-assisted (Claude Code). Synthetic tests only. |
940c51b to
e201efe
Compare
|
Thanks for the thorough pixel check and catch, Updated
Verified locally with Re |
|
Regression run for this PR: head main this PR: No device removals or crashes; 99 % of main's frames, 102 % of its peak commit. Not tested: the whole suite; the direct DXIL path this PR changes (these runs use the default HLSL path, Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
|
Quick overlap note: full credit to #1812 (@brothernog), which already implements explicit-LOD #1951 adds Direct DXIL support for |
|
Re-checked
Both points are fixed on hardware. The overlap with #1812 for the AI-assisted (Claude Code). Synthetic tests only. |
|
Heads-up on overlap, from reading the diff, not from a run: #1812, opened earlier, emulates the same Two differences:
One way to split it: #1812 for the uncompared This comment was AI-assisted. |
|
Thanks for the detailed comparison, @brothernog! Agreed on the clean split: once #1812 lands for uncompared explicit-LOD \gather4_l\ / _l_o\ across HLSL and Direct DXIL (including \T# MIN_LOD\ floor handling), we will rebase and trim #1951 strictly down to the non-overlapping \gather4_c_l\ / _c_l_o\ compare forms and non-cube \UNORM=1\ sampling paths. |
… guard, and UNORM=1 sampling
e201efe to
ff184be
Compare
|
Thanks for catching the missing T# Updated
Pushed |
|
Re-checked AI-assisted (Claude Code). Synthetic tests only. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Tested Verified PR #1951 from a clean checkout at
cargo test -p xcl --lib gpu::dxil::lower_image::gather4_lod_tests::non_cube_unorm_sampling_translates_and_validate -- --exact --nocapture1 passed, 0 failed, 0 ignored, 0 skipped (1,066 filtered out, Cargo exit 0). The one fixture translated seven synthetic Not tested GPU execution, numerical sampling or pixel parity, bounds behavior, the explicit-mip AI use T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixture and wrote this report. |
|
Regression run of Against the limits in CONTRIBUTING.md: 104 % of AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, AI use: Claude Code (Claude Opus 5.5) built both trees and ran |
|
Thanks @Toons29 for running and sharing the exact-head 60 s |
Brings main to full parity with upstream/main (cdb0891), including: - World rendering & gameplay: xcl-dev#1991, xcl-dev#1988, xcl-dev#1984, xcl-dev#2028, xcl-dev#2078 - Memory / VRAM / PSO: xcl-dev#1985, xcl-dev#2157, xcl-dev#2178, xcl-dev#2195, xcl-dev#2176, xcl-dev#1996, xcl-dev#1914 - Direct DXIL & shaders: xcl-dev#2120, xcl-dev#2174, xcl-dev#2194, xcl-dev#2207, xcl-dev#1951, xcl-dev#1973, xcl-dev#2156, xcl-dev#2064 - Preserves local Linux/Wine customizations: docs/linux.md, scripts/linux/*, in-process Wine XAsync (xgameruntime/api.rs), loader watchdog bypass, and Wine MEM_WRITE_WATCH bypass on coherent UMA windows (gpu/uma.rs). Assisted-by: Antigravity (Gemini 4)
xcl-dev#1951's direct DXIL paths for image_gather4_l (mimg_gather4_lod) and for non-cube UNORM=1 sampling (mimg_unorm_sample) still packed D16 results with f32tof16 / legacyF32ToF16, which truncates on the RTX 3070: 123 of the 256 8_8_8_8_UNORM codes came back one unit in the last place low (code 9: 0x2884 for 0x2885), the rounding xcl-dev#2030 fixed in the main sample and gather path. Both now take the T#'s format info and follow the main path's rule: a gather returns texels of the one component DMASK names, rounded once (d16_fmt); a sample through an S# that cannot filter does the same, a filtered one keeps the host's blend truncated (f16_rtz). Unnormalized coordinates still allow linear x / y filtering, so mimg_unorm_sample uses the same Filters decision. The Filters enum and its decision move out of the main path into d16_filters / d16_sample, shared by the three. The HLSL path already packs gather4_l with d16_fmt (it lowers it as a level-0 Gather) and rejects UNORM=1 sampling ("MIMG unorm"), so only the direct path changes behaviour. gpu_image_d16_gather4_l_of_unorm8_rounds_once gathers every component of a 64x1 RGBA8_UNORM texture of codes 0..255 at LOD 0 (1024 taps, all 256 codes) against code / 255 rounded once; before this change the direct path got 498 taps wrong, the HLSL path none. gpu_image_d16_unnormalized_samples_round_texels_once (direct path only) samples each texel's centre through a point S# (all 256 codes; 123 wrong before) and the edge between two texels through a bilinear S# (f16_rtz of the f32 sample). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Emulates explicit-LOD
image_gather4_l/image_gather4_l_o/image_gather4_c_l/image_gather4_c_l_o(plus_clclamp,A16,D16, andUNORM=1/FORCE_UNORMALIZED) in the direct RDNA2 -> DXIL translator across all 8 RDNA2 address modes, and adds non-cubeUNORM=1coordinate normalization forsample*andgather4*.Part of #1269 and #1833.
What is in it
crates/xcl/src/gpu/dxil/lower_image.rs(mimg_gather4_lod,apply_rdna2_addr_mode,apply_depth_compare): emulate explicit-LODgather4_l(_o)onTexture2DandTexture2DArrayvia 4 mip-leveldx.op.textureLoadtaps in hardware gather order(-,+), (+,+), (+,-), (-,-)honoring all 8SQ_TEX_CLAMPaddress modes, S# signed S5.8LOD_BIAS(s2[13:0] / 256.0), T#MIN_LOD(tw1[19:8], u4.8 /256.0—MIP_FILTER=nonereadsfloor(T# MIN_LOD)at every LOD, and filtered samplers raise S#-clamped LOD toT# MIN_LODbefore half-up rounding), S#[min_lod, max_lod]+mip_filter == 0clamping, RDNA2 half-up mip rounding (floor(lod + 0.501953125)=257/512,0x3F00_8000) +GetDimensionsmip count, signed 6-bit texel offsets (has_o), S# border color types (s3[31:30]),SQ_TEX_DEPTH_COMPARE(s0[14:12]), and#1969's MIMG heap-bounds guard (self.guarded(run, ...)).crates/xcl/src/gpu/dxil/lower_image.rs(mimg_unorm_sample): normalize unnormalized texel coordinates (and optional signed 6-bit offsets) via mipGetDimensionsfor non-cube textures (D1,D2,D3,D1Array,D2Array) before DXIL sample/gather emission, with#1969heap-bounds guard (safe_tw0forimplicit_lod).gather4_lod_tests:gather4_lod_variants_translate_and_validate,gather4_lod_emits_bias_and_rdna2_half_up_rounding,gather4_lod_honors_tsharp_min_lod_and_mip_filter_none, andnon_cube_unorm_sampling_translates_and_validate.Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly ontoae0518c(ff184be).ff184beintegrates the T#MIN_LODfix (@brothernogcatch) and#1969heap-bounds guard atopae0518cvia pure git during a local test hold; queued for GitHub ActionsBuild and testand fresh AMD / NVIDIA verification (gather4_lod_tests).e201efepassedcargo check --workspace --tests,gather4_lod_tests(3/3), and@upipibi's 5-case DXIL verification.scripts/smoke.ps1regression pair on AMD Radeon RX 9070 (@Toons29): passed (0 device removals, 0 crashes).Regression run
60 s
scripts/smoke.ps1pair on exact headff184bevsmain(AMD Radeon RX 9070, driver 32.0.32029.2010, Windows 11 26300, release,XCL_NETWORK=0on a retail title), contributed by@Toons29:main:
this PR:
Not tested
cargo check/gather4_lod_testsandscripts/smoke.ps1on updated headff184be, runtime GPU pixel comparison against HLSL on AMD / NVIDIA / Intel hardware, wave32-only adapters, and Linux/Wine/vkd3d-proton.AI use