Integrate PRs #28, #109, #110, repair_shaders skip, BrLock views & 1440p FSR/KBM updates #136

Closed
github-bot wants to merge 27 commits from github-bot/gh-136 into main AGit
Owner

@⁠Lciarallo on GitHub · 2026-12-02 00:08 UTC · original
Lciarallo:main → main · +1387 −86 · 22 files · 27 commits · closed without merging

Integrates and resolves conflicts on top of main (f7f0360) for:

  • PR #28 (VICTORY_QUAD_GUARD): guards pixel quad reads from inactive lanes in PS_Textured_Eight (eliminates colored overflow flashes on glass/bottles).
  • PR #109: fixes shadow::by_address card byte accounting (CARD_RESERVED) to limit live card bytes instead of cumulative lifetime bytes.
  • PR #110 (card_pool.rs): packs small device-local buffers (<=256 KiB) into shared 4 MiB heaps (tested: 3,200 buffers packed into 324 MiB, 0 VRAM eviction sweeps over a 10-minute session).
  • pipeline/known.rs: warn and skip untranslatable shaders during repair_shaders() instead of aborting startup.
  • Fork additions: BrLock views table lock, VICTORY_OUTPUT 1440p FSR path, mapped_from host copies, and PC keyboard/mouse layout (VICTORY_KBM_PC).

Verification (RX 9070 XT 16 GB, i7-14700F, Fedora Linux, patched Mesa 26.3.1 + vkd3d-proton)

  • cargo xwin check --workspace --locked --target x86_64-pc-windows-msvc: 0 errors, 0 warnings
  • cargo test -p victory-shader -p victory-core -p victory-formats --lib --locked: 344 passed, 0 failed
  • Automated A/B runs (Series X, RT=1, 1280x720 -> 2560x1440 FSR4 Performance, 1080p60 recording):
    • With VICTORY_PAGES=1 + PR #93: copy_ms dropped from 12.53 ms -> 3.40 ms (-73%), prep_ms from 18.13 ms -> 8.77 ms (-52%), intro avg 41.8 fps (p90 52.09 fps, max 68.69 fps), 0 crashes, 0 dropped draws.
