Repository navigation
startup: opt-in content view tokens so view records can be freed - #3377
Open
lukaslw-lab wants to merge 1 commit into
Open
lukaslw-lab wants to merge 1 commit into
lukaslw-lab wants to merge 1 commit into
Conversation
…_D3D12_VIEW_CONTENT_TOKENS)
With X2W_D3D12_VIEW_CONTENT_TOKENS=1, note_view writes a CBV or a buffer SRV into title descriptor memory as a token
that carries the view (address and size; resource, range, stride, format, flags) instead of a record id. A copy the
title makes with its own memory copy then needs no record, so the record is named only by shadow slots, which the
stand-in sees change. When the last one lets go, the record is parked: it keeps its contents and its view_ids entry,
so the same view created again finds it, and the oldest parked record is reused once more than 65536 are parked.
Draw and dispatch readers resolve both token kinds through token_view(). Off under X2W_D3D12_CAPTURE. Unset,
nothing changes.
Tests: startup_view_content_token (encoding, no device), startup_view_content_{off,on}_{warp,hardware} (token copies
survive overwrites and record reuse; records bounded; revival). startup_view_alloc_* runs with the switch off: it
reads record ids from tokens.
Refs R0Y00#1199
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Refs #1199 (view records grow without bound: one record per distinct view, never removed).
X2W_D3D12_VIEW_CONTENT_TOKENS=1(opt-in):note_viewwrites a CBV (slot 17) or a buffer SRV (slot 18,NONEorRAW) into the title's descriptor memory as a token that carries the view itself (CBV: address and size; SRV: resource,FirstElement,NumElements, stride, format, flags, component mapping) instead of a record id. Unset, nothing changes.note_view,note_copy, the out-of-memory drop, the heap release underX2W_D3D12_RELEASE_RETIRED). When the last one lets go, the record is parked: it keeps its contents and itsview_idsentry, so the same view created again finds it. The oldest parked record is reused once more than 65536 are parked (about 10 MB).FirstElement≥ 2^32, format values ≥ 1024) keep id tokens and are never freed.X2WV(readers treat anything else as a hardware descriptor), word 1 bit 31 = content (an id is below 2^31, so a reader that compares the id alone sees an unknown id and refuses the binding), word 2 = slot, word 3 = 0 (the formatted-buffer readers write their own word 3 into their copy).token_view(); a content token decodes withoutnote_lock.X2W_D3D12_CAPTURE(itsVIEWchunks are written once per id).x2w-d3d12 view content tokens: written N; records N (ids N, parked N), parked N, reused N, revived N; fixture exportsx2w_d3d12_resolve_view,x2w_d3d12_view_content_counts,x2w_d3d12_set_view_parked_keep.docs/startup-runtime.md; the census section no longer says records are never removed.Verification
Windows 10 22H2, i7-4790K, RTX 3080 Ti (NVIDIA 32.0.16.1047) and WARP; dev and release; commit
503b41ceonmainf5a6f6ba.startup_view_content_token: round trips, refused views, padding bytes, a decode that ignores word 3.startup_view_content_{off,on}_{warp,hardware}: a buffer SRV, a CBV and a texture SRV in a heap over title memory; plain-memory copies of their tokens and aCopyDescriptorsSimplecopy survive 5000 overwrites, a revival and a reuse of the first view's record. On: records 3 → 5, revived 1; off: records grow by one per view.startup_view_content_on_*: id tokens for freeable views (the title-side copy after its record was reused); no shadow reference for copies and parking at the first drop (the copied descriptor's shadow slot); never parking (the records grew with content tokens); no revival and dropping the map entry at park (the re-created first view did not revive its parked record).startup_view_content*,startup_view_alloc_*,startup_resource_retire_views*,startup_formatted_view*), no skips.9af91261), the wider view families (startup_view_alloc_,resource_retire_,descriptor_,address_,stream_draw,table_alias_,sampler_heap,copied_vertex_srv_,root_,memory_srv,formatted_view,logical_view,1d_srv,single_element,slot133_lazy,view_content,view_token_): 130/130 with the switch unset and set (release); capability skipsstartup_logical_view_warp,startup_root_heap_{warp,hardware}.Startup run of the main executable (#870), release, warm shader cache, scripted input, the merged switches (#2949, #2977, #3028, #3313) in every run, two pairs (second in reverse order), 250 s:
tokennull bindings per 1,000 translated drawsOne 800 s run with the switch set: no device removal; view records 388k at the end; process private commit flat between loads (17.1 GiB at 260–400 s, 19.3 GiB at 600–790 s). Its 1558 refused formatted-buffer draws all give "view format has no decoded buffer FORMAT", a format check that reads the same fields from both token kinds; the 250 s runs do not reach that content.
This saves memory, not time: fps is unchanged, and CPU per frame is the same or up to ~10 % higher in one window. Not covered: other adapters, hosts with more cores, Wine, an 800 s run with the switch unset.
AI-assisted: the change, tests and this description were written with Claude; I ran the startup comparison.
🤖 Generated with Claude Code