Repository navigation
gpu: defer CreateCommittedResource for read-only slot 133 textures - #2773
triggered02 wants to merge 8 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. |
|
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
|
|
I tried merging What the merge needs.
What then fails. I ran
This branch's own tests pass on the merge: The crashes look like this branch's Environment: AMD Ryzen 7 9800X3D, NVIDIA GeForce RTX 5090 driver 32.0.16.1088, WARP 10.0.26100.9818, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10. This reply was AI-assisted. |
|
Thanks for this, and for addressing both points of the first review in
Non-blocking:
Environment: Linux, static review, This comment was AI-assisted. |
|
The head is still
Environment: Linux only: git objects and This comment was AI-assisted. |
# Conflicts: # docs/startup-runtime.md # src/startup_stubs/d3d12_compute_dispatch.inl # src/startup_stubs/d3d12_xs_device.cpp # src/startup_stubs/list_copy.inl
Points from the 2026-11-28 review of 7986f2a: - The UAV size checks added in R0Y00#2902 still named `resource_desc`, which this branch renamed to `resource_desc_for_check`; they now use the renamed variable, so the head compiles again. - `view_slot` read a resource description from `args[0]` for every slot. Only slots 18-21 take a resource there; slots 17 and 22 pass a description, so `GetDesc()` read a bogus vtable. Limit the description to slots 18-21, as main does. - Add the guest-descriptor-copy control: a copy made while a lazy texture is being published now writes the real view into the destination instead of keeping the native null descriptor (counters, `create_lazy_srv`, `refresh_copied_lazy_views`, a `PublishScope` around materialization, and the fixture case in `startup_slot133_lazy_textures_check.cpp`).
|
Rebased onto current Merge. Four conflicted files resolved by hand: Point 1 — head compiles. The #2902 UAV checks still named Point 2 — Point 3 — guest-descriptor-copy control. Ported tedin7's Point 4 — not answered, and I cannot answer it here. This host is Linux and has no Windows, D3D12, WARP or GPU runner, so Scope of what I verified: a static Linux build of Also still open from your note: the CI |
This branch adds x2w_d3d12_lazy_texture_count and x2w_d3d12_set_lazy_refresh_hook to d3d12_xs, so the pinned catalog grows from 79 to 81 exports (44 to 46 unmeasured), and the d3d12_compute_dispatch include grew by one line, moving the compute-census source pin to :1745. tests/standin_exports_check.py: 472 cases, 6/6 mutations killed PASS
…pr preset
The reviewer noted the pr preset filter matches none of slot133,
resource_retire or view_census, so those fixtures would never run even once
the build passes. Add the warp variants to the filter:
startup_slot133_lazy_textures_{warp_debug[01],noretire_warp,off_warp}
startup_view_census_warp_{on,off,vary}
startup_resource_retire_{title,views}_warp_debug[01]
startup_resource_retire_off_warp
The hardware variants stay out of the pr preset, like the other *_hardware
fixtures. Checked: the regex compiles, matches all ten warp names, and does
not match the hardware variants, unrelated names or suffixed names.
|
Added the CI coverage you flagged, in The The Checked locally, Linux only: the merged regex compiles, matches all ten warp names, and does not match the hardware variants, unrelated names, or suffixed names. Head is now |
Adding the tests to the pr test filter was not enough: the pr build preset
builds an explicit target list, so the new tests were selected but their
executables did not exist and ctest reported them 'Not Run' (7 failures on
the Windows job).
- Add startup_slot133_lazy_textures_check, startup_resource_retire,
startup_resource_retire_views and startup_view_census to the pr build
targets.
- Fix the view_census filter: the tests are named
startup_view_census_${backend}, startup_view_census_off_${backend} and
startup_view_census_vary_${backend}, so the earlier 'warp_(on|off|vary)'
spelling matched nothing.
- Include the base startup_resource_retire_warp_debug[01] fixtures, which
use the startup_resource_retire target added above.
Checked here (Linux, no Windows run): the merged filter compiles, matches all
twelve expected warp names and none of the hardware, reversed-order or
suffixed names; every added target has an add_executable in CMakeLists or
tests/cmake.
|
My previous push ( What went wrong: adding the tests to the There was a second, quieter mistake: my
Checked here (Linux only, no Windows run): the merged filter compiles, matches all twelve expected warp names, and matches none of the hardware variants, the reversed-order spelling or suffixed names. Every added target has an Point 4 from your review is still open — it needs a Windows host for the |
…old is settled
Running them in CI (the previous commit) exposed a real failure on WARP:
FAIL: dispatch_translated did not materialize released tex_rel
(retained=0, expected=1)
main's d3d12_compute_dispatch.inl:1163 deliberately skips retire_hold for a
tiled-address SRV *input* ('An input of a tiled address SRV is a separate
texture outside the class'), which is the binding this fixture uses, and the
fixture predates that change. Deciding which side is right needs a WARP run
this host cannot do, so the fixture stays out of the pr preset and the finding
is reported on the PR instead of being papered over by editing the test.
startup_view_census and startup_resource_retire stay in the filter (they pass)
and the startup_slot133_lazy_textures_check build target stays, so restoring
the three tests later is a one-line change to the filter.
|
Progress and a real finding from The build-target fix worked. Windows went from 7
What the failure looks like from here. The fixture dispatches after the final guest if (texture && (output || !wrapper->own().tiled_address_srv) && !retire_hold(self, wrapper)) texture = nullptr;with the comment "An input of a tiled address SRV is a separate texture outside the class." That deliberately skips the hold for an address-only SRV input, which is the binding this fixture uses. The fixture was written before that landed, so either the fixture's expectation is now wrong or that carve-out should not apply to a lazy texture — I cannot tell which without executing it, and this host has no Windows, WARP or GPU. I am not going to edit the assertion to match code I cannot run; that is how a real regression gets hidden.
What I need from you: whether a lazy (address-only) SRV input should hold across a dispatch. If yes, the carve-out at Still open: point 4 ( |
|
CI is fully green on So the review points 1–3 hold on Windows too, and Two things are still yours to decide:
The three |
|
Correction to my own analysis from earlier tonight, before anyone acts on it. I had argued in comment 7322488779 that the carve-out at
So there are two candidate causes and I cannot separate them without running The question to settle is still the same one from comment 7321984149: should an address-only SRV input hold a released lazy texture across a dispatch? If you say yes, I will write it deliberately and note that the three existing sites then disagree with each other. If the answer is that the fixture's expectation is stale, I will move the case to the output/UAV binding instead. |
|
I can close my own question from comments 7321984149 and 7326607795, and the answer is that no code change is needed for the carve-out. This supersedes both.
I was wrong in 7322488779 when I said the carve-out should not apply to lazy textures, and I am glad I did not push the one-line patch I had prepared. Nothing about retire semantics needs changing for this PR. What is left unexplained is only why the fixture still observes 0, and the leading candidate is that its dispatch is refused before binding — the placed-buffer alias refusal that appears 11,648 times in package runs. That needs I will stop commenting on this PR now unless you reply — the open items are yours and I have nothing further I can verify from Linux. |
|
I can now reproduce the failing case locally, which should save a Windows CI round trip. Repro (Linux host, cross-compiled, Wine + vkd3d-proton — not WARP, but the failure is identical): # in the PR worktree, with the clang-cl + xwin toolchain already configured
cmake --build out/build/clang --target startup_slot133_lazy_textures_check -j 8
cd out/build/clang
WINEPREFIX=$HOME/.local/x2w/prefix \
WINEDLLOVERRIDES="d3d12,d3d12core,dxgi,d3d11=n" WINEDEBUG=-all \
X2W_D3D12_BUDGET=1 X2W_D3D12_PERMISSIVE=1 X2W_D3D12_LIST_NOOP=1 X2W_D3D12_RENDER=1 \
X2W_RESOURCE_INDEX_CHECK=1 X2W_D3D12_DEBUG=0 \
X2W_D3D12_RELEASE_RETIRED=1 X2W_D3D12_LAZY_TEXTURES=1 \
"$PROTON/files/bin/wine" ./startup_slot133_lazy_textures_check.exe warpResult, deterministic over two runs (exit 5): And the cause is visible in the stand-in's own log, just before the assertion: So the dispatch is refused before it binds anything, which is why no retire hold is taken and That refusal comes from So the fixture appears to depend on a translated compute program that nothing provides, which would make the last part of case
I have not changed the test to make it pass — that would be exactly the "edit the assertion until green" move your review warned about. The tests stay out of the |
|
One addendum to the two options in 7327938996 — I checked the code path, and it makes option 2 unnecessary while making option 1 the right fix. Short version: the fixture is asserting a hold from a dispatch that is correctly refused, so the test needs a program that actually translates. What the code does: So option 2 from my previous comment should be dropped, and the remedy is on the test side: give case That is where I stop: I am not going to rewrite the fixture around a translated-program dependency on a guess about how you want that seeded. If you tell me which seeding you prefer, it is a small change and I will do it. |
|
Ran the whole
Two distinct causes, and neither is retire semantics:
So under Wine, case Still not editing the fixture. The remaining question is the same narrow one from 7328077500: how do you want |
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 on the current head (
a70fa1db)Continuous integration, all jobs green on this head:
Local cross-compile check (Linux host, clang-cl 19 + an xwin SDK splat, Release):
startup_resource_retire_*andstartup_view_census_*now run in theprpreset and pass, so theCI coverage this PR needed is in place.
startup_slot133_lazy_textures_*is deliberately out ofthe
prpreset for now (see "Since the review"); its build target is wired, so restoring the testsis a one-line filter change.
Earlier "Verified (
92db6d4e)" numbers and fail-first mutants are no longer quoted here: they weremeasured before the review fixes and before the merge with
main, so they say nothing about thishead. The mutants themselves were temporary and reverted.
Since the review
#2902UAV checks still namedresource_desc, which thisbranch renamed; they now use
resource_desc_for_check.view_slotno longer reads a description fromargs[0]for every slot. TheGetDesc()is guarded to slots 18–21, so slots 17 and 22 stop reading a description as aresource, with the switch off as well.
published now writes the real view into the destination instead of keeping the native null
descriptor; the fixture copies the descriptor mid-publication and checks it samples the texture's
own seed texel.
startup_resource_retire_titleDebug/Release re-runs need a Windows host. I am not claiming they pass.
!tiled_address_srvretire-hold carve-out should not apply to lazy textures, and answered it myself: it should, and
the carve-out is not this fixture's problem — commit
2130dcecrecords the premise, and a lazytexture never carries
tiled_address_srv(d3d12_xs_device.cpp:7145). No retire-semanticschange is needed here.
NOT established
_debug1cases were skipped (77) without D3D12 SDK Layers on the earlier host; not re-checkedon this head.
startup_slot133_lazy_textures_*WARP cases are not run in CI yet. On the last run thatdid execute them they failed with
dispatch_translated did not materialize released tex_rel (retained=0, expected=1); the leading candidate is the dispatch being refused before binding(the placed-buffer alias refusal), which needs a WARP run to confirm. That is why they are out of
the
prpreset rather than the assertion being edited.