Skip to content

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

Open
pes7 wants to merge 81 commits into
Marvisak:mainfrom
pes7:merge/tested
Open

pes7 wants to merge 81 commits into
Marvisak:mainfrom
pes7:merge/tested

Conversation

@pes7

@pes7 pes7 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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:

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 hle: VICTORY_KEYS entries can hold a key, so a scripted run can walk #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):

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

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

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

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

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

kxiserino and others added 30 commits November 24, 2026 02:56
…oose windows that hold a range

`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 <noreply@anthropic.com>
…oose windows that hold a range

`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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…lices

# 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 <noreply@anthropic.com>
… ones

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
… the big ones"

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 <noreply@anthropic.com>
Part of Marvisak#2307 (the allocation half; Marvisak#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` (Marvisak#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` (Marvisak#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 Marvisak#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).
…lone

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 <noreply@google.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Until the slot is next made, not until its list is reset (review by
fyernald).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
…k#2699)

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.
…/array/3D NULL RTV/DSVs

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 Marvisak#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 <36782933+fxceless@users.noreply.github.com>
… records

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.
pes7 added 25 commits November 27, 2026 01:58
…peless textures and MSAA/array/3D NULL RTV/DSVs
…h (fixes a world-load deadlock under Wine)
…ME, and HOME in default directory resolution
…alues instead of overriding default log level
@pes7
pes7 marked this pull request as ready for review November 26, 2026 22:53
…tion<&ID3D12Resource>

Marvisak#450 made Host::rtv take Option<&ID3D12Resource>; Marvisak#2962's diagnostics-only
test still passed &texture, which only the --all-features build compiles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jackster

Copy link
Copy Markdown

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.

@pes7

pes7 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

@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.

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.