Skip to content

D3D12.X: XCL_TEXTURE_LEVEL_PAGES=1 gives a sampled texture's levels their pages with their texels - #2306

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
imnicho:texture-level-pages
Nov 25, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
imnicho:texture-level-pages

Conversation

@imnicho

@imnicho imnicho commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

With XCL_TEXTURE_LEVEL_PAGES=1 (off by default) a sampled texture's levels get their video memory pages when an upload first has texels for them, not all at once when the title places the texture. Part of #1773 (point 2 there, the sampled textures' half of the "target pages").

A retail title places its streamed textures at full size and has memory behind their levels only as it loads them, the small ones first. vram::place_pages gives a sampled texture a 64 KiB page of video memory for every tile at once, so most of those pages hold nothing: when that title's world is set up, 80 690 pages lie under such textures and 6 809 of them (8 %) are committed, on my card. @shortside measured the same on a Mac and has a branch for native hosts, where each texture is a reserved resource of its own (#1773 (comment)); this is the idea for the shared-pages path Windows uses, which that comment left open. Measurements and the plan: #1773 (comment).

What is in it

  • crates/xcl/src/hle/d3d12x/vram.rs: with the switch on, place_pages places a sampled 2D texture of one slice with no tile mapped. Levels keeps its tiling (GetResourceTiling) as groups of tiles: one for each level with tiles of its own, one for the packed levels. map_levels gives a group its pages - the same pages by address as before (bind_range, what bind does for a range of the tiles; map takes the subresource the range starts at), so textures placed at one address still share them. A texture unmapped as a whole (unmap_superseded) starts again with no level mapped. A tiling that does not add up to the resource's tiles, arrays, volumes, multisampled and GPU-owned textures are placed as before.
  • crates/xcl/src/hle/d3d12x/title_textures.rs: before an upload's copies, the levels of the texture that have texels (a byte that is not zero in what goes up) get their pages; the upload queue waits for the mapping (vram::before_execute, already called there). A level of zeros keeps none: it reads as zeros either way, and its copy goes to tiles that are not mapped, which drops it (tiled resources tier 2, the tier the shared pages already need). A texture the GPU writes (note_gpu_write: CopyTextureRegion, CopyResource, the resolves) gets all its pages at that call, and so does one of those when it is uncovered again.
  • Tests: the_tiles_of_a_texture_are_grouped_by_its_levels (the grouping; tilings that do not add up), and a_placed_texture_gets_the_pages_of_a_level_with_its_texels on the GPU: a 1024x1024 texture of 11 levels whose memory has every level but the largest - no page before the first upload, then pages for those levels only (counted against the driver's tiling), their texels right, zeros read from the level without pages; with memory under the largest level a texture placed there again gets that level's pages, the others shared, and holds all of it; a texture the GPU writes gets the pages of all its levels.
  • 405 lines added, 12 changed; 162 of them are the tests. Without the switch: one cached check where a sampled texture is placed, one per uploaded texture and one per GPU write into one.
  • Not done: a level the title unloads keeps its pages until the texture goes. A level that gets its pages for a GPU write holds what the pages' last user left where the GPU does not write (as a texture's pages do today before its first upload).

Tested