**@⁠Lciarallo** on GitHub · 2026-12-02 00:08 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/136) `Lciarallo:main` → `main` · +1387 −86 · 22 files · 27 commits · closed without merging Integrates and resolves conflicts on top of `main` (`f7f0360`) for: - **PR #28 (`VICTORY_QUAD_GUARD`)**: guards pixel quad reads from inactive lanes in `PS_Textured_Eight` (eliminates colored overflow flashes on glass/bottles). - **PR #109**: fixes `shadow::by_address` card byte accounting (`CARD_RESERVED`) to limit live card bytes instead of cumulative lifetime bytes. - **PR #110 (`card_pool.rs`)**: packs small device-local buffers (<=256 KiB) into shared 4 MiB heaps (tested: 3,200 buffers packed into 324 MiB, 0 VRAM eviction sweeps over a 10-minute session). - **`pipeline/known.rs`**: warn and skip untranslatable shaders during `repair_shaders()` instead of aborting startup. - **Fork additions**: `BrLock` views table lock, `VICTORY_OUTPUT` 1440p FSR path, `mapped_from` host copies, and PC keyboard/mouse layout (`VICTORY_KBM_PC`). ### Verification (RX 9070 XT 16 GB, i7-14700F, Fedora Linux, patched Mesa 26.3.1 + vkd3d-proton) - `cargo xwin check --workspace --locked --target x86_64-pc-windows-msvc`: **0 errors, 0 warnings** - `cargo test -p victory-shader -p victory-core -p victory-formats --lib --locked`: **344 passed, 0 failed** - Automated A/B runs (Series X, RT=1, 1280x720 -> 2560x1440 FSR4 Performance, 1080p60 recording): - With `VICTORY_PAGES=1` + PR #93: `copy_ms` dropped from **12.53 ms -> 3.40 ms** (-73%), `prep_ms` from **18.13 ms -> 8.77 ms** (-52%), intro avg **41.8 fps** (p90 **52.09 fps**, max **68.69 fps**), 0 crashes, 0 dropped draws.
The sweep already picks texture blocks to empty (block_fates, WaitedOut) and stops placing pieces in them, but it only lets go of idle copies, so a block that still holds textures in use never empties while the world streams (#21: 8 emptying, none returned). With VICTORY_POOL_MOVE=1 (off by default) the sweep, once a second, lets go of the host copies of textures the title fills that lie in such a block, up to VICTORY_POOL_MOVE_MB (128) a second, the way want_level replaces a copy (REPLACED, grown), and makes their slots due so the texture pass makes them anew in another block. After crbns/victory-tapin's drain_moves, reimplemented on this tree's sweep.

RX 9070 XT, 2560x1440, RT on, ~3 min driving each: blocks given back 1 -> 17, refilled for want of room 5 -> 0, 8,371 textures / 1,076 MB moved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DJe9WTewVmLUUPkT6dTccK
Pool pages are made with raw GEM calls that RADV's allocation tracker never
saw, so VK_EXT_memory_budget treated the title's own pages as another
process's memory: the budget shrank by every MB the page mover put on the
card, and the reported use was low by as much. On an RX 9070 XT with 2.9 GB
of title pages on the card the budget read 9,698 MB instead of ~12.6 GB.

Pages now count as CPU-visible VRAM on the card and GTT off it, from their
creation, through each placement, to their release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The lazy::moving() guard is released before the kick that makes the kernel
migrate a pass's pages. Under the guard every title thread that touched any
lazy page for the first time (lazy::materialize) waited out the whole
migration, up to the kick's one-second wait, once per pass.

Passes run every 400 ms (was 1 s) and move up to 32 MiB (was 8 MiB), about
80 MiB/s against the 4 GB the title may hold on the card:
VICTORY_PAGE_PASS_MS and VICTORY_PAGE_MOVE_MB (1000 and 8: the old pace).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Texture pieces take the tightest free range in a block (an exact fit ends
the look) instead of the lowest that fits, so big ranges stay whole for big
textures and blocks can empty (foxhound b90bb90). Pieces resting before
reuse are no longer counted as room by texture_room().

resource::room's two lines are switches, defaults unchanged:
VICTORY_TEXTURE_ROOM_CAP_PERCENT (92) and VICTORY_TEXTURE_ROOM_PERCENT (86).
VICTORY_VRAM_BUDGET_MB replaces the system's budget, above or below it;
above it only with the title's cgroup protected (dmem.low), or the kernel
may move the game's own buffers out.

The texture-blocks line counts textures the card had no room for that were
placed in free space of blocks already made, and those that found none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The terrain tessellation's own shader stores its mesh records as
(n, 0, 0, 0), the console's DISPATCH_MESH_X layout. Both clamps (one
execution and the batched pass) took y and z at most 1, so a record
with a zero there ran no groups: those draws ran empty and the sand
was shaded black. A record with a nonzero count now runs as (n, 1, 1),
as a direct mesh dispatch always has; (0, y, z) stays empty.

