Repository navigation
gpu: defer CreateCommittedResource for read-only slot 133 textures - #2773
triggered02 wants to merge 2 commits into
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Win2025 WARP receipt for head 3cdc4ab.
Review of this head (code + fixture tests only):
AI-assisted; commands listed were executed locally. |
R0Y00
left a comment
There was a problem hiding this comment.
Independent Windows Release ran all 8 existing lazy texture CTests on WARP and RTX 4060 Laptop, including both debug1 variants. Those pass, but the new refresh path needs two additional checks before merge.
- materialize_lazy_texture snapshots PendingSrvRefresh destinations under note_lock, releases the lock, then writes the old CPU handles. A normal slot overwrite or heap retirement can occur in between, including on a different thread from the texture copy that first materializes this resource. Revalidate slot identity and heap lifetime at publication or coordinate the update with the existing descriptor lock and recording/fence lifetime. A prepare/overwrite/resume control must leave the replacement view bound and must not touch a retired heap.
- The current fixture copies the SRV, explicitly materializes with CopyTextureRegion while the guest still owns the resource, then samples and finally releases. Add the #2764 order of copy SRV, last guest Release, and first use through that still-live descriptor on a fresh list. Give the texture a distinct nonzero reference. Keep the explicit overwrite and in-flight retirement controls. Native first use must reach a materializer or stay on the eager path.
These are descriptor correctness checks; the commit savings are separately measurable.
…ZY_TEXTURES=1 Fixes R0Y00#2764, Refs R0Y00#2379, R0Y00#1199
3cdc4ab to
92db6d4
Compare
|
Addressed both points of R0Y00's review at
Verified on
AI-assisted. |
…om spare trim, RT DispatchX hardening & SRWLOCKs - Lazy materialization for read-only 2D/3D slot-133 textures (clean-room MIT from R0Y00/Xbox2Windows#2773): defer CreateCommittedResource / VkImage + VRAM allocation until first SRV/view/copy/barrier use while answering metadata/residency queries and untouched Release with zero VRAM (LEONIDA_LAZY_SLOT133_TEXTURES). - 256 MiB existing-heap / page-commit cap for slot-133 buffers (clean-room MIT from R0Y00/Xbox2Windows#2775): oversized title buffer reservations fall back to committed DEFAULT without whole-span page commit (LEONIDA_SLOT133_HEAP_CAP_MB, LEONIDA_UNBOUNDED_EXISTING_HEAP). - VRAM-headroom-scaled spare pool retention, 64-frame idle upload-ring reclamation & non-local shared memory pressure tracking (GPL-3.0 from avatarmanz/VIctory-7900XTX#119 and Marvisak/VIctory#2972). - RT structure builder DispatchX hardening (GPL-3.0 from fxceless/victory-fork#994): accept compact 20-byte FSPX kind0 headers (w4 at byte 16..19) and inherit compute workgroup dims through derived PSOs (slot 55). - Reader-writer SRWLOCK conversion for hot read-mostly registries in d3d12_xs_device.cpp (GPL-3.0 from wolfattack199/victory-fork@d3d3760) with zero non-trivial thread_local. - Unit tests in d3d12_xs_format_sanitize_test.cpp and d3d12_texture_mip_drop_test.cpp. Verified: 10/10 CTests passed on NVIDIA GeForce RTX 3080 under LEONIDA_VK_VALIDATION=1 (0 validation errors); check_no_game_data.py 0 violations.
|
I reran the unmodified One descriptor-copy ordering still produces a null SRV. In the existing 4b refresh hook, also call guest slot 24 to copy the lazy texture's original CPU descriptor (the same The destination gets the logical view record but copies the native null descriptor, and the snapshot never included it. Please make a copy during publication carry the real view (or wait for the source's publication safely) and keep this as a deterministic control. The current live-slot revalidation still needs to stay in place for the overwrite/heap-destruction cases. |
…res) into tester-loop
tedin7
left a comment
There was a problem hiding this comment.
Win2025 check of the resource retire tests on this head (92db6d4eb):
- Dev:
startup_resource_retire_title_*andstartup_resource_retire_views_*pass (14/14). - Release: four
startup_resource_retire_titletests end in SEGFAULT:title_warp_debug0,title_off_warp,title_hardware_debug0,title_off_hardware. Thestartup_resource_retire_viewstests pass. - On current
main(8c9f168f4) the same 14 tests pass in dev and release, so the crash is specific to this head in the release build.
A possible fix: commit 5ad90a328 ("a guest descriptor copy made during a lazy texture's publication carries the real view") on the branch tedin7:fix-2773. Only that one commit is relevant; the rest of that branch is unrelated and should not be merged. On a build that includes it, the 14 retire tests pass in dev and release. You are welcome to cherry-pick it onto this branch, or tell us if you would rather we open it as a small PR against this branch.
Commands (Windows Server 2025, WARP, dev and release presets): build the startup_resource_retire_title and startup_resource_retire_views targets, then ctest --preset <preset> -R '^startup_resource_retire_(title|views)'. CTest prints only SEGFAULT, no stack yet.
AI-assisted; commands listed were executed locally.
# Conflicts: # docs/experiments.md # docs/startup-runtime.md
|
Independent startup A/B of Build note: at - skip = volume_uav_range_error(resource_desc, view.Texture3D);
+ skip = volume_uav_range_error(resource_desc_for_check, view.Texture3D);
...
- if (view.Texture1D.MipSlice >= resource_desc.MipLevels) skip = "an output 1D texture mip is outside the resource";
+ if (view.Texture1D.MipSlice >= resource_desc_for_check.MipLevels) skip = "an output 1D texture mip is outside the resource";Setup: release build of
|
Adds opt-in lazy desktop materialization (
X2W_D3D12_LAZY_TEXTURES=1) for read-onlyslot 133textures (!(Flags & (ALLOW_RENDER_TARGET | ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS))). Fixes #2764. Refs #2379, #1199.What changed
src/startup_stubs/d3d12_xs_device.cpp:X2W_D3D12_LAZY_TEXTURES=1,device_place_resource_x(slot 133) defersCreateCommittedResourceandx2w_budget::committedfor read-only 2D/3D textures by wrappingnullptr(lazy_slot133_texture = true), recording the sanitizedD3D12_RESOURCE_DESC, format, andtitle_memory, and preservingnote_resourceandretire_set_classeligibility.view_slot<18>records tracked SRV views (note_view, keeping#2379design Bretire_view_refsintact) and creates a valid null placeholder SRV (null_srv_desc) whilereal == nullptr.view_slot<19..21>andforward_slot<resource_kind, 12/13/14>materialize first if needed.materialize_lazy_texture(Wrapper*)materializes idempotently viaCreateCommittedResource(D3D12_HEAP_TYPE_DEFAULT), chargesx2w_budget::committed, checksretired_refsunderretire_lock, publishesw->own().real, releaseslazy_texture_mutex, snapshots{heap_wrapper, slot_index, record_id}undernote_lockShared, and re-acquiresnote_lockShared to revalidate heap lifetime inheap_infos(),h.shadow[slot_index] == record_id, andvr.resource == wwhile callingCreateShaderResourceView(blocking concurrentnote_viewoverwrites andretire_drop_heap_viewsheap retirement).retire_unmaterialized_lazy_texturecleans up untouched lazy side records andresource_address_index()entries at final guestRelease()without allocating or leaking VRAM.x2w_d3d12_lazy_texture_count()andx2w_d3d12_set_lazy_refresh_hook()for fixture verification.src/startup_stubs/d3d12_compute_dispatch.inl: addsretire_hold(self, view.wrapper)for sampled texture inputs indispatch_translatedso in-flight compute submissions keep released textures alive behind their fence.src/startup_stubs/d3d12_capture.inl,src/startup_stubs/d3d12_memory_srv.inl,src/startup_stubs/list_copy.inl,src/startup_stubs/list_copy_texture.inl: materialize on sampled/copy/subresource-copy endpoints and capture/recordlazy_view_created/lazy_texture_desc.tests/startup_slot133_lazy_textures_check.cpp&tests/cmake/startup_slot133_lazy_textures.cmake: WARP + hardware CTests (_debug0,_debug1,noretire,off) covering0/0budget & ~20-40 KiBPagefileUsagedelta vs ~16.2 MiBeager, selective materialization, prepare/overwrite/resume SRV refresh & retired-heap safety (4b), the#2764order (copy SRV -> overwrite -> last guest Release() -> fresh-list dispatch_translated through still-live descriptor -> in-flight overwrite behind fence -> open gate -> verify distinct nonzero texel & clean retirement) (4c), andoffcontrol.docs/startup-runtime.md,docs/experiments.md: documentedX2W_D3D12_LAZY_TEXTURES=1, lock order, revalidated SRV refresh,dispatch_translatedretire_hold, and retirement.Verified (
92db6d4e, rebased on624f5927)Fail-first mutants (temporary, reverted on
92db6d4e):target_heap->shadow[item.slot_index] != item.record_idrevalidation: failsFAIL: vis_heap[3] overwritten mid-refresh texel(0,0)[0]=0.89020 expected=0.35294.retire_hold(self, view.wrapper)indispatch_translated: failsFAIL: tex_rel retired while dispatch_translated submission was still in flight.CopyTextureRegion: failsCopyTextureRegion refused: unknown_resourceandFAIL: tex[3] CopyTextureRegion readback had 1045504 mismatched bytes.slot 133withX2W_D3D12_LAZY_TEXTURES=1: failsFAIL: lazy creation committed textures: live=16777216/16 retained=0/0.NOT established
_debug1cases skipped (77) on this host without D3D12 SDK Layers.slot 133still commits ~4.1+ GiBof textures that carryALLOW_RENDER_TARGET/ALLOW_DEPTH_STENCIL/ALLOW_UNORDERED_ACCESS(read_only_texture == false); deferring unused RT/DS/UAV textures is outside this PR.AI-assisted.