Skip to content

D3D12.X: ask for tiled support before making a GPU-owned texture reserved (#940) - #951

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
artor410:fix/940-reserved-depth-fallback
Nov 24, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
artor410:fix/940-reserved-depth-fallback

Conversation

@artor410

Copy link
Copy Markdown
Contributor

Part of #940. Some drivers have no TILED support for R32G8X24_TYPELESS depth, at 1 or 4 samples. Today place_on_pages still calls CreateReservedResource, gets refused (debug layer errors 738 / 723), and only then falls back to an arena. This PR asks the device first and goes to the arena directly. The result is the same arena texture, without the failed call or the debug-layer error.

 place_on_pages
   tiled = desc with 64KB_UNDEFINED_SWIZZLE
+  if !reservable(dev, tiled)   # FORMAT_SUPPORT2_TILED, + tiled MSAA quality levels if samples > 1
+    log "not reserved (no tiled support…): in an arena"; return None
   CreateReservedResource …

If a query itself fails, reservable returns yes, so creation decides as before. This does not address 1422 (first RT/DS use without Discard/Clear), 538 or 824 from the issue. Those need a separate change.

What is in it

  • vram.rs: can_reserve (pure) and reservable (device query), checked before CreateReservedResource. The arena log line now gives the reason.
  • Tests: reserved_needs_tiled_format_and_tiled_msaa (unit) and reservable_agrees_with_the_driver (GPU, or WARP if no hardware adapter). The second checks that reservable matches what CreateReservedResource actually does for R32G8X24_TYPELESS ×1/×4, R32_TYPELESS and RGBA8. Both failed to compile before the fix and pass after it.

Tested

  • hardware: NVIDIA RTX 3070 Ti, driver 32.0.16.1088, Ryzen 5 5600; rustc 1.100.0; debug
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 715 passed, 3 failed, 41 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware: no wave64)
  • The 3 failures are placed_title_textures_share_vram_and_preserve_pixels (cubemap page count under parallel tests), then transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory (poisoned VRAM_TEST_LOCK). Main 077ce40 fails the same 3, twice in a row. All 3 pass with --test-threads=1 on this branch.
  • On this card, d32s8_targets_… now logs format 19 … not reserved (no tiled support for its format or sample count): in an arena, so the new path is exercised.

Regression run
I have no retail title to run. Both runs below use the repo's own test title (tests/data/testgame + xcl_testtitle.exe, assembled as in e2e.rs). It stops at its argv check because smoke.ps1 passes no --hello, and it behaves the same on both builds.

main:

xcl-smoke v1
commit: 077ce40c3e371cf3df8c57985b1cc6b1db39e75a
gpu: NVIDIA GeForce RTX 3070 Ti
title: game
seconds: 30
exit: 0x1
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 
device removals: 0
crashes: 1
peak commit: n/a MB

PR:

xcl-smoke v1
commit: 38ea451dc69d11119bd27c334292c3093e3c0030
gpu: NVIDIA GeForce RTX 3070 Ti
title: game
seconds: 30
exit: 0x2
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 
device removals: 0
crashes: 1
peak commit: n/a MB

Not tested

  • A retail title with XCL_D3D12_DEBUG=1, which is what would confirm 738/723 are gone. The test title never creates these depth targets.
  • AMD and Intel drivers: there the query may say yes for R32G8X24, and nothing changes.

AI use

  • Claude Code (Claude Opus 5.5): found the code path, wrote the fix and the tests, ran the suites and smoke runs above.

Two-way door: one early return in front of an existing fallback. The blast radius is GPU-owned texture placement only.

🤖 Generated with Claude Code

