Skip to content

D3D12.X: declare tiled texture pools texture-only - #1142

Open
Filip722 wants to merge 4 commits into
xcl-dev:mainfrom
Filip722:d3d12-texture-only-page-heaps
Open

Filip722 wants to merge 4 commits into
xcl-dev:mainfrom
Filip722:d3d12-texture-only-page-heaps

Conversation

@Filip722

@Filip722 Filip722 commented Nov 24, 2026 •

Copy link
Copy Markdown

Tiled texture pools can use texture-only heaps on vkd3d-proton. This lets the Vulkan backend choose texture-compatible memory and avoid a backing buffer. Native Windows D3D12 drivers tested in this thread reject the two-category heap flags with E_INVALIDARG. Retry with the standard all-resource heap and reuse that choice after a successful fallback.

What is in it

  • Request DENY_BUFFERS when the contiguous tile allocator creates a shared 64 MiB pool. Retry with NONE only on E_INVALIDARG and remember a successful fallback per device.
  • Preserve allocation and device errors. Both texture categories still share one pool.
  • Cover flag selection, retry and error propagation with CPU tests. A GPU test checks the flags of the resulting D3D12 heap.

Tested

  • Bazzite 44 Testing F44.20261011, kernel 7.2.9-ogc2.1.fc44.x86_64, Intel Core 7 240H, GeForce RTX 5060 Laptop GPU 8 GB, NVIDIA 615.78.08. Both workspaces were cross-built for Windows MSVC in release mode with Rust 1.98.1 and run under Proton Experimental 11.0-20261112. Both used vkd3d-proton 4522cc1a8b1347f+ with local allocation changes.
  • All 19 workspace test executables ran serially on each revision with one test thread. Main 8f5fca5 reported 1,096 passed, 6 failed, 46 ignored. PR head 0005f67 reported 1,100 passed, 6 failed, 46 ignored. The same six tests failed on both. They cover depth UAV resource flags, Opus and XMA2 voice playback, the synthetic title end-to-end run, PLS disk quota and predication state.
  • Both runs printed the same 26 SKIPPED markers across 16 tests. They cover wave64, unsupported per-lane FP16/FP32 forms, driver-cache disabling, optional heap windows and D3D12 debug layers. Those subcases are excluded from hardware coverage.
  • A separate RTX run of the VRAM tests and shared-pixel fixture reported 16 passed, 0 failed, 1 ignored benchmark, no SKIPPED markers. It covered actual tiled heap flags, both texture classes, shared pixel readback, the fallback/error tests and upstream's packed 3D mip-tail test. The native NVIDIA and AMD reports in this thread reproduced the original heap creation failure on 04938bb.

Regression run

Same offline title, fresh per-arm data and cache, cloned Proton prefixes, and a 512 MiB coherent window. Both blocks below were emitted by scripts/smoke.ps1 from clean checkouts. The startup comparison finished with 195 versus 193 frames. Wine reported zero committed process memory for both.

Main

xcl-smoke v1
commit: 8f5fca5bb9ad6e695093d75294ad2cec023bba60
gpu: NVIDIA GeForce RTX 5060 Laptop GPU
title: retail-offline
seconds: 15
exit: 0x0
frames shown: 195 (PresentX 195)
presents per 2 s (last 3): 45 37 41
device removals: 0
crashes: 0
peak commit: 0 MB

PR head

xcl-smoke v1
commit: 0005f6785a255c1b5fb8b58952d774d45524ae85
gpu: NVIDIA GeForce RTX 5060 Laptop GPU
title: retail-offline
seconds: 15
exit: 0x0
frames shown: 193 (PresentX 194)
presents per 2 s (last 3): 38 38 50
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

Native Windows on this head, sustained gameplay and a reliable Windows process-commit reading. Longer guarded trials were inconclusive on this laptop. The 25-second baseline hit the VRAM reserve. An earlier 15-second PR run recorded title exit 0 but the desktop monitor stopped report collection. A separate 12-second PR run reached its external timeout.

AI use

OpenAI Codex with GPT-6.2-Sol high investigated the heap behavior, wrote the initial change and tests, and ran the earlier checks. OpenAI Codex with GPT-6.2-astra carried the change into the contiguous allocator, preserved upstream's new packed-mip coverage during this refresh, ran the matched tests and updated this report.

Tiled texture pools map sampled and attachment textures. Disallow buffers so the host can allocate the pool without a buffer compatibility requirement.

Assisted-by: OpenAI Codex (GPT-6.2-Sol high)
@fromthemoonx

fromthemoonx commented Nov 24, 2026 •

Copy link
Copy Markdown

Rerun on the new head 0005f67 (rebased onto 8f5fca5, keeping upstream's packed-mip tests): still passes on the RTX 3060. cargo test --workspace --no-fail-fast -- --test-threads=4: 1106 passed, 0 failed, 46 ignored. Merged onto main cbc296a (no conflicts): 1158 passed, 0 failed, 46 ignored. -- d3d12x::vram placed_title_textures: 16 passed, 10 of 10 runs. The e2e debug-layer messages are main's plus the same 2× id 631 for the first CreateHeap attempt, as described below. The report below is for 2331125.


Rerun on the new head 2331125: the fallback works on native Windows (RTX 3060). The full suite passes, and so do the four tests that failed on 04938bb.

Tested

  • NVIDIA GeForce RTX 3060 12 GB, driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300); rustc 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug
  • Exact head 23311256c558fd8d7b1f2e023258428d4418a90c: cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 979 passed, 0 failed, 45 ignored. Merged onto current main 20cf130 (no conflict): 980 passed, 0 failed, 45 ignored. SKIPPED in both: 21 no wave64 / per-lane refusals in gpu::recomp, and heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.
  • cargo test -p xcl --lib -- d3d12x::vram placed_title_textures: 15 passed, 0 failed, 1 ignored, 10 of 10 runs. This includes tiled_texture_pool_allows_both_texture_classes, placed_title_textures_share_vram_and_preserve_pixels and the three new texture_page_pool_* tests. The log shows the refusal and then the retry: CreateHeap(0x4000000 bytes, type 1, alignment 0x0, flags 0x4) refused (0x80070057).
  • The e2e test under the D3D12 debug layer (test_title_draws_with_a_root_signature_under_the_debug_layer) passes. Compared with main, the merged tree logs two more errors, the same one twice, for the first attempt:
    D3D12 debug layer (error, id 631): ID3D12Device::CreateHeap: D3D12_HEAP_FLAGS has invalid flag combinations set. The following flags may not all be set simultaneously. Exactly one must be left unset, or all may be left unset when the adapter supports D3D12_RESOURCE_HEAP_TIER_2 or creating a heap in conjunction with D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER: [...] D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES = 0, D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES = 0, and D3D12_HEAP_FLAG_DENY_BUFFERS = 1.
    
    So D3D12's own rules forbid DENY_BUFFERS on its own: exactly one of the three DENY flags must stay unset (the ALLOW_ONLY_* combinations), or none may be set. The refusal is not driver-specific; native Windows adapters should all take the fallback (once per device), and debug-layer runs will show this error. The other messages match main (3× id 93, 1× id 1046, 1× warning id 820).
  • Unrelated to this PR: run as one filtered set (-- vram texture_page_pool placed_title_textures), gpu::recomp::tests::gpu_sparse_vram_descriptors_buffers_and_xmem fails (submit 1 lane 0 mismatch, 0 vs 1077). It fails the same way on main 20cf130, 3 of 3 (Tests: gpu_sparse_vram_descriptors_buffers_and_xmem fails beside the title-texture tests since #288 #343).

Not tested

  • AMD / Intel on native Windows, release build, a title (no Xbox title here).

AI use

  • Claude Code (Claude Opus 5.5) ran the builds and tests on the machine above and wrote this report from the output.
Earlier run, on 04938bb

Native Windows / NVIDIA run, since Not tested lists native Windows: the new pool heap is refused here, and the title-texture tests fail.

Tested

  • NVIDIA GeForce RTX 3060 12 GB, driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974), Graphics Tools installed; rustc 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug
  • Exact head 04938bba2179c8cbfad2a09b920c1632d90ea116, which is on current main 47efa2e: cargo test --workspace --no-fail-fast -- --test-threads=4: 738 passed, 4 failed, 41 ignored
    • vram::tests::tiled_texture_pool_allows_both_texture_classes_and_denies_buffers: panics at vram.rs:740, allocate a tiled texture pool, because take_tile returns None
    • title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels: expected shared vram::Pages texture at 0x700000000 (title_textures.rs:1720)
    • transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory: PoisonError from the test above. Alone, d32s8_targets… passes.
  • Each of the first two fails the same way 3 times out of 3 when run alone (--exact). XCL's log names the cause:
    D3D12.X: CreateHeap(0x4000000 bytes, type 1, alignment 0x0, flags 0x4) refused (0x80070057); as type 1, alignment 0x0, flags 0x4: 0x80070057
    D3D12.X: no video memory for more pages of title textures (The parameter is incorrect. (0x80070057))
    
    So native D3D12 on this driver answers E_INVALIDARG to a D3D12_HEAP_FLAG_DENY_BUFFERS heap for this pool, where vkd3d-proton accepted it.
  • On main, and on every other PR tree I ran today on this machine, placed_title_textures_share_vram_and_preserve_pixels and the rest pass (e.g. 742 of 742 on main + PE loader: thread callbacks wait for a DLL to be initialised #1119), so the four failures come from this change.

Not tested

  • AMD / Intel on native Windows; whether the refusal is specific to NVIDIA's driver or a runtime rule for this flag combination (I didn't run it under the debug layer, because the test creates its own device first).

AI use

  • Claude Code (Claude Opus 5.5) ran the build and tests on the machine above and wrote this report from the output and XCL's log.

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification on current main 384f7f7 (branch already contains it — clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti (driver current, WDDM); Rust stable MSVC, debug.

The PR's own new test fails on this hardware, and it takes an existing GPU test down with it:

  • cargo test -p xcl --lib vram: 10 passed, 2 failed:
    • tiled_texture_pool_allows_both_texture_classes_and_denies_buffers (new) — pages.take_tile() fails: CreateHeap with D3D12_HEAP_FLAG_DENY_BUFFERS returns E_INVALIDARG (0x80070057) → "no video memory for more pages of title textures".
    • placed_title_textures_share_vram_and_preserve_pixels (existing) — collateral: it needs the same tiled pool.

So on this driver the texture-only heap flag is rejected outright. If the flag is required for correctness on some titles, it probably needs a fallback (try DENY_BUFFERS, on E_INVALIDARG retry with NONE) — or confirmation that other drivers accept it. As-is the PR breaks tiled-texture allocation on at least this RTX 3060 Ti.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@bjarngard

Copy link
Copy Markdown

The AMD driver refuses the heap too, so this does not look NVIDIA-specific (re the open question in the report above).

Tested (head 04938bb, native Windows)

  • AMD Radeon(TM) Graphics (Ryzen 9 9950X iGPU, RDNA2), driver 32.0.21043.5001, and RTX 5080, driver 621.24; Windows 11 build 26300; Rust 1.99.1 MSVC; debug
  • Full suite, each adapter (XCL_ADAPTER=radeon / nvidia): 738 passed, 4 failed, 41 ignored – the same four tests as above
  • Alone (--exact), on both adapters: tiled_texture_pool_allows_both_texture_classes_and_denies_buffers fails at vram.rs:740 and placed_title_textures_share_vram_and_preserve_pixels at title_textures.rs:1720, with the same log line on each driver:
    D3D12.X: CreateHeap(0x4000000 bytes, type 1, alignment 0x0, flags 0x4) refused (0x80070057); as type 1, alignment 0x0, flags 0x4: 0x80070057
    
  • On the merge base 47efa2e, the three pre-existing tests pass on both adapters.

Not tested: the D3D12 debug layer, so the runtime's own message for the refusal is not captured.

AI use: the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…vall#1142, ivall#1150, ivall#1156, ivall#1182, ivall#1191, ivall#1195, ivall#1221

Integrate 10 high-impact open upstream PRs on top of upstream/main (930e8b4):
- ivall#1182: share video memory across render targets aliased onto one physical page (~1.85-2.1 GB VRAM saved)
- ivall#1142: declare tiled texture pools texture-only (D3D12_HEAP_FLAG_DENY_BUFFERS) for vkd3d-proton
- ivall#1097: report process memory under Wine via PagefileUsage fallback
- ivall#1078: bound BCPack record scratch memory to 2 KiB stack batches
- ivall#1150: convert console clear-value formats in CreatePlacedResource
- ivall#1156: release the interface returned by QueryInterface in class_for
- ivall#1139: check pointer alignment in is_adopted before dereferencing
- ivall#1195: skip ExecuteIndirect dispatch of untranslated console compute pipelines
- ivall#1191: VirtualProtect commits lazy pages in its range first
- ivall#1221: unmark lazy away mappings in FreeTitlePhysicalPages

Assisted-by: Antigravity (Google DeepMind)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…ps (ivall#594)

Re-apply XCL_PAGE_BUDGET_MB LRU texture eviction (ivall#640) and fenced unmaps (ivall#594) on top of upstream/main (930e8b4) + ivall#1182/ivall#1142/ivall#800, using real::create_raw_fence for vram queue fences under Wine.

Assisted-by: Antigravity (Google DeepMind)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…ll#1221, and updated Linux PRs

Update fork README for upstream/main 930e8b4 (BCPack BC1-BC7, XCL_PSO_WAIT_MS, low-VA ASLR < 2^40, alloc_pool, sparse tile parking/pool reuse, direct page moves, write-watch merge), newly integrated PRs (ivall#1078, ivall#1097, ivall#1139, ivall#1142, ivall#1150, ivall#1156, ivall#1182, ivall#1191, ivall#1195, ivall#1221), and updated Linux PRs (ivall#867, ivall#871, ivall#877).

Assisted-by: Antigravity (Google DeepMind)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
Apply the texture-only heap preference and per-device E_INVALIDARG fallback when the contiguous tile pool allocates its next heap.

Assisted-by: OpenAI Codex (GPT-6.2-astra)
@Filip722

Copy link
Copy Markdown
Author

Tested the runtime change from 2331125 during late Series X loading on an RTX 5060 Laptop (8 GiB), Bazzite 44, NVIDIA 615.78.08 and Proton Experimental 11.0-20261112. Both runs used main 689f2db with #541 and #1124, matching initial caches, input and memory limits. The second changed only the texture heap allocation policy from this PR. The local vkd3d-proton build at 4522cc1 also has an experimental policy that can place eligible texture pools in non-local memory.

Allocation trace Before With this change
64 MiB default heaps with flags NONE 144 0
64 MiB default heaps with DENY_BUFFERS 0 146
Experimental non-local placement decisions 0 97

The control logged an access violation inside Vulkan memory allocation immediately after an unflagged 64 MiB heap request and exited. The patched run reached the external timeout with loading artwork still on screen. It recorded 2,877 presents, 82,401 storage requests, 148 storage failures, and no presents in the last 18 two-second samples. Neither run logged a device removal or kernel Xid. This single pair confirms the heap choice under streaming load. Gameplay and native Windows fallback remain unverified on this machine.

OpenAI Codex assisted with the matched runs and trace analysis.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent native Windows check of exact PR head 0005f6785a255c1b5fb8b58952d774d45524ae85 on an AMD laptop.

Tested

  • Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver 30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5; debug test build.
  • cargo test --locked -p xcl --lib -j 2 texture_page_pool -- --test-threads=1 --show-output: 3 passed, 0 failed, 0 ignored, 0 SKIPPED. These are the heap flag selection, fallback, and error-propagation unit tests.
  • xcl-c507a8c30a120d13.exe --exact hle::d3d12x::vram::tests::tiled_texture_pool_allows_both_texture_classes --show-output: 1 passed, 0 failed, 0 ignored, 0 SKIPPED with XCL_REQUIRE_GPU=wave64. It reached native D3D12 tiled-page setup and asserted the created heap's resource-category flags. I used a temporary Windows high-performance per-app preference for that exact-head test executable and restored the previous setting afterward. A separate D3D12CreateDevice(None) adapter-LUID probe under the same preference selected the RX 6800M (00000000:00014d72); without the preference, Windows selected the integrated AMD GPU. The test itself does not print its device LUID, so adapter attribution follows from the per-app setting and the matching device-creation call.

I did not run the full GPU workspace suite or a paired title smoke on this PR. The focused GPU test confirms heap creation and flag assertions; it does not measure sustained texture streaming or identify in its output whether the fallback was used.

AI-assisted testing, adapter-selection verification, and report drafting with OpenAI Codex (GPT-6). No game data was used.

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.

5 participants