From ReVIctory f165475 (also in VKtory)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	README.md
#	apps/victory/src/warm.rs
#	crates/victory-gpu/src/descriptor.rs
#	crates/victory-gpu/src/descriptor/host.rs
#	crates/victory-gpu/src/device.rs
#	crates/victory-gpu/src/host.rs
#	crates/victory-gpu/src/host/panel.rs
#	crates/victory-gpu/src/lib.rs
#	crates/victory-gpu/src/pipeline.rs
#	crates/victory-gpu/src/resource.rs
#	crates/victory-gpu/src/shader_cache.rs
#	crates/victory-hle/src/modules/gameinput.rs
#	crates/victory-hle/src/modules/lifecycle.rs
#	crates/victory-shader/src/emit/bitcode.rs
#	crates/victory-shader/src/emit/intersect.rs
#	crates/victory-shader/src/emit/lower.rs
#	crates/victory-shader/src/emit/mod.rs
#	crates/victory-shader/src/native.rs
#	crates/victory-shader/src/resource.rs
The title lays its interface out one to one on a 3840x2160 canvas: at a
2560x1440 output the HUD and menus are half again too large and overlap
(at 1920x1080 twice). VICTORY_UI_PLANE=3840x2160 gives it the interface
plane it has on Series S, drawn at that size and composed over the scene,
through the settings' defaults (+0x5b37a20), with the back buffer pool
(+0x247ad4a) sized for two buffers of the output and two planes (112 MiB
at 2560x1440, which Series S's 82 MiB does not hold). Off without the
switch; every site is compared byte for byte first.

Refs #24.
Each BC7 entry of the BCPack table file has two width bytes, then 32
words. BCPack.dll takes all 32 as the entry's indices, pixel 0 first. In
entries 1-254 that first word holds the widths again, and parse() took it
for a repeat: it skipped the word and read 31, so every index of those
entries landed one pixel early, and so did every block predicted from
them, directly or through the history. Entry 0, whose first word is not
the widths, was already read with all 32. Checked against BCPack.dll by
trustno1-coder/VIctory-NVIDIA f9de61c5 and ubiquitarianism/leonida
b589e0fe: 2,101,646 of the title's 2,866,176 BC7 blocks differed before,
none after. Every BC7 texture DirectStorage serves goes through this.

parse() now reads 32 words for every entry. On by default;
VICTORY_BC7_DICTIONARY=0 restores the old reading (read once).

Tests (victory-formats, native x86_64-unknown-linux-gnu): 52 passed,
7 ignored, with and without VICTORY_BC7_DICTIONARY=0. New
bc7_dictionary_entries_read_as_bcpack_dll_reads_them parses the shipped
table both ways: entry 0 unchanged (2, 1, 0, ...); in every other entry
pixel 0 holds the widths word, the old indices sit one pixel later, the
last of them in set 1's slot 0; endpoints and control words unchanged.

bc7_dictionary_indices_line_up asserted that a set with 0 index bits holds
nothing. With 32 words, 233 of the 254 entries put their last word in set
1's slot 0, and no entry gives set 1 any bits. That slot never reaches a
block: the decoder skips a set with 0 bits, and add_index drops a
reference index of 0 bits. The test now asserts that instead (slot 0
dropped by add_index, slots 1-15 empty); its anchor check is unchanged
and passes (pixel 0 is the widths, 3 or 4, inside the anchor range).
Not checked here against BCPack.dll: reference_chunks (ignored) does that
with VICTORY_BCPACK_TABLES and VICTORY_BCPACK_CASES.

Ported from BrayanOfficiel/VIctory-linux 8a79f3b5 (where the new reading
is the default and VICTORY_BC7_SKIP_WIDTHS=1 the old one), after
trustno1-coder/VIctory-NVIDIA f9de61c5.

Co-authored-by: BrayanOfficiel <[email protected]>
Co-Authored-By: Claude <[email protected]>
The title's decoration bake copies its result (a character's make-up,
stubble, tattoos, the prints and numbers on its clothes) into a
block-compressed texture and samples it through a view placed at the same
address, often in another block format: a BC3 texture written, a BC7 view
sampled. On the console those are the same bytes. Here the view gets a
texture of its own (resource::texture_at), filled from title memory, which
the host's copy never reaches: zeros, or whatever lay in that memory
before, where the bake's result belongs, for as long as the view lives.
alias_of does not cover it: it pairs views only with textures the host
renders to or writes with shaders, of the same levels.

With VICTORY_PLACED_COPIED=1:
- each copy into a title texture (CopyTextureRegion, CopyResource) is made
  into the textures of the views placed over it that are laid out alike
  (resource::placed_twins: the same dimension, size and layers, elements
  or blocks of the same size, no more levels; a 9-level BC7 view over an
  11-level BC3 texture is one). The level written goes through a buffer
  (texture::twin_copy), since the host copies between two block formats in
  no other way. The first time for a view, a whole copy, or when either
  host copy changed since, every level goes, the view's texture made whole
  first (want_level 0);
- such a view's texture then counts as written by the host
  (texture::host_written_view; not entered by address), so upload_from
  sends nothing from title memory over it, the idle sweep leaves it, and
  want_level does not make it again from title memory;
