Repository navigation
D3D12.X: XCL_TEXTURE_LEVEL_PAGES=1 gives a sampled texture's levels their pages with their texels - #2306
Conversation
…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>
|
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.
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. |
|
Linux/RADV (RDNA3) verification over Wine: green with the switch on and off, one single-shot flake to note. Tested:
So on this rig the change is clean: no deterministic failure with the switch on. The one 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. |
|
Independent native Windows Radeon iGPU check of Tested
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. |
|
RTX 4090, clean PR head
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 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
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 In the precompiled run, the two late compute records ( 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 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 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 That thread went on to wait for 21 further graphics keys whose builds had not started in the reference run. Twenty completed. The last, What was the presenter waiting for? In a 300 s replay on the same RTX 4090 and The coordinator completed 81 event waits and stopped on the 82nd ( 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. |
|
Independent RX 6800M check of exact PR head Environment: Windows 11 build 26200; Ryzen 9 5980HX; discrete AMD Radeon RX 6800M driver Unchanged-head tests: Selected-RX diagnostic: I changed only the GPU test's adapter setup locally to use 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. |
|
@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: 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 @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. |
|
Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head Hardware & environment
Unit / GPU tests (
Retail title (1.0.2.1) A/B on RADV
Not tested
AI use
|
|
@imnicho I ran the requested parent control on the AMD Radeon RX 6800M, driver The checked-in The expanded parent fixture passed 1 passed, 0 failed, 0 ignored, with no 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. |
|
Linux (Wine + vkd3d-proton) + NVIDIA, the title, 3 runs with Setup:
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. |
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.
|
@imnicho I narrowed the RX 6800M failure on unchanged PR head
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. |
|
@imnicho Four RX 6800M controls on exact head
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
left a comment
There was a problem hiding this comment.
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
53aac418from #775), DXVK v3.1.1-97dxgi - 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 sysfsmem_info_vram_usedreached 11.5 GB, where my guard stops the run (a full card has crashed the compositor here before).
Not tested
cargo testunder 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.
|
Merged into
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this on the maintainer's behalf. |
|
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.
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. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Mac test report for head Tested
Not tested
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. |
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)
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)
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)
…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).
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_pagesgives 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_pagesplaces a sampled 2D texture of one slice with no tile mapped.Levelskeeps its tiling (GetResourceTiling) as groups of tiles: one for each level with tiles of its own, one for the packed levels.map_levelsgives a group its pages - the same pages by address as before (bind_range, whatbinddoes for a range of the tiles;maptakes 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.the_tiles_of_a_texture_are_grouped_by_its_levels(the grouping; tilings that do not add up), anda_placed_texture_gets_the_pages_of_a_level_with_its_texelson 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.Tested
stable-x86_64-pc-windows-msvc; debug for the tests, release for the title.cargo build --workspace && cargo test --workspace -- --test-threads=4on3ea5edc: 1252 passed, 0 failed, 46 ignored. SKIPPED (27 notices): the wave64 cases ofgpu::recomp::lower::tests(4 tests) andgpu::recomp::lower_dxil::tests(14 cases), 3 per-lane cases the per-lane form refuses,gpu_wave32_program_in_wave64_hardwareandgpu_geometry_wave32_prefix_count_over_a_mask(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(its switch is off),pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode is off),uploads_start_from_each_subresources_stateandtest_title_draws_with_a_root_signature_under_the_debug_layer(no D3D12 debug layer on this PC).XCL_TEXTURE_LEVEL_PAGES=1 XCL_ACTIVITY=1, default settings otherwise): one run of 150 s through its menus and first loading screens, 1 958 frames shown, no device removal, no crash, no failed upload; the logo and the loading artwork are right in the frame captures. By 93 s 17 591 placed textures standing for 2 422 MB had pages for 940 MB (the linemap_levelslogs).XCL_NETWORK=0, scripted pad; the same for the run above), on a local tree that is not this head: D3D12.X: integration branch that reaches the in-world HUD on NVIDIA (reference, not for merge) #2057 at4df1e6e+mainat0f13d2a+ Recompiler: emit per-instruction globallycoherent on compute flat memory (stacked on #1850) #2067, XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684, Rect lists: the CPU expansion finds the rect's corner, not always v1 #266, Activity: the local video memory budget, and a warning within XCL_VRAM_HEADROOM_MB of it #1515, kernelx: XMemMapPhysicalPagesScatter with no page array unmaps #495, DirectStorage: read a physical-page list again when its request runs #1405, D3D12.X: title texture reads outside the coherent window use the safe copy #751, D3D12.X: execute two-pass mesh shaders on DispatchMesh and ExecuteIndirect (supersedes #724) #2092, D3D12.X: shaders that index the heaps themselves get the heaps' addresses #1803, D3D12.X: the console's DispatchMesh indirect argument (107) is a PC DispatchMesh #1887, D3D12.X: a console MS in the AS slot is translated as the mesh shader it is #541, D3D12.X: XCL_DUMP_TARGETS dumps the most-drawn render targets of a frame #2050 and the samevram.rschange. There the uploads are D3D12.X: integration branch that reaches the in-world HUD on NVIDIA (reference, not for merge) #2057's, which send parts of a texture: the hook is in its plan of an upload, a level counts as there when memory is committed behind it, and a level that gets its pages goes up whole.XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1, Series X profile, two pairs of runs of 300 s, alternating:target pages) at the end0x887a0006136 s after the set-up0x887a000558 s after it0x887a0006160 s after itReports by others on this head (
3ea5edc, in the comments below)gpu_tests as on that machine'smainwith the switch off and on.Regression run (default settings: the switch is off)
main:
PR (this PR's head commit):
A second round of the same two binaries:
main1134 frames, PR 1323.Not tested
AI use
🤖 Generated with Claude Code