Skip to content

D3D12.X: slice direct mesh draws within the record cap - #2902

Draft
coolpersonnn wants to merge 4 commits into
xcl-dev:nvidia-devfrom
coolpersonnn:d3d12x/slice-mesh-draws-under-cap
Draft

coolpersonnn wants to merge 4 commits into
xcl-dev:nvidia-devfrom
coolpersonnn:d3d12x/slice-mesh-draws-under-cap

Conversation

@coolpersonnn

@coolpersonnn coolpersonnn commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2817. This PR adds the top commit, 96dfa767.

Part of #2688. Direct two-pass mesh draws that fit the normal record limit can lose groups if the cap allows only a smaller buffer. Record those draws in slices while keeping the console group IDs used to generate geometry.

What is in it

  • Prepare each slice with its group offset and reuse the same records between compute and mesh passes. The HLSL and direct DXIL paths use that offset when generating geometry.
  • Extend the GPU mesh-record test to compare a sliced group with the corresponding group in a full draw.

Tested

  • Windows 11 Pro build 26300, Ryzen 9 9950X3D, RTX 5090 with driver 32.0.16.2101, Radeon integrated graphics with driver 32.0.21045.29003, Rust 1.100.0, and DXC 1.8.2502.11.
  • The debug gpu_mesh_mode_two_passes regression on the lab version passed on each adapter with both shader backends exercised and zero GPU skips.
  • A 180-second RTX 5090 world-load probe with XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684 on both arms and XCL_TWO_PASS_MB=256 recorded 126 direct mesh groups dropped on control ad352c36 and zero on patched lab build 001e9abf. The patched run still recorded 4,687 allocation refusals. Both runs stopped presenting during world load.
  • Rebased onto D3D12.X: cap two-pass buffers by DXGI headroom with wait and shrink #2817 head a2c10b4a and verified the top patch with git range-diff and git diff --check.
  • Debug on rebased head 96dfa767, RTX 5090 plus WARP. cargo test --offline --locked -j 4 -p xcl --lib -- gpu_mesh_mode_two_passes later_queue_completion_during_sleep_reclaims_before_wait_deadline --test-threads=1 --nocapture reported 2 passed, 0 failed, 0 ignored, and zero GPU skips.

Regression run

  • Exact-head paired retail smokes and the full workspace suite are pending on this draft.

Not tested

  • Lower-VRAM discrete GPUs, sustained gameplay, or indirect mesh slicing.

AI use

  • T3 Code, Codex (gpt-6.2-sol) wrote the slicing change and regression coverage, ran the GPU and title checks, and rebased the patch.

Sweep expired reusable buffers even when an allocator releases no
buffers of its own. The WARP regression seeds the free pool, then
checks it directly after an unrelated allocator release.

