Skip to content

Alias copies: the buffer's layouts are made again when the view's source texture changed (a copy the host refuses at Close) - #3776

Merged
trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
Lyrnc:fix/late-did-not-close
Nov 30, 2026
Merged

trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
Lyrnc:fix/late-did-not-close

Conversation

@Lyrnc

@Lyrnc Lyrnc commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Scope: this fixes one invalid-copy path I found while tracing the late "did not close" reports below. It is a real bug with a unit test, but nothing yet shows it is the command in those reports. The bench run under NOT tested is how to find out. Related: #3488 (CubeB) names the culprit command after a failed Close.

Problem

a host command list did not close (0x80070057): a command recorded into it was invalid, late in a session and under texture pressure:

Root cause: what the code says (vnv/main 41adb55)

  1. The over-line admission records nothing of its own. draw.rs, the heap texture pass, around lines 4320-4373: when room is false and the slot has no host texture, room_for_first_upload + first_upload_reserve decide first_upload. An admitted slot then goes the way every first upload under the line goes: host.mirror → readable → texture::upload_from → record_upload. first_upload is read once more, at around 4618, only to sample the budget again. The two log lines are the pass's only frequent info lines while resource::room says no room (they print at n = 1 and every 250th or 500th). So during a streaming burst they are the last lines before any failure. Skipping the admission or flushing before it would bring back the black faces and remove no command.
  2. The three guesses in the task:
    • A view of an evicted or placeholder resource. Views are descriptors, not commands. slot_evict runs only with VICTORY_SLOT_EVICT=1 or a flush, and it nulls the slots before it lets the copy go. Gone slots show the neutral texture or a null view (descriptor/host.rs, gone_neutral_on). A view of a released resource faults on the card (0x887A0006, the other ending sailcat saw), and does not fail Close.
    • A barrier on a resource in the wrong state. The runtime keeps no states (the debug layer does). A wrong StateBefore does not fail Close. What does fail it is a state the resource cannot take: buffer bits alone on a texture, a write state on an upload buffer (measured in gpu: close guard, aliasing barriers, copy repairs, and naming/surviving a failed Close (0x80070057) #3488). gpu: make texture states D3D12 refuses legal before they reach a barrier (0x80070057) #3487 handles those. Our pressure paths add no new state.
    • A copy into a released heap. A pooled piece comes back only when the texture's last COM reference goes (pool.rs::give_back_to, a private-data object), and then rests 2.5 s (REST). Lists hold their copies by Arc (slot_evict and let_go_idle check strong_count, and host::references). A use after free would fault or remove the device. It would not give a clean E_INVALIDARG.
  3. What fails Close with E_INVALIDARG is a command the runtime checks when it is recorded: copies (format family, subresource index, box), barriers (state legality), and root arguments without the right root signature. The open PRs for this error:
  4. Which one T07 is cannot be read from the text. The text fits a copy better than the root signature: the failures come with streaming bursts (the chapter load) and scale with the texture volume (Series S lowers it). draw: clear the host tracking when the host list or its epoch changed #2305 cannot be ruled out, because it is also "the same scene every time". The bench run names it.
  5. Found while tracing, and fixed here: texture.rs::alias. This is a view the title placed, in another format, in the memory of a texture the host writes, read through a buffer. It keeps the buffer and both sides' copy layouts in THROUGH, by the view alone. The source is the newest texture the host writes at the view's memory (resource::alias_of → TARGETS_AT, newest at an address wins). alias_with only asks that it has the view's width, height, levels and layers, and a one-texel element of the same bytes. So a target the title makes at that address later (a scene or chapter change that makes its targets again) can be of another format of the same width, for example R16G16_FLOAT where R32_UINT was. The entry is not dropped then: texture::forget of the old target removes only an entry keyed by it. Its layouts still name the old format, and the copy of the new texture into them is a texture ↔ footprint copy between formats that do not copy into each other. The host refuses that at Close (gpu: close guard, aliasing barriers, copy repairs, and naming/surviving a failed Close (0x80070057) #3488's read_back_repaired exists for the same rule). The same happens if the view's host copy has fewer levels than when the entry was made (one want_level keeps as the host wrote it): the copies then name subresources it does not have.

Fix

crates/victory-gpu/src/texture.rs:

  • through_fits(parts, buffered, written, read): the layouts still fit if both sides have as many parts as the entry, each side's format is the one its layouts name, and there is a buffer exactly when the formats do not copy straight across (direct). alias_parts is the old count closure, as a function.
  • alias: reads both host descriptions before the lookup. An entry that does not fit is removed and made again as a new one would be. The info line an alias copy's layouts were made for other textures: made again (first 8, then powers of two) names the view, the source, the formats it was made for and the formats now. THROUGH_STALE counts them.
  • Dimensions are not compared. alias_with already asks for the same size, and World start: no 1.6 s stall (heap buffer views made while the title loads), plus DirectStorage, detiler and pipeline-crash ports #3138's block alias (VICTORY_ALIAS_BLOCKS) has footprints of other widths on purpose. An entry that fits costs two GetDesc calls more than before.

Verification

On 2a63761, target dir C:\pt-close, each under the shared heavy lock:

NOT tested: in-game check pending

Nothing was run in the title. Steps for the bench agent (RTX 5080 16 GB, 9800X3D, 32 GB). The goal is to name T07's command, not just to test this branch.

  1. Builds, each with its own target dir, release (cargo build --release --locked -p victory):
  2. Same for every run: warm shader cache (preloaded), Discord and Firefox closed, no other GPU load, Series X, 2560x1440, DLSS Quality, frame generation 2X, ray tracing off. Texture pressure: VICTORY_TEXTURE_ROOM_PERCENT=40. If R0 does not fail in 15 min, use VICTORY_VRAM_BUDGET_MB=9000 (as v2026.11.29.02: DXGI_ERROR_DEVICE_HUNG after 40-190s on RTX 5080, pipeline library fails to load 72/72 entries #3050 did) instead. Forced pressure can take 8 GB-card paths that are not this bug. Note which setting gave the failure.
  3. Route: a save in the open city. Drive fast for 10 minutes through areas not seen in that session (a streaming burst every few seconds). Then, if we have a save just before a chapter end, play through the chapter load (Huanhuanna917's reliable crash point).
  4. R0 first, 2 runs of at most 15 min. Record the minute of a host command list did not close and the 30 log lines before it. If neither run fails at either pressure setting, stop: "not reproduced on the 5080". Report the room lines (textures picked by index: ... uploaded so far, memory now: ...) so the pressure can be compared with Runtime crash on 0x80070057 (host command list did not close) when texture slots run out — 4070 Ti SUPER 16GB, quality + FG 3X, v2026.11.29.03/.04 #3254's (card 12.0 / 14.3 GB, shared 12.2 GB).
  5. R1 with VICTORY_CLOSE_GUARD=log (commands are judged and logged, still recorded), same route and pressure, 2 runs. Grep the log for:
    • close guard: a command D3D12 would refuse: method, why, command (formats, box, subresources, states) name the command before Close fails.
    • close failure: ... and the replay's line the list's copies, resolves and barriers in the ring were each recorded alone and closed (culprits named), or no command in the ring fails Close alone. The latter means the command is of a kind the guard does not judge (root arguments, a draw, a state call).
    • an alias copy's layouts were made for other textures: made again (this branch).
  6. Read the result:
  7. R1 with the guard on (default), 1 run: it must get through the route. Count close guard lines. They are copies left out, which may show as a texture wrong for a frame. Look at faces and signs after the chapter load.

Overlap

AI use

Claude Code (Claude Opus 5.5) read the issues' text (not the attachments), the code and the open PRs, wrote the change and its test, ran the checks listed above, and wrote this note. Nothing was run in game.

🤖 Generated with Claude Code

texture::alias keeps the buffer and both sides' copy layouts of a view the
title placed, in another format, in the memory of a texture the host writes
(THROUGH), by the view alone. The source is the newest such texture at the
view's memory (resource::alias_of), and alias_with asks only for the view's
size and a texel of the same bytes. A target the title makes there later
can be of another format of that width (R16G16_FLOAT where R32_UINT was):
the kept layouts still named the old format, and the copy of the new
texture into them is one the host refuses, so the list does not close
(0x80070057). The same held for a view's host copy with fewer levels than
when the layouts were made.

through_fits checks the part count of both sides, each side's format and
whether a buffer is wanted (direct); an entry that does not fit is made
again, with an info line ("an alias copy's layouts were made for other
textures: made again"). Found while tracing the late "did not close" under
texture pressure (trustno1-coder#3135, trustno1-coder#3254); not shown to be that one's command.

Test: texture::alias_layout_tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
moritz-eckhard-nickel added a commit to moritz-eckhard-nickel/VIctory-NVIDIA that referenced this pull request Nov 30, 2026
…outs are made again when the view's source texture changed (a copy the host refuses at Close))

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trustno1-coder
trustno1-coder merged commit db3b720 into trustno1-coder:main Nov 30, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants