descriptor: a slot the host unmakes, or can only null, shows the neutral texture #557
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!557
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-557"
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?
@deebsy on GitHub · 2026-12-05 04:44 UTC · original
deebsy:neutral-stand-ins→main· +186 −38 · 3 files · 2 commits · merged 2026-12-05 17:28 UTCProblem
Two places hand a slot a null view where its texture is a 2D texture or an array, and a null reads zeros. The title unpacks a texture's channels itself (BC5 normals, YCoCg colour), so a zero read is not a black texel: it is whatever that arithmetic makes of it. The reporter of #37 found it makes green, and the same thing happens here.
HostHeap::unmake— a slot whose memory a newer view of other memory made stale:unmake_stalecalls it for every stale slot: 160,623 of them in one four-minute session here.null_for— any 2D texture view the host cannot make (its host copy is not there yet):Change
Both now show the neutral texture that the waiting paths already show for 2D textures and arrays (
show_later,mirror,unmade_shader_texture).neutral_at()is split out ofneutral_for()so the descriptor is built in one place. Only views that read as colour take it:*_UINT/*_SINTand depth/stencil views keep their null (an integer view reads the grey bytes as a garbage integer, and a comparison over RGBA8 is undefined; the card and WARP disagreed on it), with a depth texture also found by its resource's flags. The stand-in is a 256-slice array, and an array's view covers the slices the title named, so slices after the first read grey too. Every other kind keeps its null of the same kind: buffers, unordered access, 1D, 3D textures and cubes.One new log line carries the two counters, so a run says how often each path fired.
Measured
RX 7900 XTX (24 GB), Series X profile, 2560x1440 output from a 1920x1080 render, ray tracing on, the boat yard and the bushy shoreline of #37:
Frame times are unchanged: the title's own 30 fps cap held throughout, and the log has no new warnings.
What this does not fix: a whole tree at medium distance can still be solid lime green, and a fast camera pan can flash it for a frame or two. That is texture streaming latency (#396) — the slot holds a real texture whose pages have not all arrived, so it is not a null and not this change. It still turns to correct and stays correct. A follow-up can clamp the levels a view exposes to the levels that are there; this patch does not touch that path.
Evidence that the remaining green is not the stand-in: the neutral texture was recoloured magenta, then white (local debug builds, not in this PR); the remaining trees stayed lime green both times.
Cost
None measurable. The neutral texture is one 1x1 RGBA8 texture of 256 slices (1 KiB), made once and alive for the process, so the new call sites add no allocation.
For the RDNA3 branch
neutral-stand-inscherry-picks ontoorigin/rdna2-3with no conflicts:Both files auto-merge, and
stand_in_room_lately's texture stand-in work is untouched — the two changes are about different slots (unmade/null ones vs. rewritten ones), so they should complement rather than fight. Testing there is welcome; if it helps, take it.Testing
The new line appears with the 5-second host statistics:
PKG=victory-gpu ./build.sh test --lib descriptor::host::tests -- --test-threads=2passes 35 tests, including the newa_null_2d_texture_view_is_the_neutral_texture.Assistance
This change was written with DeepSeek V4.1. The code, the evidence for it and this text were audited by GLM-5.3 (OpenCode): the quoted code against the commit's parent, the log line and the test against the commit, and the counters and the recolour runs against the session logs.
26c0b3c13bto1363fc1c50@deebsy on GitHub · 2026-12-05 05:17 UTC · original
After reading #543 and the #216 commits it carries, a note on where this PR sits.
Both build on the neutral stand-in this PR extends. In the runs behind #396, #543 counts 394,468 of 915,000 slots showing the stand-in while their upload ran, and its
VICTORY_SMALL_BACKLOGthen shows a blurred texture instead — one made from a first copy that holds only a texture's first page's levels, while the pass is behind. That is complementary rather than overlapping: #543 shortens how long a slot's first copy waits during a backlog; this PR fixes what slots read that have no view to wait for — the unmade (160,623 in a four-minute session here; 74,636 of them 2D or arrays, now the neutral texture) and the nulled 2D views (313,412), which read zeros, which the title's own channel unpacking turns green.What this PR does not fix — the whole tree green until it is approached, in #37 — is the third piece: a partly arrived copy's view still exposes the levels whose pages are not there, and they read as zeros. Clamping such a view to the levels that are verifiably there is being prepared separately.
@deebsy on GitHub · 2026-12-05 05:17 UTC · original
Merge-order note: #543 (carrying #216's small-first commits) also changes
crates/victory-gpu/src/descriptor/host.rsand the statistics block inhost.rs— the two files this PR touches. I have not line-audited #543's diff against this branch, so treat this as a heads-up rather than a conflict report: this PR's shape is a function split (neutral_atout ofneutral_for), two fallback call sites and two counters, which should keep the rebase small. Whichever merges second rebases; either order works for this branch.@Kal0s-design on GitHub · 2026-12-05 05:47 UTC · original
Checked
1363fc1on native Windows (one NVIDIA desktop card plus WARP, didn't run the game). Merge base is current main (b581f7e).The change is unconditional, there's no switch. Every 2D texture or 2D array slot that
HostHeap::unmakeornull_forused to null now gets the 1x1 grey texture, whatever the title's view format is. The quoted "before" code matches main, the three waiting paths that already usedneutral_forare as described (descriptor/host.rs:2576, 3522, 4947), anddescriptor::host::testshas 35 tests as the body says.For the test suite I ran
cargo test -p victory-gpu --lib --test-threads=4, skipping views_die_with_their_resource. The PR gives 354 passed and 4 failed, main gives 352 passed and 5 failed. The four are the known ones on both (the two indirect host_list tests and the two pipeline library loads) and main's fifth is the flaky watch test. The new test passes. A diagnostics build with VICTORY_D3D12_DEBUG=1 gives 401 passed and 5 failed on the PR, the same four plus the flaky watch test. On WARP it's 400 and 6, the extra one being views_are_made_beside_the_heap_and_copied_in, which I didn't rerun on this main but which has failed on main under WARP in earlier runs too. I ran the new test with the rest ofdescriptor::six times in a row on 4 threads and it never failed, so I saw no sign of its global counter racing with other tests. views_die_with_their_resource on its own still crashes with an access violation on both PR and main, and this PR doesn't touch that path. clippy on victory-gpu --all-targets reports nothing new, andcargo check -p victoryis clean.I also wanted to see what a shader actually reads, so I wrote a throwaway compute test (not pushed). It writes one slot with
null_for(the PR path) and one withnull_like(what main wrote), dispatches a shader that reads the slot, and copies the result back. I ran it on the card and on WARP with the debug layer plus GPU-based validation, and read the info queue myself after each dispatch. As a control I bound a 3D null to a Texture2D shader, and validation flagged that on both devices, so the layer was listening.Texture2D<uint>over an R32_UINT title view reads 0x3f008081 on the PR (the float bits of 0.502), and 0 on main. Same on both devices. The debug layer and GPU-based validation said nothing.SampleCmpLevelZeroover an R32_FLOAT title view returned 0.502 on the card and 0 on WARP. Main gave 0 on both. No validation message either.The cause is that
neutral_at(descriptor/host.rs:445) only looks at the dimension and never atdesc[0]. On main a null reads 0 whatever the format, which is harmless. A real RGBA8_UNORM view behind a uint or comparison declaration is undefined in D3D12, and the two devices already disagree on it. The waiting paths had the same blind spot before this PR. What's new is the reach.unmake(descriptor/host.rs:2760) runs for slots whose placed memory a newer view overlapped, and nothing innote_buffer(2916) filters that by format.null_for(5284, 5291) runs for any 2D viewmirrorcouldn't make or is holding back (3555). I didn't check which formats actually go down these paths in a real session, so this may never bite in practice, but a garbage uint where a 0 used to come back is the case I'd worry about if a title uses it as an index. I'd gateneutral_aton the format and keepnull_likefor the *_UINT and *_SINT formats and the depth/stencil SRV formats (R32_FLOAT_X8X24_TYPELESS, X32_TYPELESS_G8X24_UINT, R24_UNORM_X8_TYPELESS, X24_TYPELESS_G8_UINT, plus R32_FLOAT and R16_UNORM when the resource is known to be a depth one). That covers the waiting paths too, since they go through the same function.On locking, from reading only (no stress test),
unmakekeeps the same lock and the same quick_is, put, clear_twin, keep sequence as before, now with the neutral texture passed tokeepthe wayshow_lateralready does. The firstneutral()call can still create the texture and wait on a fence while a slot lock is held, but main already does that fromshow_laterandmirror, so it isn't new.A few smaller things.
unmakeis also called fromtexture_slot_gone(descriptor/host.rs:2506, the 3 second away path), not only fromunmake_stale, soUNMADE_NEUTRAL(5010) and the new log line in host.rs:7965 ("unmade as their memory was another texture's") count those too, and the 74,636 in the body mixes both. The warning inunmade_shader_texture(descriptor/host.rs:4956) still says "(null, reads as zeros)", but itsNonereturn ends atnull_forthroughmirror, which now writes grey for 2D views. And the new test only checks the counter, never that the slot reads something other than zero, so a readback like the one above would pin the behaviour down.I didn't test the game itself, the RDNA3 branch cherry-pick, an AMD or Intel card, or draws, everything above was compute. I also didn't drive the real
unmake,unmake_staleortexture_slot_gonepaths end to end. My probe only went throughnull_forandnull_like, andunmakereaches the sameneutral_atthroughneutral_for.AI-assisted: yes
@deebsy on GitHub · 2026-12-05 06:07 UTC · original
Took the format point. Pushed
ec05865:neutral_atnow takes the view's format and a depth flag.neutral_formatkeeps the all-zero null for*_UINT/*_SINT(including the stencil planes 22/47) and for depth/stencil formats;resource::is_depthalso catches anR32_FLOATSRV of a depth texture. This covers the waiting paths too, since they all go throughneutral_at, so the card/WARP comparison disagreement no longer has a grey RGBA8 behind it.TEXTURE2DARRAYview binds the number of slices the title named (clamped to 256). Slice 2 of your probe reads grey now, not 0. A load past 256 is still zero.R32_UINT), format 40 (D32_FLOAT) and a depth-flagged placed resource in a colour-format view do not incrementNULL_NEUTRAL; 2D and array colour views do.unmade_shader_texturewarning ("reads as zeros") and theUNMADE_NEUTRALcounter label (thetexture_slot_gone3-second path callsunmaketoo).Checks:
cargo test -p victory-gpu --lib descriptor::host::tests— 35 passed under Wine.cargo clippy -p victory-gpu --all-targets --no-deps -- -D warnings— no findings in the touched lines; the workspace still has its pre-existing clippy-1.98 lints (26 lib / 28 lib-test) elsewhere.Still open: your readback assertion. I left the test counter-based plus the negative gate cases; a Load/SampleLevel check would pin the 0.502 value if you want to send it, or I can add it. I did not test a draw, the game, or an AMD/Intel card this time.
@Kal0s-design on GitHub · 2026-12-05 06:23 UTC · original
Re-checked
ec05865on native Windows (one NVIDIA desktop card plus WARP). Everything I raised on1363fc1is addressed.neutral_format(descriptor/host.rs:457) keeps the null for every DXGI *_UINT and *_SINT format. I went through the list and it's complete, including the single channel R8/R16/R32 ones, R10G10B10A2_UINT and the two stencil planes 22 and 47. The depth side covers 19, 20, 21, 40, 44, 45, 46 and 55, plus the console's 118 to 120 throughpc_format. R32_FLOAT and R16_UNORM views of a depth texture are caught by the resource flag, throughis_depth(resource.rs:353) for resource views andresource[12] & 2for placed ones. TYPELESS formats can't be SRV formats, so their absence doesn't matter. The neutral texture now has 256 slices (descriptor/host.rs:357, filled at 427), and the array view takes the title's ArraySize clamped to 1..256 (508).neutral_atbuilds its own desc with MostDetailedMip 0, MipLevels 1 and FirstArraySlice 0, so a title view asking for 10 mips or a non-zero first slice still gets a valid desc. The warning inunmade_shader_texture(5004), theUNMADE_NEUTRALdoc comment and the meter line in host.rs:7965 now match what they count.I rebuilt the throwaway compute probe (not pushed) and ran it with the debug layer and GPU-based validation, reading the info queue after each dispatch. All writes went through
null_for. As before, a 3D null bound to a Texture2D shader was flagged on both devices, so validation was active. Results were the same on the card and on WARP, with no validation messages in any other case.One case is left over. An R32_FLOAT view of a texture that isn't flagged as depth, read with SampleCmp, still gets 0.502 on the card and 0 on WARP, because the code has no way to tell it from a colour view. That would only matter if a title copies depth into a colour texture and compares against it, so I think it's fine to leave. The
is_depthpath for resource views I only checked by reading the code, since my probe used placed views for the depth flag. The new test asserts both directions through the counter but doesn't read anything back.cargo test -p victory-gpu --libon 4 threads, skipping views_die_with_their_resource, gives 353 passed and 5 failed. The failures are the known two indirect host_list tests, the two pipeline library loads and the flaky watch test. Both neutral tests pass. clippy on victory-gpu --all-targets reports the same 42 warnings as on1363fc1, none of them on the changed lines.As before, I didn't test the game, draws, or AMD and Intel cards.
AI-assisted: yes
@Widget9337 on GitHub · 2026-12-05 07:06 UTC · original
Tried this on an RX 9070 XT 16 GB (Ryzen 9 7950X3D, 64 GB RAM, CachyOS, this repo's Mesa and vkd3d-proton), Series X, 1080p with FSR 4 Balanced, ray tracing on. It merged cleanly onto
mainb581f7e(plus #428 and #445), release build. I'm keeping it: no frame rate change, and the gray stand-in looks fine in play.With the stand-in colored magenta (a local switch, the same as on #463: the first texel of the neutral texture's upload set to
ff 00 ff ff, which your copy loop puts on every slice), both paths fire a lot here:No errors in either log.
What turned magenta: glass more than anything, car windows and a sunroof, and the windows of most boats at the marina; also a banana plant, a fire hydrant, and a patch of road at a crossing. These weren't one frame blips. They stayed magenta for seconds, until I left the area and came back, and then they were correct (the crossing and the hydrant were back to normal on the return). So some of these slots stay unmade or null much longer than a frame or two here. With the switch off, a tree went gray for a bit before its real texture came in, which looks much better than whatever the zeros made of it before.
The one frame flashes from #69 and #463 didn't change. Surfaces that go black or bright for a single frame stayed black or bright, never magenta. With this and the earlier magenta test of the waiting slots on #463, none of the stand-in paths seem to be behind those.
@t-jonesy on GitHub · 2026-12-05 14:19 UTC · original
Supporting data for the format gate in
ec05865, from real sessions. Kal0s's review left open which formats reach these paths in a real session.Our setup. We ported ec05865's
neutral_format/ depth-flag gate into a fork, on every path that writes the neutral texture. That includes the waiting-path stand-ins, which go throughneutral_foron main and throughneutral_atwith #557. The runs were on an RX 9070 XT, game 1.0.2.1, 4K output with FSR 4 Performance, ray tracing on, on thedowntownroute of #554. In these runs only the stand-in half of the gate was exercised; the unmade/null half was off.What the gate kept null in a stand-in:
SampleCmpLevelZeroof about 0.502 on the card, where a null gives 0.resource[12] & 2) reads the flags word correctly: one logged depth + UAV description had flags0x80300006.A possible visible effect (not confirmed). We have a ray-traced shadow flicker on one ramp with a period of exactly 3 frames. That fits a 3-deep ring of shadow inputs in which one slot sometimes waits a frame. If that waiting slot is a depth view given the grey stand-in, its comparisons return about 0.5, which would read as half shadow. We have not yet run that spot with the gate on and off, so this is only a lead. It would explain why neutral stand-ins in shadow inputs were seen to flicker highway shadows on the rdna2-3 branch.
So the gate is not a theoretical guard: on this title, a few thousand integer and depth views reach the stand-in paths at every load.