Tested merge candidate: open PRs added a batch at a time, each batch built, tested and run on the title (replaces #3327) #3409

Open
github-bot wants to merge 81 commits from github-bot/gh-3409 into main AGit
Owner

@⁠pes7 on GitHub · 2026-11-26 22:51 UTC · original
pes7:merge/tested → main · +2834 −213 · 24 files · 81 commits · open

Draft, a tested merge candidate. main plus 27 open pull requests, added a few at a time. Each step was checked by building, testing and running the title, so maintainers can see which PRs are known to work together and with the title. It replaces #3327, which is closed (see below for why).

Nothing here closes or replaces any of these pull requests: each stays open and is closed only when it lands in main. If it helps, merging this branch lands them all at once with the checks below already done. Picking single PRs from the list is just as fine.

Why a smaller tested set, not everything that is green

In #3327 I merged every open PR that merged cleanly and had a green check, 375 of them. That set builds and passes cargo test, but it does not run the title. Each problem below was found by bisecting that set or by others' reports:

  • Device removal (0x887A0004) about 70-90 s in, at the first cutscene, on a machine with three adapters. One cause found in the set was #967 (the adapter choice); other combinations still did it after #967 was reverted.
  • Access violations, writes to read-only pages, in a group of xmem / guard PRs. #2848's guard-reopen commit was one of them, confirmed independently in #2848 by @⁠Jackster and since removed from it.
  • A black or washed-out picture with the audio still running.
  • Tests that pass alone but fail in the set: #2012 (the table decoder fails about 320 shader tests together with the rest), #2336, #2731, and #2626 (with a PR of mine that changed the same formats, since closed in favour of #2626).
  • A semantic conflict (#2706 with #1653) and lower.rs growing past the 512 KiB asset policy once enough shader PRs are combined.

So "mergeable and green" alone is not enough: individually fine PRs break the title in combination. This branch therefore grows only by steps that keep the title running.

How each PR got in

PRs taken, most useful first:

  • triage verdict merge-candidate on their current head;
  • the change is in runtime code, not only tests;
  • no negative reports from testers in the discussion;
  • ranked by the number of independent confirmations and by whether the title fixes a crash or wrong behaviour.

They were added in batches of six. A batch stays only if all of these hold:

  1. cargo check --workspace --all-targets --locked
  2. cargo test --workspace --locked: 0 failures (the one known flaky relaunch_closes_its_duplicated_process_handle is ignored)
  3. The title for 300 s (release + diagnostics, Series X, a scripted Enter / hold schedule through #3392, warm shader cache), judged automatically, with screenshots every 30 s also looked at:
    • no device removed;
    • no unhandled exception or panic;
    • no black picture from 150 s on;
    • the world reached (over 10 000 draws a frame).

A batch that fails is halved until the PR that fails it is out. That PR is listed with the reason.

The base, main + #3392 alone, reaches the prison yard in 300 s with 10 552 draws a frame. #3392 is in the base only because the scripted input needs a held key.

In this branch (27)

Batch 1, title OK (max 10132 draws a frame):

  • #2703 GPU: a root constant's dword 4 is a value, not a view offset (#2699) (@⁠Calvix2k)
  • #2319 GPU: create a texture without a host UAV format without the flag (@⁠Calvix2k)
  • #601 GPU: bound texture upload and capture slices to the allocated buffer (@⁠AwsAli05)
  • #1406 GPU: fix NULL/UNKNOWN SRV/UAVs on promoted-typeless textures and MSAA/array/3D NULL RTV/DSVs (@⁠ESAT586)
  • #1849 GPU: free memory is not the runtime's to watch (fixes a world-load deadlock under Wine) (@⁠crashbashash)
  • #2598 GPU: giving up a texture leaves the dynamic slots of recorded lists alone (@⁠BastienRodz)

Batch 2, title OK (max 11200 draws a frame):

  • #602 GPU: report retained snapshot, texture scratch and upload memory (@⁠lucaseddd)
  • #2088 GPU: reuse loose windows that hold a range (#402), 256 KiB windows opt-in (VICTORY_LOOSE_WINDOW_KIB) (@⁠desplmfao)
  • #1978 GPU: no texture layouts or name copies per draw for unchanged answers (@⁠0xkn0wh3r3)
  • #2579 Core: ignore empty LOCALAPPDATA, XDG_CACHE_HOME, and HOME in default directory resolution (@⁠reeledMarek)
  • #2553 HLE: avoid data race in DirectStorage late page-list polling (@⁠reeledMarek)

Batch 3, title OK (max 10581 draws a frame):

  • #2666 GPU diagnostics: end draw traces at every present (@⁠andrewpozdnakov7-jpg)
  • #2327 GPU: a save that fails gives its changes back for the next one (@⁠denkencar-sketch)
  • #2630 PE: refuse a tls directory that runs outside the image (@⁠imjustprism)
  • #1217 GPU: the copies timing no longer counts the flush before a title copy twice (@⁠neonbyte1)
  • #2704 Round rectangle half-float attributes to even and preserve NaNs (@⁠VlREX)
  • #3005 GPU: make already-used pipeline lookups read-only (@⁠AwsAli05)

Batch 4, title OK (max 11409 draws a frame):

  • #2437 GPU: a marked copy-back advances the snapshot of declared ranges over its page (@⁠BastienRodz)
  • #3064 GPU: round depth-twin UNORM16 copies at the exact midpoint (@⁠andrewpozdnakov7-jpg)
  • #3022 GPU: read D24S8 and D32S8 planes into guest buffers (@⁠andrewpozdnakov7-jpg)
  • #3039 GPU: a lost host list's heaps are not a wanted pair (@⁠kotekompotek)

Batch 5, title OK (max 10827 draws a frame):

  • #2578 Core: ignore empty VICTORY_LOG and RUST_LOG values instead of overriding default log level (@⁠reeledMarek)
  • #2392 HLE: a null or empty subkey opens the emulated OEM key itself (#765) (@⁠KainanP)
  • #2099 GPU: stop the descriptor view table growing without bound (@⁠0xkn0wh3r3)
  • #2962 GPU: sample packed 10-bit frames for black-frame diagnostics (@⁠andrewpozdnakov7-jpg)
  • #2873 GPU: a title buffer view takes a format the host takes, or stays null (@⁠0xkn0wh3r3)
  • #450 GPU: preserve typed null render target slots (@⁠fuzeofficlal)

One fix on top (1e25b23): #2962's diagnostics-only test called Host::rtv(&texture, ..), and #450 changed that to take Option<&ID3D12Resource>. It surfaced only in the --all-features clippy that CI runs. That build is now part of every step: on this head, clippy -D warnings is clean both ways, cargo test --workspace passes 908 tests with 0 failures, and victory-gpu with --all-features passes 278 with 0 failures.

Conflict with the set so far (need a rebase onto it, not judged)

#2821, #2542, #2727, #3065

Status

  • Next: the rest of the runtime PRs outside victory-shader (about 140), in the same way, as the machine is free for title runs. This branch is pushed only at points where the title run passed. A failing run is repeated before a PR is left out, since a device removal can come and go.
  • Then the 85 shader PRs, in larger groups, because every translator change makes the title translate all shaders again.

Not checked: other GPUs (all title runs are on one NVIDIA machine) and Series S mode. The tests ran on the same machine's GPU.

🤖 Generated with Claude Code

**@⁠pes7** on GitHub · 2026-11-26 22:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/3409) `pes7:merge/tested` → `main` · +2834 −213 · 24 files · 81 commits · open **Draft, a tested merge candidate.** `main` plus **27 open pull requests**, added a few at a time. Each step was checked by building, testing and running the title, so maintainers can see which PRs are known to work together and with the title. It replaces #3327, which is closed (see below for why). Nothing here closes or replaces any of these pull requests: each stays open and is closed only when it lands in `main`. If it helps, merging this branch lands them all at once with the checks below already done. Picking single PRs from the list is just as fine. ## Why a smaller tested set, not everything that is green In #3327 I merged every open PR that merged cleanly and had a green `check`, 375 of them. That set builds and passes `cargo test`, but **it does not run the title**. Each problem below was found by bisecting that set or by others' reports: - **Device removal (`0x887A0004`) about 70-90 s in**, at the first cutscene, on a machine with three adapters. One cause found in the set was #967 (the adapter choice); other combinations still did it after #967 was reverted. - **Access violations, writes to read-only pages**, in a group of `xmem` / guard PRs. #2848's guard-reopen commit was one of them, confirmed independently in #2848 by @⁠Jackster and since removed from it. - **A black or washed-out picture with the audio still running.** - **Tests that pass alone but fail in the set:** #2012 (the table decoder fails about 320 shader tests together with the rest), #2336, #2731, and #2626 (with a PR of mine that changed the same formats, since closed in favour of #2626). - **A semantic conflict** (#2706 with #1653) and `lower.rs` growing past the 512 KiB asset policy once enough shader PRs are combined. So "mergeable and green" alone is not enough: individually fine PRs break the title in combination. This branch therefore grows only by steps that keep the title running. ## How each PR got in PRs taken, most useful first: - triage verdict `merge-candidate` on their current head; - the change is in runtime code, not only tests; - no negative reports from testers in the discussion; - ranked by the number of independent confirmations and by whether the title fixes a crash or wrong behaviour. They were added in batches of six. A batch stays only if all of these hold: 1. `cargo check --workspace --all-targets --locked` 2. `cargo test --workspace --locked`: 0 failures (the one known flaky `relaunch_closes_its_duplicated_process_handle` is ignored) 3. **The title for 300 s** (release + `diagnostics`, Series X, a scripted `Enter` / hold schedule through #3392, warm shader cache), judged automatically, with screenshots every 30 s also looked at: - no `device removed`; - no unhandled exception or panic; - no black picture from 150 s on; - the world reached (over 10 000 draws a frame). A batch that fails is halved until the PR that fails it is out. That PR is listed with the reason. The base, `main` + #3392 alone, reaches the prison yard in 300 s with 10 552 draws a frame. #3392 is in the base only because the scripted input needs a held key. ## In this branch (27) Batch 1, title OK (max 10132 draws a frame): - #2703 GPU: a root constant's dword 4 is a value, not a view offset (#2699) (@⁠Calvix2k) - #2319 GPU: create a texture without a host UAV format without the flag (@⁠Calvix2k) - #601 GPU: bound texture upload and capture slices to the allocated buffer (@⁠AwsAli05) - #1406 GPU: fix NULL/UNKNOWN SRV/UAVs on promoted-typeless textures and MSAA/array/3D NULL RTV/DSVs (@⁠ESAT586) - #1849 GPU: free memory is not the runtime's to watch (fixes a world-load deadlock under Wine) (@⁠crashbashash) - #2598 GPU: giving up a texture leaves the dynamic slots of recorded lists alone (@⁠BastienRodz) Batch 2, title OK (max 11200 draws a frame): - #602 GPU: report retained snapshot, texture scratch and upload memory (@⁠lucaseddd) - #2088 GPU: reuse loose windows that hold a range (#402), 256 KiB windows opt-in (VICTORY_LOOSE_WINDOW_KIB) (@⁠desplmfao) - #1978 GPU: no texture layouts or name copies per draw for unchanged answers (@⁠0xkn0wh3r3) - #2579 Core: ignore empty LOCALAPPDATA, XDG_CACHE_HOME, and HOME in default directory resolution (@⁠reeledMarek) - #2553 HLE: avoid data race in DirectStorage late page-list polling (@⁠reeledMarek) Batch 3, title OK (max 10581 draws a frame): - #2666 GPU diagnostics: end draw traces at every present (@⁠andrewpozdnakov7-jpg) - #2327 GPU: a save that fails gives its changes back for the next one (@⁠denkencar-sketch) - #2630 PE: refuse a tls directory that runs outside the image (@⁠imjustprism) - #1217 GPU: the copies timing no longer counts the flush before a title copy twice (@⁠neonbyte1) - #2704 Round rectangle half-float attributes to even and preserve NaNs (@⁠VlREX) - #3005 GPU: make already-used pipeline lookups read-only (@⁠AwsAli05) Batch 4, title OK (max 11409 draws a frame): - #2437 GPU: a marked copy-back advances the snapshot of declared ranges over its page (@⁠BastienRodz) - #3064 GPU: round depth-twin UNORM16 copies at the exact midpoint (@⁠andrewpozdnakov7-jpg) - #3022 GPU: read D24S8 and D32S8 planes into guest buffers (@⁠andrewpozdnakov7-jpg) - #3039 GPU: a lost host list's heaps are not a wanted pair (@⁠kotekompotek) Batch 5, title OK (max 10827 draws a frame): - #2578 Core: ignore empty VICTORY_LOG and RUST_LOG values instead of overriding default log level (@⁠reeledMarek) - #2392 HLE: a null or empty subkey opens the emulated OEM key itself (#765) (@⁠KainanP) - #2099 GPU: stop the descriptor view table growing without bound (@⁠0xkn0wh3r3) - #2962 GPU: sample packed 10-bit frames for black-frame diagnostics (@⁠andrewpozdnakov7-jpg) - #2873 GPU: a title buffer view takes a format the host takes, or stays null (@⁠0xkn0wh3r3) - #450 GPU: preserve typed null render target slots (@⁠fuzeofficlal) One fix on top (`1e25b23`): #2962's diagnostics-only test called `Host::rtv(&texture, ..)`, and #450 changed that to take `Option<&ID3D12Resource>`. It surfaced only in the `--all-features` clippy that CI runs. That build is now part of every step: on this head, clippy `-D warnings` is clean both ways, `cargo test --workspace` passes 908 tests with 0 failures, and `victory-gpu` with `--all-features` passes 278 with 0 failures. ## Conflict with the set so far (need a rebase onto it, not judged) #2821, #2542, #2727, #3065 ## Status - **Next:** the rest of the runtime PRs outside `victory-shader` (about 140), in the same way, as the machine is free for title runs. This branch is pushed only at points where the title run passed. A failing run is repeated before a PR is left out, since a device removal can come and go. - **Then the 85 shader PRs**, in larger groups, because every translator change makes the title translate all shaders again. Not checked: other GPUs (all title runs are on one NVIDIA machine) and Series S mode. The tests ran on the same machine's GPU. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`shadow::find` looked at only the 64 buffers starting closest below an
address. A big buffer with more than 64 smaller buffers placed in it
before the address was missed, and the range fell through to `loose`,
which made a second 4 MiB host copy of memory the big buffer's copy
already had, not aliased with it. The search now goes back as far as the
longest buffer registered so far (`MAX_SPAN`): one starting further below
cannot hold the range.

`loose` reused a window only for the exact same (start, length), so a
range inside a window made for a range spanning two windows got another
copy. It now reuses any window holding the range. It also gives no copy
for null-page addresses, or for memory that is not committed when a new
window would be made, instead of 4 MiB of zeros.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`shadow::find` looked at only the 64 buffers starting closest below an
address. A big buffer with more than 64 smaller buffers placed in it
before the address was missed, and the range fell through to `loose`,
which made a second 4 MiB host copy of memory the big buffer's copy
already had, not aliased with it. The search now goes back as far as the
longest buffer registered so far (`MAX_SPAN`): one starting further below
cannot hold the range.

`loose` reused a window only for the exact same (start, length), so a
range inside a window made for a range spanning two windows got another
copy. It now reuses any window holding the range. It also gives no copy
for null-page addresses, or for memory that is not committed when a new
window would be made, instead of 4 MiB of zeros.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Memory outside every buffer object gets host copies of the aligned
windows lookups touch. While Grand Theft Auto VI loads its world, about
700 such 4 MiB windows (3.4 GB of host memory) were live; the lookups
touched about 30% of their bytes (in 64 KiB pieces). With 256 KiB
windows, at the same point of loading: 5,713 windows, 2.2 GB, and the
process 15.4 GB instead of 17.3 to 20.4 GB. No descriptor-slot warnings
for the extra windows' page-table entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	crates/victory-gpu/src/capture.rs
#	crates/victory-gpu/src/texture.rs
A range in one window, then a range across its end, which gets a window
of its own over both: the title's writes reach both copies at their
refresh, and a shader's write through the spanning copy goes back to
title memory and into the first copy at its next refresh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A miss in the buffer lookup scanned every buffer starting within the
longest buffer's length below the address (MAX_SPAN, 174 MB in the
world): about 480 entries per miss on average, at most 2,842, and some
330,000 misses every 5 s, all under BUFFERS' lock (measured in Grand
Theft Auto VI's world, RTX 5080 under Proton).

Buffers of 1 MiB or more are now also kept in a small map of their own.
A lookup scans BUFFERS only within the longest smaller buffer's length
below the address, then the big buffers further below, back to
MAX_SPAN. Only a big buffer can hold the range from further below, so
the result is the same innermost buffer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RegOpenKeyW and RegOpenKeyExW returned ERROR_FILE_NOT_FOUND for any
path below our stand-in for HKLM\...\CurrentVersion\OEM, including a
null or empty one. The documented behaviour, and the host's: RegOpenKeyW
gives back the key it was passed, RegOpenKeyExW a handle to the same
key. Other paths below it still are not found (it has no subkeys).

Test: both functions with a null and an empty subkey, on our key and on
a host key for comparison.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With a null phkResult and a subkey other than null or empty, open()
returned ERROR_FILE_NOT_FOUND for our OEM key before it looked at the
output pointer. The host checks the pointer first: on Windows 11 its
RegOpenKeyW and RegOpenKeyExW return ERROR_INVALID_PARAMETER for a null
phkResult whether the subkey is missing, empty or null. Microsoft's
pages do not name the error for this case, so the test asks the host
for the same calls on a host key and holds ours to the same answers.

Test: nowhere_to_put_the_key_is_an_invalid_parameter, ours and the
host's, for a missing, an empty and a null subkey.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit b73bb8b. With it, Grand Theft Auto VI's world showed
spikes out of the player character's head and triangles stretched across
the scene in two runs; the same build without it is clean. A stale entry
in the map of big buffers (a key registered again shorter) explains the
spikes, but with that fixed the triangles stayed, so the change goes until
it is understood. The lookup cost it targeted is back as before (about 480
entries per miss).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Part of #2307 (the allocation half; #1763 covers the view half).

A texture the title creates with `D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS` in a format the host has no typed UAV for, and that has no typeless family to stand in (`B5G5R5A1_UNORM`, and the console's two-byte formats that pass through as DXGI numbers), removes the device at `GetResourceAllocationInfo` on a strict driver: "a texture that has ALLOW_UNORDERED_ACCESS must be created with a format that ... can be used as unordered access". `host_desc` now drops the flag for exactly those formats with a one-time warning, so the texture is created and the title keeps running; its unordered views are refused later by `fits` (#1763), instead of the device disappearing.

Formats with a family are untouched: the sRGB case keeps its existing mapping, and a format whose type the device stores to keeps the flag.

## Verification

- `cargo test -p victory-gpu --features diagnostics --lib` on Windows 10 19045 / RX 7800 XT: 146 passed, 1 failed — the known placed-view test on a runtime without `ID3D12Device10` (#1999), identical on `main`; clippy `-D warnings` clean.
- `a_format_without_unordered_access_loses_the_flag` checks the new arm and the "keeps the flag" arm. It skips where the device does report a typed UAV for those formats — this AMD driver does (85, 86, 115 all true here), which is why the removal is NVIDIA-only in the reports; the drop needs an NVIDIA/WARP run to be exercised.
Review feedback on #2319: `family(f) == f` is also true for every typeless
format, so the new drop would have taken `ALLOW_UNORDERED_ACCESS` from sRGB
textures the block above just made typeless (29 -> 27, 91 -> 90, 93 -> 92)
and from typeless UAV textures of the title's own (R32_TYPELESS). Their
unordered views would then be refused by `descriptor::host::fits`, a
regression from `main`.

Use the test `fits` uses for "no family at all": `family(f) == f &&
family(f + 1) != f`. The test now also checks that an sRGB UAV texture (29)
keeps the flag and comes out as its typeless family 27; that assertion runs
before the device-dependent early return, so it is checked on AMD too. Move
the test inside `mod tests` (it sat after the module's closing brace).
Since 69d1e8e, giving up a host texture (idle, or past the card's
budget) nulls every heap slot viewing it (HostHeap::evict). Since
ed25c0e it finds them by scanning `kept`, which covers the dynamic slots
too: the descriptor tables lists build for their draws. A recorded list
not yet reset still uses those (the dynamic slots it took are not
released until then), and its table is not made again before it runs,
so its draws read a null 2D view, and the slot no longer held the
texture. resource.rs: "Lists recorded before hold it until they are
reset, so no GPU work reads it freed".

evict now leaves dynamic slots a list still holds (taken in `next`), and
holds `made` and `next` across the scan and the clearing.

Co-Authored-By: Gemini 4 Neon <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Until the slot is next made, not until its list is reset (review by
fyernald).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A loose copy of title memory for a null address covers 0..4 MiB, and
`runtime_pages` takes free memory for the runtime's (its `shortcut:`),
so free parts of the window are tracked and guarded once something is
committed there. On Windows nothing is. Under Wine the process heap is:
its pages became read-only, and a heap write by a thread holding the
guard lock (in `Tracked::take`, `writing` or the fault handler itself)
faulted into the handler, which waited for that lock forever: the title
stopped at the end of loading.

The region check now leaves free memory out, as it leaves out plain
committed memory and images; reserved memory still counts (the
shortcut keeps that part).

Test: a block reserved and released (free memory at a known address)
is not tracked. It fails without the change; it only counts if the
block is still free afterwards, since other tests allocate meanwhile.
In the user-data loop, a dword numbered `ROOT_VIEW_OFFSET` (4) was taken
for a root view's offset without asking whether the parameter was a root
descriptor at all. Root constants with five or more dwords have a real
dword 4; it was looked up as a root view, none was found, and the draw or
dispatch was refused ("a root view's offset: no root view, or outside
title buffers") with no log line. The ray-tracing builder's dispatches
were among the casualties.

Ask `u.root == RootType::Descriptor` too, through a helper beside
`is_root_view`, so a root constant's dword 4 goes to the title's user data
as the value it is.

The test pins the predicate: descriptor dword 4 is an offset, constants
and table dword 4 are not.
AI-authored and verified by Gemini 4 Neon (High Mode) — zero game data used.

Fixes VIC-BT-004 (P0) and VIC-BT-012 (P1) from #1242:
- `crates/victory-gpu/src/descriptor/host.rs`: when a typed console texture was
  promoted to a typeless host copy (`host_texture` for sRGB+UAV or
  shader-readable depth targets), `fits()` previously rejected NULL-desc and
  `DXGI_FORMAT_UNKNOWN` SRV/UAVs, replacing them with null views. Now resolves
  the promoted view format (shader-readable depth plane 0 format for depth SRVs,
  linear twin for sRGB UAVs, title format for sRGB SRVs) and synthesizes a
  dimension-matched default SRV/UAV description when `desc` is `None`.
- `crates/victory-gpu/src/descriptor.rs`: `RtvRecord::desc()` and
  `RtvRecord::depth_desc()` previously hardcoded `TEXTURE_2D` for NULL-desc
  RTV/DSVs on promoted-typeless targets; now inspect the host texture's
  `Dimension`, `DepthOrArraySize`, and `SampleDesc.Count` to emit the exact
  `1D`, `1DArray`, `2D`, `2DArray`, `2DMS`, `2DMSArray`, or `3D` view desc.
- Adds unit tests plus a real D3D12 hardware test verifying NULL/UNKNOWN views
  on promoted sRGB+UAV and 2D-array depth textures on the host GPU.
Every view a title writes is kept in one table, and a descriptor's
record (the tag and two words) names its entry and generation, which
survives titles copying descriptors as bytes. Views of resource objects
are freed with their resource, but views without one (constant buffers,
views of placed memory) have nothing that releases them, so their
entries were kept for the run. Grand Theft Auto VI writes some 14,000
constant buffer views a frame, each at the address its constants have
that frame: on fxceless/victory-fork, 2,450,139 entries after four
minutes of play, about 1 GB with the index, growing by 11,000 a second.

The record's two words now say what they hold in the generation's top
two bits: 0, a table entry as before (generations stay below those
bits); a constant buffer view whole (a 47-bit address and a 15-bit
size: bytes below 16 KiB, else 256-byte units below 4 MiB); or a view of
placed memory whole (a 40-bit title address and the number of its
"shape", the view's description without its address, kept in a table
of their own: as many as the title has kinds of textures and buffers).
Views that do not fit (larger addresses or sizes, shapes past 2^22)
stay table entries. Every reader goes through `view_at`, which decodes
all three; the host heap keys its slots by the same two words, which
stay equal for equal views and differ for different ones.
`VICTORY_VIEW_INLINE=0` keeps every view a table entry.

Ported from fxceless/victory-fork (commit 578d459), the view-table part
only (not that commit's other descriptor changes).

Tests (no GPU needed):
- `constant_views_fit_their_records`: addresses and sizes round-trip,
  and those that do not fit say so.
- `views_at_new_addresses_add_no_entries`: 20,000 constant buffer and
  placed views at new addresses add no entries and one shape.
- `released_entries_keep_their_generations_below_the_kind_bits`: a
  generation bumped past the top wraps to 1, and the released view's
  record goes stale.

Co-authored-by: fxceless <[email protected]>
The VICTORY_VIEW_INLINE switch is gone, and the view table's doc comment
says only what the code does; the measurements stay in the pull request.
`views_current`, which a heap sync uses to look at a page's records under
one lock, compared every record with the table entry it names, so a
record holding a constant buffer view or a view of placed memory whole
was never current and its slot was never made: a title copying such
records as bytes left the copies null. It now decodes records as
`view_at` does: a table entry at its own generation, a constant buffer
view, or a placed view whose shape is numbered.

Tests:
- `views_held_whole_are_current_for_heap_syncs` (no GPU needed):
  `views_current` agrees with `view_at` on constant and placed views held
  whole, live and released table entries, unknown shapes and kinds, and
  records without the tag.
- `heap_syncs_make_the_slots_whose_records_hold_their_views_whole`: a
  heap sync makes slots given byte copies of a constant buffer view's and
  a placed view's records, and leaves a cleared one null.
copy_back_marks runs before the copy-backs of declared ranges. It puts a
marked page's GPU bytes back, and the copy takes the title's others
(`*h = *t`), but the snapshot of a declared range over that page
(Shadow::before) kept the bytes from before the submission. That range's
copy-back then found the title's bytes the copy had taken differing from
the snapshot, took them for the GPU's, and put them back over what the
title had written in between.

copy_back_marked now brings the snapshot over the page to the copy's
bytes (sync_snapshot).

Co-Authored-By: Gemini 4 Neon <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Materialize an explicit null RTV when recording host render-target bindings. Keep the resource-transition list limited to real textures. A synthetic MRT draw verifies that the real target receives SV_Target1 after a typed null in slot 0.
Title buffer views reached CreateShaderResourceView and
CreateUnorderedAccessView with the title's own format. The title's heap
holds views the host refuses: made for its own runtime, or old ones in
slots it does not use. On WARP with the debug layer:

  - a raw view of R32_UINT: "When creating a RAW Shader Resource View,
    the format must be DXGI_FORMAT_R32_TYPELESS", then device removal
    (DXGI_ERROR_INVALID_CALL) for the shader resource view;
  - a structured view with a format: "it must be DXGI_FORMAT_UNKNOWN";
  - a typed view of a typeless format: "cannot be used when creating a
    typed View of a Buffer".

A raw or structured view reads its bytes whatever its format says, so it
is now made in the format the host wants (R32_TYPELESS, UNKNOWN); a raw
view with a structure stride, or a typed view of no format or a typeless
one, has none and stays null, with a warning once. Structure strides are
left as they are (2, 6 and 4096 are taken by the debug layer).

Test: buffer_views_take_a_format_the_host_takes.

From DexNom/VIctory@570a941e9b
(buffer_view_ok in descriptor/host.rs), reworked: views are corrected
where their bytes do not depend on the format instead of refused, and
the stride limits and the raw 16-byte start, which the debug layer does
not ask for or which #123 covers, are left out.

Co-authored-by: DexNom <[email protected]>
Two lookups every draw makes did work whose answer rarely needs it:

- `resource::alias_source` runs for every placed view a draw reads and
  built the placed texture's full console layout (`texture_layout`, a
  mip chain of vectors) under the global `TEXTURES_AT` lock before
  looking at the other textures at its address. Most placed views have
  no texture the GPU writes at that address, so the layout is now built
  only once one is found; the cheap tests (another resource, written by
  the GPU, its own host texture) come first. Same answer in every case.
- `memory::note_use` copied the pipeline's name into a new String on
  every draw that reads title memory, under the process-wide stats lock,
  even when the name was counted already. It now looks the name up first
  and copies it once per frame.
The marks were cleared before the library was serialised and written, so a
failure at shutdown left nothing to save.
Review: a typed title buffer view of a format the device's buffer views
do not take (block-compressed, depth, sRGB...: BC1_UNORM has no
D3D12_FORMAT_SUPPORT1_BUFFER) still reached the device. The typed path
now asks the device, once a format and kind: a shader view needs buffer
and shader-load support, an unordered view buffer and typed
unordered-access support; a view without stays null.

Test: typed_buffer_views_take_only_formats_the_device_buffers_take
(R32_UINT taken, BC1_UNORM and D32_FLOAT refused, shader and unordered
alike; R8G8B8A8_UNORM taken for shader views).
Conflicts in crates/victory-gpu/src/shadow.rs: main's copies now come
back as Arc from Shadow::new and bump GENERATION through changed(); kept
that and added #402's MAX_SPAN search, the loose-window reuse
(LOOSE_SPAN, enclosing_window) and the committed/null-page checks on top.
#402's tests join main's `pub(crate) mod tests`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
update/402-main is #402 with main merged in. Its shadow.rs replaces this
branch's copy of #402's commit (same change on an older main); this
branch's own changes go on top: 256 KiB windows and the
overlapping-windows test. The two-step lookup stays reverted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
r4tedx's in-game A/B of this branch (RTX 5070) measured the 256 KiB
windows at +428 ms median frame time: host copies grew from about 0.55 GB
to about 6 GB per frame in the open world, for about 2.9 GB of host
memory saved. Loose windows are 4 MiB again (main's size) unless
VICTORY_LOOSE_WINDOW_KIB asks for a power of two from 64 to 4096 KiB.
#402's window reuse stays as it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
No range: sizes far from the default are the user's own experiment. Only
a value that is not a power of two, or one whose bytes overflow, falls
back to 4 MiB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
host_state_lost marked host_heaps [usize::MAX; 2], but a list that binds
no heaps and reads title memory wants [MEMORY_HEAP, SAMPLERS_OURS] —
the same pair. After a cut or an external record, bind_heaps found them
equal and bound nothing; the next directly-indexing root signature ran
with no heaps, the device removal #1778 was written to prevent.

None now marks the lost state: it equals no pair wanted can make, so
the next bind_heaps binds again.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
`VICTORY_KEYS=<seconds>:<key>` held each key for 200 ms: enough for a menu
press, not for walking. An entry now takes an optional third field, the hold
in milliseconds:

    VICTORY_KEYS=10:Enter:300,20:Enter:300,200:W:6000

Without it the hold stays 200 ms, so existing schedules behave as before.
Both the keyboard device and the stand-in pad see the keys (`Enter` is the
pad's A, `W` the left stick up), with or without window focus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#450 made Host::rtv take Option<&ID3D12Resource>; #2962's diagnostics-only
test still passed &texture, which only the --all-features build compiles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:06:55 +00:00
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 23:40 UTC · original

Windows 11, 63bcca4 + this PR, the CI job's three commands:

  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • cargo test --workspace --locked: 908 passed / 0 failed across 30 suites (unpatched 63bcca4 here: 872; victory-gpu alone goes 232 → 261 tests).
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: FAILS:
error[E0308]: mismatched types
    --> crates\victory-gpu\src\host.rs:4093:57
4093 |                         .ClearRenderTargetView(host.rtv(&texture, Some(&desc)), &color, None);
     |                                                     --- ^^^^^^^^ expected `Option<&ID3D12Resource>`, found `&_`
note: method defined here
    --> crates\victory-gpu\src\host.rs:1621:19
1621 |     pub(crate) fn rtv(

A test call site still passes &texture where rtv now takes Option<&ID3D12Resource> — one of the batches rolled up here changed that signature without its caller. So the diagnostics build does not compile; the default build and the whole test suite do.

Synthetic only. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 23:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/3409#issuecomment-7205755395) Windows 11, `63bcca4` + this PR, the CI job's three commands: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo test --workspace --locked`: **908 passed / 0 failed** across 30 suites (unpatched `63bcca4` here: 872; `victory-gpu` alone goes 232 → 261 tests). - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: **FAILS**: ``` error[E0308]: mismatched types --> crates\victory-gpu\src\host.rs:4093:57 4093 | .ClearRenderTargetView(host.rtv(&texture, Some(&desc)), &color, None); | --- ^^^^^^^^ expected `Option<&ID3D12Resource>`, found `&_` note: method defined here --> crates\victory-gpu\src\host.rs:1621:19 1621 | pub(crate) fn rtv( ``` A test call site still passes `&texture` where `rtv` now takes `Option<&ID3D12Resource>` — one of the batches rolled up here changed that signature without its caller. So the diagnostics build does not compile; the default build and the whole test suite do. Synthetic only. AI-assisted.
Author
Owner

@⁠pes7 on GitHub · 2026-11-27 00:52 UTC · original

@⁠Jackster thanks, that's exactly it. #2962's diagnostics-only test still called rtv(&texture, ..) after #450 changed it to take Option<&ID3D12Resource>, and my batch checks did not build --all-features. Fixed in 1e25b23 on top of the set, and CI is green on that head. On it, locally: clippy -D warnings clean both ways, cargo test --workspace 908 / 0, and victory-gpu --all-features 278 / 0. The --all-features check is now part of every batch.

**@⁠pes7** on GitHub · 2026-11-27 00:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/3409#issuecomment-7206824950) @⁠Jackster thanks, that's exactly it. #2962's diagnostics-only test still called `rtv(&texture, ..)` after #450 changed it to take `Option<&ID3D12Resource>`, and my batch checks did not build `--all-features`. Fixed in `1e25b23` on top of the set, and CI is green on that head. On it, locally: clippy `-D warnings` clean both ways, `cargo test --workspace` 908 / 0, and `victory-gpu --all-features` 278 / 0. The `--all-features` check is now part of every batch.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3409/head:github-bot/gh-3409'
git switch 'github-bot/gh-3409'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3409'
git switch 'github-bot/gh-3409'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3409'
git switch 'github-bot/gh-3409'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3409'
git switch 'main'
git merge --squash 'github-bot/gh-3409'
git switch 'main'
git merge --ff-only 'github-bot/gh-3409'
git switch 'main'
git merge 'github-bot/gh-3409'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3409
No description provided.