without with without with
texture pages (target pages) at the end 9 227 MB 4 949 MB 9 483 MB 4 835 MB
local video memory, peak (budget 15.1 GB) 20 382 MB 19 156 MB 22 003 MB 19 382 MB
draws after the world's set-up 26 535 114 436 42 677 215 154
end 300 s reached 0x887a0006 136 s after the set-up 0x887a0005 58 s after it 0x887a0006 160 s after it
  • In the minute the world is set up local video memory was 17.3 GB without and 12.9 GB with (one run each).
  • The logo and the loading artwork are right with the switch (frame captures); the world is grey on that tree either way (Memory: more than 4 memory windows once #680 lands, so title memory stops falling back to plain memory #697). No upload failed and no texture warning in five runs with the switch.
  • It does not keep this card's device: the texture pages are halved, the rest of the video memory is other things (the issue comment has the parts), and the runs still end over the budget.

Reports by others on this head (3ea5edc, in the comments below)

  • RTX 3080 Ti (@thehollowedone): the whole suite 1252 passed, 0 failed, 46 ignored; the GPU fixture also under D3D12 validation and GPU-based validation, no error.
  • RX 7900 XT on Linux / RADV over Wine (@SlopTart): both new tests pass, the gpu_ tests as on that machine's main with the switch off and on.
  • Radeon integrated graphics, driver 32.0.21042.62 (@nnonno91): both new tests pass.
  • RTX 4090, the retail title on this head (@minimalhipster990): target pages 8 828 MiB without the switch and 4 342 MiB with it at the same loading artwork, local video memory 12 918 and 8 660 MiB.
  • RX 6800M, driver 30.0.13002.13003 (@luckyteagirl): the GPU fixture fails where the second texture's level 0 is read back - part of it is zero. Not explained yet; a control run is asked for in the comments. Not verified on that adapter.

Regression run (default settings: the switch is off)

main:

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1323 (PresentX 1324)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14064 MB

PR (this PR's head commit):

xcl-smoke v1
commit: 3ea5edc1c941be6350d66b45e1e5c91f72158c18
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1341 (PresentX 1341)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14105 MB

A second round of the same two binaries: main 1134 frames, PR 1323.

Not tested

  • The title's world on this head itself: not run. The world runs above are on the local tree named, whose upload path differs as said.
  • Whether a world's textures look right with the switch: the world is grey on that tree for another reason.
  • By me: AMD and Intel GPUs, native 64-lane waves, Linux / Wine (see the reports above, one of them a failure on an RX 6800M); a driver whose tiling does not group this way (the texture is then placed as before).
  • Other titles.

AI use

  • Claude Code with Claude Fable 5.2: wrote the change and its tests, ran the suite and the title runs on the machine named, and wrote this description.

🤖 Generated with Claude Code

…heir pages with their texels

A retail title places its streamed textures at full size and has memory behind
their levels only as it loads them, the small ones first. vram::place_pages
gives a sampled texture a 64 KiB page of video memory for every tile at once:
when that title's world is set up about 92 % of those pages have nothing behind
them (80 690 pages, 6 809 committed, on one card).

With the switch (off by default) a sampled 2D texture of one slice is placed
with no tile mapped. Its tiling is kept as groups of tiles, one for each level
with tiles of its own and one for the packed levels, and a group gets its pages
before the first upload that has texels for it - the same pages by address as
before, so textures placed at one address still share them. A texture the GPU
writes gets all its pages.

Part of xcl-dev#1773.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thehollowedone

Copy link
Copy Markdown

Independent Windows check of 3ea5edc. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11.

  • On the clean head, cargo build --offline --locked --workspace -j 6 passed. cargo test --offline --locked --workspace -j 6 --no-fail-fast -- --test-threads=4 --nocapture finished with 1,252 passed, 0 failed, 46 ignored. The pass count includes 25 runtime skips. The two new tests also passed in isolation with zero skips.
  • I reran the stock 11-mip texture fixture twice with test-only instrumentation, using standard D3D12 validation and then GPU-based validation. Each run passed 1/1 with zero skips, zero D3D12 errors or warnings, and a healthy device. The unmapped top mip read back as zero, it read back the expected texels after mapping, and the two resources at the same address shared the expected pages. The production code was unchanged in these runs.

Synthetic fixtures only. Retail world-load timing and visual output were outside these runs.

AI-assisted. Codex (GPT-6, exact variant unavailable) added the temporary test instrumentation, ran the tests, and drafted this report.

@SlopTart

Copy link
Copy Markdown

Linux/RADV (RDNA3) verification over Wine: green with the switch on and off, one single-shot flake to note.

Tested: origin/main 379725ae + PR head 3ea5edc1 (merge 4fc3b501, no conflicts). Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, official MS DXC (binaries 2026-09-29). gpu_ suite = cargo test --release --locked --target x86_64-pc-windows-gnu -p xcl --lib -- gpu_.

  • Switch off (default), --test-threads=2: 142 passed / 3 failed / 1 ignored. The 3 are this rig's known baseline (fuzz seed 1003 of DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed). Both tests the PR adds pass.
  • XCL_TEXTURE_LEVEL_PAGES=1, run 1, --test-threads=2: 141 / 4: one extra, gpu_geometry_wave32_prefix_count_over_a_mask.
  • Same flag, run 2, --test-threads=2: 142 / 3, the extra one gone.
  • Same flag, --test-threads=1: 142 / 3.
  • That test solo, --exact --test-threads=1 with the flag set: green 3 of 3.

So on this rig the change is clean: no deterministic failure with the switch on. The one gpu_geometry_wave32_prefix_count_over_a_mask red appears once in three full-suite runs at --test-threads=2 with the flag on and never again; on a rig where geometry/wave tests are a known flake family, I would not read that as caused by this change, but the count is reported so the record is complete.

Not tested: Windows hosts; the streamed-texture retail measurements in the PR body (no title data run here, counts only).

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

@nnonno91

Copy link
Copy Markdown

Independent native Windows Radeon iGPU check of 3ea5edc1c941be6350d66b45e1e5c91f72158c18.

Tested

  • AMD Radeon(TM) Graphics, driver 32.0.21042.62, Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC, unoptimized test profile.
  • cargo test --locked -p xcl --lib the_tiles_of_a_texture_are_grouped_by_its_levels -- --nocapture --test-threads=1 gave 1 passed, 0 failed on the unchanged head.
  • The GPU fixture normally uses DXGI adapter index 0. I temporarily changed only its adapter lookup and printed the selected Radeon. cargo test --locked -p xcl --lib a_placed_texture_gets_the_pages_of_a_level_with_its_texels -- --nocapture --test-threads=1 gave 1 passed, 0 failed per run, with XCL_TEXTURE_LEVEL_PAGES=1 and 0 in separate processes. The fixture explicitly enables lazy pages internally, so both runs exercise that path.
  • The fixture verified the level page counts, uploaded texels, zeros from the unmapped top level, shared pages after re-placement, and allocation for a GPU-written texture. No ignores or skips in any run. The test-only adapter edit was restored.

Not tested

A forced eager-page GPU control, retail gameplay, memory savings in a title, and the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) adapted the adapter selection for the test, ran the checks and wrote this report.

@minimalhipster990

minimalhipster990 commented Nov 25, 2026 •

Copy link
Copy Markdown

RTX 4090, clean PR head 3ea5edc1c941be6350d66b45e1e5c91f72158c18. With XCL_TEXTURE_LEVEL_PAGES=1, target pages fell by 50.8% at the same loading artwork. Neither run reached a visible gameplay HUD or recognizable 3D world within 300 s.

Measurement Default (off) On
Target pages at the matched artwork 8,828 MiB 4,342 MiB
Local video memory at that artwork 12,918 MiB 8,660 MiB
Process commit at that artwork 26,618 MiB 23,701 MiB
Target pages at 120 s, after presentations had stopped 9,816 MiB 4,458 MiB
Local video memory at 120 s 14,431 MiB 8,797 MiB
Available Windows system commit near 120 s 10.47 GiB 14.61 GiB
Last 2 s activity interval with any presents ended at 100.061 s 90.039 s
Total PresentX calls at cutoff 1,336 1,239
Peak sampled process private memory 30.00 GiB 25.41 GiB

The matched images were frames 1247 at 86.623 s (off) and 1223 at 86.963 s (on). Memory comes from the nearest XCL activity samples at 86.054 and 86.037 s. Their artwork looks consistent in both readbacks. With the switch on, XCL explicitly logged 17,299 textures representing 2,135 MiB with 940 MiB backed at 65.389 s.

End of run. Both reached the configured cutoff with exit code 0, a null crash field and no logged D3D12 device removal. After the last interval with any presents, the logs recorded 52 large compute PSO builds finishing with the switch off, and 63 compute plus 2 graphics builds with it on. Pipeline builds were still progressing near cutoff. The logs do not identify which build, if any, held up the presenter.

Setup. RTX 4090 24 GB, NVIDIA 621.40, Ryzen 7 5800X3D, 32 GB RAM, Windows 11 build 26300. Retail 1.0.2.1, Series X. Built once with cargo build --locked --release -p xcl --bin xcl, Rust 1.99.1 MSVC. Ran xcl run <title> with XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_ACTIVITY=1 XCL_NETWORK=0 XCL_FRAME_DUMP=12 XCL_RUN_SECONDS=300. Identical scripted input and separate, identical starting copies of an already configured title profile and a 6,432-file XCL cache from earlier #2057 runs. Some large pipeline builds still lacked driver blobs on this head. Default ran first. NVIDIA’s internal cache was uncontrolled. An initial setup-only attempt with a blank profile was excluded from the pair.

Not tested: post-HUD stability, texture correctness in the rendered world, or behavior after 300 s. One run per setting. AI use: OpenAI Codex (GPT-6) built the PR, ran the pair, inspected the frame captures and logs, and drafted this report.


Follow-up on the 63 compute pipelines. On the same 3ea5edc build and RTX 4090, I reran the title with XCL_TEXTURE_LEVEL_PAGES=1 in both runs. Precompiling all 63 compute pipelines identified above moved their last runtime driver completion to 10.248 s. The title still stopped presenting during loading. The frame captures showed loading artwork and fades. Neither run showed a gameplay HUD or recognizable world geometry.

Runtime measurement Control After compute precompile
Tracked compute records supplied with a driver blob 1/63 63/63
Last driver completion among those 63 108.627 s 10.248 s
Last 2 s activity interval with any presents ended at 92.054 s 98.059 s
Total PresentX calls at 300 s 1,240 1,222
Compute pipeline builds started after that last active interval 213 2

Both runs started from identical copies of the XCL cache, title profile and 1,069-key used-pipeline list. Only the second copy went through xcl shaders <pack> --precompile --only cs --pipelines --used-only --split 1 --windows 4. The pass reported 723 pipelines made, zero errors or refusals, and produced 715 new distinct driver-cache files, including the 62 distinct files used by all 63 tracked records. Each configuration ran once, control first. NVIDIA’s internal cache was uncontrolled.

In the precompiled run, the two late compute records (33fefb7c44c5d469 and 9eb0518ab8808787) were outside the input list. Both finished by 139.965 s. Another 147 graphics pipeline builds finished after the last active interval, the last at 295.493 s. In all five thread samples from 115 to 285 s, the same worker was in bind::execute_indirect → pso_async::resolve_wait. The thread that had called PresentX had the same title return address (+0x56a0d) in each sample. The samples do not identify the pipeline key the worker awaited. Both runs exited with code 0 at the configured cutoff, with no logged device removal.

AI assistance for this follow-up: OpenAI Codex ran the comparison, matched the cache files to the runtime trace, inspected the captures and thread samples, and drafted the update.

Which pipelines did ExecuteIndirect wait for? One 300 s diagnostic run on 3ea5edc with local logging, the same RTX 4090 and the same compute-only cache preparation. The last active presentation interval ended at 100.051 s (1,275 PresentX calls total). The captures still showed loading artwork. The run exited with code 0 and no logged device removal.

Between 100.051 and 300 s, one title worker spent 197.66 s waiting on 51 distinct graphics shader-set keys at ExecuteIndirect. All 51 were in the 1,069-key input list. Fifty waits resolved. Their corresponding driver calls all started without a blob and overlapped 56.05 s of the wait time. At 155 and 285 s the matching build threads were waiting for DXC results. The longest completed wait was 7.667 s for key d32baf54e8764425 (pixel record 526ed1b2012b0772, 1.963 s in the driver). The final key, ca5c6bb91e008c1f, was still pending at cutoff. These timings locate the waits on that worker. The presenting thread’s dependency on it remains unverified. AI assistance: OpenAI Codex (GPT-6) added the local trace, ran it and correlated the logs and thread samples.

Warm graphics-cache replay, 300 s. I repeated the diagnostic run with the same binary, fresh copy of the same title profile and identical inputs, using a verified copy of the preceding run’s full XCL cache. The 1,069-key list was unchanged. Across the same 50 completed graphics waits, total time in the instrumented ExecuteIndirect binds fell from 194.509 s to 0.387 s. Driver calls went from 56.029 s to 0.250 s combined, with blobs supplied to 48/50 on replay. The previously unfinished key ca5c6bb91e008c1f then resolved at 102.445 s.

That thread went on to wait for 21 further graphics keys whose builds had not started in the reference run. Twenty completed. The last, 62298dad417480a1, was outside the input list and still pending at 300 s. The last active presentation interval ended at 94.074 s (1,180 PresentX calls total). Captures showed loading artwork and fades, with no gameplay HUD or recognizable world geometry. Exit code 0, no logged device removal. One run per cache state, NVIDIA’s internal cache uncontrolled. OpenAI Codex (GPT-6) ran and analyzed this replay.

What was the presenter waiting for? In a 300 s replay on the same RTX 4090 and 3ea5edc, with local synchronization logging and the preceding warm test’s starting cache, the PresentX thread waited indefinitely on a Windows semaphore (0x1018). Its last observed release was at 99.490 s. The presenter returned successfully at that time, entered another wait on the same handle at 100.798 s, and remained there for the last 199.202 s. The thread that issued the release was itself waiting for work from 99.604 s onward.

The coordinator completed 81 event waits and stopped on the 82nd (0x1a3c, auto-reset). We matched that event and the same job descriptor and payload in the pending queue and on worker 4. During the presenter’s final wait, this worker completed 64 graphics pipeline waits in ExecuteIndirect and entered a 65th. Neither a completion signal on the coordinator’s event nor another release of the presenter’s semaphore was logged by cutoff. This ties the graphics work to the coordinator’s wait. Whether completing that job would release the presenter remains open.

1,347 PresentX calls, last active interval ending at 100.062 s, loading artwork, exit 0. An earlier attempt ended with an access violation at 85.110 s coinciding with a scheduled full thread dump. The completed replay used the same diagnostic binary with scheduled full dumps disabled. AI assistance: OpenAI Codex (GPT-6) ran the replay and correlated the synchronization trace and worker samples.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent RX 6800M check of exact PR head 3ea5edc1c941be6350d66b45e1e5c91f72158c18 found a reproducible GPU-fixture failure when the discrete adapter is selected.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; discrete AMD Radeon RX 6800M driver 30.0.13002.13003 alongside integrated Radeon graphics; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Isolated debug Cargo target. cargo build --locked --workspace --release -j 2 passed on the clean head.

Unchanged-head tests: the_tiles_of_a_texture_are_grouped_by_its_levels passed 1/0/0. a_placed_texture_gets_the_pages_of_a_level_with_its_texels also reported 1/0/0 with no skip, but its checked-in fixture uses EnumAdapters1(0) and does not identify that adapter. I cannot attribute this pass to the RX 6800M even though XCL_ADAPTER=6800M was set.

Selected-RX diagnostic: I changed only the GPU test's adapter setup locally to use gpu::adapter::Selector::from_env_or("auto") and candidates, then printed the selected name. The fixture printed AMD Radeon RX 6800M and failed 0 passed, 1 failed, twice at the unchanged assertion level 0 once all of it is there. A further test-only diagnostic produced the same failure. Before that assertion, the test had passed its checks for the expected page count, mips 1–10 after the first upload, and zeros for unmapped mip 0. After the full texture is placed again, mip 0 readback is 4,194,304 bytes as expected, but the first mismatch is consistently at byte 3,072, where the GPU readback is zero and the synthetic expected texels are nonzero. One diagnostic run counted 302,336 mismatching bytes. This suggests missing texels in part of mip 0 on this adapter; I have not isolated whether the cause is XCL mapping, the fixture, or the AMD driver.

I removed the test-only selector and diagnostic edits; the worktree is clean at the exact PR head. A guarded 20-second owned-title baseline run stopped for low available commit memory before producing a smoke result. I did not run a title comparison with this switch on, and I am not claiming title impact or a performance change.

AI use: OpenAI Codex (GPT-6; exact variant unavailable in this session) ran the native Windows tests, made and restored the test-only diagnostics, checked the release build, and drafted this report. No game data was uploaded.

@imnicho

imnicho commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@luckyteagirl thank you, that is the kind of result this needs before anyone merges it. I cannot reproduce it here (RTX 5080: the fixture passes), so what I can add is how I read it and one run that would tell the cases apart.

What the failing step is. By then the fixture has passed the page counts, levels 1 – 10 and the zeros of the unmapped level 0. The second texture is placed at the same address, its upload maps level 0's tiles (64 of them with 128x128 tiles) on the pages' queue, the upload queue waits for that fence, and then all levels are copied. A zero from byte 3 072 of row 0 on is the start of the seventh 128-pixel column, so whole tiles of level 0 read as not mapped or not written, rather than a wrong texel here and there.

The same fixture on other AMD drivers. @nnonno91's Radeon iGPU (driver 32.0.21042.62) and @SlopTart's RX 7900 XT on RADV pass it; the RX 6800M here is on 30.0.13002.13003. So it may be that driver, but nothing above shows that.

One run that would separate the change from the driver, if you have the time, with the same adapter selection you used: placed_title_textures_share_vram_and_preserve_pixels. It is on main already and does not use this switch: its last part uploads mip chains to textures on the same shared pages, with every tile mapped when the texture is placed. If that fails on the RX 6800M too, the pages' mapping or the copies into reserved textures misbehave there without this PR. If it passes, the difference is what this PR adds: tiles mapped a level at a time, right before the upload that fills them.

What I will do with the answer: if that test fails as well, I note the adapter in this PR's "Not tested" and the switch stays off by default as it is; if only this PR's fixture fails, the switch is not safe on that driver and I either find the cause or make it refuse to turn on there, before this can go in. Until then, please read this PR as not verified on RDNA2 with that driver.

On the fixture taking adapter 0: yes, it copies that from the test next to it. Using gpu::adapter::Selector as you did is right; I would rather do that for both tests in a small PR of its own than push here now, since a push would drop the reports on this head.

@minimalhipster990 thank you for the numbers on the clean head: 8 828 → 4 342 MiB of target pages at the same artwork is the same halving I see on the local tree in the world (9.2 – 9.5 GB → 4.8 – 4.9 GB).

AI use: Claude Code with Claude Fable 5.2 wrote this.

@ClosetPie107

Copy link
Copy Markdown

Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head 3ea5edc1c941be6350d66b45e1e5c91f72158c18 (merged locally onto main 06c9f55).

Hardware & environment

  • AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1, native wave64), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux
  • Proton Experimental (experimental-11.0-20261112), vkd3d-proton master ec207194 (3.2.0) + dxil-spirv 694cc674 + two-hunk relaxed-vtable patch (-Db_ndebug=true), DXVK v3.1.1-209, DXC 1.9.2609.5, Rust x86_64-pc-windows-gnu (debug for tests, release for retail)

Unit / GPU tests (XCL_REQUIRE_GPU=wave64, VKD3D_CONFIG=ignore_shared_fence)

  • hle::d3d12x::vram: 16 passed, 0 failed, 1 ignored (0 skipped; the_tiles_of_a_texture_are_grouped_by_its_levels passed, peak VRAM 1,727 MiB)
  • hle::d3d12x::title_textures: 19 passed, 0 failed, 0 ignored (0 skipped; GPU test a_placed_texture_gets_the_pages_of_a_level_with_its_texels ran on RADV and passed, peak VRAM 1,366 MiB)

Retail title (1.0.2.1) A/B on RADV
Same warm PSO/vkd3d cache and flags (XCL_DIRECT_DXIL=1, XCL_PSO_WAIT_MS=50, XCL_SPLIT_MIDLIST_WAIT=0, XCL_COHERENT_MB=1024, VKD3D_CONFIG=ignore_shared_fence, XCL_PSO_PRELOAD=0, XCL_NETWORK=0), capped at MemoryMax=18G:

Metric Without #2306 With #2306 (XCL_TEXTURE_LEVEL_PAGES=1)
VRAM at 76 s / 81 s / 91 s 15,029 / 16,296 / 16,297 MiB 10,469 / 11,564 / 11,650 MiB (−4.6 GiB)
Min free system RAM (MemAvailable) 387 MiB (RAM guard at 166 s, ~10 GiB GTT spill) 12,014 MiB (0 GTT spill, 0 swap)
level pages at 47.9 s — 16,859 textures (2,061 MB virtual → 941 MB mapped)
Draws / dispatches 37,377 (36 skipped) / 131,072 (68 skipped) at 155 s 49,111 (20 skipped) / 114,950 (64 skipped) at 105.9 s
Outcome Stopped by host RAM guard at 167 s Reached #2140's 0x80000003 at game_scarlett_master.exe+0x4da6315 at 111 s (0 device removals, 0 upload errors)

Not tested

  • Native Windows, full workspace test suite, default HLSL path, visual frame-capture verification of world textures, or other titles.

AI use

  • T3 Code / Antigravity (Gemini 4 Neon) merged the PR locally, ran the tests and retail A/B runs on this machine, and drafted this report.

@luckyteagirl

Copy link
Copy Markdown
Contributor

@imnicho I ran the requested parent control on the AMD Radeon RX 6800M, driver 30.0.13002.13003, against PR #2306's exact parent 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6.

The checked-in placed_title_textures_share_vram_and_preserve_pixels initially reported a harness pass but printed SKIPPED ... this adapter makes no reserved cube with mips; its early cube gate prevents any shared-page assertions on this driver. I then made a local test-only overlay to select and print XCL_ADAPTER=6800M, removed that early cube gate, omitted the cubemap shape that this driver cannot reserve, and added the PR fixture's exact 1024×1024 RGBA8, 11-mip shape to the existing 2D mip-chain cases. Production code stayed at the unchanged parent.

The expanded parent fixture passed 1 passed, 0 failed, 0 ignored, with no SKIPPED line, in 3.33 s. Its shared-page aliasing/overlap checks and all 2D mip-chain GPU readbacks, including the added 1024×1024 RGBA8 shape, completed. An intermediate diagnostic with the cube still in the shape list reached the 2D readbacks but then failed at the fixture's place_tex assertion for a second non-reserved cubemap; removing that unsupported case let the 2D control complete.

Compared with the PR-head selected-RX fixture's reproducible mip-0 failure at byte 3,072, this narrows the problem to the difference between eager whole-texture mapping/upload and this PR's level-at-a-time sequence on this adapter. It does not yet identify whether the mapping call, timing/barrier, fixture, or driver causes that difference. I removed every local test edit and verified both parent and PR worktrees clean. No title data was used.

AI use: OpenAI Codex (GPT-6; exact variant unavailable in this session) made and restored the test-only overlay, ran the native Windows control, and drafted this follow-up.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA, the title, 3 runs with XCL_TEXTURE_LEVEL_PAGES=1 and 3 without: once 4.2 GB had been read through DirectStorage (4.2–4.4 GB, at 58–71 s), target pages was 8,653–8,756 MB without the switch and 4,274–4,354 MB with it, and non-local video memory 8,117–8,255 MB against 4,145 MB, the level all six runs had by 45 s. No run faulted; the warnings were of the same kinds both ways. With the switch set, one existing test fails.

Setup: main 06c9f55 + #684 e56dbc3 + #2306 3ea5edc, merged locally (913fcf8), one release build, the runs alternating. RTX 4070 12 GB (615.71.09), Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch. Series X profile, 120 s, the first-run screens completed once and no story progress, A pressed once at 16.3–18.3 s, XCL_ACTIVITY=1, XCL_PSO_PRELOAD=0, WINEDEBUG=err+all,fixme-all.

switch unset (3 runs) =1 (3 runs)
target pages at 28 s 3,579–3,580 MB 3,417–3,418 MB
once 4.2 GB had been read through DirectStorage (58–71 s): target pages / non-local 8,653–8,756 / 8,117–8,255 MB 4,274–4,354 / 4,145 MB
at the peak (all runs read 5.2–5.3 GB in the end): target pages / non-local 9,589–9,624 / 9,295–9,395 MB 4,367–4,429 / 4,145 MB
level pages: at 16,384 levels given pages (logged at powers of two; no later line came) – 17,332–17,416 textures standing for 2,387–2,392 MB have pages for 924–973 MB (at 41–44 s)
first #101 73.0, 75.8, 83.3 s 52.6, 70.9, 72.1 s
last 2 s with a present 74.1, 78.4, 84.8 s 68.1, 72.2, 74.0 s
faults / WARN lines 0 / 77–79 0 / 76–78
  • With the switch the first #101 came earlier in all three runs (52.6–72.1 s against 73.0–83.3 s), and they had read more by 60 s (4.0–4.6 GB against 3.3–4.0 GB). 3 runs of each cannot show that this is the switch's doing.
  • vram and title_textures tests under Wine: 35 passed, 1 ignored with the switch unset; with it, 33 passed, 2 failed, 1 ignored, the two new tests passing both ways. placed_title_textures_share_vram_and_preserve_pixels fails at title_textures.rs:2114 (left: 0, right: 16777216): it counts the pages of placed textures before any upload, and vram::level_pages reads the variable, so the test does depend on the switch, and the RX 6800M control above holds only with the variable unset. d32s8_targets_take_their_own_size_of_video_memory failed only on the lock the first one poisoned, and passed alone.

Not tested: the rest of the suite; the title past 120 s or in its world; whether textures look right; Windows; AMD and Intel.

AI use: Claude Code (Claude Opus 5.5) ran the title and the tests and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
Integrates upstream PR xcl-dev#2306 (opt-in per-level texture page allocation via XCL_TEXTURE_LEVEL_PAGES=1), composed cleanly with xcl-dev#2270's HeldUnmap.
@luckyteagirl

Copy link
Copy Markdown
Contributor

@imnicho I narrowed the RX 6800M failure on unchanged PR head 3ea5edc1c941be6350d66b45e1e5c91f72158c18 with two local test-only controls. This is the same Windows 11 / RX 6800M driver 30.0.13002.13003 setup as my earlier reports; the fixture selected and printed that adapter.

  1. I temporarily printed map_levels_with_texels's requested and newly mapped levels, without changing its behavior. The first partial upload requested/mapped [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. The full texture's upload requested/mapped [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. The test still failed 0/1 at level 0 once all of it is there. Thus mip 0 is included in the normal mapping decision.
  2. I removed that print and, only in the fixture, called vram::map_levels(&full, None) immediately after let full = place_tex(at), before refresh(queue.as_raw()). It returned [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. The unchanged page-count and readback assertions then passed 1/0/0 twice, with no skip.

The difference is when the second texture's levels are mapped relative to refresh and upload preparation. This result does not establish whether it is a driver ordering issue, a missing synchronization step, or another side effect of that timing. All temporary edits were restored and the PR worktree is clean. No title data was used.

AI use: OpenAI Codex (GPT-6) made and restored the diagnostic edits, ran the GPU controls, and prepared this follow-up.

@luckyteagirl

Copy link
Copy Markdown
Contributor

@imnicho Four RX 6800M controls on exact head 3ea5edc1c941be6350d66b45e1e5c91f72158c18 refine my earlier pre-map result. All changes were local diagnostics on the same Windows 11 / driver 30.0.13002.13003 setup, with the discrete adapter selected; I restored the worktree afterward.

  • Wait after the normal late map: In upload_all, after vram::before_execute(&queue) I made texture::wait(dev, &queue) finish the queued mapping wait on the CPU before texture::upload_batch records copies. The fixture still failed 0/1 at level 0 once all of it is there. So finishing that wait at this point did not repair the late-map path.
  • Pre-map, without sparse sync: I mapped all levels of full immediately after place_tex, as in the passing control, but disabled sparse::before_execute only for the second refresh. The fixture still passed 1/0/0, with no skip. Its pass does not require the sparse page-sync call to fill the texture.
  • Map at the start of upload_all: I removed the place_tex pre-map and instead mapped all levels of the second texture immediately before subresources_of_all (CPU detiling), leaving the later map_levels_with_texels call intact. It returned [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; the fixture passed 1/0/0 twice, no skip.
  • Delay after the normal late map: I restored the normal mapping position but inserted a test-only 100 ms CPU sleep after map_levels_with_texels maps mip 0 and before the upload batch. The fixture passed 1/0/0 twice, no skip. The sleep is a diagnostic, not a viable runtime fix.

Together with the normal path's logged request/mapping of all eleven levels followed by a failed mip-0 readback, these controls point to timing after the mapping call on this driver: moving it ahead of CPU detiling or waiting 100 ms afterward both change the result, while finishing the mapping queue's GPU fence did not. They do not establish which driver or XCL operation needs that elapsed time. The early-map controls map all levels for diagnosis and are not a proposed memory-saving implementation. No title data was used.

AI use: OpenAI Codex (GPT-6) ran and restored the test-only controls and prepared this report.

@crastinator crastinator left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Linux and a 12 GB RDNA2 card, XCL_TEXTURE_LEVEL_PAGES=1 is the only one of the VRAM PRs I tried that gets a retail title's world load through without filling the card.

main this PR, knob on
local at 60 s 8693 MB 8250 MB
texture pages (pools) at 60 s 4626 (4800) MB 4390 (4416) MB
after that card full at 87 s pages stay at 4392 (4544) MB from 90 s to 500 s
peak (sysfs) 11.5 GB, run stopped 9.9 GB

The log says 17044 textures standing for 2078 MB have pages for 1029 MB at 62 s.

From about 100 s the title stops presenting while it builds its world compute pipelines (about one a second), and at about 500 s my run hit its own 11 GB RAM cap. Both have nothing to do with this PR. Head 3ea5edc.

Tested (head 3ea5edc, merged onto main 06c9f55, no conflicts unless noted)

  • AMD Radeon RX 6700 XT 12 GB (RDNA2, gfx1031, RADV, Mesa 26.3.1), Ryzen 7 5700X, 16 GB RAM, Linux 7.3.5 (CachyOS)
  • proton-cachyos 11.0-20261015 Wine, vkd3d-proton v3.1 + #257's patch (dxil-spirv 53aac418 from #775), DXVK v3.1.1-97 dxgi
  • release build, XCL_COHERENT_MB=512 (the 4095 MB learned window is ~1 fps here, #284), XCL_ACTIVITY=1
  • A retail title from a cold start: it goes from the menus into its world load at about 50 s. Numbers are the activity log's memory: line; "card full" means sysfs mem_info_vram_used reached 11.5 GB, where my guard stops the run (a full card has crashed the compositor here before).

Not tested

  • cargo test under Wine: these were title runs only.
  • Whether textures look right: I did not check image quality. No new warning kinds in the log compared with main, beyond ones from getting further into the load.
  • Past about 100 s of the world load (pipeline builds, then my RAM cap).

AI use

  • Claude Code (Claude Opus 5.5) merged, built and ran this and wrote the report; I checked the results.

@ivall

ivall commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Merged into main (65fc114), off by default as you have it; no conflicts with main.

  • Tested: AMD RDNA4, Windows, DXC 1.8.2502.11, merged tree: suite 1279 passed, 2 failed (DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115, as on main), 46 ignored.
  • In a title: a retail title in Series S mode, same scene and stage (about 75 s in; a tree with other open PRs, XCL_TEXTURE_LEVEL_PAGES=1): video memory 14.8 GB to 6.0 GB, the target pages 11.9 GB to 3.4 GB, process commit 23.5 GB to 15.4 GB. Later the texture list reached "53 525 textures standing for 22 068 MB have pages for 2 695 MB".
  • Not seen yet: a lit picture of that world, so whether a texture is ever drawn before its pages are there has not been judged; another reason to keep it off by default until it has been.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this on the maintainer's behalf.

@pane33

pane33 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

I ran an off/on comparison with a newer retail game on upstream 50a9fde. Both runs used the same release binary on Windows 11, a Ryzen 5 7600X, 16 GB RAM, and an RTX 4060 8 GB (driver 32.0.16.2124), with the default HLSL route and XCL_ACTIVITY=1. Each run started from a separate copy of the same Series X profile with cold XCL caches and a 120 s cap. The driver cache was uncontrolled.

At about 44 s, both runs had logged 22,859 DirectStorage requests and approximately 1,262 MiB of I/O, with zero failed requests at that point.

Metric (MiB) D: flag unset E: flag =1 Change
Texture pool capacity 4,608 4,416 −4.2%
Mapped texture pages 4,530 4,353 −3.9%
DXGI LOCAL usage 7,270 7,078 −2.6%
DXGI NON_LOCAL usage 4,687 4,657 −0.6%
Process commit 15,738 15,511 −1.4%
System commit 29,324 29,167 −0.5%
  • D: A 64 MiB CreateHeap returned E_OUTOFMEMORY (0x8007000E) at 55.46 s. The title exited with 0x80000003.
  • E: The log showed no heap refusal or device removal. DirectStorage first logged 0x89240009 at 51.92 s, and the activity counters recorded 459 failed requests. No further presents were recorded after the interval ending at about 84 s. The configured timer ended the run at 120 s with exit code 0.

This was one run per setting. The checkpoint was matched by I/O progress, and visual parity was unverified. The cause of the DirectStorage failures remains open.

AI use: Codex (GPT-6.2-Sol) analyzed the existing logs and drafted this comment.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@shortside

Copy link
Copy Markdown

Mac test report for head 3ea5edc as pushed (its base is main 1a0bbe3). Short version: on D3DMetal the switch has nothing to act on, and the change breaks nothing here.

Tested

  • MacBook Pro M5 Pro, 24 GB, macOS 27.2.1, Rosetta 2; CrossOver 26.3, D3DMetal; DXC 1.9.2609. Cross-built for x86_64-pc-windows-msvc (release) with clang-cl / lld-link.
  • The 36 lib tests in hle::d3d12x::vram:: and hle::d3d12x::title_textures::, one per process:
    • 30 passed, 1 ignored (churn_update_tile_mappings_timing).
    • the_tiles_of_a_texture_are_grouped_by_its_levels: passed.
    • a_placed_texture_gets_the_pages_of_a_level_with_its_texels: skipped itself ("this adapter's texture was not placed with lazy levels"). Expected on this host: place_pages gives nothing on D3DMetal, so no texture is placed that way.
    • 4 failed, crashed or ran into the time limit: gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes (panic, then no exit), placed_title_textures_share_vram_and_preserve_pixels (failed), d32s8_targets_take_their_own_size_of_video_memory (crash), reservable_agrees_with_the_driver (failed). The same four do the same on main 1a0bbe3 on this host, at the same asserts (line numbers shifted by the lines this PR adds), so none is from this change.
  • The newer retail title (my own copy), 60 s through scripts/smoke.ps1, once without and once with XCL_TEXTURE_LEVEL_PAGES=1: both end at 60 s with exit 0x0, no crash, no device removal.

Not tested

  • The switch doing anything. On main the title submits no GPU work on this host in 60 s (0 presents, 0 submits, 0 draws in the log), so the two title runs do not reach the changed code, and the PR's GPU test skips itself here. The memory effect is not something this machine can show for this path.
  • Windows, any other title, the rest of the test suite.

AI use: Claude Code with Claude Fable 5.2 built the head, ran the tests and the two runs on my machine and wrote this report.

raylitebull added a commit that referenced this pull request Nov 25, 2026
Bring in 36 upstream PRs from origin/main (#2310..#587) onto amd-dev (c7a18d8) while preserving all local AMD RDNA4 work (#615 pipelined presenter SRVs, #495/#1405 XCL_PAGE_ALIAS=1 hooks, #2306 level tiling timers, #1989 vtable fix, mesh user SGPRs).

Resolved 4 conflicts:
- console_list.rs: kept both mesh_arguments_go_in_user_sgprs_from_s16 and #2323 dispatch-heap tests
- real.rs: kept both effective_st depth-UAV tracking and #2280 pc_clear_for_desc
- vram.rs: kept Step::Tiling timer around level_tiling
- kernelx.rs: kept XCL_PAGE_ALIAS=1 hooks in physical_pages_live and XMemMapPhysicalPagesScatter

Assisted-by: Antigravity (Gemini 4 Neon High)
raylitebull added a commit that referenced this pull request Nov 25, 2026
Port upstream PR #2436 (by Saintwolf, adapted for #2306 lazy level pages and #2275 multi-queue retirement) onto amd-dev.

Streamed sampled textures placed on shared 64 KiB video-memory pages previously called CreateReservedResource and GetResourceTiling on every placement, costing 0.6-1.7 ms per texture on AMD drivers (#1268).

Keep a bounded per-device pool (512 idle entries, FIFO eviction, opt-out via XCL_RESERVED_POOL=0) of released reserved sampled textures keyed by exact (D3D12_RESOURCE_DESC, uniform D3D12_RESOURCE_STATES), also caching the #2306 Levels tiling layout so XCL_TEXTURE_LEVEL_PAGES=1 placements skip both CreateReservedResource and GetResourceTiling on reuse. When late_release finishes draining all live GPU queues past a texture's batch, vram::recycle_ready unmaps any still-mapped tiles on the background thread (skipping unmap for lazy textures that had zero mapped levels) and parks the ID3D12Resource for reuse.

Fixes #1268. Part of #1833.

Assisted-by: Antigravity (Gemini 4 Neon High)
raylitebull added a commit that referenced this pull request Nov 25, 2026
Port upstream PR #1835 (commits 2441d59..5005620) cleanly onto amd-dev with #2436 reserved-texture recycling and #2306 lazy levels.

Small sampled textures (< 64 KiB) previously each consumed a full 64 KiB tile plus CreateReservedResource, GetResourceTiling, and UpdateTileMappings overhead. Pack eligible sub-64 KiB sampled textures (when not aliasing an existing live 64 KiB GPU-owned page) into shared 4 KiB-aligned 4 MiB default heaps via CreatePlacedResource in vram_small.rs, reclaiming their 4 KiB slots on release in vram::forget_for_recycle before falling through to reserved-page recycling.

Fixes #1835.

Assisted-by: Antigravity (Gemini 4 Neon High)
vakaobr added a commit to vakaobr/xcl that referenced this pull request Nov 25, 2026
…M_ARENAS=0

6a78ce4 put sampled title textures on shared pages on a Mac, with
pages under every level. That came before the level tiles
(title_textures), which give a streamed texture video memory level by
level only once place_pages says no. shortside ran a retail title on this
branch at 5f9a58f on a 24 GB M5 Pro (xcl-dev#258): about 80 s into loading,
wired memory was 16.5 GB with it, and 12.6 GB with XCL_VRAM_ARENAS=1
(12.3 - 14.0 GB on their earlier builds with the level tiles).

So on a Mac sampled_on_pages() is off unless XCL_VRAM_ARENAS=0, as before
6a78ce4; render targets (24809ec) follow it. Until the shared pages map a
texture's levels with their texels (xcl-dev#2306 on main), XCL_VRAM_ARENAS=0 is
the switch for trying them.

render_targets_at_one_address_share_their_pages skips where title
textures keep arenas, decided from XCL_VRAM_ARENAS and mac_host(): not
from on_pages(), which caches its answer and reads a native-host flag
set only once the first texture is placed. vram + title_textures tests
on this Mac (29): by default 26 passed and 3 SKIPPED (the two
shared-page tests and read_committed_tolerates_concurrent_decommit); with
XCL_VRAM_ARENAS=0 28 passed and 1 SKIPPED (that last one, which SKIPPED
before this change too).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.