Skip to content

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

Open
razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/share-zero-mip-upload-staging
Open

razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/share-zero-mip-upload-staging

Conversation

@razormontana

Copy link
Copy Markdown
Contributor

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)
@razormontana
razormontana marked this pull request as ready for review November 25, 2026 23:25
@DavidM1911

Copy link
Copy Markdown
Contributor

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

@xpatfussy69x

Copy link
Copy Markdown

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.

@thehollowedone

Copy link
Copy Markdown

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.

@pickles976

Copy link
Copy Markdown

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.

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

Copy link
Copy Markdown

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).

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.

5 participants