D3D12.X: share staging for zero-filled lazy texture mips (#1773) #2573

Open
github-bot wants to merge 1 commit from github-bot/gh-2573 into main AGit
Owner

@⁠razormontana on GitHub · 2026-11-25 23:18 UTC · original
razormontana:d3d12x/share-zero-mip-upload-staging → main · +229 −31 · 3 files · 1 commits · open

Part of #1773 and #1833. Lazy texture uploads can contain several all-zero mips. The title-texture uploader now uses one zero-filled staging span for their sources, reducing the staging request while still copying every mip.

What is in it

  • title_textures.rs passes the existing lazy-level zero detection into the CPU uploader. texture.rs shares one aligned span when at least two zero sources are present, retaining the driver's footprint dimensions and each copy and transition. The reused staging span is cleared through the final row of every depth slice.
  • The planner test covers ordinary and shared offsets, full pitched clearing and requested size. For eight synthetic 1024² R8 textures, the request falls from 11,403,072 to 4,063,232 bytes, which selects 16 MiB and 4 MiB size classes for a fresh uploader. The GPU test refreshes a placed texture and verifies zero readback of a previously mapped top mip and a packed mip, with nonzero neighbors preserved.

Tested

  • Windows 11 Pro (22631.5335), Core i7-10700K, NVIDIA GeForce RTX 3070 8 GB (driver 617.42), Rust 1.100.0 MSVC. Debug workspace tests, release retail smoke.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output on 1bfa05d reported 1424 passes, 0 failures, and 46 ignored. There were 26 explicit runner skips within the pass count.
  • The focused staging planner and placed-texture refresh tests each passed 1/0/0 with zero skips. The old dense planner failed the new size assertion. Native RTX 3070 refresh cleared both previously mapped levels and preserved the nonzero neighbors byte for byte.
  • cargo build --offline --locked --release -p xcl succeeded. scripts/smoke.ps1 ran the same title offline for 60 seconds per arm with direct DXIL and matching cache seeds.

Regression run

Main

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 493 (PresentX 493)
presents per 2 s (last 3): 12 13 8
device removals: 0
crashes: 0
peak commit: 15495 MB

PR head

xcl-smoke v1
commit: 1bfa05d9214cf5f68e602233072d8786fd3c529a
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 658 (PresentX 658)
presents per 2 s (last 3): 9 0 12
device removals: 0
crashes: 0
peak commit: 14469 MB

Not tested

  • Retail staging savings and world-load timing. The fixture measures staging layout and texel correctness. It does not quantify VRAM savings. Other GPU vendors remain unmeasured.

AI use

Yes, Codex GPT-6.2 Sol implemented and independently reviewed the patch, ran the tests, and prepared this description.

**@⁠razormontana** on GitHub · 2026-11-25 23:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/2573) `razormontana:d3d12x/share-zero-mip-upload-staging` → `main` · +229 −31 · 3 files · 1 commits · open Part of #1773 and #1833. Lazy texture uploads can contain several all-zero mips. The title-texture uploader now uses one zero-filled staging span for their sources, reducing the staging request while still copying every mip. **What is in it** - `title_textures.rs` passes the existing lazy-level zero detection into the CPU uploader. `texture.rs` shares one aligned span when at least two zero sources are present, retaining the driver's footprint dimensions and each copy and transition. The reused staging span is cleared through the final row of every depth slice. - The planner test covers ordinary and shared offsets, full pitched clearing and requested size. For eight synthetic 1024² R8 textures, the request falls from 11,403,072 to 4,063,232 bytes, which selects 16 MiB and 4 MiB size classes for a fresh uploader. The GPU test refreshes a placed texture and verifies zero readback of a previously mapped top mip and a packed mip, with nonzero neighbors preserved. **Tested** - Windows 11 Pro (22631.5335), Core i7-10700K, NVIDIA GeForce RTX 3070 8 GB (driver 617.42), Rust 1.100.0 MSVC. Debug workspace tests, release retail smoke. - `cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output` on `1bfa05d` reported 1424 passes, 0 failures, and 46 ignored. There were 26 explicit runner skips within the pass count. - The focused staging planner and placed-texture refresh tests each passed 1/0/0 with zero skips. The old dense planner failed the new size assertion. Native RTX 3070 refresh cleared both previously mapped levels and preserved the nonzero neighbors byte for byte. - `cargo build --offline --locked --release -p xcl` succeeded. `scripts/smoke.ps1` ran the same title offline for 60 seconds per arm with direct DXIL and matching cache seeds. **Regression run** Main ``` xcl-smoke v1 commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 493 (PresentX 493) presents per 2 s (last 3): 12 13 8 device removals: 0 crashes: 0 peak commit: 15495 MB ``` PR head ``` xcl-smoke v1 commit: 1bfa05d9214cf5f68e602233072d8786fd3c529a gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 658 (PresentX 658) presents per 2 s (last 3): 9 0 12 device removals: 0 crashes: 0 peak commit: 14469 MB ``` **Not tested** - Retail staging savings and world-load timing. The fixture measures staging layout and texel correctness. It does not quantify VRAM savings. Other GPU vendors remain unmeasured. **AI use** Yes, Codex GPT-6.2 Sol implemented and independently reviewed the patch, ran the tests, and prepared this description.
A lazy upload batch can use one zero-filled source span for multiple
zero mips. Keep every copy and preserve its pitch and transitions.

