Repository navigation
gpu, docs: keep placed texture views in step with title memory - #62
Conversation
|
Other open pull requests change the same files. Check that they do not do the same work, and agree with their authors on which lands first: the other one will then need a rebase.
This comment is kept up to date automatically and removed when the overlap ends. |
eae33a4 to
a323476
Compare
simnJS
left a comment
There was a problem hiding this comment.
Thanks for the probe table and the census. The commit numbers are very useful.
Requesting changes:
- Resident creation on the title's thread (
resource.rs:1544-1549,1325,1367). A deferred texture is created withHEAP_FLAG_NONEat its first host use, and that includes the title's own SRV creation.docs/analysis/stall.mdmeasured this kind of call at 0.3–3.6 s per creation, while holding the residency mutex, and main keeps that wait off the title's thread. Could you report first-use creation times from your sessions, or keep the not-resident path? - Pool bypass (
resource.rs:1167). Promoted textures never reach the pool. We are reworking the pool right now toward reserved textures whose tiles are mapped on upload and returned on eviction; your own probe shows those cost no commit until mapped. Deferral would route textures around that design. - Concurrent placed views (
resource.rs:2243-2244,descriptor/host.rs:1969). While one thread creates a view, a second thread getsNoneand writes a null descriptor, which can overwrite the good view until the next re-mirror. This affects every host, not only low-memory ones. - Tests choose deferral from the host's RAM (
resource.rs:1597-1618), so CI and machines with 32 GiB or more test different paths. Please default to eager undercfg(test). - Title: please name every area, e.g.
gpu, hle, docs: ….
Suggestion: the placed-view fixes and the census/per-origin accounting complement the pool rework, and could land soon as their own PR. Hold the deferral until the pool rework is on main, then measure again against it.
The failing gpu-debug-layer job (message 1419 in a draw.rs test) also fails on main and is unrelated to this PR; we are fixing it.
a323476 to
878d9ac
Compare
|
Thanks for the review. I followed your suggestion: this PR now holds only the placed-view fixes and the per-origin accounting, rebased on
The census of address textures is out as well: it shares the deferral's bookkeeping, so it will come with it. |
simnJS
left a comment
There was a problem hiding this comment.
Thanks for the rework. Splitting the PR, fixing the title and dropping the deferral settle points 1, 2, 4 and 5, and the ticket scheme in texture_at_with reads well. The gpu-debug-layer failures (message 1419) are the same three as on main; we're fixing those there.
Two small points:
descriptor/host.rs:1955-1960:Some(None)means "another thread is making it", but also "no mapped page" or "creation failed". So after an unmap, a slot keeps the old mapping's copy instead of following the memory. Couldtexture_atreport "building" separately, so that only that case keeps the slot? A test that unmaps and then mirrors would cover it.resource.rs:2153, 2195:view.changesis now recorded only on success, so a failed rebuild is retried on every lookup; main recorded it first. On a low-memory host, that could repeat a slow creation on the title's thread.
Happy to approve once these are answered.
Placed texture views (host copies made for a texture the title placed in its own memory) now follow that memory: - A remap or unmap cancels a view still being created, so a creation that finishes late can no longer reinsert a stale entry. - Expired views are reaped during normal submissions instead of only at the next invalidation. - A read-only view waits for at least one mapped page. - A slot whose view cannot be made now gets a null view, with no second attempt under the descriptor lock. - A slot already made over a placed view's texture keeps it when a racing mirror finds no texture there because another thread is still making one (texture_lookup reports that case apart). Before, that mirror wrote a null view over the good one until the slot was made again. With no mapped page or a failed creation, the slot still follows the memory and is made null. - A failed rebuild still records the alias change, as before, so it is not tried again on every lookup. The frame report gives host texture count and MiB by creation origin (committed, heap offset, address, placed view, external) and the placed-view cache counts.
878d9ac to
dfbbd92
Compare
|
Thanks, both done in the same commit.
Tests on the RTX 5070: |
simnJS
left a comment
There was a problem hiding this comment.
Thanks for the quick rework. Both points are settled. texture_lookup now reports Building separately, so only a slot racing its maker keeps its view, and an unmapped or failed view follows the memory; the unmap test covers it. A failed rebuild records view.changes again, as main did.
Optional, in a follow-up: a test showing that a failed rebuild is not retried before the next alias change. Also, the PlacedLookup::Building doc says "the first one", but it is also returned during a rebuild.
The gpu-debug-layer failures are the three known message-1419 tests that also fail on main. We're fixing them there, and I'll merge once that job is green. Approving.
What and why
Reworked after review: this PR now holds only the placed-view fixes and the per-origin accounting. The deferral of address textures is out, held until the pool rework is on
main, then measured again against it, as suggested.Placed texture views are the host copies XTP makes for a texture the title placed in its own memory. Today they can outlive or miss changes to that memory, and a race can leave a slot null:
texture_lookupnow reports that case apart (PlacedLookup::Building), and only then a slot already made for the same record over a texture keeps it (descriptor/host.rs,mirror). With no mapped page or a failed creation, the slot follows the memory and is made null. A slot not made yet still gets a null view, and is made by the next mirror that finds the texture.The frame report also gives:
On the RTX 5070 (12 GB, driver 32.0.16.1664, 16 GB RAM), main
c3da2f9with #61, first world frames: placed views 15,449 live, 3,753 MiB; address textures 2,073 MiB. On that driver every DEFAULT texture is charged in full to process commit, even created not resident or evicted. A probe of 32 × 64 MiB RGBA8 textures, deltas in MiB:CREATE_NOT_RESIDENTEvictSo the reserved textures of the pool rework should help this host most. The origin counts show how much it takes off each path.
Not in this PR, to come after the pool rework: the deferral and the census of address textures (it shares the deferral's bookkeeping).
Size: +500/−86 over 7 files, of which about half is tests.
Fixes: none
Depends on: none
Area
crates/xtp-gpu/src/resource.rs,resource/alias.rs,resource/format.rs: placed-view lifetime, accounting by origin, a test helpercrates/xtp-gpu/src/descriptor/host.rs: the concurrent mirror fix and its testscrates/xtp-gpu/src/host.rs,device.rs: reaping during submissions, the report linedocs/analysis/vram.mdTests
cargo xtask pr-checkpasses on my machine. fmt, both clippy passes, policy and conventions ran. The test step was run per crate (below), because the app integration tests launchxtp.exe.Tests on the RTX 5070, on this branch (main
c3da2f9):cargo test -p xtp-gpu --lib -- --test-threads=1: 479 passed, 13 ignored.New tests:
a_placed_slot_keeps_its_view_while_another_is_made: a slot made over a placed view keeps it while the view's entry looks as if another thread were still making it. It fails without the fix (the slot kept its view).a_placed_slot_follows_its_memory_when_unmapped: a slot made over a placed view is made null once its memory is decommitted and the remap reported. It fails if every "no texture" keeps the slot.a_read_only_placed_view_waits_for_its_first_mapped_pagea_remap_cancels_a_placed_view_still_being_createdRan on a title: the placed-view part ran in five guarded world sessions of the 1.0.2.1 Xbox Series build (Series S mode, RTX 5070, 16 GB RAM) on
448bb93, together with the deferral. This exact branch was not run on the title.Provenance
Written for XTP from XTP's own code. What was read: XTP's logs from the sessions; public Microsoft documentation on process memory counters, DXGI budgets,
Evictand WDDM backing stores. xcl and AnyPS5 were not read for this.AI assistance: AI coding tools wrote this change and its tests, mainly OpenAI Codex.
Checklist
<area>: <summary>; one topic; under 400 changed lines, or the reason is above