D3D12.X: heap samplers and views carry their real S#/T# words (incl. T# MIN_LOD) #3730

Open
Kalmarv wants to merge 1 commit from upstream-pr/3730 into main
Kalmarv commented 2026-12-02 20:50:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T20:50:02Z.


Consolidates #3248 and the T# MIN_LOD part of #3258 onto main, addressing all review findings from @Foniass (dropping #3258's unrelated wildcard SRV/3D-UAV count and CreateUnorderedAccessViewAt changes, fixing MIN_MAG_ANISOTROPIC_MIP_POINT mip-filter encoding, documenting the HLSL implicit-LOD offset path, and adding MostDetailedMip > 0 D3D12 parity coverage).

Previously:

  1. dev_create_sampler_x wrote [0, 0, 0, slot.index & 0xFFF] into the console sampler heap, so shader paths that decode S# directly (mimg_gather4_lod for IMAGE_GATHER4_L* / IMAGE_GATHER4_C_L* in gpu/dxil/lower_image.rs, and the HLSL fallback implicit-LOD offset path in gpu/recomp/emit.rs which reads MIP_FILTER from S# word 2) saw WRAP, MAX_LOD = 0, MIP_FILTER = NONE, DEPTH_COMPARE_FUNC = NEVER, and transparent-black border for heap-created samplers.
  2. srv_tsharp_from_desc left T# MIN_LOD (t[1][19:8], u4.8 fixed-point relative to BASE_LEVEL) at 0 for all SRV dimensions, so direct-DXIL IMAGE_GATHER4_L* ignored ResourceMinLODClamp.

What is in it

  • crates/xcl/src/gpu/desc.rs:
    • Add xcl_sampler_for_desc(&D3D12_SAMPLER_DESC, u32) -> [u32; 4] encoding RDNA2 S# words (w[0..2] and w[3][31:30] border color type, keeping sampler_heap_index & 0xFFF in w[3][11:0], saturating MaxLOD = f32::MAX to 0xFFF, encoding point mip as SQ_TEX_MIP_FILTER_POINT = 1 including for MIN_MAG_ANISOTROPIC_MIP_POINT 0x54 and its variants, and linear mip as 2).
    • Note: in the HLSL fallback path for implicit-LOD offset sampling in pixel shaders (gpu/recomp/emit.rs), reading the real MIP_FILTER from S# word 2 means linear-mip heap samplers now take the two-mip blend instead of collapsing to a single Sample as when word 2 was zero.
    • Add unit test view_tests::sampler_desc_encodes_and_decodes_back.
  • crates/xcl/src/hle/d3d12x/real.rs:
    • Wire xcl_sampler_for_desc into dev_create_sampler_x (keeping [0, 0, 0, slot.index & 0xFFF] fallback when desc is null).
    • Add encode_tsharp_min_lod(clamp, base_level) and populate T# MIN_LOD (t[1][19:8]) in srv_tsharp_from_desc across all 7 SRV dimensions that carry ResourceMinLODClamp (1D, 1DArray, 2D, 2DArray, 3D, Cube, CubeArray). Because D3D12 ResourceMinLODClamp is measured from resource mip 0 while GFX10 T# MIN_LOD is relative to BASE_LEVEL (MostDetailedMip), this encodes max(0, clamp - base_level) (verified against native D3D12 SampleLevel on hardware).
    • Add unit test srv_tsharp_encodes_min_lod_across_dimensions_and_most_detailed_mip, WARP test dev_create_sampler_writes_ssharp_and_copy_preserves_it, and GPU parity tests gpu_heap_sampler_gather4_l_and_c_l_use_created_ssharp and gpu_srv_tsharp_min_lod_clamp_controls_image_gather4_l_mip (which compares direct-DXIL IMAGE_GATHER4_L against native HLSL SampleLevel for both MostDetailedMip = 0 and MostDetailedMip = 1).

Tested

  • Hardware & toolchain: AMD Ryzen 9 9950X 16-Core, Windows 11 Pro 10.0.26200.0, NVIDIA GeForce RTX 5070 Ti (driver 610.74), rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609.5.
  • cargo build --release -p xcl: succeeded, 39 warnings (0 new vs origin/main 39).
  • Targeted tests (cargo test -p xcl --lib -- sampler_desc_encodes_and_decodes_back dev_create_sampler_writes_ssharp_and_copy_preserves_it gpu_heap_sampler_gather4_l_and_c_l_use_created_ssharp srv_tsharp_encodes_min_lod_across_dimensions_and_most_detailed_mip gpu_srv_tsharp_min_lod_clamp_controls_image_gather4_l_mip --nocapture): 5 passed, 0 failed, 0 ignored (0 skipped). Confirmed native D3D12 SampleLevel returns [0.5, 0.25, 0.5, 0.75] and translated IMAGE_GATHER4_L matches [0.5, 0.25, 0.5, 0.75] for (MostDetailedMip=0, clamp=1.0), (0, 0.0), (1, 1.0), and (1, 2.0).
  • .\scripts\test.ps1 (full workspace build, bench compile-check, and test suite, no --skip filters): 3,010 passed, 0 failed, 52 ignored across 44 test binaries (GPU tests skipped on this wave32-only adapter: 24 total — 22 no wave64, 2 no heap windows opt-in).

Regression run
Base (origin/main 817eb1fc9):

xcl-smoke v1
commit: 817eb1fc9fb0763008ae5d8de1f7f586f442b51d
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1610 (PresentX 1610)
presents per 2 s (last 3): 54 192 82
device removals: 0
crashes: 0
peak commit: 14895 MB

PR (1f2b9f045):

xcl-smoke v1
commit: 1f2b9f04520fb58f4cfacd542506c5da34c3bd54
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1407 (PresentX 1407)
presents per 2 s (last 3): 91 12 53
device removals: 0
crashes: 0
peak commit: 14936 MB

Not tested

  • AMD RDNA / native wave64 hardware adapters (22 wave64 GPU tests + 2 opt-in heap-window GPU tests skipped on this wave32-only RTX 5070 Ti).
  • HLSL fallback implicit-LOD offset sampling (XCL_DIRECT_DXIL=0) with linear-mip heap samplers.
  • Custom non-black/white border colour register tables (BORDER_COLOR_TYPE == 3 maps to standard border types 0/1/2).
  • Note for follow-up (not changed here): gpu/desc.rs::image_d3d12 passes t.min_lod directly to ResourceMinLODClamp without adding t.base_level.

AI use

  • Antigravity (Gemini 4 Neon): consolidated #3248 and the T# MIN_LOD part of #3258 onto main, fixed MIN_MAG_ANISOTROPIC_MIP_POINT mip-filter encoding and MostDetailedMip > 0 T# MIN_LOD offset relative to BASE_LEVEL, added the native-D3D12 SampleLevel parity test, and ran release build, full scripts/test.ps1, and 60 s retail smoke verification.
