Skip to content

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

Merged
Prime1997 merged 1 commit into
xcl-dev:nvidia-devfrom
Kalmarv:nvd-small-tex
Nov 28, 2026
Merged

Prime1997 merged 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>
@Kalmarv
Kalmarv marked this pull request as ready for review November 27, 2026 15:13
@UncommonDLL

UncommonDLL commented Nov 27, 2026 •

Copy link
Copy Markdown

@Kalmarv We can test the freed-slot case you flagged using small 2D textures on an RTX 5070 Ti. We’ll check whether a replacement actually reuses the retired texture’s heap offset, then read back both the replacement and a neighboring texture that stayed alive. We’ll reuse the #1835 fixture if it reaches this path.

Update: The freed-slot test passed on a physical RTX 5070 Ti with driver 621.40. We tested local commit 16b040f016133c221d9284c188a19c67c1cb9377 on #3008 head 24fdb7b9297e47af1433a7c1069436becfe7a724. One run completed with zero skips.

After GPU completion, XCL’s late_release path retired texture A. Texture C then reused A’s exact 16 KiB range at offset 0 in the same small_tex heap. All 16,384 bytes of C matched its new pattern. The neighboring texture B stayed live at offset 16,384, and every byte matched its original pattern before and after reuse. None of the three allocations fell back to a committed resource.

This covers serial reuse after GPU completion. Release with GPU work still in flight remains open. We can share the test-only patch. OpenAI Codex ran the Windows test, and Claude Sonnet 5.5 Extra reviewed the fixture design.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #3008 at head 24fdb7b9297e47af1433a7c1069436becfe7a724 (1 commit; exact parent & merge-base: a5e2d851a503fc0e04609f773ea53f2d2c4e3269, ancestor of nvidia-dev).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted tests & build (24fdb7b9)

Command Result
cargo test --release -p xcl --lib -- --nocapture hle::d3d12x::small_tex:: (3 consecutive runs) 2 passed; 0 failed; 0 ignored; 1727 filtered out × 3 (0.19s, 0.20s, 0.18s, 0 skipped; live RTX 4060 D3D12 device exercised only_textures_the_pc_places_on_4_kib_are_taken)
cargo build --release -p xcl Clean build (2m 04s, exit 0, 0 new warnings in small_tex.rs, device_x.rs, late_release.rs, or PR-touched lines)

Paired quiet 60 s retail smoke (title: 29640639, XCL_PREPARE=0, XCL_NETWORK=0, A/B default vs. XCL_SMALL_TEXTURES=1)

Exact parent & merge-base (a5e2d851a503fc0e04609f773ea53f2d2c4e3269, nvidia-dev ancestor):

xcl-smoke v1
commit: a5e2d851a503fc0e04609f773ea53f2d2c4e3269
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1513 (PresentX 1513)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14868 MB

PR #3008 (24fdb7b9297e47af1433a7c1069436becfe7a724, default — XCL_SMALL_TEXTURES unset):

xcl-smoke v1
commit: 24fdb7b9297e47af1433a7c1069436becfe7a724
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1559 (PresentX 1559)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14587 MB

PR #3008 (24fdb7b9297e47af1433a7c1069436becfe7a724, opt-in — XCL_SMALL_TEXTURES=1):

xcl-smoke v1
commit: 24fdb7b9297e47af1433a7c1069436becfe7a724
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1551 (PresentX 1551)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 14576 MB

A/B runtime telemetry observed in xcl.log on RTX 4060 (621.14)

  • Default (XCL_SMALL_TEXTURES unset): 0 small textures log lines; steady-state memory at ~58.6 s: 14500 MB committed (peak commit: 14587 MB), 6115 MB local, 4702 MB non-local (budget 6860 MB).
  • Enabled (XCL_SMALL_TEXTURES=1): logged D3D12.X: small textures: heap 1 of 4 MiB made, residency priority: default, no override (as for a committed texture) at 3.457 s with 0 4 KiB placement failed warnings; steady-state memory at ~58.4 s: 14576 MB committed (peak commit: 14576 MB, -11 MB vs. default), 6116 MB local (+1 MB), 4737 MB non-local (budget 6863 MB). Because small_tex::place logs its placement summary at powers of two starting at k >= 64, fewer than 64 eligible small textures were placed during this 60 s startup window.

Limits of coverage

  • Both hle::d3d12x::small_tex:: tests (units_are_taken_first_fit_and_given_back and live-RTX 4060 only_textures_the_pc_places_on_4_kib_are_taken) passed 3/3 with 0 skips, and the A/B 60 s smokes (XCL_PREPARE=0, XCL_NETWORK=0) verified default-off behavior and clean 4 MiB small-texture heap creation + 4 KiB CreatePlacedResource placement (0 placement failures, 0 device removals, 0 crashes, steady 60 Hz).
  • The 60 s startup window created fewer than 64 small textures (1 4 MiB heap allocated), so multi-heap VRAM savings under heavy in-world streaming (hundreds/thousands of small lookup textures) and the XCL_LATE_RELEASE=0 interaction were not exercised in this short smoke.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@pickles976

Copy link
Copy Markdown

Wine/NVIDIA offscreen verification at exact production head 24fdb7b9297e47af1433a7c1069436becfe7a724 (immediate parent a5e2d851a503fc0e04609f773ea53f2d2c4e3269). xcl-pr3008 differs only by a local GPU regression in small_tex.rs and a required-device assertion in the existing admission fixture.

With XCL_SMALL_TEXTURES=1, XCL_LATE_RELEASE=1, and DXVK_CONFIG='dxgi.hideNvidiaGpu = False', Windows-MSVC Wine cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib hle::d3d12x::small_tex::tests:: -- --nocapture --test-threads=1 passed 3/3, 0 ignored, 0.69 s after fresh intended-worktree compilation (33.32 s).

The new nvidia_upload_readback_survives_serial_heap_offset_reuse requires vendor 0x10de and real 4-KiB placement eligibility. Reproduction recipe:

  1. Production small_tex::place creates two sampled RGBA8 1D textures, 256 texels each. On this RTX 4060 Laptop, allocation is 8192 bytes each, at offsets0 and8192 in the same4MiB heap.
  2. Upload1024 bytes of 0x19 to the first and 0x5c to its live neighbour; GPU copy/readback checks every texel byte after an actual completion fence.
  3. Reset the completed command list, drop the first adopted resource, and wait for the production final-Release / late_release retirement to remove its live placement (not a direct call to small_tex::gone).
  4. Require the replacement to reuse the exact original heap, byte offset and allocation size. Record an aliasing barrier and upload 0xa7; a second GPU submission verifies all replacement bytes and that every neighbour byte remains unchanged. Both resources subsequently retire through the same production path.

This is serial reuse after completed GPU work, not pending-use safety across queues. No deliberately blocked GPU queue; fence/retirement waits bounded to10s. The two original admission/first-fit unit fixtures also pass. Heap pooling/reuse is proven; physical memory saving, heap reclamation, title peak RAM/VRAM and frame time are not measured.

Linux6.17/i7-13620H/16GiB/Wine11/NVIDIA590.48.1, physical RTX4060Laptop8GiB. Diagnostic relaxed-vtable vkd3d 2576c0b4adfae4a+, not stock certification. Unchanged9GiB/512MiB scope and external guards; sampled GPU158MiB, available RAM minimum9032.2MiB, disk minimum11.820GiB. Evidence .compat-runtime/logs/verify-xcl3008-small-texture-reuse-20261127T173952Z/. No matched parent or title run; this does not address our separate Game-Init incomplete producer fence. A useful remaining owner gate is retaining a placement across a pending consumer before reuse, with bounded teardown.

AI-assisted local fixture/verification: OpenAI Codex GPT-6-Astra. No game assets, saves or imagery attached.

@throny throny mentioned this pull request Nov 27, 2026
@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 24fdb7b

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: d1be810 (nvidia-dev)
head: 24fdb7b
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1826 passed, 8 failed, 48 ignored (27 SKIPPED lines). The 8 failures are the base's own on this GPU, the same six names with and without the PR (#2771 and #2788 fix three of them). Base alone: 1824 passed, 8 failed, 48 ignored.
review: one finding that blocks the feature, read in the code and not reproduced at run time: units_for asks the device it is given for GetResourceAllocationInfo, and small_tex::place gives it the title's device, whose vtable is XCL's console one. Slot 25 there is get_resource_allocation_info_x (device_x.rs), which answers with the console's size and alignment for every texture its console model knows and with the PC driver's only otherwise. So the 4 KiB check and the unit count can be the console's, not this driver's; where the console size is smaller than the PC's (the PR itself notes 8 KiB on PC for one small 1D texture), the next texture would be placed over it, and CreatePlacedResource does not complain. The unit test uses a fresh, unhooked device, so it cannot see this. Fix: take the driver's function the way that hook does (real::orig_fn(this, 25)). Opt-in (XCL_SMALL_TEXTURES=1), so nothing changes by default.
performance: none by default (one OnceLock read).
verdict: not yet: size and alignment must come from the PC driver; then I will rerun, and I can add a world run with the switch on.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite unless said).

@andrewDoing

Copy link
Copy Markdown
Contributor

I checked the slot-25 sizing concern on exact head 24fdb7b9297e47af1433a7c1069436becfe7a724, RTX 5070 / NVIDIA 616.92, with a test-only native fixture. The device was adopted, and I verified that its slot 25 differed from the original driver function. The fixture called production small_tex::units_for and compared its result with the original driver method on that same COM object.

For the 256×1 RGBA8 sRGB example, both reported 8,192 bytes at 4,096-byte alignment; units_for returned two 4 KiB units. Across 738 tested descriptors, eligibility and unit counts agreed with the original driver.

The likely reason is that adoption installs a split guard for slot 25: the call originating in XCL's units_for is routed to the PC target, while a title-originated call is routed to the console target. This tests that particular caller and descriptor set; it does not prove correctness for every descriptor, neighboring texture contents, or GPU lifetime.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the checks and traced the routing; Codex reviewed and prepared this report.

@Prime1997
Prime1997 merged commit 01b94f5 into xcl-dev:nvidia-dev Nov 28, 2026
4 of 5 checks passed
@UncommonDLL

Copy link
Copy Markdown

Following up on the pending-consumer case left open by the earlier serial reuse tests: we now have a passing physical result on main fa204595a488c60c6c5f905244f0172072c9c2a9 with a local test-only fixture.

Hardware: RTX 5070 Ti, NVIDIA driver 621.40 (32.0.16.2140), Windows, Rust 1.100.0 MSVC. Enabled XCL_SMALL_TEXTURES=1, XCL_LATE_RELEASE=1 and XCL_VRAM_ARENAS=1.

  • Created two 64×64 RGBA8 textures, A and B, in adjacent 16 KiB ranges of the same small-texture heap.
  • Submitted a DIRECT-queue copy consumer behind an unsignaled fence, then released A through the production retirement path.
  • While the gate was 0/1, copy fence 1/2 and retirement fence 0/1, texture C occupied offset 32,768 rather than overlapping A or B.
  • Opened the gate and verified the pending readbacks. After A's retirement fence completed and its native Release returned zero, texture D reused A's exact heap, offset and allocation size.
  • All seven 16,384-byte readback comparisons passed. B retained its original contents without reupload. Final teardown reached zero native references for B, C and D.

The isolated test reported 1 passed, 0 failed, 0 skipped. The D3D12 debug layer was enabled, with zero stored InfoQueue messages. The fixture retained its native command allocator and list until fence completion.

This covers one synthetic DIRECT-queue consumer on one adapter and driver. Placement offsets come from allocator bookkeeping. GPU-based validation was not requested, and discarded InfoQueue messages were not counted. Cross-queue consumers, retail workloads, stress behavior and memory savings remain untested.

We can share the test-only regression fixture if useful.

AI assistance: OpenAI Codex prepared and executed the fixture, Claude Opus reviewed source readiness, and a separate Codex reviewer checked the measured evidence. Exact Codex model variants were not recorded.

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.

7 participants