Skip to content

D3D12.X: preserve the NVIDIA world-streaming integration - #2706

Draft
ZekkJJ wants to merge 21 commits into
xcl-dev:mainfrom
ZekkJJ:codex/nvidia-world-streaming-reference
Draft

ZekkJJ wants to merge 21 commits into
xcl-dev:mainfrom
ZekkJJ:codex/nvidia-world-streaming-reference

Conversation

@ZekkJJ

@ZekkJJ ZekkJJ commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This draft preserves the historical local integration that accepted an offline Series X profile on an RTX 4060 Laptop GPU and sustained world asset streaming without a device reset in the longest on-demand run. It captures the interaction among sparse mappings, texture lifetime, DirectStorage, and driver pipeline caching. The laptop used 16 GiB system RAM and an 8 GiB GPU.

The branch starts from historical upstream ancestor cbc296a. The two tip commits reproduce the archived source deltas from the tested executables. The diff also contains the earlier commits needed to reconstruct the experiment. Paired current-main smoke runs and review of standalone changes remain open. The visual evidence ends at loading artwork, black frames, and the account picker.

Changes

  • Order sparse mapping, title use, readback, and retirement across queues and expose bounded trace evidence at the submit and fence boundaries.
  • Keep deferred title-memory backing through the upload and protect overlapping render-target pages from stale unmaps. Related work includes #1514, #594, #1182, and #2177.
  • Integrate the two-pass mesh and geometry driver PSO cache and canonical identities. Related work includes #827, #1942, and the separately scoped #2448.
  • Refresh DirectStorage destination page lists and preserve snapshots for stack-backed requests. The second snapshot isolates the stack follow-up. Related work includes #819 and #1405.

Guarded retail evidence

The RTX 4060 runs used Series X and offline input. The principal local run used a 4,800 MiB coherent window, two DXC workers, and on-demand PSOs. Present counts include repeated loading frames.

Run Presents Stop reason Observed milestone
Historical clean upstream 0829441 2,791 0x887a0007 after 177.87 s Loading artwork
Reference #2057 at 4df1e6e, 4,800 MiB coherent 3,843 0x887a0007 after 208.94 s Loading artwork
Local DD109428, on-demand PSOs, source snapshot 01b6a34 6,699 Hard timeout after 703.29 s Player1 accepted. BCPack unpacked BC1, BC5, BC6H, and BC7. At least 16,384 page lists refreshed. Indirect mesh work recorded.
Local E33D3AE2, stack-page follow-up, source snapshot f614add 3,329 sampled Host-memory guard after 761.61 s At least 16,384 page lists refreshed. Last saved frame was artwork. A black window at 0 FPS followed in the live run.

In the 6,699-present run, the last present-bearing sample ended at 400.225 s and the last captured title execute was at 438.202485 s. All 24 sampled fence identities with issued signals in the retained checkpoint completed and none reported removal. One active native compute PSO finished after 54.299 s at 605.963 s, with another still active at cutoff. Peak private commit was 25,682 MiB, with 7,951 MiB dedicated and 5,683 MiB shared GPU memory. These are separate historical runs with different workload depth, cache warmth, and input timing. A rendered world frame and a causal memory or performance improvement remain unverified.

#2371 is a related independent compiler experiment. A later RTX 4060 run we captured showed a 42.007 s cold compute PSO and a 235 ms cached build on the same executable. That run recorded zero split compute programs. Eligibility for #2371 and its retail effect here remain unverified.

Tests and open issues

  • The original local integration passed 16 focused tests and the two-pass GPU integration fixture covering cache-off, cold, warm, and corrupt-cache paths. One heap-window case passed in its required layout after a default-layout skip.
  • The stack follow-up passed 33 focused DirectStorage tests and a real RTX 4060 fixture with byte-exact multi-mip readback.
  • The new f614add workspace attempt reported 1,135 passing library tests, six failures, and 26 ignored. One texture-retirement test reproduced a 64 KiB accounting assertion after the queue signal returned E_INVALIDARG. The other five library failures followed from the poisoned fixture lock. Two executable tests also lacked prebuilt workspace fixtures. The host-memory guard ended the full attempt before completion. Baseline attribution of the retirement assertion remains open.
  • The ordered sparse fixture previously passed its gates and readback with validation ID 1047 still logged. Validation-clean sparse mapping and equivalent current-main retail runs are pending.

AI assistance was used for implementation, test analysis, and preparing this draft.

Standalone follow-up

The compute driver disk cache fix is available on ZekkJJ:codex/compute-driver-cache-ram-budget at 9ecae592, based on main b49be183. It preserves the original author of ee0183fd and keeps disk persistence available when the compute blob RAM store is full. The disk and RAM key formats stay compatible with current main.