<!-- greyfinch-sync:ivall/xcl:issue:5614472603 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3730). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T20:50:02Z. --- Consolidates #3248 and the `T# MIN_LOD` part of #3258 onto `main`, addressing all review findings from @Foniass (dropping #3258's unrelated wildcard SRV/3D-UAV count and `CreateUnorderedAccessViewAt` changes, fixing `MIN_MAG_ANISOTROPIC_MIP_POINT` mip-filter encoding, documenting the HLSL implicit-LOD offset path, and adding `MostDetailedMip > 0` D3D12 parity coverage). Previously: 1. `dev_create_sampler_x` wrote `[0, 0, 0, slot.index & 0xFFF]` into the console sampler heap, so shader paths that decode `S#` directly (`mimg_gather4_lod` for `IMAGE_GATHER4_L*` / `IMAGE_GATHER4_C_L*` in `gpu/dxil/lower_image.rs`, and the HLSL fallback implicit-LOD offset path in `gpu/recomp/emit.rs` which reads `MIP_FILTER` from `S#` word 2) saw `WRAP`, `MAX_LOD = 0`, `MIP_FILTER = NONE`, `DEPTH_COMPARE_FUNC = NEVER`, and transparent-black border for heap-created samplers. 2. `srv_tsharp_from_desc` left `T# MIN_LOD` (`t[1][19:8]`, u4.8 fixed-point relative to `BASE_LEVEL`) at `0` for all SRV dimensions, so direct-DXIL `IMAGE_GATHER4_L*` ignored `ResourceMinLODClamp`. **What is in it** - `crates/xcl/src/gpu/desc.rs`: - Add `xcl_sampler_for_desc(&D3D12_SAMPLER_DESC, u32) -> [u32; 4]` encoding RDNA2 `S#` words (`w[0..2]` and `w[3][31:30]` border color type, keeping `sampler_heap_index & 0xFFF` in `w[3][11:0]`, saturating `MaxLOD = f32::MAX` to `0xFFF`, encoding point mip as `SQ_TEX_MIP_FILTER_POINT = 1` including for `MIN_MAG_ANISOTROPIC_MIP_POINT` `0x54` and its variants, and linear mip as `2`). - Note: in the HLSL fallback path for implicit-LOD offset sampling in pixel shaders (`gpu/recomp/emit.rs`), reading the real `MIP_FILTER` from `S#` word 2 means linear-mip heap samplers now take the two-mip blend instead of collapsing to a single `Sample` as when word 2 was zero. - Add unit test `view_tests::sampler_desc_encodes_and_decodes_back`. - `crates/xcl/src/hle/d3d12x/real.rs`: - Wire `xcl_sampler_for_desc` into `dev_create_sampler_x` (keeping `[0, 0, 0, slot.index & 0xFFF]` fallback when `desc` is null). - Add `encode_tsharp_min_lod(clamp, base_level)` and populate `T# MIN_LOD` (`t[1][19:8]`) in `srv_tsharp_from_desc` across all 7 SRV dimensions that carry `ResourceMinLODClamp` (`1D`, `1DArray`, `2D`, `2DArray`, `3D`, `Cube`, `CubeArray`). Because D3D12 `ResourceMinLODClamp` is measured from resource mip 0 while GFX10 `T# MIN_LOD` is relative to `BASE_LEVEL` (`MostDetailedMip`), this encodes `max(0, clamp - base_level)` (verified against native D3D12 `SampleLevel` on hardware). - Add unit test `srv_tsharp_encodes_min_lod_across_dimensions_and_most_detailed_mip`, WARP test `dev_create_sampler_writes_ssharp_and_copy_preserves_it`, and GPU parity tests `gpu_heap_sampler_gather4_l_and_c_l_use_created_ssharp` and `gpu_srv_tsharp_min_lod_clamp_controls_image_gather4_l_mip` (which compares direct-DXIL `IMAGE_GATHER4_L` against native HLSL `SampleLevel` for both `MostDetailedMip = 0` and `MostDetailedMip = 1`). **Tested** - Hardware & toolchain: AMD Ryzen 9 9950X 16-Core, Windows 11 Pro 10.0.26200.0, NVIDIA GeForce RTX 5070 Ti (driver 610.74), `rustc 1.99.0 (b940084d7 2026-09-28)`, DXC `1.9.2609.5`. - `cargo build --release -p xcl`: succeeded, 39 warnings (0 new vs `origin/main` 39). - Targeted tests (`cargo test -p xcl --lib -- sampler_desc_encodes_and_decodes_back dev_create_sampler_writes_ssharp_and_copy_preserves_it gpu_heap_sampler_gather4_l_and_c_l_use_created_ssharp srv_tsharp_encodes_min_lod_across_dimensions_and_most_detailed_mip gpu_srv_tsharp_min_lod_clamp_controls_image_gather4_l_mip --nocapture`): 5 passed, 0 failed, 0 ignored (0 skipped). Confirmed native D3D12 `SampleLevel` returns `[0.5, 0.25, 0.5, 0.75]` and translated `IMAGE_GATHER4_L` matches `[0.5, 0.25, 0.5, 0.75]` for `(MostDetailedMip=0, clamp=1.0)`, `(0, 0.0)`, `(1, 1.0)`, and `(1, 2.0)`. - `.\scripts\test.ps1` (full workspace build, bench compile-check, and test suite, no `--skip` filters): 3,010 passed, 0 failed, 52 ignored across 44 test binaries (GPU tests skipped on this wave32-only adapter: 24 total — 22 `no wave64`, 2 `no heap windows` opt-in). **Regression run** Base (`origin/main` `817eb1fc9`): ``` xcl-smoke v1 commit: 817eb1fc9fb0763008ae5d8de1f7f586f442b51d gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1610 (PresentX 1610) presents per 2 s (last 3): 54 192 82 device removals: 0 crashes: 0 peak commit: 14895 MB ``` PR (`1f2b9f045`): ``` xcl-smoke v1 commit: 1f2b9f04520fb58f4cfacd542506c5da34c3bd54 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1407 (PresentX 1407) presents per 2 s (last 3): 91 12 53 device removals: 0 crashes: 0 peak commit: 14936 MB ``` **Not tested** - AMD RDNA / native wave64 hardware adapters (22 wave64 GPU tests + 2 opt-in heap-window GPU tests skipped on this wave32-only RTX 5070 Ti). - HLSL fallback implicit-LOD offset sampling (`XCL_DIRECT_DXIL=0`) with linear-mip heap samplers. - Custom non-black/white border colour register tables (`BORDER_COLOR_TYPE == 3` maps to standard border types `0`/`1`/`2`). - Note for follow-up (not changed here): `gpu/desc.rs::image_d3d12` passes `t.min_lod` directly to `ResourceMinLODClamp` without adding `t.base_level`. **AI use** - Antigravity (Gemini 4 Neon): consolidated #3248 and the `T# MIN_LOD` part of #3258 onto `main`, fixed `MIN_MAG_ANISOTROPIC_MIP_POINT` mip-filter encoding and `MostDetailedMip > 0` `T# MIN_LOD` offset relative to `BASE_LEVEL`, added the native-D3D12 `SampleLevel` parity test, and ran release build, full `scripts/test.ps1`, and 60 s retail smoke verification.
vasanex commented 2026-12-03 02:44:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:44:38Z.

