Experiment/pr2121 #2815

Open
github-bot wants to merge 35 commits from github-bot/gh-2815 into main AGit
Owner

@⁠theDVNVS on GitHub · 2026-11-25 21:17 UTC · original
theDVNVS:experiment/pr2121-nemotron → main · +53163 −2092 · 121 files · 35 commits · open

No description provided.

**@⁠theDVNVS** on GitHub · 2026-11-25 21:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2815) `theDVNVS:experiment/pr2121-nemotron` → `main` · +53163 −2092 · 121 files · 35 commits · open *No description provided.*
World rendering, lighting, frame-rate and memory work for Grand Theft Auto VI
(Xbox Series X profile) on one Windows PC with an NVIDIA RTX 4070. The README
describes the state, the changes and the credits. Based on VIctory by Marvisak
and contributors (GPL-3.0-or-later); XCL by ivall and contributors was used as
a reference. No game files are included.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
- 59 of the 64 trace programs and the irradiance-cache shading program
  translate; 51 programs leave the approximate wave64 forms.
- The workspace passes the lint with warnings as errors in both feature sets;
  a few style lints are let through in Cargo.toml for this fork.
- README status updated (relay and in-place memory results);
  docs/fork-ray-tracing.md describes what the title does and what is built.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-authored-by: ZazaJr24 <[email protected]>
- Shader tests: a software adapter given as the default device is not taken
  for a hardware device, so the tests that need a real card skip there.
- Diagnostics: the stencil plane of dumped depth-stencil targets and the
  title's descriptions of its stencil views.
- README: the newest commits lose the GPU device shortly after start on the
  test machine; the cause is not found yet.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The update moved the particle light-atlas compute programs to a form that
puts group barriers inside branches and loops; a dispatch of them stood on
the card until the device was reset. That form is now off unless
VICTORY_WAVE_WIDE=1, and the shader cache key includes the wave switches.
Checked with a plain run of this tree on the test machine.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Hosted runners list a display stub first, so the default device there is the
software adapter; the tests that need a real card now skip it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
- Clean-up passes over each translated module (VICTORY_SHADER_OPT bits: dead
  code, folding, reuse, branch facts, loads within a block, wave64 first-lane
  exchange), part of the shader cache key. About 43 % fewer host instructions
  over the pack; about 20 ms less GPU time per frame on the test machine.
- translate: a census of the emitted code.
- Checked with plain game runs of this tree on the test machine.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The console compiler parks a wave64 lane mask in two lanes of a spare VGPR
and may restore the halves with other instructions between the two
v_readlane_b32. The pair restore now looks ahead in the block (nothing between
may touch the second register, write the first, or save into the lanes), so
the mask comes back as a mask. This lets indirect_light_probes
CS_IrradianceCache_Shade / ShadeSecondary translate: they were dropped every
frame, leaving the irradiance cache unlit and everything in shadow black.

An M0-relative read (v_movrels_b32) names every VGPR from its base up, which
marked the parking VGPR as an ordinary one and turned unspilling off for the
whole program. Relative reads no longer count there (relative writes still
do). billboard_nobump CS_RaytracingResolve_a56bfb9c translates with it.

translate: VICTORY_TRANSLATE_ONLY=<hash prefixes> limits a run to those
containers; VICTORY_HOST_MAX_WAVE=32 translates as on a 32-lane host, so
--pipelines matches what the runtime creates on NVIDIA.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Comments, documents and descriptions now say "the title". No code changes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Its programs translate and run, but on the test machine the lighting gain
could not be shown, it costs about 40 ms of GPU time per frame, and the
picture is being re-checked one change at a time from a known-good tree.
It may come back once that is settled.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The previous commit took it out; that was not wanted. The tree is again as
it was before that commit.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Double-precision shader instructions (v_cvt_f32_f64, v_add_f64 sums, the
makeDouble overload name and flag), a first half of a paired interpolation
read as data, sooner eviction of idle textures and caches under memory
pressure, a retried DirectStorage destination write, the texture catch-up
budget, VICTORY_FIRSTLANE_OWN, and zlib-rs in place of miniz_oxide.

Left out: the fork's personal launcher scripts and its readme.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Every host view heap ends at a null slot that view indices past the heap
read (a host that takes large heaps gets 2^21 views; one that caps them
keeps the capped heap), the cache key includes that limit, and
v_permlane16/x16 are lowered.

Both forks lower v_cvt_f32_f64. The IEEE form with its test is the one in
use; this branch's flush-to-zero form is kept beside it, unused, and its
test is ignored until the console's float mode for the instruction is
checked.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A texture a shader picks by index was uploaded once, when the title wrote
its view, and again only if the view was rewritten or the runtime told of
a remap. The title often fills the texture's memory only afterwards (its
streaming reads land later), so the host copy kept what the memory held at
the first look for the rest of the run: zeros. Which textures lost that
race changed from launch to launch; the main character's face came out
black and her hair pale in about three launches of four.

Now a texture uploaded whole is looked at again after 4, 12, 40, 120 and
400 frames (a fingerprint of 48 KiB of its memory); a changed one is
uploaded again and the looks start over. One test launch re-uploaded more
than 6,000 textures this way. VICTORY_HEAP_RECHECK=0 turns it off.

Known gap: the fingerprint samples the start, middle and end of the
memory, so a texture whose other parts arrive later is still missed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
- The depth bounds test (#82 by Kaivyyy, as is): a pipeline that enables
  it is made from a DEPTH_STENCIL1 stream under its own library name, and
  the title's OMSetDepthBounds reaches the host list. Before, such draws
  passed at every depth. On the test machine (RTX 4070) the first room is
  lit by its lamp for the first time: walls, table, bunks.
- Defaults: what shaders wrote is copied back by a thread of its own
  (stage 2), wide copy-back, card copies from 1 MiB up to 1,024 MB, and
  256 lists in the air. About 230 ms a frame where it was about 400.
  Off: VICTORY_RELAY=0, VICTORY_WIDE_BACK=0, VICTORY_CARD_BUFFERS_MIN_MB=16
  VICTORY_CARD_BUFFERS_MB=512, VICTORY_LATE_WAIT_LISTS=128.
- Textures picked by index are uploaded while loading and before a draw of
  the title's decoration bake, which samples them by index and runs once
  (VICTORY_EARLY_TEXTURES_MS, VICTORY_BAKE_TEXTURES_MS; 0 turns each off).
- Placed textures are keyed without the filler words of their description:
  two views that differed only there each had a host copy
  (VICTORY_PLACED_FILLER=1 keeps the old key).
- VICTORY_TEXTURE_ROOM_PERCENT (90, unchanged) sets how full the card may
  get before textures picked by index wait.

Known: the first room's walls are still missing in some launches, and
shaded areas are too dark (the bounce light has no ray-tracing structure
to trace yet).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Two fixes for textures that shaders pick by index, both proven with a
slot listing before they were made:

- The title keeps only a texture's small levels and places the next
  texture in the address range of the absent large ones. Described at full
  size every neighbour overlapped, and each view written took the textures
  beside it out of the upload queue and made their host slots null (tens
  of thousands of slots a run). A newer view now makes an older one stale
  only when it starts within that one's first 4 KiB.
  VICTORY_STALE_TEXTURES=overlap: the old rule; =0: never. Unit tests on
  the span table alone. The first room is lit with its walls and the
  characters' textures in the first launch with it.
- With the card at its limit, a texture that already has its host copy is
  uploaded again when the title changed its memory (it took no new card
  memory, and was refused all the same).
  VICTORY_REUPLOAD_WHEN_FULL=0: as before.

Logging only, off unless asked for: both video memory groups and budget
moves; card accounting (VICTORY_CARD_ACCOUNTING=1); the slots a listed
draw's shaders read, with their state (VICTORY_LIST_SLOTS=); a trace for
the missing first-room walls (VICTORY_WALLS_TRACE=1 or 2). A card test of
what a bare command costs (ignored by default):
cargo test -p victory-gpu --release -- --ignored bare_command_cost --nocapture

Known: about 3 to 5 frames a second; more than half of the texture memory
on the card is held for levels the title has not loaded yet (next).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
- Coalesced CARD_COMPARE compute shader (64 threads/piece, LDS hash) + 128 MiB inline L0 readback ring (0 ms relay fetch waits)
- Scoped indirect clamp barriers (VICTORY_CLAMP_SCOPED), per-list UAV barrier deduplication (VICTORY_BARRIER_MERGE), 4096-record indirect windows (VICTORY_INDIRECT_WINDOW), and light PSO restore
- Parallel texture refresh overlap (memcopy.rs), O(N^2) fixes in host.rs, incremental 1/16th heap_buffers refresh, relaxed VRAM eviction, and ahead-of-time shader precompile
- Ported GPL-3.0-or-later lighting stand-ins (ambient/shadowmask/exposure), merged shaders, Series S overlay compositing, KBM input, ReBAR/readback experiments, and loader upscaler/render-scale hooks from ZigZagBoi1/ScarlettPort
- Updated README with Ryzen 7 9800X3D + RTX 4070 SUPER 10-14+ fps benchmarks and credits
- Mesh shader primitive index fix: mask 9-bit vertex indices (0x1FF) to drop edge-flag bits 9/19/29
- Compute dispatches > 65,535 groups split in 2 parts (USER_GROUP_BASE + indirect::bound_split)
- Wave64 partial-lane half reduction fix (half_sum_here) + source-based shader cache key
- Partial-mip streamed texture support (Layout::bytes_from, placed_bytes_from, upload_from, texture_sweep, separate recheck queue, unseen_write)
- Physical-page multi-view guard (VICTORY_VIEW_GUARD, fixes missing room walls & face shading) + DirectStorage/fread bounce-buffer guard-race fix + late page-array wait + xmem shown tracking
- Pipeline loading wait window (Sharing::Window, separate compute loading budget) & early-pipeline persistence

Ported from ZSlayerHQ/victory-world-runtime (GPL-3.0-or-later; credits: myokex, JoshuaO22, Spexivus, joroyt, tightfall).
- Replace JOURNAL Mutex with RwLock + AtomicU64 asking counter; run GetWriteWatch (thread-local buffer) and guard() outside JOURNAL so 16-thread wide_refresh and texture_overlap run in true parallel
- Cache VIEW_GUARDED state on Shadow and texture::Staging and skip view-guarded copies in ask_ahead/ask_once (eliminates thousands of failing GetWriteWatch kernel syscalls per frame)
- Batch inplace::alias_blocks_in (1 lock per range) and coalesce contiguous alias VirtualProtect calls in watch::protect, plus zero-alloc clean fast path in watch::guard
- Use NtReadVirtualMemory directly in host::read
- Smooth heap_buffers (1/64 rolling bucket, timed separately from heap_textures) and bound heap_textures/recheck/sweep budgets (24ms/80ms catchup, 2ms recheck, 8192/250ms sweep)
The windows crate passes a dangling non-null pointer for an empty slice;
vkd3d-proton rejects that with E_INVALIDARG, so under Proton there was no
host pipeline library and pipelines were never kept on disk.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Wine's ws2_32 exports neither; a title calling them panicked in the host!
lookup and aborted. The overrides now fail the call (WSAEOPNOTSUPP, or the
name is not found), and the export test skips them where they are missing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
vkd3d-proton does not check DXIL container hashes, so pipelines with a
zero or wrong digest are accepted there; the rest of the test still runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every s_endpgm (and the loop-limit abort) now branches to one shared ret
block, as DXC's output always has. A loop left by both a break and a
return could not be structured by dxil-spirv (vkd3d-proton): it emitted
invalid SPIR-V ("exits the loop ... but not via a structured exit"),
on which RADV segfaulted in vkCreateGraphicsPipelines (exit code 3).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Grand Theft Auto VI places its descriptor heaps in its own memory and
copies whole slots there itself; no create or copy call reports those
writes, so the host slot kept what it was mirrored from before. Slots a
shader reads directly by index (not through a table) are only made from
what was mirrored: in the world a mesh shader read a slot as a constant
buffer while the host slot still held a texture view, whose upper half
it took for a buffer at address 0 (a GPU page fault and a lost device;
likely the "world's low-address page faults" noted at null_view).

Before each submission, the 64 KiB blocks of every shader-visible heap
written since the last one (watch::writes) are mirrored again; mirror()
skips slots whose record did not change.

Found with umr wave dumps under Proton (RX 9070 XT): the faulting waves
held s[8:11] = {0, 0x00400000, 0x00248000, 0}, the second half of an image
descriptor, loaded from heap slot ~1,061,522. Before, the world lost the
device after 5-90 s; with this, 90 s, then a different fault (next commit).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
NVIDIA takes shader-visible view heaps of at most 1,000,000 descriptors;
the title lays out 1,245,184 slots, and translated shaders index up to
HEAP_VIEWS (2^21). The capped heap left title slots past the cap out
("title slot past the host heap"): views there read null.

A host that refuses a view heap of every index shaders take and the
dynamic slots (descriptor::host::view_pages, asked once; set
VICTORY_VIEW_PAGES=1 to page on any host) keeps the title's order in a
virtual heap of 256-slot pages:

- The host heap is what the host accepts. Host page 0 stays null (where
  pages with no place read), page 1 takes writes once there is no room
  left, and the dynamic slots' pages are placed together after them.
  Any other page is placed in turn when a slot of it is first written,
  and entered in the page table: a dword per page past the view-stride
  table, which shaders already have bound. A null made in a page with
  no place takes none.
- Translated shaders take each view heap index through the table when
  view pages are set (Shader::heap_handle: one table load, a shift and
  an or per handle; samplers are not paged). The host sets it where it
  pages, and the shader cache key carries it, so a host that does not
  page translates as before.
- Draws bind the page table of whichever view heap they bind: the
  title's, else our own.
- Physical descriptor writes and GPU reads use the mapped physical slot
  (HostHeap::cpu/gpu_handle translate through pages).

Pages are not given back yet. When they run out, further pages read null
with a warning; the pages in use are logged at each power of two, so a
run shows whether a title's live slots fit.

Tests:
- descriptor::host::tests::pages_are_placed_once_on_first_write: page
  placement, its table entries, reads placing none, running out.
- descriptor::host::tests::written_slots_are_counted_per_page: slots
  written are counted once each, in the pages placed on a write and in
  the pages with no room left; reads count none.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:14:56 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:15 UTC · original

Automated triage for the maintainers.

This PR does not merge cleanly into main: it conflicts in about 60 files across every crate (among them crates/victory-gpu/src/list.rs, crates/victory-hle/src/modules/xmem.rs, crates/victory-loader/Cargo.toml and crates/victory-shader/src/emit/lower.rs). Its content will be reviewed once it is rebased onto current main. A branch that carries only the change it means to make is much easier to review.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2815#issuecomment-7177317613) <!-- victory-triage v1 head=66c099263bce554f4da1cfcb69906406fc334a94 verdict=needs-rebase at=2026-11-25T23:13:52Z --> Automated triage for the maintainers. This PR does not merge cleanly into `main`: it conflicts in about 60 files across every crate (among them `crates/victory-gpu/src/list.rs`, `crates/victory-hle/src/modules/xmem.rs`, `crates/victory-loader/Cargo.toml` and `crates/victory-shader/src/emit/lower.rs`). Its content will be reviewed once it is rebased onto current `main`. A branch that carries only the change it means to make is much easier to review. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • README.md
  • apps/victory/src/main.rs
  • apps/victory/src/run.rs
  • apps/victory/src/translate.rs
  • crates/victory-formats/src/texture.rs
  • crates/victory-game/src/sgd5.rs
  • crates/victory-gpu/src/capture.rs
  • crates/victory-gpu/src/copystat.rs
  • crates/victory-gpu/src/descriptor.rs
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/device.rs
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/fence.rs
  • crates/victory-gpu/src/frame.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/indirect.rs
  • crates/victory-gpu/src/lib.rs
  • crates/victory-gpu/src/list.rs
  • crates/victory-gpu/src/memory.rs
  • crates/victory-gpu/src/pipeline.rs
  • crates/victory-gpu/src/pipeline/host.rs
  • crates/victory-gpu/src/pipeline/library.rs
  • crates/victory-gpu/src/pipeline/make.rs
  • crates/victory-gpu/src/primitive.rs
  • crates/victory-gpu/src/queue.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-gpu/src/shader_cache.rs
  • crates/victory-gpu/src/shadow.rs
  • crates/victory-gpu/src/texture.rs
  • crates/victory-gpu/src/watch.rs
  • crates/victory-hle/src/lib.rs
  • crates/victory-hle/src/modules/audio.rs
  • crates/victory-hle/src/modules/dstorage.rs
  • crates/victory-hle/src/modules/files.rs
  • crates/victory-hle/src/modules/gameinput.rs
  • crates/victory-hle/src/modules/xmem.rs
  • crates/victory-loader/Cargo.toml
  • crates/victory-shader/src/emit/bitcode.rs
  • crates/victory-shader/src/emit/container.rs
  • crates/victory-shader/src/emit/diff_tests.rs
  • crates/victory-shader/src/emit/host.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/mod.rs
  • crates/victory-shader/src/emit/rect.rs
  • crates/victory-shader/src/emit/shader.rs
  • crates/victory-shader/src/emit/valu_tests.rs
  • crates/victory-shader/src/emit/waterfall_tests.rs
  • crates/victory-shader/src/emit/wave.rs
  • crates/victory-shader/src/io.rs
  • crates/victory-shader/src/ir.rs
  • crates/victory-shader/src/native.rs
  • crates/victory-shader/src/resource.rs
  • crates/victory-shader/src/structure.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2815'
git switch 'github-bot/gh-2815'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2815'
git switch 'github-bot/gh-2815'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2815'
git switch 'main'
git merge --squash 'github-bot/gh-2815'
git switch 'main'
git merge --ff-only 'github-bot/gh-2815'
git switch 'main'
git merge 'github-bot/gh-2815'
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!2815
No description provided.