- the slots that show it are made again once the copy has run, when its
  host copy is a new one (levels_changed_after).
Without the switch nothing changes: placed_twins is empty.

Off by default because it has not run on this tree's own path. On ours
(a fork with unified-memory changes; Radeon 8060S, Proton Experimental,
RADV 26.3.1) the log showed 128 copies going into views placed before the
copy in one session, mostly 1024x1024 BC3 sRGB textures of 11 levels under
9-level views, and the clothing prints, jersey numbers and lettering that
had been missing in every run came back, together with two other new
switches, so not isolated to this one.

Not covered: a view placed after the last copy into the texture under it
still fills from title memory (VIctory-NVIDIA's seed_later; not ported).
An upload of the view asked for by a list recorded before the copy and
submitted after it can still land over it: the race PR #47 closes for the
written texture itself; with #47 in, twin_copy should note its writes the
same way (note_gpu_written).

Tests: resource::tests::a_view_is_a_twin_of_the_texture_under_it_where_they_are_laid_out_alike;
resource::tests::placed_copied_card (ignored; needs the card): a one-level
BC7 sRGB view placed over a two-level BC7 texture before a title list
copies into it; read back, the view holds the copied blocks with the
switch and not without. victory-gpu --lib (diagnostics, Proton
Experimental, Radeon 8060S): 309 passed with the switch off and on; the
11 failures and the crash in descriptor::tests::views_die_with_their_resource
are the same on 37bb30f96 unchanged.

A hand port of trustno1-coder/VIctory-NVIDIA e530c003 (the placed views'
half; aventureroestelar-source, from ScarlettPort, on by default there)
and of 523485ba's concern (the twin's own level), by way of our fork's
095c3b1b9. There the copy goes from the title's source straight into the
view's texture; here through a buffer, as alias does.

Co-authored-by: aventureroestelar-source <[email protected]>
Co-authored-by: mikey <[email protected]>
Co-Authored-By: Claude <[email protected]>
With VICTORY_FSR_4K and VICTORY_FIDELITYFX_FRAMEGEN=1 the presenter's swap
chain is AMD's frame generation proxy (amd_fidelityfx_framegeneration_dx12.dll
from the FidelityFX SDK v2.4.0, its built-in 3.x provider; ./setup.sh fsr4
fetches it). The title asks for no frame generation: each host upscale hands
its depth, motion vectors and constants to the next present
(Recording::frame_generation_inputs), which prepares the generator in its own
list. The depth and motion copies are held with that list until it has run,
and a generator is only replaced after the presents that name it have
settled. Without the switch, or when the proxy is refused, the plain swap
chain is made as before.

When the title presents its interface on a plane of its own, the plane is
copied each frame into a texture of ours, the F3 panel is drawn into it, and
the proxy composes it over every real and generated frame (premultiplied,
double buffered). Interpolated with the scene, the HUD shook against the
world and the healthbar covered the panel. With one plane the interface stays
in the scene and is interpolated with it.

The panel's badge shows FG:OFF / FG:IDLE / FG:ON instead of the fixed FG:OFF.

RX 9070 XT, Ryzen 7 9800X3D, Gentoo, Wine 11.22, Series X, FSR 4
performance to 3840x2160 (1920x1080 render): proxy 3.1.7, generator 3.1.6;
frame pacing visibly smooth; with the interface plane (VICTORY_UI_PLANE, #63)
the HUD and panel stay still and the panel sits over the HUD.
With VICTORY_FSR_4K, run.rs skips apply_asked (which would also apply
VICTORY_OUTPUT over FSR's 4K output), so VICTORY_UI_PLANE made no plane.
The plane's sites move into push_ui_plane and the write loop into
write_all, which apply_asked uses as before; apply_ui_plane(base, size,
output) applies the plane alone, and the FSR path calls it with
3840x2160 (pool 144 MiB). apply_asked behaves as before.

Suggested in the pull request's discussion.

Co-authored-by: coil111 <[email protected]>
A DPP quad_perm read with fi:1 fetches a quad neighbour's register lane even
when that lane is outside EXEC; on the console it then holds what it last
held, 0 for a sum it never added to. On the host the neighbour's value is
undefined when it did not take the branch, so quad sums take in noise.

VICTORY_QUAD_GUARD=1 makes a second quad read of the value XORed with a fixed
marker at the same place and gives 0 where the pair does not match. =2 also
guards pixel ds_swizzle quad reads. Off by default; part of the shader key.

Runtime-tested on the 5a60834 base (RX 7900 XTX, RADV); compile-tested here.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The card-side byte count in two_sided was a function-local static that
only grew: a copy that went was never taken off. After 4 GiB had passed
through it over a session, every later copy went to the PC's memory
however much room the card had.

The count is now a module-level CARD_RESERVED. reserve_card reserves a
copy's bytes and undoes the reservation when the limit is passed or the
buffer isn't made; Shadow::drop gives the bytes back.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Every buffer Host::uav_buffer makes is a committed resource, and the AMD
driver gives each one in local video memory 256 KiB of the card however
small it is. Buffers of 256 KiB or less (indirect batches, indirect
budgets, indirect arguments) are now placed in shared 4 MiB
ALLOW_ONLY_BUFFERS heaps at 64 KiB multiples (card_pool.rs), falling back
to uav_buffer if the pool can't place one.

A slot is reused only once the pool's own reference is the last one
(host::references). VICTORY_CARD_POOL=0 turns it off.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 00:10:24 +00:00
The proxy composes an interface plane only at the swap chain's size, so
`ui_plane` gave up on any other and left the interface to be interpolated
with the scene. With `VICTORY_UI_PLANE=3840x2160` (the size the title lays
its interface out for) and a smaller output, e.g. `VICTORY_FSR_4K` with
`VICTORY_OUTPUT=2560x1440`, the HUD shook against the world in every
generated frame ("the interface plane is interpolated with the scene
plane=[3840, 2160] screen=[2560, 1440]").

Such a plane is now drawn, linearly filtered and with its premultiplied
alpha as it is, over a texture of the screen's size (`compose::Scaler`, a
one-plane sibling of `Composer`), which is registered with the proxy as
before and left in copy-destination state for the panel. A plane of the
screen's size is still copied as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
read_through (f68c5c9) takes pages on the card that our reads cover down at
the next wave, and a strike keeps them down a short while; they go up again
after it while the copies that refresh the host's copies still read them
every frame. With VICTORY_PAGES_CPU_QUIET=<ticks>, a page off the card that
such a read covers also stays off that many ticks (of 200 ms), and the
kernel reads of copy_mapped count too.

RX 7600 XT, Ryzen 7 5800X, Series S, VICTORY_FSR_HOST=1, 1080p, ray tracing
on, the same save, from the log's 5 s stats lines:
  without: 17.8 fps, median 54.6 ms, preparing 19.1 ms, copy 10.9 ms,
           550 MiB read from the card (4.8 min in the world)
  =75:     22.5 fps, median 45.4 ms, preparing 8.8 ms, copy 2.1 ms,
           18 MiB read from the card (1.8 min in the world)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot closed this pull request 2026-12-02 02:01:55 +00:00
Author
Owner

@⁠goldfishdev on GitHub · 2026-12-02 01:58 UTC · original

Thanks! I've pulled the standalone stuff into main:

  • #28 quad guard → cherry-picked as 0bab220
  • #109 shadow byte accounting → cherry-picked as 7df1fdd
  • repair_shaders skip → cherry-picked as 1b517fd

(I'd already merged #110 separately.)

I'd be fine with the other changes as their own PRs for easier review.

**@⁠goldfishdev** on GitHub · 2026-12-02 01:58 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/136#issuecomment-7332325116) Thanks! I've pulled the standalone stuff into main: - #28 quad guard → cherry-picked as `0bab220` - #109 shadow byte accounting → cherry-picked as `7df1fdd` - repair_shaders skip → cherry-picked as `1b517fd` (I'd already merged #110 separately.) I'd be fine with the other changes as their own PRs for easier review.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.