Recompiler: dispatch integer formats for non-comparison image_gather4 #3240
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3240"
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-28T23:44:44Z.
Non-comparison
image_gather4*lowering (includingUNORM=1and explicit-LODimage_gather4_l) hardcodedTexture*<float4>/dx.op.textureGather.f32and appliedf32-to-f16conversion whenD16was set. Gathering aUINTorSINTtexture (such asR16_UINT) through a float4 handle mismatches the D3D12 SRV return type, andf32tof16on integer values flushes results to zero.What is in it
crates/xcl/src/gpu/dxil/lower_image.rs: dispatch non-comparisonimage_gather4*onimg_cls((tw1 >> 20) & 0x1FF)(CompType::U32/I32/F32, matchingimage_load) acrossmimg,mimg_unorm_sample, andmimg_gather4_lod; emit integer border colors (0/1) forgather4_land mask low 16 bits (x & 0xFFFF) instead off32_to_f16whend16is set on integer formats; keep comparisongather4_c*float-only.crates/xcl/src/gpu/recomp/emit.rs: match the 3-wayimg_clsdispatch (Texture*<uint4>/<int4>/<float4>) and integerd16masking for non-comparisongather4in the HLSL backend.crates/xcl/src/gpu/recomp/tests.rs: addgpu_gather4_integer_formatscoveringR16_UINT,R16_UINT+D16,R32_SINT(Direct DXIL + HLSL), plusIMAGE_GATHER4_LandUNORM=1(Direct DXIL).Tested
cargo test --workspace -- --test-threads=4: 2597 passed, 0 failed, 49 ignored.SKIPPEDGPU tests on RTX 5070 Ti (26 total): 21no wave64(wave32-only adapter), 3#1426per-lane f16 refusals (V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32), 2no heap windows(defaultXCL_HEAP_WINDOWSoff). Zerono GPUorno DXCskips.gather4_dispatches_integer_and_float_formats(DXC 1.9 validated),gpu_gather4_integer_formats(Direct DXIL + HLSL on RTX 5070 Ti),gather4_lod_tests(5/5), andgpu_images_sample_load_store_atomic.XCL_DIRECT_DXIL=alland DXC 1.9.2609.5 (1956frames vs1695on main,0device removals,0crashes).Regression run
Not tested
no wave64tests skipped on RTX 5070 Ti).image_gather4variants and non-gather integer explicit-LODimage_sample_l/image_sample_lzinstructions.AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:12:15Z.
merge-check
base:
d0832e614fhead:
779ca19f4bmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (lower_image.rs +173/-30, recomp/emit.rs +42/-7, tests). It changes the default path: every non-comparison gather4 now reads the format table once and carries three guarded copies of its body (uint, sint, float), chosen at run time from the T#'s format (wave-uniform, SGPR-based); for
gather4_leach copy has 2 GetDimensions and 4 textureLoads. Sampling andgather4_c*are unchanged. Findings: (1) the cost isn't measured: shaders get bigger and slower to compile, and the only evidence is one NVIDIA smoke run whose +15 % frames is within noise. (2) The PR's CI is red only in pipeline_library / warm_library (the test race main fixed in2c003dd6, not in this PR's base); they pass in the run above. (3) AI use says "Antigravity (Google Gemini)", not an exact model. (4) Nit: an unused.enumerate()andlet _ = i;at emit.rs ~2797. Fine: it uses the same uint / sint / float dispatch and integer D16 low-16-bit masking as image_load, textureGather / textureLoad pick the i32 overload from the texture's type, gather4 / _lz / _o / UNORM=1 / gather4_l are covered with gather4_c* left float, both backends match, the T# words come from SGPRs that waterfall collapse never touches (it refuses loops whose SRSRC overlaps them), and the tests fail without the fix (the GPU one compares exact texel values; it skipped with "no wave64" in CI).performance: 60 s smoke of a retail title, main
d0832e61vs this merge (0d5dbfcd): 1516 -> 1431 frames shown (94 %; last presents per 2 s: 61 60 60), peak commit 18133 -> 16436 MB, 0 device removals, 0 crashes. A first run of this PR's suite hit the intermittent lib-test crash right after gpu::agility::tests::create_device_sets_dred_first (0xc0000005 in the NVIDIA driver) also seen on unrelated PRs today; this rerun is clean.verdict: safe to merge (after a CI rerun on current main; the extra per-gather shader size and compile cost isn't measured, and the description should name the AI model)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.