D3D12.X: clamp translated sampler LOD bias #1374
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1384"
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 hajduzsolt on 2026-11-24T15:28:16Z.
What is in it
Tested
cargo test -p xcl --lib sampler_lod_bias_stays_within_d3d12_limits: 1 passed.cargo test --workspace -- --test-threads=4 --nocapture: 752 passed, 0 failed, 41 ignored. The reported passes include tests that returned early.test_title_draws_with_a_root_signature_under_the_debug_layeranduploads_start_from_each_subresources_state, because the D3D12 debug layer is unavailable.Regression run
main:
PR:
Not tested
AI use
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:34:40Z.
Full-suite run, since this PR has no test report yet. Tested exact head
e15ddb2(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.sampler_lod_bias_stays_within_d3d12_limits.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:55:28Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
Imported from ivall/xcl. Originally posted by afpruivo on 2026-11-26T12:18:17Z.
Tested
e15ddb2on an RTX 3090, as part of a batch merged ontomainb49be18: no failures, no regression.e15ddb2, #15946ea563b, #162139788e8, #165369f70c1. They touch no common file and merged cleanly ontob49be18(local commit1e3fb07). Check posted in #1607: B21, https://github.com/xcl-dev/xcl/issues/1607#issuecomment-7191828681.cargo test --workspace -- --test-threads=4(debug): 1,439 passed, 0 failed, 47 ignored. 26SKIPPEDGPU tests, mostly no wave64 on this card; they are not coverage.scripts/smoke.ps1, 60 s, retail 1.0.2.1 (title: 3c290c16), release. Peak commit was lower on the batch.mainb49be181e3fb07sampler_d3d12, so comparison and plain samplers both get it, and the new test covers the edges on both sides (0x2000–0x2fffto the minimum,0x0ffe–0x1fffto the maximum).Not tested: a run that reaches this change on purpose (the smoke title only shows that nothing regresses); AMD.
AI use: Claude Code (Claude Opus 5.5) ran the commands on my machine and drafted this. Checked by me before posting.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:39:06Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T17:39:31Z.
merge-check claim
head:
e15ddb2dffImported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T17:45:32Z.
merge-check
base:
9dfbe3ea66head:
e15ddb2dffmerge: clean (trial merge 702a7b490165a81f303f1434401242781ae2f84a; git diff --check clean; +19/-1 in crates/xcl/src/gpu/desc.rs)
build: cargo build --workspace -> ok (pre-existing warnings only, none from the PR's lines)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored (base + 1 new test); SKIPPED: 27, the standard set for this card (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"). Failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 — pre-existing on this machine, identical on base
9dfbe3ea. The new sampler_lod_bias_stays_within_d3d12_limits passes with the change and fails on a clean base worktree with only the test added (raw 0x2000: -32.0 unclamped vs the D3D12 minimum of -16.0).review: read the whole diff. The console sampler word encodes MipLODBias as a 14-bit two's-complement 5.8 fixed-point value (s5_8, desc.rs:310: sign bit 13, five integer bits, eight fraction bits, / 256), whose range is -32.0 .. 31.996 — outside D3D12's D3D12_MIP_LOD_BIAS_MIN/MAX (±16.0), which CreateSampler requires. The one-line .clamp() brings the translated descriptor into spec; it sits in the shared struct literal, so comparison and plain samplers both get it, and in-range values pass through unchanged (the existing test's -1.5 is untouched). I verified every vector of the new test by hand against that encoding: 0x2000/0x2fff clamp to the minimum (-32.0 and -16.0039), 0x3000 is exactly -16.0 and 0x3fff is -1/256 unclamped, 0x0ffd = 4093/256 passes through, 0x0ffe/0x1fff (15.992 and 31.996) clamp to the maximum; the loop runs each raw value for both comparison and plain samplers. Thread: futurepro62's full workspace runs on an RTX 5070 Ti (752/0/41) and the RDNA2 iGPU of a 9800X3D (752/0/41) pass at this head with the new test running; DavidM1911's RTX 3060 Ti lib run is clean; afpruivo batch-ran this PR with three others on an RTX 3090 (1,439/0/47) plus a 60 s retail xcl-smoke (1,627 frames, 15,516 MB peak commit vs 1,649 / 17,023 MB on main, no crashes) and read the diff to confirm the clamp reaches both sampler kinds — the smoke pair is on the batch commit, which touches no common file with this one. No duplicates; one file, no unsafe, no new dependencies, no stop-criteria files.
performance: none; one f32 clamp in the sampler descriptor translation.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Imported from ivall/xcl. Originally posted by coolpersonnn on 2026-11-30T17:58:44Z.
merge-check claim
head:
e15ddb2dffImported from ivall/xcl. Originally posted by coolpersonnn on 2026-11-30T18:05:35Z.
merge-check
base:
9dfbe3ea66head:
e15ddb2dffmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored (25 SKIPPED: 22 no wave64, 2 no heap windows, 1 cannot disable the driver cache); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 (fails identically on base
9dfbe3eaalone); new test gpu::desc::tests::sampler_lod_bias_stays_within_d3d12_limits passedreview: none. Read the full diff (+19/-1 in crates/xcl/src/gpu/desc.rs). In sampler_d3d12, s5_8(w[2] & 0x3FFF) decodes a 14-bit signed 5.8 fixed-point value in [-32.0, 31.99609375], which is always finite and can exceed D3D12's CreateSampler limits [D3D12_MIP_LOD_BIAS_MIN (-16.0), D3D12_MIP_LOD_BIAS_MAX (15.99)]. Clamping in the shared D3D12_SAMPLER_DESC literal covers both normal and comparison samplers without altering in-range values. The new unit test covers both clamped extrema, adjacent fixed-point boundaries (0x2fff/0x3000, 0x0ffd/0x0ffe), and both comparison modes; without the clamp, 0x2000 decodes to -32.0 and fails the test. Scope is minimal; no duplicates found in open/merged PRs or #1607.
performance: none (reasoned: a single f32 clamp during sampler descriptor translation; no extra allocations or hot-path cost)
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5090 (driver 32.0.16.2101), AMD Ryzen 9 9950X3D, Windows 11 Pro build 26300, Rust 1.100.0 / T3 Code (Antigravity), Gemini 4 Neon (Medium)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:36:14Z.
Triage (#1607) – head
e15ddb2No open or merged PR clamps
MipLODBiasindesc::sampler_d3d12; main still passess5_8(w[2] & 0x3FFF)unclamped (range -32..32, D3D12 allows -16..15.99). #1885 and #3248 change other sampler fields.No problems found in the diff; the test covers both ends of the range for both sampler kinds.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.