Skip to content

D3D12.X: XCL_SMALL_TEXTURES=1 puts small sampled textures on 4 KiB placements - #3008

Draft
Kalmarv wants to merge 1 commit into
xcl-dev:nvidia-devfrom
Kalmarv:nvd-small-tex
Draft

Kalmarv wants to merge 1 commit into
xcl-dev:nvidia-devfrom
Kalmarv:nvd-small-tex

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

A sampled texture of the title that the shared 64 KiB pages do not take (vram::place_pages refuses it; a 1D texture cannot be a reserved resource) is made a committed resource, and a committed resource takes at least 64 KiB of video memory. On the title we run, that fallback held thousands of tiny textures (mostly Texture1D RGBA8 lookup tables of a few hundred bytes), at 64 KiB each. With XCL_SMALL_TEXTURES=1 such a texture goes on a 4 KiB placement in a heap of XCL's own instead. Off by default. Part of #2688.

What is in it

  • hle/d3d12x/small_tex.rs (new): the PC's rules decide. No render target, depth or UAV flag, one sample, and GetResourceAllocationInfo returning 4 KiB alignment for the description with Alignment = D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT (its most detailed level fits in 64 KiB). Such a texture is placed first-fit in 4 KiB units of 4 MiB DEFAULT heaps (ALLOW_ONLY_NON_RT_DS_TEXTURES), made through the adopting CreatePlacedResource. Anything else, and a texture no heap can take, is committed as before. Its units are free again where late_release lets the texture go (the queues are past the work before it). With XCL_LATE_RELEASE=0 the switch does nothing (logged once): XCL's uploads into a texture could still be in flight at the title's release. XCL asks no residency priority for the heaps, as for a committed texture. Heaps are kept once made.
  • device_x.rs: the committed fallback of CreatePlacedResourceX tries it first. real.rs, late_release.rs: small_tex::gone next to placements::gone.
  • Tests: units_are_taken_first_fit_and_given_back (the allocator), only_textures_the_pc_places_on_4_kib_are_taken (the rules, against the PC's GetResourceAllocationInfo).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), Ryzen 9 9950X, Windows 11 Pro 26200, Rust 1.99.0 MSVC, debug tests, release smoke; DXC 1.9.2609 via XCL_DXC_DIR.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 on 24fdb7b (with CARGO_PROFILE_DEV_DEBUG=0: no debug info, for disk space): 1826 passed, 8 failed, 48 ignored. The same command on nvidia-dev a5e2d851: 1822 passed, 10 failed, 48 ignored.
  • Failed here and on a5e2d851 as well: async_compute_pso_registers_real_pso_and_not_standin, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays, hle::d3d12x::texture_upload::tests::pieces_hold_the_texels_of_their_levels, split_compute_prefers_the_offline_whole_pipeline, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.
  • 26 SKIPPED: 8 no wave64; 1 const_mask, wave64: no wave64; 1 f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); 1 f16 arithmetic, wave64: no wave64; 1 f32 arithmetic, wave64: no wave64; 1 f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); 1 f16 packed, wave64: no wave64; 1 f32 compares, wave64: no wave64; 1 f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); 1 f32 conversions, wave64: no wave64; 1 f64, wave64: no wave64; 1 integer arithmetic, wave64: no wave64; 1 f32 rounding, wave64: no wave64; 1 mask_ff0_flbit, wave64: no wave64; 1 integer carries, wave64: no wave64; 1 f32 transcendentals, wave64: no wave64; 1 f32 three-source, wave64: no wave64; 1 no heap windows (opt-in: XCL_HEAP_WINDOWS=1); 1 no heap windows.
  • On the title (one 480 s run with the switch and one without, same base and env; the runs were on our team branch, whose tree differs from this head by translator and memory changes that do not touch this path): 8,192 small textures were live on 4 KiB placements in 58 MiB of 15 heaps, against at least 512 MiB as committed resources (the log's own count). Local video memory over 250-310 s: 18,332 vs 18,793 MB (-461 MB), with the sparse pools and target pages equal in both runs. One run per arm. The process stayed 3.1 GB over its video memory budget, and the frame rate did not move (8.3 fps in both); none was expected while still over budget. Picture (39 sampled frames in the world, compared by a teammate agent): the run with the switch showed the scene's common state, its median mask overlapping a reference run's by 96.2 % with zero median edge displacement; the run without it was in another state of the scene (a clear tower in view), so the two arms are not a like-for-like picture pair. Not every texture was checked, and no frame-rate change is put down to the placement.
  • CI: Build and test (Windows, no GPU) is red on nvidia-dev itself and on every PR into it, this one included: the lib test process ends with 0x887a0020 in a sparse test on the runner's software adapter, with no test reported failed. Tests: sparse tests take CI's Basic Render Driver for a software device #2837 fixes that test; nothing here touches it.

Regression run
150 s runs, same title, same env (XCL_HEAP_WINDOWS=1 XCL_DIRECT_DXIL=all XCL_DIRECT_SPLIT_INSTRUCTIONS=0 XCL_PSO_JOURNAL=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=120000, DXC 1.9); the head with XCL_SMALL_TEXTURES=1 as well. The main run from a hard-link copy of our team branch's DXIL cache; the base and head runs from hard-link copies of one cache warmed on nvidia-dev a5e2d851 (on this branch the title starts after about 75-90 s of startup shader preparation, so 60 s would end inside it).

A commit of main (b49be183, the last one before the shader preparation screen of #2555):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1917 (PresentX 1917)
presents per 2 s (last 3): 0 0 2
device removals: 0
crashes: 0
peak commit: 33080 MB

The base, nvidia-dev a5e2d851:

xcl-smoke v1
commit: a5e2d851a503fc0e04609f773ea53f2d2c4e3269
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 2464 (PresentX 2464)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 34597 MB

This PR's head:

xcl-smoke v1
commit: 24fdb7b9297e47af1433a7c1069436becfe7a724
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 2641 (PresentX 2641)
presents per 2 s (last 3): 1 1 0
device removals: 0
crashes: 0
peak commit: 37649 MB

The head run reached the switch: by 171 s its log counted 4,096 small textures on 4 KiB placements, 4,096 live in 28,108 KiB of 7 heaps (at least 262,144 KiB as committed resources); 8 heaps were made by the end of the run.

Not tested

  • AMD, Intel, Wine. A title whose small textures are mostly 2D (the rules allow them; this title's were 1D). Reuse of freed units by later textures: at the run's counts every placed texture was still live, so freeing and reuse ran only in the unit test. XCL_LATE_RELEASE=0 (the switch is off then, by design).

AI use

  • Claude Code (Claude Opus 5.5) wrote the change and its tests, ran the suite and the runs on the hardware above, and wrote this description. A teammate agent (batman, Claude Code) reviewed it and compared the pictures.

🤖 Generated with Claude Code

…acements

A sampled texture the shared 64 KiB pages do not take (vram::place_pages refuses it; a 1D
texture cannot be a reserved resource) was a committed resource, which takes at least 64 KiB
of video memory. On the title the committed fallback held 8,361 x 64 KiB = 523 MiB
(XCL_COMMITTED_AUDIT), mostly ~5k Texture1D RGBA8_SRGB textures of 4 KiB or less.

With the switch, such a texture goes on a 4 KiB placement in a 4 MiB DEFAULT heap of XCL's own
(ALLOW_ONLY_NON_RT_DS_TEXTURES), made through the adopting CreatePlacedResource. Only when
the PC allows it: no RT/DS/UAV flags, one sample, and GetResourceAllocationInfo returning
4 KiB alignment for the description asking for it (most detailed level within 64 KiB).
Otherwise, and when no heap can take it, it is committed as before. Its units are free again
where late_release lets its last reference go (the queues are past the work before it); with
XCL_LATE_RELEASE=0 the switch does nothing (logged once), as uploads of XCL's into a texture
could still be in flight at the title's release. XCL asks no residency priority for the heaps,
as for a committed texture (logged per heap).

Measured on the title (RTX 5070 Ti, one 480 s run per arm, same base and env, with and
without the switch): 8,192 small textures live in 58 MiB of 15 heaps, against at least 512 MiB as committed
resources; local video memory over 250-310 s 18,332 vs 18,793 MB (-461 MB) with equal sparse
pools and target pages. Still 3.1 GB over the budget there, and the frame rate did not move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant