Skip to content

CI check: PR #1296 rebased onto bundle #1542 - #2

Open
antikohza wants to merge 169 commits into
mainfrom
feat/texture-mip-drop-on-1542
Open

antikohza wants to merge 169 commits into
mainfrom
feat/texture-mip-drop-on-1542

Conversation

@antikohza

Copy link
Copy Markdown
Owner

Fork CI verification of feat/texture-mip-drop-on-1542 (PR Marvisak#1296 stacked cleanly onto Marvisak#1542 / Marvisak#431 / Marvisak#967 / Marvisak#1418 / Marvisak#1426 / Marvisak#1439).

a55uka and others added 30 commits November 24, 2026 00:08
The console's GPU allows uses of some formats that other host GPUs do
not. On an RTX 4070 two 2560x1440 textures failed to create with
E_INVALIDARG (vkd3d-proton: "Requested resource flags Marvisak#5, but no format
in cast list supports it"): format 86 (BGRA8) with unordered access, and
format 115 (B4G4R4A4) as a render target.

When creation fails, try again without unordered access, then without
render-target use, as is already done for depth targets that ask for
unordered access. The views the host cannot make are skipped. A clear
value is only passed while the texture is still a render target or
depth target, since the host refuses it otherwise.

Not checked: whether the title draws to or writes these textures in a
way that now goes missing.

Tested: Linux (Wine 11.21, vkd3d-proton 3.1), i7-12700K, RTX 4070. The
two textures are created and the title runs on.
Co-Authored-By: GPT 6.2 Sol <noreply@openai.com>
Ask Windows for the live allocation type before guarding physical-page views. Keep the existing VirtualQuery fallback for unknown region flags and query failures. This avoids walking a long run of read-only pages solely to learn its memory type.

Validate ordinary mapped files, executable images, private stack memory and free addresses alongside the existing pagefile guard and write-watch tests.
Textures in memory with no write watch (the physical-page views of the
texture pool) were checked with committed() and then read directly,
twice (hash, detile). A title unmapping those pages in between, for
example evicting a texture a big descriptor table still lists, faulted
on the read, and the vectored handler takes only writes. The memory is
now read through copy_mapped (ReadProcessMemory, zeros for unmapped
pages), as the watched path already does, into a per-thread scratch
buffer reused between textures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
frame::wait marked the tick it waited for as taken (LAST) only after
the sleep, outside the clock's lock, so two threads waiting for one
event kind at once both got the same tick and both returned on it,
against the module's once-per-tick rule (an origin wait then begins two
frames in one interval). next_tick now takes the tick under the clock's
lock when the wait comes within its time-out; a time-out takes none, as
before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace implicit D3D12CreateDevice(None, ...) with explicit DXGI adapter
selection via IDXGIFactory6::EnumAdapterByGpuPreference(HIGH_PERFORMANCE)
(with IDXGIFactory1::EnumAdapters1 fallback), skipping software adapters
by default while preserving diagnostics VICTORY_D3D12_WARP software
validation.

Add optional VICTORY_D3D12_ADAPTER override supporting either a 0-based
hardware adapter index or a case-insensitive description substring match.

Probe and store host D3D12 capabilities on Host in HostCaps (adapter
description, vendor/device IDs, dedicated VRAM, Options 0/1/5/7/9/11,
and highest supported shader model), log a single concise startup summary,
expose capability getters on Host (including supports_wave64,
wave_lane_count_max, supports_atomic_int64_typed, and
resource_binding_tier), and add unit tests covering adapter filter
parsing/matching, capability helpers, and WARP device capability probing.
No graphics object's interface list holds IUnknown, so QueryInterface
for it (and every call that hands out an object by interface id) said
E_NOINTERFACE and returned null. COM code asks for it to compare two
pointers for identity, to keep an object as a plain reference, or to
pass it on to an API that takes any object.

object::is, which all of those go through, now also matches IUnknown.
The DXGI device answers with the D3D12 device, which it already stands
for: one pointer whichever of the object's interfaces is asked.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A descriptor picked without a branch, as the compiler does when it
hoists both loads (invariant memory) and turns the if/else into a
select, reaches the resource instruction through s_cselect_b64 per half
(or s_cselect_b32 / s_cmov per dword). None of its dwords is then a
load, so tracking stopped with "a descriptor neither loaded nor built"
and the whole program, and every draw using it, was dropped.

Such words are now split by the SCC value they all read: what each is
when SCC is set (S0) and when it is clear (S1, or the old destination
for s_cmov), with words not selected the same on both sides, and each
side traced on its own into a new Source::Select. Selections with
different conditions stop, and a choice that mixes two descriptors
still stops as "a descriptor changed after loading". The lowering picks
the heap index of the two loaded descriptors by SCC and creates one
heap handle, as a phi of loaded descriptors already does per edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
A descriptor held in VGPRs is used through a waterfall loop: each pass
reads the first active lane's dwords with v_readfirstlane_b32, compares
them with every lane's own (v_cmp_eq), runs the access with the lanes
that match and repeats for the rest. Tracing stopped at the readfirstlane
results ("a descriptor neither loaded nor built").

The tracer now follows the read lanes' dwords to where each lane gets its
own: global_load_dword* from a table or heap at a per-lane address (an
image descriptor's two x4 loads lined up), or a v_cndmask_b32 choice per
lane between such sources (e.g. two s_load descriptors). Other sources
fail naming them (LDS read, buffer load, phi, input, computed VGPRs).
The loop's compares of those reads with their own dwords are recorded.

Lowering gives the access each lane's heap index (its load address over
the descriptor size, or a per-lane select of indices) with
createHandleFromHeap's nonUniformIndex set, lowers the recorded
readfirstlanes as the lane's own dword and their compares as true, so
the loop runs once with all lanes. Wave32 and wave64 are tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Two copies into title memory asked the host about the destination before
every copy. copy_mapped's own comment tells what that costs: asking
VirtualQuery about the source took about 2 ms per copy in the title's big
pools, because the query walks the page tables to the end of the region
with the same state, whatever the size of the copy.

- A list's copy into title memory checked that the whole destination was
  committed first, with VirtualQuery. The destinations were private pools
  of about 600 MiB.
- The copy-back of what shaders wrote used WriteProcessMemory, which asks
  for the destination's region before it writes: the same walk for every
  64 KiB piece.

Both now rely on the kernel copy the other copies already use
(ReadProcessMemory on our own process). It fails on a destination page
that is not mapped writable as it does on a source page it cannot read,
without faulting. A title destination is asked for its region only after
its copy has failed, which keeps the page retries (they write their zeros
themselves) off unmapped memory. write_mapped does what it did: mapped
pages are written, unmapped and read-only ones are not.

One difference: a title destination that was not all mapped used to be
left alone, and the bytes before its first unmapped page may now arrive
(the kernel copy stops at that page). No title copy of the run below had
such a destination, and none failed.

Measured in the world (first mission's intro; i7-13650HX, RTX 4060
Laptop, diagnostics build), with the old and the new call timed on the
same copies of one run, 41 frames of about 1.15 s each:

  title copies, 80 per frame (0.45 MB): the check alone 59.5 ms per
  frame; the whole copy now 0.56 ms
  copy-back, 110 pieces per frame (4.9 MB): 38.6 ms per frame; now
  0.55 ms

That is 98 ms of a frame (8.6 %) down to about 1 ms. In stacks of the
submitting thread sampled at 10 Hz, VirtualQuery under these two calls
was 47 of 462 samples before and 0 of 189 after.

Two tests run both copies against reserved memory with a committed block
on each side of a hole (no GPU, no game data).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tion

host_shader goes through the shader cache, which translates on a miss
and then writes the entry. When the write failed (a full disk, a file
where the entry's folder goes, a scanner holding the new file during
the rename), the error came back as the shader's: a translation that
had worked was thrown away, the shader was marked as not translating
for the rest of the run, and every draw using it was dropped.

The converter now records that its translation worked; a cache error
after that is logged as such and the shader is translated without the
cache, as when there is none.
A mesh pipeline never loaded from the host pipeline library: LoadPipeline
refused it with E_INVALIDARG (debug layer 972, "does not match the one used
to create the PSO") even with the very stream it was made from, so every
mesh pipeline was compiled again on every run and its store then refused
(970, "already exists"), the 972/970 pair in Marvisak#264.

Measured with synthetic pipelines on an RTX 3060 Ti, Windows 11 26300, with
and without the debug layer: compute, graphics (DXBC and DXIL) and VS/PS
streams load; a mesh stream loads only with a PRIMITIVE_TOPOLOGY subobject
that is not UNDEFINED. The debug layer wants it to match the mesh shader's
output topology (1323), and the translation makes triangle mesh shaders
only (mesh_prologue), so the stream now names TRIANGLE. Mesh pipelines get
a new library name ("mesh triangles"), so entries stored without a
topology are not looked up again.

a_mesh_pipeline_loads_from_the_library makes a mesh pipeline twice through
mesh_pipeline and requires the second to come from the library; it fails
before this change and passes after (skipped without a PC dxc.exe).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An empty slice still has an address, and vkd3d-proton answers E_INVALIDARG to a non-null blob of length 0, so under Wine no pipeline library was ever created and host pipelines were not kept.
The title's descriptor writes and texture releases reach the host at
once, from its own threads, while the host runs a submission for most of
a second in the world. A descriptor slot rewritten then dropped the
resource it held, and a released title texture dropped its host copy,
while the running submission still read them: device-removed data showed
a page fault inside a freed 1024x1024 BC7 texture, about 65 s into the
world (DXGI_ERROR_DEVICE_HUNG, RX 7600).

Those objects now go to a retired list tagged with the submission count
and are dropped when that submission has been waited for (at once if
none is running).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSD61BBk7E79WkryEQA
The world's peak counted 3,630 host textures, 8.9 GB, against a 7 GB
video memory budget on an 8 GB card: the driver moves the excess to
system memory, where it counts against the commit limit. A texture the
title makes and the GPU never uses (no view, target, copy or barrier)
now costs nothing; the creation state and clear value are kept for the
copy made on first use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSCvCZuokASx7f59sAG
The device-removed report printed `[heap N: …]` after every user-data
value, constants included, so a constant 0 next to slot 0's view read as
a draw using slot 0. Each value is now marked `table` or `const`; a table
is followed by `[heap N: …]` as before, a constant by
`[as heap index N: …]`, kept because dynamic resources may index the heap
with one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The resource tally in `victory translate` matched every `Source` variant
by hand, so the new `Select`, `Fetched` and `Lanes` kinds left it
non-exhaustive and `cargo check -p victory` failed. A fetched descriptor
is counted with the loaded ones; selections and per-lane choices are
never leaves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
A root SRV is a bare GPU address: nothing bounds what a shader reads
through it. Vertex fetch reads its stream through a root SRV with no
record limit, and a mesh shader read past the end of the buffer's host
copy into memory the host had already freed (the "inside freed texture"
device removal after the fix for Marvisak#59: the fault lay just past the copy's
end, in the gap where released textures had been).

Each root SRV is now a one-descriptor table holding a raw view of the
host copy from the root address to the copy's end, made once per address
per list in the heap's dynamic slots; reads past the end return zero, as
for any bounded view. A root SRV the title did not set, or one with no
host copy, gets a null raw view (an unset table is undefined). Addresses
not on 16 bytes, which a raw view cannot start at, read zeros and are
logged once. VICTORY_ROOT_SRV_DIRECT=1 restores root descriptors.
…a waterfall loop

A descriptor read with v_readfirstlane_b32 was traced to each lane's
own dwords wherever it was, so a first-lane read outside a loop, or one
without the v_cmp_eq that hands every lane its turn, sampled for lanes
the program skipped (reported on the PR with the back edge of the
fetched waterfall test replaced by s_nop).

Now:
- a compare counts only when it and the v_readfirstlane it reads are in
  one loop (each block reaches the other);
- every descriptor read from the first lane needs each of its dwords
  compared that way, or translation stops with "a descriptor read from
  the first lane outside a waterfall loop".

Two tests cover the missing back edge and the missing compare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
MamaLeVrai and others added 30 commits November 24, 2026 18:59
…ied together

Merges Marvisak#72 Marvisak#347 Marvisak#1000 Marvisak#358 Marvisak#352 Marvisak#626 Marvisak#1152 Marvisak#1129 Marvisak#1203 Marvisak#24 Marvisak#642 Marvisak#427 Marvisak#485
Marvisak#550 Marvisak#174 Marvisak#1279 onto main (ffe310e), each head unchanged, no conflicts.

One change of mine: three of the PRs each add a `mod tests` at the end of
pipeline/host.rs, so the merge defines `tests` three times (E0428). The
second and third are named `library_tests` and `blend_tests`; nothing else
changes.

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(367 passed, 6 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… mip-drop

- Select the non-software adapter with the most DedicatedVideoMemory during
  D3D12CreateDevice to prevent hybrid laptops (Intel/NVIDIA) from defaulting
  to the 128 MiB integrated GPU.
- Match device.GetAdapterLuid() against DXGI adapter LUIDs to record the exact
  memory of the active device.
- Read device_memory() live in texture_mip_drop to avoid stale caching during
  early device initialization.
- Clamp most_detailed in adjust_mips to host_mips - 1 to guard out-of-range
  guest SRV descriptors.

Reported-and-tested-by: Logan-Gaillard <Logan-Gaillard@users.noreply.github.com>
Reviewed-by: geiyiliyabumo <geiyiliyabumo@users.noreply.github.com>
…arvisak#1439, verified together

Merges Marvisak#346 Marvisak#431 Marvisak#493 Marvisak#967 Marvisak#1082 Marvisak#1143 Marvisak#1165 Marvisak#1173 Marvisak#1265 Marvisak#1298 on top of the
three GPU bundles (Marvisak#1418, Marvisak#1426, Marvisak#1439, on main ffe310e), each head
unchanged. Marvisak#346, Marvisak#967, Marvisak#1082 and Marvisak#1143 conflict in host.rs (and Marvisak#346 in
indirect.rs) with the PRs of those bundles; those hunks were merged by
keeping both sides, and each PR was kept only if cargo clippy -p
victory-gpu --all-targets --all-features -- -D warnings still passed.

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(463 passed, 8 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…d adapter probe

- Adjust ResourceMinLODClamp across all 7 SRV dimensions and avoid duplicate GetDesc() in descriptor/host.rs
- Return (texture, drop) from host_texture() so HostTexture.mip_drop is computed once, and guard BCn 4x4 block alignment for custom MIN_SIZE
- Replace mip-drop mismatch skip in copy_resource() with safe CopyLocation::subresource overlapping-mip copies
- Track per-subresource HostWritten via zero-alloc u128 bitmask (with HashSet fallback) for partial copies and resolves
- Probe D3D_FEATURE_LEVEL_12_0 in best_adapter() with fallback to default adapter in Host::create()
- Add unit tests for out-of-range SRV clamping, ResourceMinLODClamp, BC7 alignment, VRAM threshold, and HostWritten tracking
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.