Suggested-by: thehollowedone (xcl-dev#2815 (comment))

Publish the retired batch and its byte charge under the same lock. Otherwise reclamation can subtract a batch before the publisher adds its bytes.

Reclaim retired and reset two-pass record, batch, and argument scratch
buffers when their recording's submit queue fences pass, without waiting
for the owning command allocator to reset. Guard fence polling against
device removal (`u64::MAX` / `FenceState::Removed`) so in-flight buffers
are never returned to the reuse pool on a lost device, keep closed command
lists' buffers intact across idle trims for Reset-less replay, and track
upstream `batch_buf` allocations through the same submit fences.

Part of xcl-dev#2688

Assisted-by: T3 Code / Antigravity (Gemini Pro Orchestrator Neon)
Assisted-by: Codex (GPT-6.2 Sol)
Assisted-by: Codex (gpt-6.2-sol)
…uckets

Add 256 KiB half-step record buffer buckets and async GPU group-count
feedback for two-pass ExecuteIndirect draws (including deferred batch
mode), eliminate cold-start clamping so initial indirect draws keep
full capacity, keep active frustum-culled PSOs warm over a 16-window
history while dropping unused PSOs to 256 KiB, report exact clamped
command and dropped group counts, guard feedback readback against
device removal (`u64::MAX` / `q.Signal`), and bound reuse growth in
`ensure_res_buffer`.

Part of xcl-dev#2688

Assisted-by: T3 Code / Antigravity (Gemini Pro Orchestrator Neon)
Assisted-by: Codex (GPT-6.2 Sol)
Reclaim completed batches on other queues at elapsed-time intervals
during the cap wait. One pending fence must not hide a reusable
record buffer until the wait deadline. The WARP regression completes
the later batch after polling changes from yields to sleeps.

Reported-by: thehollowedone (xcl-dev#2817 (comment))
Assisted-by: Codex (gpt-6.2-sol)

Cap the two-pass pool dynamically at 25% of remaining DXGI local VRAM
headroom with a card-scaled floor `(local_budget / 32).clamp(256 MiB, 512 MiB)`
and a `min(local_budget / 4, 2048 MiB)` ceiling cached for 250 ms, remove
the `/ 2` reuse pool clamp in `put_free_bufs` that caused buffer churn,
retry oversized reuse candidates before waiting, bound submit-fence waits
at 10 ms with 250 ms timeout backoff and device-removal short-circuiting,
walk every 256 KiB half-step bucket while shrinking record buffers down
to a single record (avoiding unnecessary jumps past 1.5x steps) while
counting direct `DispatchMesh` cuts/drops, and let `XCL_TWO_PASS_BATCH`
halves and batch-buffer allocations fall back without polluting `TP_REFUSED`.

Part of xcl-dev#2688

Assisted-by: T3 Code / Antigravity (Gemini Pro Orchestrator Neon)
Assisted-by: Codex (GPT-6.2 Sol)
Give each slice its original console group IDs while reusing the same records. The mesh shader test compares the generated records in both shader backends.

Assisted-by: Codex (gpt-6.2-sol)
@coolpersonnn
coolpersonnn force-pushed the d3d12x/slice-mesh-draws-under-cap branch from 8e16f9c to 96dfa76 Compare November 26, 2026 23:14
@andrewDoing

Copy link
Copy Markdown

RTX 5070 direct mesh slice verification

The focused tests on clean PR #2902 head 96dfa767b927190f0d57eba22f9dba56c995deaf passed on Windows. The mesh fixture ran with the 12 GB RTX 5070 selected and strict mesh capability required. Both the HLSL-generated shader and the direct DXIL shader produced the group-1 geometry from the unsliced draw when writing record 0 of a one-group slice. The fixture compares the vertex and primitive counts, active vertex records and primitive indices. The unsliced draw also checks triangle pixels and the unmapped background. Run log

The command was cargo test --locked --offline -p xcl --lib -- gpu_mesh_mode_two_passes later_queue_completion_during_sleep_reclaims_before_wait_deadline --test-threads=1 --nocapture, with XCL_ADAPTER=RTX 5070, XCL_REQUIRE_GPU=mesh, and a fresh writable DXIL cache. It reported 2 passed, 0 failed, 0 ignored and no explicit skip markers in 1.10 s. The second test explicitly creates a WARP device and uses simulated fence completions.

This verifies the group-base math on a discrete GPU with less memory than the original RTX 5090 host. The mesh fixture supplies the slice base directly. It does not drive the allocator into a low-memory state, measure a retail world load, or exercise indirect mesh slicing.

AI use: OpenAI Codex selected and ran the existing tests, checked the fixture and prepared this report.

@JJAutoCompare

Copy link
Copy Markdown

Tested

Clean 96dfa767b927190f0d57eba22f9dba56c995deaf on Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC. A standalone synthetic boundary probe linked against the exact-head XCL library built using cargo build --offline --locked -j 2 -p xcl --lib --message-format=json. Ran the pinned probe as boundary-gpu.exe --test-threads=1 --nocapture with XCL_ADAPTER=A770 under the shared Arc mutex. The runtime identified the Arc A770, PCI 8086:56a0.

Both HLSL and direct DXIL matched every active record, checking counts and group IDs for workloads of 13, 14, 15, 28 and 29 groups at a 14-record cap. The 29-group case split 14+14+1 and returned 87 vertices and 29 primitives. One test passed, zero failed, ignored, or skipped. Executable SHA-256 matched before, during, and after the locked run.

Not tested

The probe supplies the IO group base and invokes the runner once per slice. Production allocator-driven DispatchMesh staging under pressure, indirect slicing, the full suite, and retail smoke were outside this run.

AI use

T3 Code / Codex (gpt-6.2-sol) prepared the synthetic boundary probe and ran and reproduced its Arc readback.

@LocranKing

Copy link
Copy Markdown

Tested PR #2902 (96dfa767) on Windows 11 with a 180 s open-world smoke run (lockhart) and the d3d12_mesh_stream integration tests against base a5e2d851.

Environment

  • GPU: NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2140)
  • CPU / RAM: AMD Ryzen 5 5500 (6C/12T), 32 GB DDR4, Windows 11 Build 26300
  • Shader cache & runtime: Frozen nvidia-dev DXIL cache (XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_TEXTURE_LEVEL_PAGES=1, XCL_PREPARE_GRAPHICS=0, XCL_DRED=1), Series S (lockhart) profile.

Integration tests (d3d12_mesh_stream)

Ran cargo test --locked -p xcl --test d3d12_mesh_stream -- --nocapture on both #2902 (96dfa767) and a5e2d851:

  • 96dfa767: 2 passed; 1 failed
    • malformed_and_truncated_pipeline_streams_do_not_panic_or_crash — ok
    • concurrent_mesh_stream_refusals_across_five_threads_survive — ok
    • console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly — FAILED (expected AS-slot refusal in translation_errors: ["MS: no NGG hardware variant"])
  • Baseline a5e2d851: 2 passed; 1 failed — identical failure on console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, so that failure is pre-existing on a5e2d851.

180 s Open-World Smoke Run (lockhart, delayed XCL_PRESS_AT=78..134)

  • Outcome: exit: 0x0, 0 crashes, 0 device removals
  • Frames & timing: 1836 frames (PresentX 1836), entry timer: finest at 72.51 s, heavy world draws began at 176.63 s (1095 draws, 5089 dispatches in 2 s)
  • Memory peaks: commit 25001 MB, local VRAM 7662 MB, non-local 4248 MB, target pages 3729 MB (pools 3776 MB), sparse pools 2560 MB (2250 MB mapped)

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.

4 participants