shader: lower explicit-LOD 2D gather in direct DXIL #3068

Merged
RonLogic merged 1 commit from upstream-pr/3068 into main 2026-11-27 15:14:34 +00:00
RonLogic commented 2026-11-27 13:45:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-27T13:45:12Z.


Change

Fixes #3066. Refs #1802 and #3065. Lower image_gather4_l in the direct C++ DXIL frontend for a fixed table-bound 2D SRV. The frontend validates the constant sampler, rounds the clamped LOD, limits it to the SRV's visible mip range and emits four typed loads in guest tap order. The clamp and rounding match the existing startup HLSL path. Nonfinite coordinates or LOD give zero in active destination lanes.

The baseline rejected the explicit opcode in both native Pixel and Compute containers. This change is for explicit LOD with a normalized clamp, point-mip sampler. The guest implicit-mip proof remains tracked in #1802.

Verification

Tested 09bdd3082a26d67357147fd2bd656498561371bd on 36d2cbeb with Windows 11 build 26300.10075, MSVC 19.52, Windows SDK 10.0.26100 and DXC 1.9.2602.17.

$env:XBOX2WINDOWS_ADAPTER = 'RTX 4070'
$tests = '^(native_(gather_lod_.+|direct_container|gather_compare_warp)|startup_(compute_gather_l|image_get_lod_view|image_gather_lz)_(warp|hardware))$'
foreach ($preset in 'release', 'dev') {
    cmake --build --preset $preset --target compile_dxil offscreen_check native_recording_check
    ctest --preset $preset --no-tests=error -j 1 -R $tests -V
}
  • Debug and Release each had 12 passes, zero failures and one capability skip.
  • Native Pixel passed on WARP 10.0.26100.10068 and RTX 4070 32.0.16.2124. Native Compute passed on RTX 4070. Local WARP exposed 4..4 lanes, so the Compute run requiring wave32 skipped with exit 77. GPU readback ran with the D3D12 debug layer enabled and zero errors or warnings.
  • Both stages emitted four texture loads and two dimension queries and refused the seven unsupported cases. Docs links, bidi controls and git diff --check passed.

Evidence and follow-up

The source-built fixtures check the original four-channel texel pattern against an independent CPU reference, including a view whose resource base mip is 1, a full three-mip view, both sides of the half-mip threshold, sampler clamping, edge coordinates, and nonfinite operands. Four Compute lanes select resource mips 1, 2, 2, 2 in one dispatch. Forcing mip zero made the Pixel readback fail at (0,0) and changed exactly four words in Compute.

Checklist

  • One reviewable behavior.
  • Test commands, results and capability limits recorded.
  • Baseline refusal and wrong-mip control checked.
  • Experiment notes updated.
  • Diff checked for game files, dumps, distribution links and secrets.

