startup-runtime: every non-aliased placed buffer keeps its own committed buffer for the process, and re-placing the same address adds another #3474
Open
opened 2026-11-29 16:27:50 +00:00 by Leyukaka
·
3 comments
No Branch/Tag specified
main
codex/indirect-large-backed-views
codex/word3-preflight-check
codex/vertex-table-two-records
codex/live-index-alias
codex/copied-vertex-buffer-srv
codex/windows-stage-test-output
codex/preserve-live-srv-retirement
codex/share-render-target-tracking
codex/sgd5-negative-offset-fixture
coverage-dashboard
codex/mesh-loose-root
codex/mesh86-cache-padding
codex/xmem-scatter-preflight
codex/mesh-depth-ps
codex/indirect-dispatch-refresh
codex/compute-container-index
codex/startup-compute-formatted-load
codex/compute-indirect-producer
codex/compute-atomic-soffset
codex/mesh-dual-handoff
codex/startup-run-sh-watcher-control
codex/queue31-page-alias
codex/indexed-indirect-compute-root
codex/typed-buffer-view-metadata
codex/translated-indexed-address-alias
codex/fixed-mesh-create-result
codex/xmem-section-lease
codex/startup-slot86-mesh-cache
codex/restore-mesh-barrier-iteration
codex/translated-indirect-upload-index
codex/xapu-completion-opt-in
codex/translated-indexed-rect
codex/translated-indexed-indirect
codex/startup-mesh-lds-integration
codex/startup-console-ms24
codex/startup-slot57-mesh-request
codex/indirect-copy-provenance
codex/present-color-producer-trace
codex/compute-dispatch-binding-trace
codex/translated-indirect-table-buffers
codex/indirect-copy-provenance-base
codex/mix-half-literal-source
codex/translated-indirect-draw
codex/xmem-scatter-diagnostics
codex/slot148-recording-upload
codex/slot70-loading-art-verified
codex/command-list-upload-arena
codex/recover-failed-command-list
codex/startup-heap-timing-notes
codex/align-audio-input-timeline
codex/synthetic-depth-export-control
codex/startup-texture1d-on-windows
codex/1629-packed-position-fixture
codex/cpu-srv-refresh
codex/stream-root-srv-draw
codex/audio-mixer-timer
codex/startup-reload-published-shader
codex/priority-integrate-1284
codex/guest-sixteen-page-record
codex/aot-placed-dxr-batch
codex/guest-directory-selection
codex/gamesave-enumerate-read
codex/readme-archive-to-pixels
codex/pe-placed-view-draw
codex/archive-directory-gpu
codex/slot133-dxr-build
codex/materialize-placed-vertex-view
codex/dstorage-directory-offsets
codex/xg-nine-bc-copy
codex/xg-slot10-bc64-arrays
codex/dxr-guest-address-readback
codex/gpu-va-high-bits
codex/clarify-diagnostic-startup-scope
codex/xg-six-levels
codex/typed-derived-blend
codex/english-legal-text-progress
codex/address-bc-4ks
codex/dstorage-bounded-file-read
codex/wide-srv-offsets-menu
codex/startup-memory-srv
codex/bound-view-tail
codex/language-selector-readback
codex/setup-menu-progress
codex/cpu-plane-refresh
codex/startup-ubyte-vertex
codex/presenter-window-selection
codex/startup-uniform-buffer-lane
codex/intro-loop-timing
codex/static-clzero-loops
codex/document-rtx-intro
codex/startup-insertq
codex/nv12-startup-texture
codex/stream-stage-draw
codex/startup-null-uav-format
codex/startup-draw-capture
codex/shorten-windows-checks
codex/dstorage-rfc1950
codex/startup-dump-fence
codex/pr1135-review-base
codex/startup-stream-requests
codex/startup-chroma-view
codex/readme-graphics-pipeline-streams
codex/static-crt-free-tls
codex/arc-140t-rtx-5080-laptop-gpu-reports
codex/main-startup-progress-entry
codex/signed-dxil-catalogue
codex/reloc-free-preferred-base
codex/quad-dpp-bit-mask
codex/raw-srv-bounds
codex/rx9070-31044-hardware-report
codex/gpu-page-source-provenance
codex/runtime-placeholder-interior
codex/gpu-copy-queue-tile-order
codex/pe-pin-external-providers
codex/xmem-placeholder-reservations
codex/xmem-shared-physical-pages
codex/pe-package-startup
codex/xmem-tools-memory-query
codex/cpu-stack-output-import
codex/pe-load-security-cookie
codex/record-three-bvh-retests
codex/cpu-rbp-frame-anchor
codex/xmem-default-startup
codex/record-rtx-3050-ti-9597
codex/docs-readme-start-here
codex/check-compute-mad24-truncation
codex/docs-discord-community
codex/bound-rcx-branch-mutants
codex/rtx5060ti-bvh-62114
codex/837-neutral-readme-disclaimer
codex/record-rtx-3070-ti
codex/title-neutral-public-wording
codex/exe-shadow-frame-submissions
codex/exe-shadow-runtime-chain
codex/readme-polish
codex/gpu-coverage-nov23
codex/spirv-minlod
codex/shadow-shim-device
codex/exe-two-shadow-frames
codex/shim-dispatch-cleanup
codex/fix-spirv-cache-probe
codex/sampler-use
codex/ballot-bit-extract
codex/packed-fma-release
codex/cpu-packed-fma-o2
codex/publish-coverage-dashboard
codex/mesh-cbv-binding-order
codex/spirv-window-fixture
codex/ps-e32-float-uint
codex/ps-cbuffer-reads
codex/fixed-profile-rescan
codex/shim-compute-integration
codex/readme-visible-coverage
codex/readme-research-navigation
codex/integrate-pr-256
codex/indexed-mesh
codex/sampled-coverage
codex/first-ms
codex/dual-ps
codex/ps-attribute
codex/compute-first
codex/ps-export
codex/readme-research-status
codex/ps-layout
codex/blast-window
codex/chart-caption
codex/reviewer-roles
codex/blast-aot
codex/archive-program
codex/crc-stream-program
codex/exe-image-data-chain
codex/local-cpu-fixture-coverage
codex/exe-bound-frame-chain
codex/exe-mapped-comparison
codex/contribution-dependencies
codex/exe-entry-aot
codex/bink-frame-heap-integration
docs/hardware-seven-reports
codex/bink-custom-heap
codex/bink-heap-callers
codex/discussions-entry-points
codex/gpu-community-batch-64
codex/ffx-scratch-writers
codex/generic-project-documentation
codex/ffx-dispatch-rcas
codex/four-windows-gpu-reports
codex/title-neutral-project-wording
codex/community-coverage-provenance
codex/rcas-packed-texels
codex/community-gpu-retests
codex/community-build-and-gpu-reports
codex/ffx-provider-loop
codex/ffx-recurrent-views
codex/ffx-recurrent-resource
codex/amd-wave64-reports
codex/ffx-backend-slots
codex/upscaler-device-init
codex/ffx-context-lifecycle
codex/ffx-version-query
codex/ffx-provider-contract
codex/typed-object-callback
codex/cpu-ordinal-import
codex/chained-cpu-ranges
codex/cpu-import-call
codex/cpu-direct-call
codex/cpu-leaf-aot
codex/community-project-status
codex/script-state-path-replay
codex/script-state-evidence
codex/bc7-resident-tail
codex/bcpack-mip-tail
codex/bc7-texture-draw
codex/asset-ranges
codex/pixel-constants
codex/pixel-aot
codex/pre-exe-workloads
codex/root-signature-device-coverage
engineering/packed-bvh-leaves
engineering/bvh-build-and-update
engineering/intake-root-roundtrip
community/gpu-check-release
community/english-contributor-entry
gpu-check-v0.1.0
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
R0Y00/Xbox2Windows#3474
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T16:27:50Z.
Commit
mainat36914379. Line numbers below are insrc/startup_stubs/d3d12_xs_device.cppat that commit.What the code does
device_place_resource_x(device slot 133) aliases guest memory only when the offset in the allocation is 64 KiB aligned, the range is covered and the allocation isMEM_PRIVATE(:5933-5936). Otherwise, or whenCreatePlacedResourcefails, it creates a committed default-heap buffer per call (:5970-5975, loggednot aliased). Nothing looks for an earlier buffer at the same address.release()(:1068-1094) removes the placement from the index (retire_placement) and ends its budget use, but keeps the desktop object: "The wrappers and their desktop objects stay alive for the process" (:1045).X2W_D3D12_RELEASE_RETIRED=1, is off by default and excludes buffers:retire_classifyreturnsRetireNever::buffer(:889) andpublish_placed_buffersets the same reason (:5767).D3D12 sizes a committed buffer in 64 KiB units, so each non-aliased placement holds at least 64 KiB until the process exits, whatever its width, and placing the same address again after a Release allocates a second one.
Measured
One long local run of the application (about 20 min), slot 133
not aliasedplacements, sizes rounded up to 64 KiB:The count did not level off. At the last sample 14,826 of the buffers are 8 bytes wide (0.9 GiB at 64 KiB each), and about 4,000 were created at an address that an earlier placement had already used. Aliased placements stayed at 56. Shorter runs ended near 3,975 buffers (1.1 GiB).
#2379 covers the same retention for committed textures; its retirement slices leave buffers out, and the reason counter there reported them as
never-class:buffer(8,178 buffers / 0.55 GB in one run, 5,163 / 339 MiB in another).Proposal
Aliased placements are not touched.
initial_state.retire_resource/drain_retired_resources,:6238,:6280): the release-time fence of every queue has passed, no list or submission holds it, and no tracked descriptor names it (retire_view_refs). The rule from #2379 stays: a live descriptor owns the resource until its slot is overwritten or its heap is destroyed. Todayretire_holdis taken for copies and texture binds only; a list that resolved a placed buffer by address (vertex, index, root and memory-SRV paths) takes no hold. A buffer would enter the class only where each such use records a hold, and stay retained otherwise. Opt-in, underX2W_D3D12_RELEASE_RETIRED.Test: a synthetic fixture that places and releases the same small unaligned buffer N times and checks that the number of live committed fallbacks stays bounded, with controls that a buffer named by a recorded or in-flight list, or by a live descriptor, is still readable after its Release, and a mutant that frees early.
Not covered: non-aliased placements that are never released, and the wrapper storage, which stays.
I'm working on this.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-29T16:57:28Z.
Same class here, and one data point for proposal 2 before it is built.
On a 360 s startup run I had 9,182 copied 64 KiB placed buffers (0.60 GB by count), close to your 319 s row. I prototyped your step 2 locally: these buffers joined the retire class at final Release, waited for list holds, release fences and
retire_view_refs, and were freed by the drain. Result: 19,527 freed over two runs, 0 late reads, no device removal, but no measurable memory change:A fresh buffer freed the same way drops DXGI local at once, so the long-released ones are probably already evicted, and count × 64 KiB may overstate what the process pays. Logging
QueryVideoMemoryInfolocal / non-local and the process commit next to the count at your 928 s and 1,237 s points would show it: if they grow with the count, step 1 (reuse) is the part that pays off.On an older
mainI also listed the readers that bind a copied buffer without aretire_hold(the ExecuteIndirect index view, root CBV/SRV at draw, vertex/index views, copies). I can re-check them on currentmainand post the list with line numbers.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T17:24:42Z.
Reuse (step 1): I prototyped it on a branch, not opened as a PR. Our own check of it estimated that it would reuse few buffers: every shim use of a copied fallback goes through
placed_buffer_rangefirst, and after that the buffer is not eligible.A later long local run with the budget line on: local video memory went over budget from about 166 s. At the end textures were about 72% of it, about 6.5 GiB of them retained after the application released them (#2379's area). The 64 KiB placed-buffer fallbacks were about 401 MiB (6,360 retained).
So the placed buffers are a small share of it, which fits your A/B, and I will not open the reuse PR.
A
QueryVideoMemoryInfolocal / non-local and process commit line next to the buffer count is useful. I will add it as a diagnostic PR (Refs #3474) unless you prefer to do it.Yes to the re-check of the readers that bind a copied buffer without a
retire_holdon currentmain; please post the list with line numbers here.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T00:41:03Z.
Readers of a copied placed buffer (
Placement::copied_buffer, found throughplaced_buffer_range) onmain2ff74a6a, by reading. These are what a copied-buffer retire class would have to hold.No hold (neither
retire_holdnorretain_with_recording):srv … root)compute_root_srv_buffer,d3d12_compute_dispatch.inl:653-660(whenlist_copied_gpu_range):845; the only holds there are textures (:899) and tokens (:1104)indirect_table_buffer,d3d12_draw.inl:2692-2697d3d12_draw.inl:3482(buffer_view);d3d12_compute_dispatch.inl:1029,:1235list_execute_indirect,d3d12_xs_device.cpp:4114-4121(any placement, no alias check):4165(IASetIndexBuffer)d3d12_xs_device.cpp:4093-4099:4099placed_as_buffer,d3d12_memory_srv.inl:666-680:690; a descriptor, so it outlives any one recording: it needs a view ref, not a list holdresolve_placed_build,d3d12_xs_device.cpp:8365-8373Already held: fixed vertex views (
d3d12_draw.inl:2953), the draw index and table aliases (:3296,:3550, aliased buffers only), slot-57 mesh buffers (native_mesh57.inl:193), and copies (list_copy.inl:282-283).Go ahead with the
QueryVideoMemoryInfodiagnostic PR.