Review: COMMENTED


Review of 1f2b9f04 (code reading and the tests named below, not a merge-check) · no findings

In short: CreateSampler now writes the sampler's real S# words where it wrote zeros, and SRVs carry T# MIN_LOD relative to the view's first mip. The encoding matches the decoder in the same file and the field positions the readers use. Every reader of S# word 3 masks the heap index (11 or 12 bits), so the border type in its top bits disturbs nothing. Words 0 to 2 are read in two places only: the explicit-LOD gather in direct DXIL, which this fixes, and the HLSL implicit-LOD offset path, where a linear-mip heap sampler now takes the two-mip blend the path was written for (the description says so).

Result: no blockers found. From the code, nothing stands in the way of a merge. This is a review, not a merge-check: the suite and a title run are not covered here.

Measured (RTX 3080, Ryzen 9 7950X, merge of this head onto main 395405e4, debug)

  • The five tests the description names (cargo test -p xcl --lib -- sampler_desc_encodes_and_decodes_back dev_create_sampler_writes_ssharp_and_copy_preserves_it gpu_heap_sampler_gather4_l_and_c_l_use_created_ssharp srv_tsharp_encodes_min_lod_across_dimensions_and_most_detailed_mip gpu_srv_tsharp_min_lod_clamp_controls_image_gather4_l_mip): 5 passed, 0 failed, none skipped.
  • With dev_create_sampler_x writing [0, 0, 0, index] again and MIN_LOD left at 0: 4 of the 5 fail (all but the encoder's own unit test), so the tests pin both changes.

Notes, none blocking

  1. Not from this PR, but it limits what it reaches: mimg_gather4_lod takes S# words 0 to 2 from the scalar registers (sreg(ssamp..ssamp+2)) and only word 3 per lane (mimg_s3) after a sampler waterfall was collapsed. If a collapsed loop contains an explicit-LOD gather, the sampler picked per lane is right, but its address modes, LOD clamps and compare function come from whatever those registers held before the loop. Read, not run; main has the same gap.
  2. sampler_desc_encodes_and_decodes_back checks the raw mip bits for MIN_MAG_ANISOTROPIC_MIP_POINT; decoded through sampler_d3d12 those words come back as ANISOTROPIC. No runtime code decodes heap sampler words today, so nothing depends on it.

Not checked: the whole suite and a title run on this head; AMD and Intel; the HLSL fallback path with a linear-mip heap sampler and a non-zero LOD bias (whether the bias is applied once), which the description lists as not tested.

Review by Claude Code (Claude Fable 5.2), with an independent second read by a subagent (Claude Fable 5.2) whose points were checked before use, posted without a human check of each point. An automated PR review workflow is running at the request of the user.

<!-- greyfinch-sync:ivall/xcl:review:6162846971 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3730#pullrequestreview-6162846971). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:44:38Z. **Review:** COMMENTED --- **Review** of `1f2b9f04` (code reading and the tests named below, not a merge-check) · no findings **In short:** `CreateSampler` now writes the sampler's real S# words where it wrote zeros, and SRVs carry T# `MIN_LOD` relative to the view's first mip. The encoding matches the decoder in the same file and the field positions the readers use. Every reader of S# word 3 masks the heap index (11 or 12 bits), so the border type in its top bits disturbs nothing. Words 0 to 2 are read in two places only: the explicit-LOD gather in direct DXIL, which this fixes, and the HLSL implicit-LOD offset path, where a linear-mip heap sampler now takes the two-mip blend the path was written for (the description says so). **Result:** no blockers found. From the code, nothing stands in the way of a merge. This is a review, not a merge-check: the suite and a title run are not covered here. **Measured** (RTX 3080, Ryzen 9 7950X, merge of this head onto `main` `395405e4`, debug) - The five tests the description names (`cargo test -p xcl --lib -- sampler_desc_encodes_and_decodes_back dev_create_sampler_writes_ssharp_and_copy_preserves_it gpu_heap_sampler_gather4_l_and_c_l_use_created_ssharp srv_tsharp_encodes_min_lod_across_dimensions_and_most_detailed_mip gpu_srv_tsharp_min_lod_clamp_controls_image_gather4_l_mip`): 5 passed, 0 failed, none skipped. - With `dev_create_sampler_x` writing `[0, 0, 0, index]` again and `MIN_LOD` left at 0: 4 of the 5 fail (all but the encoder's own unit test), so the tests pin both changes. **Notes, none blocking** 1. Not from this PR, but it limits what it reaches: `mimg_gather4_lod` takes S# words 0 to 2 from the scalar registers (`sreg(ssamp..ssamp+2)`) and only word 3 per lane (`mimg_s3`) after a sampler waterfall was collapsed. If a collapsed loop contains an explicit-LOD gather, the sampler picked per lane is right, but its address modes, LOD clamps and compare function come from whatever those registers held before the loop. Read, not run; `main` has the same gap. 2. `sampler_desc_encodes_and_decodes_back` checks the raw mip bits for `MIN_MAG_ANISOTROPIC_MIP_POINT`; decoded through `sampler_d3d12` those words come back as `ANISOTROPIC`. No runtime code decodes heap sampler words today, so nothing depends on it. **Not checked:** the whole suite and a title run on this head; AMD and Intel; the HLSL fallback path with a linear-mip heap sampler and a non-zero LOD bias (whether the bias is applied once), which the description lists as not tested. Review by Claude Code (Claude Fable 5.2), with an independent second read by a subagent (Claude Fable 5.2) whose points were checked before use, posted without a human check of each point. An automated PR review workflow is running at the request of the user.
Foniass commented 2026-12-03 05:51:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T05:51:56Z.


merge-check
base: 078358a058
head: 1f2b9f0452
merge: clean
build: ok
tests: 3011 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 4 medium, 1 nit (below)
performance: 60 s smoke run: 1669 → 1676 frames (100 % of main), peak commit 17577 → 18168 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 233 s there, 0 device removals, 0 crashes, 2.7 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Heap samplers from CreateSampler/CreateSamplerX now carry their real S# words 0-2 and border type, and SRV T#s carry MIN_LOD from ResourceMinLODClamp, counted from MostDetailedMip. The encoding converts back through sampler_d3d12 unchanged, the GPU test compares against native D3D12 SampleLevel, and no blocking bug was found. Open points: two features in one 742-line PR, an untested behaviour change on the HLSL path, and a smoke run at 87 % of main's frames.

Medium

  1. Two features in one PR over the size target. The S# encoding (desc.rs, dev_create_sampler_x) and the T# MIN_LOD (srv_tsharp_from_desc) are independent changes from #3248 and #3258: 742 lines in total, about 120 of them runtime. That is under 800, but the description gives no reason not to keep them as two PRs.
  2. HLSL implicit-LOD offset path changes without a test. recomp/emit.rs reads MIP_FILTER from S# word 2, so heap samplers with a linear mip filter now take the two-mip blend (3 samples) instead of one Sample. The description now says so, which fixes the earlier finding, but Not tested lists it and no test covers it (XCL_DIRECT_DXIL=0).
  3. MIN_LOD convention differs from image_d3d12. The encoder writes max(0, clamp - MostDetailedMip) (real.rs ~1910), which matches lower_image's gather4_l. But desc::image_d3d12 (desc.rs ~241) passes T# MIN_LOD straight into ResourceMinLODClamp as an absolute value, so a title-written T# with BASE_LEVEL > 0 is read one way by the lowering and the other way by view creation. This is not a regression (main wrote 0), and the description flags it as a follow-up; worth an issue.
  4. Smoke frames at 87 % of main. 1610 -> 1407 frames shown (last presents 54 192 82 against 91 12 53). The main run is on 817eb1fc, not the merge-base 5ad98adb. That is within the 80 % limit and probably noise, but nothing explains it; the gaming-PC run should confirm.

Nit

  1. Custom border colours become transparent black in the S#. xcl_sampler_for_desc maps every non-standard BorderColor to type 0. Only paths that decode the S# directly see this (the PC sampler keeps the real colour). It is listed under Not tested; a comment near desc.rs ~389 would help.
Checked and fine
  • Earlier finding fixed: MIN_MAG_ANISOTROPIC_MIP_POINT (0x54) and its variants now encode a point mip filter from bit 0 of the filter, with a test
  • Earlier finding fixed: T# MIN_LOD with MostDetailedMip > 0 is now counted from BASE_LEVEL, and a GPU test compares IMAGE_GATHER4_L with native SampleLevel for MostDetailedMip 0 and 1
  • Earlier finding fixed: #3258's unrelated wildcard-count and CreateUnorderedAccessViewAt changes are dropped, and AI use names the model
  • The S# fields match sampler_d3d12 and the RDNA2 layout: clamp modes, aniso ratio, depth compare 0..7, filter mode, u4.8 LODs with f32::MAX saturating, s5.8 bias, and the XY, Z and mip filters
  • The fallback for a null desc keeps [0, 0, 0, idx], and CopyDescriptors keeps words 0-2 and the border type (WARP test)
  • NaN, negative, infinite and >= 16 ResourceMinLODClamp values saturate correctly, and MSAA views keep MIN_LOD 0
  • Merges cleanly into main and with #3731
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 61 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7369197220 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3730#issuecomment-7369197220). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T05:51:56Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 1f2b9f04520fb58f4cfacd542506c5da34c3bd54 merge: clean build: ok tests: 3011 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 4 medium, 1 nit (below) performance: 60 s smoke run: 1669 → 1676 frames (100 % of main), peak commit 17577 → 18168 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 233 s there, 0 device removals, 0 crashes, 2.7 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Heap samplers from CreateSampler/CreateSamplerX now carry their real S# words 0-2 and border type, and SRV T#s carry MIN_LOD from ResourceMinLODClamp, counted from MostDetailedMip. The encoding converts back through sampler_d3d12 unchanged, the GPU test compares against native D3D12 SampleLevel, and no blocking bug was found. Open points: two features in one 742-line PR, an untested behaviour change on the HLSL path, and a smoke run at 87 % of main's frames. #### Medium 1. **Two features in one PR over the size target.** The S# encoding (desc.rs, dev_create_sampler_x) and the T# MIN_LOD (srv_tsharp_from_desc) are independent changes from #3248 and #3258: 742 lines in total, about 120 of them runtime. That is under 800, but the description gives no reason not to keep them as two PRs. 2. **HLSL implicit-LOD offset path changes without a test.** recomp/emit.rs reads MIP_FILTER from S# word 2, so heap samplers with a linear mip filter now take the two-mip blend (3 samples) instead of one Sample. The description now says so, which fixes the earlier finding, but Not tested lists it and no test covers it (XCL_DIRECT_DXIL=0). 3. **MIN_LOD convention differs from image_d3d12.** The encoder writes max(0, clamp - MostDetailedMip) (real.rs ~1910), which matches lower_image's gather4_l. But desc::image_d3d12 (desc.rs ~241) passes T# MIN_LOD straight into ResourceMinLODClamp as an absolute value, so a title-written T# with BASE_LEVEL > 0 is read one way by the lowering and the other way by view creation. This is not a regression (main wrote 0), and the description flags it as a follow-up; worth an issue. 4. **Smoke frames at 87 % of main.** 1610 -> 1407 frames shown (last presents 54 192 82 against 91 12 53). The main run is on 817eb1fc, not the merge-base 5ad98adb. That is within the 80 % limit and probably noise, but nothing explains it; the gaming-PC run should confirm. #### Nit 5. **Custom border colours become transparent black in the S#.** xcl_sampler_for_desc maps every non-standard BorderColor to type 0. Only paths that decode the S# directly see this (the PC sampler keeps the real colour). It is listed under Not tested; a comment near desc.rs ~389 would help. <details><summary>Checked and fine</summary> - Earlier finding fixed: MIN_MAG_ANISOTROPIC_MIP_POINT (0x54) and its variants now encode a point mip filter from bit 0 of the filter, with a test - Earlier finding fixed: T# MIN_LOD with MostDetailedMip > 0 is now counted from BASE_LEVEL, and a GPU test compares IMAGE_GATHER4_L with native SampleLevel for MostDetailedMip 0 and 1 - Earlier finding fixed: #3258's unrelated wildcard-count and CreateUnorderedAccessViewAt changes are dropped, and AI use names the model - The S# fields match sampler_d3d12 and the RDNA2 layout: clamp modes, aniso ratio, depth compare 0..7, filter mode, u4.8 LODs with f32::MAX saturating, s5.8 bias, and the XY, Z and mip filters - The fallback for a null desc keeps [0, 0, 0, idx], and CopyDescriptors keeps words 0-2 and the border type (WARP test) - NaN, negative, infinite and >= 16 ResourceMinLODClamp values saturate correctly, and MSAA views keep MIN_LOD 0 - Merges cleanly into main and with #3731 </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 61 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3730:upstream-pr/3730'
git switch 'upstream-pr/3730'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/3730'
git switch 'upstream-pr/3730'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3730'
git switch 'upstream-pr/3730'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3730'
git switch 'main'
git merge --squash 'upstream-pr/3730'
git switch 'main'
git merge --ff-only 'upstream-pr/3730'
git switch 'main'
git merge 'upstream-pr/3730'
git push origin 'main'
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
xcl-dev/xcl!3730
No description provided.