I used Codex to prepare the change and ran verification locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5527672516 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3068). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-27T13:45:12Z. --- ## Change Fixes #3066. Refs #1802 and #3065. Lower `image_gather4_l` in the direct C++ DXIL frontend for a fixed table-bound 2D SRV. The frontend validates the constant sampler, rounds the clamped LOD, limits it to the SRV's visible mip range and emits four typed loads in guest tap order. The clamp and rounding match the existing startup HLSL path. Nonfinite coordinates or LOD give zero in active destination lanes. The baseline rejected the explicit opcode in both native Pixel and Compute containers. This change is for explicit LOD with a normalized clamp, point-mip sampler. The guest implicit-mip proof remains tracked in #1802. ## Verification Tested `09bdd3082a26d67357147fd2bd656498561371bd` on `36d2cbeb` with Windows 11 build 26300.10075, MSVC 19.52, Windows SDK 10.0.26100 and DXC 1.9.2602.17. ```powershell $env:XBOX2WINDOWS_ADAPTER = 'RTX 4070' $tests = '^(native_(gather_lod_.+|direct_container|gather_compare_warp)|startup_(compute_gather_l|image_get_lod_view|image_gather_lz)_(warp|hardware))$' foreach ($preset in 'release', 'dev') { cmake --build --preset $preset --target compile_dxil offscreen_check native_recording_check ctest --preset $preset --no-tests=error -j 1 -R $tests -V } ``` - Debug and Release each had **12 passes, zero failures and one capability skip**. - Native Pixel passed on WARP `10.0.26100.10068` and RTX 4070 `32.0.16.2124`. Native Compute passed on RTX 4070. Local WARP exposed `4..4` lanes, so the Compute run requiring wave32 skipped with exit 77. GPU readback ran with the D3D12 debug layer enabled and zero errors or warnings. - Both stages emitted four texture loads and two dimension queries and refused the seven unsupported cases. Docs links, bidi controls and `git diff --check` passed. ## Evidence and follow-up The source-built fixtures check the original four-channel texel pattern against an independent CPU reference, including a view whose resource base mip is 1, a full three-mip view, both sides of the half-mip threshold, sampler clamping, edge coordinates, and nonfinite operands. Four Compute lanes select resource mips 1, 2, 2, 2 in one dispatch. Forcing mip zero made the Pixel readback fail at `(0,0)` and changed exactly four words in Compute. ## Checklist - [x] One reviewable behavior. - [x] Test commands, results and capability limits recorded. - [x] Baseline refusal and wrong-mip control checked. - [x] Experiment notes updated. - [x] Diff checked for game files, dumps, distribution links and secrets. I used Codex to prepare the change and ran verification locally.
R0Y00 commented 2026-11-27 15:14:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T15:14:21Z.

Review: APPROVED


Independent review at 09bdd308 with main de1595b9 (tree 28f16ed40147aba0dc026d31e492e212a13e882e). The path checks the sampler and channel, bounds the LOD by the SRV's visible mip count, and clamps each coordinate before integer conversion. The four loads preserve guest tap order. Nonfinite inputs are masked in active destination lanes.

Built compile_dxil offscreen_check native_recording_check. ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(native_(gather_lod_.+|direct_container|gather_compare_warp)|startup_(compute_gather_l|image_get_lod_view|image_gather_lz)_(warp|hardware))$' gave 12 passes and one capability skip per preset. Native Pixel matched the CPU taps on WARP and RTX, and native Compute matched on RTX. The fixed-mip substitution was detected. The native Compute WARP case returned 77 because the adapter reports four lanes. Windows 11 26200.9974, WARP 10.0.26100.9818, RTX 4060 Laptop driver 32.0.16.1656, SDK 10.0.26100, GPU fixture debug layer enabled. This verifies explicit LOD; #1802 still tracks guest implicit mip selection.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6090201898 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3068#pullrequestreview-6090201898). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T15:14:21Z. **Review:** APPROVED --- Independent review at `09bdd308` with `main` `de1595b9` (tree `28f16ed40147aba0dc026d31e492e212a13e882e`). The path checks the sampler and channel, bounds the LOD by the SRV's visible mip count, and clamps each coordinate before integer conversion. The four loads preserve guest tap order. Nonfinite inputs are masked in active destination lanes. Built `compile_dxil offscreen_check native_recording_check`. `ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(native_(gather_lod_.+|direct_container|gather_compare_warp)|startup_(compute_gather_l|image_get_lod_view|image_gather_lz)_(warp|hardware))$'` gave 12 passes and one capability skip per preset. Native Pixel matched the CPU taps on WARP and RTX, and native Compute matched on RTX. The fixed-mip substitution was detected. The native Compute WARP case returned 77 because the adapter reports four lanes. Windows 11 26200.9974, WARP 10.0.26100.9818, RTX 4060 Laptop driver 32.0.16.1656, SDK 10.0.26100, GPU fixture debug layer enabled. This verifies explicit LOD; #1802 still tracks guest implicit mip selection.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3068
No description provided.