The extraction passed three compute blob unit tests on RTX 4060 Laptop (616.56). The seven-test GPU integration run reported zero failures and one heap-window skip. That case passed separately on the same commit with XCL_HEAP_WINDOWS=1 and no runtime skip. The standalone branch still needs its own full GPU suite and retail smoke before submission.

DirectStorage parallel decode and stack page retention are already in main via #819 and #1405. The compute-window coherence change is in main via #2346. The reference remains an integration archive.

mgrein and others added 21 commits November 24, 2026 23:39
The newer factory's CreateQueue (slot 10) takes a 0x20-byte desc whose
u64 @0x18 is the queue's DSTORAGE_QUEUE_OPTIONS; a new retail game sets
bit 0, AutoSubmitDisabled. XCL ignored it, and a half-full queue still
submitted by itself. The title writes a request's destination page list
after EnqueueRequest and before its own Submit, so a request that the
half-full submit sent to the worker could run before its list was
written, with the pages of the slot's previous request.

Such a queue now runs its requests only at Submit, and an enqueue into
it at capacity waits until Submit, a cancel or Close takes entries, as
the console's queue stalls one. Queues made without the option, or
through the first CreateQueue, submit when half full as before. Other
option bits are logged once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retail title keeps its destination page lists in slots of its own
table and writes a slot's pages after EnqueueRequest. At enqueue such a
slot can still name the pages of the slot's previous request, and the
snapshot taken then is what execute() wrote to (xcl-dev#289 rereads only the
entries that are 0). Over 16 000 requests a run were written into pages
the title had since reused: its objects got garbage pointers and it
crashed about 20 s into world loading; when the old pages were freed,
the request failed with E_ACCESS_VIOLATION.

The console reads the list when it runs the request. execute() now
reads it again (through read_own, as the snapshot) and takes it when it
differs and every page in it is allocated (kernelx::physical_pages_live);
otherwise the snapshot stays, so arrays on the stack that were
overwritten since still work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Helpers for the copy path that changes no behaviour yet:

- sparse.rs: extract new_state from the inline closure in init, so
  shadow_window (next commit) can call it when no sparse windows exist
- uma.rs: Uma::shadowed flag and is_gpu_copy(p): a sparse window or a
  committed one the GPU has a copy of. Never set to true in this commit.
- list_x.rs: note_copy_into tracks PC copies into console buffers whose
  memory the GPU has a copy of; note_write uses is_gpu_copy
- real.rs: uma_shadowed helper, res_map and dev_create_placed_resource_x
  use is_gpu_copy (= is_sparse while shadowed is false)

Based on Ahmet-Dedeler's c70bf8a on mac-on-main-wip.

