D3D12.X: force MipLevels=1 and skip mip arithmetic for MSAA descriptors in image_d3d12 #1329
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1339"
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 b3IKK on 2026-11-24T14:59:18Z.
valid_image_shapereturns early forD2MsaaandD2MsaaArraywithout validatingmax_miporlast_level(which encodeslog2(samples)for MSAA).image_d3d12then unconditionally computedt.max_mip + 1andt.last_level.saturating_sub(t.base_level) + 1, overflowing onu32::MAXand settingMipLevels > 1for 1x MSAA textures (last_level == 0,samples == 1).This sets
mips = 1andlevels = 1directly whenevert.tyisD2MsaaorD2MsaaArray.What is in it
crates/xcl/src/gpu/desc.rs: forceMipLevels = 1and skipmax_mip + 1/last_levelmip-level arithmetic forD2Msaa/D2MsaaArrayinimage_d3d12; add unit testmsaa_resources_always_have_one_mip_and_never_overflow(verified failing before the fix).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib msaa_resources_always_have_one_mip_and_never_overflow: 1 passed, 0 failed (failed before the fix withMipLevels == 16)Regression run
main:
PR:
Not tested
AI use
desc.rs, wrote the fix and unit test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T15:05:50Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 708 passed, 0 failed, 21 ignored.Thanks!
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:05:53Z.
Full-suite run, since this PR has no test report yet. Tested exact head
ad9c154(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.msaa_resources_always_have_one_mip_and_never_overflow.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-24T15:56:07Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T09:54:12Z.
Independent Windows test on ad9c154. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC.
cargo build --workspace --offline --locked -j 4passed.cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4finished with 752 passed, 0 failed, 41 ignored. The pass count includes two wave64 runtime skips.With the D3D12 debug layer enabled,
cargo test --offline --locked -j 4 -p xcl --lib local_msaa_descriptors_create_native_resources -- --nocapture --test-threads=1passed 1 of 1 without skips in a scratch fixture. Both 1× cases created native resources with one mip, and a regular 2D control kept three mips. Both 4× cases, withmax_mip = u32::MAX, created one-mip native resources and valid shader-resource views after the fixture addedALLOW_RENDER_TARGET. Passing the unmodified 4× resource descriptors directly producedE_INVALIDARGand debug message 599, which requires a render-target or depth-stencil flag for multisampled resources. All five successful resource and view cases emitted zero debug messages. This was synthetic descriptor and resource creation coverage.AI use: Codex (GPT-6, exact variant unspecified) wrote the scratch fixture, ran the tests and drafted this report.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:19:37Z.
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 BBareth on 2026-11-30T13:11:39Z.
merge-check claim
head:
ad9c154d77Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T13:22:11Z.
merge-check
base:
9dfbe3ea66head:
ad9c154d77merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on the base alone too (base: 2885 passed, 1 failed, 51 ignored, 28 SKIPPED lines). 28 SKIPPED lines, as on the base. The new test
gpu::desc::tests::msaa_resources_always_have_one_mip_and_never_overflowpassed, as did the existing desc tests. Note: the base failure above is in the MSAA tests too, and this PR does not change it (it fails the same way with and without the PR).review: no blocking finding; one file, every hunk read. For
D2Msaa/D2MsaaArrayimagesimage_d3d12now sets the mip count to 1 from the image type and no longer fromsamples > 1, and the view's level count to 1. Two cases change: an MSAA-typed image with one sample (last_level0) gotmax_mip + 1mip levels before and gets 1 now; andmax_mip + 1/ the level arithmetic are no longer evaluated for MSAA images, wherelast_levelholds the sample count, somax_mip = u32::MAXno longer overflows (a panic in debug builds). Non-MSAA images take the same path as before. Not tested by me: a title that binds a one-sample MSAA-typed image.performance: none.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T13:46:41Z.
merge-check
base:
9dfbe3ea66head:
ad9c154d77merge: clean
build: cargo build --workspace -> ok (also
cargo build --release -p xcl)tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing:
gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails the same way on the base alone (2885 passed, 1 failed, 51 ignored; #3513 fixes it). The new testgpu::desc::tests::msaa_resources_always_have_one_mip_and_never_overflowran and passed. With the two lines put back to main (mips = t.max_mip + 1andMipLevels: if samples > 1 { 1 } else { mips }), it fails atdesc.rs:597(left 16, right 1); file restored after.review: one file, whole diff read. What this adds to the first check: no path a title reaches today runs the changed lines for an MSAA image. In production
image_d3d12is called only fromtexture::create(texture.rs:142), which first callssubresourcesand soplacement, andplacementreturns an error forD2Msaa/D2MsaaArray(texture.rs:61-63, "not yet (MSAA)"). The other callers are tests (real.rs:10456,real.rs:10492,recomp/tests.rs:5565). The overflow case also needsmax_miporlast_levelnearu32::MAX, butimage()decodes both from 4-bit fields (desc.rs:68-69), so only a hand-builtImagereaches it. The change is still correct and consistent:levelsis not used by the MSAA view arms (desc.rs:279-283), and a one-sample MSAA image now gets one mip. A note for whoever enables MSAA upload later:tiling::image_chainstill buildsmax_mip + 1levels (tiling.rs:927), so a one-sample MSAA image withmax_mip > 0would give more subresources thanMipLevelsand failvalidate_subresource_count(texture.rs:185); todayplacementstops it first. Overlap: #540 adds D3D12 tests ofimage_d3d12that includeD2Msaa; I did not check whether its expectations match the new mip count.performance:
scripts/smoke.ps1, 60 s of a retail title, release, after one warm-up run of the base: 1667 frames and 17425 MB peak commit against 1659 frames and 17322 MB on the base (warm-up: 1689, 17197 MB). No device removal, no crash. The changed path is not reached, so this only shows no regression elsewhere.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite, tests and smoke, reviewed the diff against the merged source and wrote this)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:28:27Z.
Triage (#1607) – head
ad9c154No open or merged PR makes this change. On main,
image_d3d12still computest.max_mip + 1andlast_level - base_level + 1for MSAA images.valid_image_shapereturns early for MSAA without boundingmax_mip, so a largemax_mipoverflows, and a 1-sample MSAA image getsMipLevels = max_mip + 1. The new test exercises both cases. No problems found in the diff.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.