…rved (xcl-dev#940)

R32G8X24_TYPELESS depth (and its 4x MSAA) has no TILED support on some
drivers: CreateReservedResource was refused, an error in the debug layer,
before the arena fallback. Check FORMAT_SUPPORT2_TILED and tiled MSAA
quality levels first and go to the arena directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ettehn

ettehn commented Nov 24, 2026

Copy link
Copy Markdown

Verified 38ea451 on native Windows, RTX 5070 Ti Laptop. All 9 hle::d3d12x::vram::tests passed. For the 3840×2160 format-19 depth targets, the placement log changed from the old driver refusal (0x80070057) to no tiled support for its format or sample count, followed by successful arena placement. The depth/stencil readback test also passed.

One small edge in reservable: when FORMAT_SUPPORT succeeds with TILED clear, the code still queries MSAA for multisampled textures. If that second query errors, it returns true even though the first query already ruled the format out. An early return false on a known-clear TILED bit would preserve the first result and avoid the second query for these formats. This is from code inspection; my adapter passed the driver comparison. No retail files used.

Verification assisted by OpenAI Codex (GPT-6.2 Astra).

@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@077ce40 (baseline 716 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
718 passed; 0 failed; 41 ignored   (exit 0)

Two more passing tests than the baseline; asking for tiled support before making a GPU-owned texture changes no verdict.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@oVolkra

oVolkra commented Nov 24, 2026

Copy link
Copy Markdown

Tested 38ea451 (PR head, based on 077ce40) on an RTX 3060 12 GB, driver 617.14, Ryzen 5 5600X, 15.9 GB RAM, Windows 11 10.0.26100, rustc 1.100.0, debug.

New tests: reserved_needs_tiled_format_and_tiled_msaa and reservable_agrees_with_the_driver pass in both full runs that reached them, and cargo test -p xcl --lib hle::d3d12x::vram -- --test-threads=1 gives 7 passed, 0 failed.

New path: here the driver reports no TILED support for R32G8X24_TYPELESS (1 and 4 samples; a temporary, uncommitted eprintln showed Support2 = 0x0), and d32s8_targets_… logs not reserved (no tiled support for its format or sample count): in an arena instead of (0x80070057). Main 077ce40 logs the old 0x80070057.

Whole suite (cargo test --workspace --no-fail-fast -- --test-threads=1, 2 SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware, no wave64):

Tree Run 1 Run 2 Run 3
PR 38ea451 717 passed, 1 failed, 41 ignored 713 passed, 5 failed, 41 ignored -p xcl --lib aborted: memory allocation of 3145728 bytes failed
main 077ce40 716 passed, 0 failed, 41 ignored 711 passed, 5 failed, 41 ignored –

The failures are not from the PR: main's run 2 fails the same 5 tests as the PR's run 2. They are sparse::…ensure_mapped_with_query_holes… and title_textures::gpu_mirror_upload_… with E_OUTOFMEMORY (0x8007000E), then placed_title_textures_…, transitions_apply_… and d32s8_targets_… with PoisonError from the poisoned VRAM_TEST_LOCK. This PC cannot always run the whole suite.

Not tested: scripts/smoke.ps1 and any title, --test-threads=4, AMD, the early return false suggested by ettehn.
Not explained: in 3 isolated runs of d32s8_targets_… right after a full suite, the log showed the old 0x80070057 (so reservable let it through; by design it says yes when its query fails). It did not repeat in the next 6 runs.

AI use: Claude Code, Claude Sonnet 5.5, ran the tests and wrote this report.

@eizispark

Copy link
Copy Markdown

Hardware check of 38ea451dc69d11119bd27c334292c3093e3c0030 (verified clean merge with main 6efdabc): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace -- --test-threads=4: 715 passed, 3 failed, 41 ignored (GPU tests skipped on this adapter: none); the 3 parallel failures were the known concurrent VRAM/lock-poison set (hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels and downstream PoisonErrors in hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory and hle::d3d12x::title_textures::tests::transitions_apply_when_their_list_is_submitted), each 1 passed, 0 failed solo (--exact --test-threads=1)
  • cargo test -p xcl --lib hle::d3d12x::vram::tests -- --test-threads=1: 9 passed, 0 failed (reserved_needs_tiled_format_and_tiled_msaa and reservable_agrees_with_the_driver pass; on RDNA4 the driver also reports no TILED support for R32G8X24_TYPELESS, so d32s8_targets_take_their_own_size_of_video_memory logs not reserved (no tiled support for its format or sample count): in an arena before CreateReservedResource and places all 14 3840x2160 D32S8 targets directly in arenas)

Regression run
main (6bac4b4):

xcl-smoke v1
commit: 6bac4b4419886acc940d479dcf8815d0b1804435
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1669 (PresentX 1669)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14860 MB

PR (38ea451):

xcl-smoke v1
commit: 38ea451dc69d11119bd27c334292c3093e3c0030
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1667 (PresentX 1667)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14859 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); retail run under XCL_D3D12_DEBUG=1; gameplay past the menus

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head 38ea451 onto main 9aec53d, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 715 passed, 11 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). tiled-support probe for GPU-owned textures green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@raylitebull

Copy link
Copy Markdown
Member

Looks very close — just two small items to tidy up before merge: (1) return false early when D3D12_FORMAT_SUPPORT2_TILED is unset (before running the MSAA quality-level query), and (2) refresh the xcl-smoke block so the PR description check passes.