The synthetic eight-texture case moves from 16 MiB to 4 MiB of staging
capacity. RTX 3070 readback confirms mapped zero mips clear and their
nonzero neighbors keep their texels.

Assisted-by: Codex (GPT-6.2 Sol)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:34:08 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 23:28 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-25 23:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/2573#issuecomment-7177617755) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 26 ignored. Thanks! — Devin
Author
Owner

@⁠xpatfussy69x on GitHub · 2026-11-26 00:02 UTC · original

Test run on exact head 1bfa05d (1bfa05d9214cf5f68e602233072d8786fd3c529a, on its base e1d84b7), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1424 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib shared_zero_mip_staging: 1 passed, 0 failed
  • This PR's new tests in the workspace run:
    • shared_zero_mip_staging_compacts_and_clears_the_full_span: ok

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1571 (PresentX 1571)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14042 MB

this PR:

xcl-smoke v1
commit: 1bfa05d9214cf5f68e602233072d8786fd3c529a
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1639 (PresentX 1640)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14036 MB

No crash or device removal; frames 104 % of main's, peak commit 100 %. The main run is on current main (08db802), newer than this PR's base.

Not tested

  • Whether the title creates lazy textures with zero-filled mips in this run (default settings): a regression check only
  • The PR merged into current main (tested on its own base; it merges into 08db802 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
**@⁠xpatfussy69x** on GitHub · 2026-11-26 00:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/2573#issuecomment-7178321267) Test run on exact head `1bfa05d` (`1bfa05d9214cf5f68e602233072d8786fd3c529a`, on its base `e1d84b7`), clean tree. **Tested** - NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs - `cargo test --workspace -- --test-threads=4`: 1424 passed, 0 failed, 46 ignored - SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused `V_MUL_F16` / `V_PK_MUL_F16` / `V_CVT_F16_F32` (on `main` too) - `cargo test -p xcl --lib shared_zero_mip_staging`: 1 passed, 0 failed - This PR's new tests in the workspace run: - `shared_zero_mip_staging_compacts_and_clears_the_full_span`: ok **Regression run** (60 s, default settings, a retail title) main: ``` xcl-smoke v1 commit: 08db8020d323bf478964fcc586152cce54959cfc gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1571 (PresentX 1571) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14042 MB ``` this PR: ``` xcl-smoke v1 commit: 1bfa05d9214cf5f68e602233072d8786fd3c529a gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1639 (PresentX 1640) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14036 MB ``` No crash or device removal; frames 104 % of `main`'s, peak commit 100 %. The `main` run is on current `main` (`08db802`), newer than this PR's base. **Not tested** - Whether the title creates lazy textures with zero-filled mips in this run (default settings): a regression check only - The PR merged into current `main` (tested on its own base; it merges into `08db802` without conflicts) - AMD / native wave64 **AI use** - Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-26 00:17 UTC · original

Independent Windows/NVIDIA check of the current clean head 1bfa05d. RTX 3080 Ti / driver 621.35, Windows 11 build 26300, rustc 1.99.1, DXC 1.8.2502.11; debug build.

Tested

  • cargo test -p xcl --lib shared_zero_mip_staging_compacts_and_clears_the_full_span -- --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib a_placed_texture_gets_the_pages_of_a_level_with_its_texels -- --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored. This exercised placed-resource refresh and GPU readback: the newly zeroed top and packed mips read back zero, while the nonzero neighboring mips retained their expected bytes. Neither focused test skipped.
  • cargo build --workspace: passed. cargo test --workspace --no-fail-fast -- --test-threads=4: 1,424 passed, 0 failed, 46 ignored; 25 explicit SKIPPED GPU notices. Both named tests passed in the workspace run too.

Not tested: a paired retail-title smoke on this machine, AMD/native wave64, retail staging allocation savings, VRAM use, or world-load time. The synthetic planner's size assertions are not a measured retail performance result.

AI use: Codex (GPT-6.2 Sol) reviewed the tests, ran the commands, and drafted this report; GPT-6.2 Astra reviewed the staging and queue-lifetime reasoning.

**@⁠thehollowedone** on GitHub · 2026-11-26 00:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/2573#issuecomment-7178600048) Independent Windows/NVIDIA check of the current clean head [`1bfa05d`](https://github.com/xcl-dev/xcl/commit/1bfa05d9214cf5f68e602233072d8786fd3c529a). RTX 3080 Ti / driver 621.35, Windows 11 build 26300, rustc 1.99.1, DXC 1.8.2502.11; debug build. **Tested** - `cargo test -p xcl --lib shared_zero_mip_staging_compacts_and_clears_the_full_span -- --nocapture --test-threads=1`: 1 passed, 0 failed, 0 ignored. - `cargo test -p xcl --lib a_placed_texture_gets_the_pages_of_a_level_with_its_texels -- --nocapture --test-threads=1`: 1 passed, 0 failed, 0 ignored. This exercised placed-resource refresh and GPU readback: the newly zeroed top and packed mips read back zero, while the nonzero neighboring mips retained their expected bytes. Neither focused test skipped. - `cargo build --workspace`: passed. `cargo test --workspace --no-fail-fast -- --test-threads=4`: 1,424 passed, 0 failed, 46 ignored; 25 explicit `SKIPPED` GPU notices. Both named tests passed in the workspace run too. **Not tested:** a paired retail-title smoke on this machine, AMD/native wave64, retail staging allocation savings, VRAM use, or world-load time. The synthetic planner's size assertions are not a measured retail performance result. AI use: Codex (GPT-6.2 Sol) reviewed the tests, ran the commands, and drafted this report; GPT-6.2 Astra reviewed the staging and queue-lifetime reasoning.
Author
Owner

@⁠pickles976 on GitHub · 2026-11-26 04:42 UTC · original

Wine/NVIDIA cross-check: planner test passes; the GPU fixture cannot run under stock vkd3d-proton on this host. Head 1bfa05d9214cf5f68e602233072d8786fd3c529a, Linux + Wine 11.0, vkd3d-proton 3.2.0 (2576c0b4adfae4a), NVIDIA 590.48.1, RTX 4060 Laptop GPU 8 GiB, --locked --target x86_64-pc-windows-msvc, one test thread, fresh Compiling xcl .../xcl-pr2573/... provenance, vendor masking disabled.

  • gpu::texture::tests::shared_zero_mip_staging_compacts_and_clears_the_full_span — 1/1 pass (CPU-only, 0.00 s): shared offsets, full pitched clearing and requested size all check out on this host.
  • hle::d3d12x::title_textures::tests::a_placed_texture_gets_the_pages_of_a_level_with_its_texels — aborts before the test body on stock vkd3d-proton's replaced-vtable assertion: ID3D12Fence1 – 12 PC methods, 10 internal slots under the guard, +64 stubs then Assertion failed: iface->lpVtbl == &d3d12_fence_vtbl, file ../src-vkd3d-proton/libs/vkd3d/vkd3d_private.h, line 705, exit 3. This is the known #175 infrastructure wall on Linux/Wine (the same abort shape as the GPU fixtures of #2428/#2558 here), not a failure of this PR's code: the fixture's fence-guard setup itself trips the stock library. No pass/fail claim for the placed-texture extension on this stack; the Windows RTX 3070 result in the PR description remains the only GPU coverage of it.

So on this host: staging-planner logic verified; zero-mip GPU readback unverified pending a vkd3d-proton build that tolerates replaced vtables (the #175 proposal, or the relaxed-vtable two-hunk build described in #2140). No title run; no staging-byte savings measured at retail.

Logs: .compat-xcl/logs/verify-pr2573-wine-planner.log, verify-pr2573-wine-placed.log (local). AI-assisted verification and report (OpenAI Codex).

**@⁠pickles976** on GitHub · 2026-11-26 04:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/2573#issuecomment-7182838084) **Wine/NVIDIA cross-check: planner test passes; the GPU fixture cannot run under stock vkd3d-proton on this host.** Head `1bfa05d9214cf5f68e602233072d8786fd3c529a`, Linux + Wine 11.0, vkd3d-proton 3.2.0 (`2576c0b4adfae4a`), NVIDIA 590.48.1, RTX 4060 Laptop GPU 8 GiB, `--locked --target x86_64-pc-windows-msvc`, one test thread, fresh `Compiling xcl .../xcl-pr2573/...` provenance, vendor masking disabled. - `gpu::texture::tests::shared_zero_mip_staging_compacts_and_clears_the_full_span` — **1/1 pass** (CPU-only, 0.00 s): shared offsets, full pitched clearing and requested size all check out on this host. - `hle::d3d12x::title_textures::tests::a_placed_texture_gets_the_pages_of_a_level_with_its_texels` — **aborts before the test body** on stock vkd3d-proton's replaced-vtable assertion: `ID3D12Fence1 – 12 PC methods, 10 internal slots under the guard, +64 stubs` then `Assertion failed: iface->lpVtbl == &d3d12_fence_vtbl, file ../src-vkd3d-proton/libs/vkd3d/vkd3d_private.h, line 705`, exit 3. This is the known #175 infrastructure wall on Linux/Wine (the same abort shape as the GPU fixtures of #2428/#2558 here), not a failure of this PR's code: the fixture's fence-guard setup itself trips the stock library. No pass/fail claim for the placed-texture extension on this stack; the Windows RTX 3070 result in the PR description remains the only GPU coverage of it. So on this host: staging-planner logic verified; zero-mip GPU readback unverified pending a vkd3d-proton build that tolerates replaced vtables (the #175 proposal, or the relaxed-vtable two-hunk build described in #2140). No title run; no staging-byte savings measured at retail. Logs: `.compat-xcl/logs/verify-pr2573-wine-planner.log`, `verify-pr2573-wine-placed.log` (local). AI-assisted verification and report (OpenAI Codex).
Author
Owner

@⁠pickles976 on GitHub · 2026-11-26 04:57 UTC · original

Follow-up: the placed-texture GPU fixture now runs and passes on a relaxed diagnostic stack. My earlier comment reported the GPU leg aborting pre-body on stock vkd3d-proton's fence-vtable assertion (vkd3d_private.h:705) with no verdict possible.

Rebuilt the same exact provenance commit our stock DLL came from (2576c0b4adfae4a) with -Db_ndebug=true plus the two from_iface relaxations from #175 (local diagnostic build only), same RTX 4060 Laptop / Wine 11.0 / NVIDIA 590.48.1 host: a_placed_texture_gets_the_pages_of_a_level_with_its_texels passes 1/1 (1.16 s, 0 ignored), fresh Compiling xcl .../xcl-pr2573/... provenance.

That completes this machine's verification of the PR: staging planner 1/1 (stock stack) and the placed-texture zero-mip GPU fixture 1/1 (relaxed diagnostic stack) — both consistent with the author's Windows RTX 3070 result. The fixture exercises the shared zero-span clearing of a previously mapped top mip and a packed mip with nonzero neighbours preserved, on the real adapter. No retail staging savings measured. Log: .compat-xcl/logs/verify-pr2573-wine-placed-relaxed.log (local). AI-assisted verification and report (OpenAI Codex).

**@⁠pickles976** on GitHub · 2026-11-26 04:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/2573#issuecomment-7183055511) **Follow-up: the placed-texture GPU fixture now runs and passes on a relaxed diagnostic stack.** My earlier comment reported the GPU leg aborting pre-body on stock vkd3d-proton's fence-vtable assertion (`vkd3d_private.h:705`) with no verdict possible. Rebuilt the same exact provenance commit our stock DLL came from (`2576c0b4adfae4a`) with `-Db_ndebug=true` plus the two `from_iface` relaxations from #175 (local diagnostic build only), same RTX 4060 Laptop / Wine 11.0 / NVIDIA 590.48.1 host: `a_placed_texture_gets_the_pages_of_a_level_with_its_texels` **passes 1/1** (1.16 s, 0 ignored), fresh `Compiling xcl .../xcl-pr2573/...` provenance. That completes this machine's verification of the PR: staging planner 1/1 (stock stack) and the placed-texture zero-mip GPU fixture 1/1 (relaxed diagnostic stack) — both consistent with the author's Windows RTX 3070 result. The fixture exercises the shared zero-span clearing of a previously mapped top mip and a packed mip with nonzero neighbours preserved, on the real adapter. No retail staging savings measured. Log: `.compat-xcl/logs/verify-pr2573-wine-placed-relaxed.log` (local). AI-assisted verification and report (OpenAI Codex).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2573/head:github-bot/gh-2573'
git switch 'github-bot/gh-2573'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2573'
git switch 'github-bot/gh-2573'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2573'
git switch 'github-bot/gh-2573'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2573'
git switch 'main'
git merge --squash 'github-bot/gh-2573'
git switch 'main'
git merge --ff-only 'github-bot/gh-2573'
git switch 'main'
git merge 'github-bot/gh-2573'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.