Co-authored-by: Ahmet Dedeler <105894172+Ahmet-Dedeler@users.noreply.github.com>
Assisted-by: Claude Code (Claude Opus 4.6 ported it; Claude Opus 5.5 reviewed it)
D3DMetal answers E_NOTIMPL for OpenExistingHeapFromAddress. A committed
UMA window is then a buffers-only heap of video memory (Uma::shadowed),
kept in step like a sparse window's tiles (sparse::shadow_window): CPU
writes go up before each ExecuteCommandLists (the window's write watch),
GPU writes come back on Map and after the lists' memory writes, and PC
copies into console buffers there are read back after the submit
(list_x::note_copy_into). XCL_UMA_SHADOW=1 forces the path on a GPU
that has such heaps, =0 never.

On main 930e8b4: the start-up check that the GPU sees CPU writes
(check_uma_import) is not run for a shadowed window (it is a copy by
design); sparse::new_state carries the new parked list. The runner's
run_in_region falls back to upload/readback copies per window on
E_NOTIMPL. The sparse test's shadowed readback and constant-rewrite
stress validate the data path.

Part of xcl-dev#258.

Based on Ahmet-Dedeler's c70bf8a on mac-on-main-wip.

Co-authored-by: Ahmet Dedeler <105894172+Ahmet-Dedeler@users.noreply.github.com>
Assisted-by: Claude Code (Claude Opus 4.6 ported it; Claude Opus 5.5 reviewed and fixed the import-check assertion)
`readback_after_execute` made the sparse queue GPU-wait for the title's
queue and then waited on the CPU for the copy, on the thread that was
submitting. The title's queues can wait for work that same thread submits
next (four compute queues waiting for a Write64 on q1 whose list is
recorded but not submitted yet). So the copy waited its 5 s on every such
submission, and the uploads queued behind it on the sparse queue waited
too (`before_execute` waiting for ring room). In thread dumps of a retail
title on an RTX 5090, the submitting thread is in `readback_ranges` ->
`wait_for` while another title thread waits for the sparse state's lock in
`commit_range`. lucsoft found the same cycle on RDNA3 / Linux (xcl-dev#505).

The copies now run on a queue of their own, which GPU-waits for the
title's queue, and the submitting thread returns. Readback buffers are
sized to the copy (64 KiB and up) and reused. Without a readback queue (it
could not be made), the old path runs.

The data lands in the title's memory once the copy is done, before the
title can see the work it follows is done:
- on the next submit, and from a thread that looks every 0.5 ms;
- before Map's readback and in the CPU memory waits of Wait64BitValueX
  (`settle_readbacks`), which wait for the copy once the title's lists it
  follows are done;
- in the title's fence observations: `GetCompletedValue` settles the copies
  first. `SetEventOnCompletion` hands the fence an event of XCL's own, and a
  thread-pool wait on it settles them, then sets the title's event.

The new test `a_copy_back_does_not_wait_for_the_title_queue` waits 5.0 s
on the old path and under 1 s with this change. Without the fence hooks,
the e2e test title read 0 for its Write32BitValueBottomOfPipeX after its
fence wait. With them, both e2e tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ir fence; looks counted against list closes (local test)
Hold one title queue while a second writes a distinct range. Check each CPU-visible pattern and fence completion before and after releasing the first queue.

Assisted-by: OpenAI Codex (GPT-6.2-Sol)
…ough the memory store is full

The disk cache of compute driver blobs (xcl-dev#634) wrote a blob only when the
in-memory store had taken it first: keep_compute_blob stored it there within
COMPUTE_BLOBS_MAX (512 MB) and the caller then looked it up for the file. Once
the store was full the lookup found nothing and no later build was written.
Those are the builds that matter most: a retail title's world needs compute
pipelines of 20 to 150 s each in the NVIDIA driver, made after hundreds of
smaller ones, and it built them again in every run.

keep_compute_blob now returns the blob it fetched; it is kept in memory only
while there is room (remember_compute_blob), and goes to the disk either way.

Assisted-by: Claude Code (Claude Fable 5.2)
…(local diagnostic)

The watchdog's first three time-outs log, for every GPU wait not yet met, which queue waits for
which value of which cell or title fence, and which submitted signal (queue and its place among
that queue's calls) will meet it; a wait for a value nothing has signalled yet says so. Used to
find the loop all five queues of a title were in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retail title's intro cutscene ran at 0.3-0.5 fps with the GPU at
98-100 %, and nothing in XCL measured GPU time per draw or dispatch: the
logs could not say which console programs the GPU time went to.

With XCL_GPU_PROFILE=1 each translated draw, dispatch and ExecuteIndirect
(and an ExecuteIndirect with a PC pipeline) gets a timestamp query on its
PC list before and after it, resolved right behind it into a readback
ring of 2^17 pairs. Nothing on the CPU waits: a reporter thread takes
the written pairs every 100 ms, and every 2 s logs the 15 console
programs with the most GPU time (every 20 s also since the start):
hash, kind, calls, total and longest ms, group counts of the longest
call, and for compute the thread group size, wave64 / split form, code
and DXIL size. Ticks are converted with a title queue's
GetTimestampFrequency. Off by default; with it off each op pays one
LazyLock read.

Overlapping queues are each charged in full, so the sum can exceed wall
time; bundles get no stamps; a recording run again without a Reset is
counted once. The resolve waits on the GPU for the op to finish, so with
the profile on a queue runs its ops one after the other. The unit tests
cover the pair states and the ranking.

Assisted-by: omp (Claude Opus 5.5)
Keep pending shader bytes shared and release their payloads with the last owner. Remove expired weak metadata, verify colliding inputs byte for byte, and release unclaimed jobs when their stand-ins are released. Add optional ownership telemetry.

Assisted-by: Codex (GPT-6, exact variant unavailable)
Integrate xcl-dev#1835 at 39014d3 on the gameplay checkpoint. Defer small-slot retirement with the retained COM resource until GPU fences complete. Record small heap use and DXGI budgets, and classify DRED addresses against populated UMA ranges.

Assisted-by: Codex (GPT-6, exact variant unavailable)
Record the source snapshot used for the guarded RTX 4060 world-loading and pipeline-cache experiments. Keep the original port history and the diagnostic and GPU fixtures needed to reproduce those observations.

Assisted-by: Codex (GPT-6)
Port the final stack safeguard from xcl-dev#1405 to the reference snapshot. Its regression reproduces a write to a reused live page without the safeguard and validates both stack and non-stack destination page lists.

Assisted-by: Codex (GPT-6)
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.

8 participants