@ivall
ivall merged commit 6828e07 into xcl-dev:main Nov 24, 2026
1 of 2 checks passed
ivall added a commit that referenced this pull request Nov 24, 2026
…he MSAA query says

Review point on #951 (ettehn, raylitebull): with TILED clear in the format's
support, the multisample quality query still ran, and if that query failed,
reservable() said yes, so CreateReservedResource was tried and refused again.
The format's answer now decides first.
@ivall

ivall commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Merged in 6828e07 – thanks. On top of it, 24d8b92 takes the review point of @ettehn and @raylitebull: with TILED clear, reservable now says no before the MSAA query, so a failing second query cannot send the texture to CreateReservedResource again. On the retail run below the new path was taken for 4 depth textures (no tiled support for its format or sample count). Tested on the merged batch (#990, #1037, #951, #1016): cargo test --workspace --no-fail-fast -- --test-threads=4: 741 passed, 0 failed, 41 ignored, no SKIPPED. Retail title, 90 s with scripted presses, against main before the batch the same way: exit 0, no crash, no device removal, 1500 frames, peak process commit 27.7 GB against 29.2 GB.

@mikebuckets171

Copy link
Copy Markdown

The inputs of this gate, measured on a macOS / D3DMetal host - and this host is exactly the shape your change guards against.

Host: MacBook Pro M5 Pro (48 GB), macOS 27.2.1, CrossOver 26 with D3DMetal (the adapter reports "AMD Compatibility Mode"), Rosetta 2. A plain D3D12 program (no XCL, no game content), cross-built with LLVM-MinGW (clang 23.1.6), run under Wine. Feature level requested 12_1, MaxSupportedFeatureLevel 0xc100.

Device (CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS), S_OK):

TiledResourcesTier 2, ResourceBindingTier 3, ResourceHeapTier 2, StandardSwizzle64KBSupported 0, MaxGPUVirtualAddressBitsPerResource 64.

So Pages::new()'s tier check passes here: on this host the "textures in title memory, tiled resources on 64 KiB pages" path is taken rather than the arena fallback - while StandardSwizzle64KBSupported reads 0.

Per-format Support2: none of these formats reports D3D12_FORMAT_SUPPORT2_TILED (0x200). All queries S_OK:

format Support1 Support2 TILED
R32G8X24_TYPELESS 0x03E051FF 0x000001C0 no
D32_FLOAT_S8X24_UINT 0x03E051FF 0x000000C0 no
D24_UNORM_S8_UINT 0x03E051FF 0x000001C0 no
D32_FLOAT 0x05E515FF 0x00000040 no
R32_FLOAT 0x03E4D1FF 0x000000C0 no
R8G8B8A8_UNORM / B8G8R8A8_UNORM / R8G8B8A8_UNORM_SRGB 0x03ECD3FF 0x000001C0 no
R16G16B16A16_FLOAT 0x03E4D3FF 0x000000C0 no
BC7_UNORM 0x018013FF 0x00000040 no

The MSAA half is the permissive part, which is what your ordering change fixes: CheckMultisampleQualityLevels returns S_OK with NumQualityLevels = 1 for every format above at 1, 2, 4 and 8 samples - including the typeless depth formats. So on this host, before this change reservable() said yes for R32G8X24_TYPELESS at 1 and 4 samples (the #940 pair) purely from the quality-level query, and CreateReservedResource then had to refuse it. With the TILED check first, reservation is declined up front and the driver call never happens - the sequence your commit message describes, on a second host.

One thing this host shows that is worth keeping in mind for the rest of the VRAM work: the two gates disagree here. The device says TiledResourcesTier 2, yet no format's Support2 carries TILED. So on D3DMetal, tier 2 does not imply any reservable format - if anything downstream treats a passing tier as "reserved textures will work", this host is a counter-example, and the format query is the one that actually decides per texture.

Not tested here: a title actually creating reserved resources or tiled MSAA textures; no native-Windows or AMD-driver comparison (I have no host where Support2 is expected to carry TILED, so I cannot show what a "yes" looks like in the same table); Support2 was read for the ten formats above, not for every format XCL can be asked for.

Host: macOS 27.2.1 (Apple silicon, M5 Pro), CrossOver 26, D3DMetal; local inference unloaded and the bottle's wineserver stopped for the run. The probe is a ~300-line plain D3D12 PE with no XCL in it and it reads no files. AI use: GPT-6 Luna wrote and ran the probe and drafted this comment; the codes, masks and tier values are from that run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants