Skip to content

GPU: preserve refreshed gaps inside page snapshots - #4

Open
likecrank-dotcom wants to merge 4 commits into
wbkepler:gpu/snapshot-pagesfrom
likecrank-dotcom:codex/fix-page-snapshot-gaps
Open

likecrank-dotcom wants to merge 4 commits into
wbkepler:gpu/snapshot-pagesfrom
likecrank-dotcom:codex/fix-page-snapshot-gaps

Conversation

@likecrank-dotcom

Copy link
Copy Markdown

When a submission declares two disjoint ranges inside one page, its snapshot spans the intervening gap. Refreshing and declaring that gap later does not extend Snap.lo..hi, so its old bytes are kept. Copy-back can mistake the refresh for a GPU write and overwrite a newer CPU write.

Compute the portions not previously declared before merging spans. After growing each page extent, refresh only those portions inside its old extent. Previously declared bytes keep their original snapshot.

Synthetic regression: declare offsets 0..16 and 128..144; refresh offset64 to1 and declare64..80; CPU writes2 afterwards, and a separate actual GPU change is simulated in the first range. At PR497 head5ff3a35, copy-back replaces2 with1. With the fix,2 and the actual GPU change both survive.

Windows11,RTX5060Ti8GB,Rust1.98.1: regression FAIL before (1 vs2); complete victory-gpu diagnostics library suite49 passed,0 failed,1 ignored after,serial. D3D12 debug layer unavailable. These are synthetic shared-buffer/copy-back checks, not in-game validation.

Based directly on gpu/snapshot-pages for incorporation into Marvisak#497. No game data,binaries,captures or raw dumps. OpenAI Codex assisted with regression,implementation and validation on the owner's PC.

wbkepler and others added 4 commits November 24, 2026 04:43
A copy of view memory (physical-page views, which cannot be
write-watched) guards each 64 KiB block it took read-only. A block that
is not mapped (a placeholder between views of a GPU heap) cannot be made
read-only, so it never became clean: every asking reported it written
again, and the copy read it through the per-page fallback, whose
failing kernel reads cost hundreds of ms per world frame.

Note such blocks absent (only after VirtualProtect fails and the block is
not committed). An absent block is not reported again until
title_memory_remapped, which the runtime calls after mapping or
unmapping views, clears it. The copy keeps the zeros it took.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before a submission runs, the bytes of each range its shaders write are
kept to tell afterwards what the GPU changed. They were one buffer per
copy, grown to the bounding range of every range the submission
declared: each growth took a buffer from a pool of eight (a fresh one,
page faults and all, when none was free and big enough) and copied the
whole old snapshot into it.

Keep them per title page instead, in 64 KiB buffers from a pool of up to
4,096, each page's part grown as ranges in it are declared (newly covered
bytes taken from the copy as it is then, as before). A range inside one
already taken returns at once. Copy-back compares page by page as it did
by 64 KiB piece, with its scratch page from the same pool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wbkepler added a commit that referenced this pull request Nov 24, 2026
…w oleaut32

- crash.rs: enforce page-bound checks before reading faulting bytes in
  emulate_amd_only, clwb_len, and sse4a (fixing clwb emulation in the last
  14 bytes of a page); guard thrown() against C++ rethrows (null ThrowInfo),
  null object pointers, and invalid/out-of-range catchable-type tables; make
  report_crashes() idempotent via Once, serialize crashes.log writes with a
  Mutex, and reserve overflow stack via SetThreadStackGuarantee on handler
  install, title main thread, and thread attach.
- prepare.rs, windows.rs, tls.rs: strip IMAGE_DLLCHARACTERISTICS_GUARD_CF
  alongside FORCE_INTEGRITY; resolve title DLL direct and forwarded exports
  through victory-pe ExportInfo and ImportResolver (with recursion depth
  guard) instead of host GetProcAddress/LdrpResolveForwarder; wrap _tls_index
  writes in VirtualProtect and call FlushInstructionCache after writing TLS
  thunks.
- host.rs: allow oleaut32.dll in default HostPolicy so standard OLE
  Automation/BSTR imports (including ordinals #4 SysAllocStringLen and Marvisak#6
  SysFreeString) resolve cleanly to the host.
- Add unit tests covering page-end emulation against PAGE_NOACCESS, C++
  rethrow/invalid ThrowInfo guards, idempotent report_crashes and stack
  guarantee, GUARD_CF stripping, forwarded/cyclic export resolution,
  read-only _tls_index patching, and oleaut32 ordinal resolution.
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.

2 participants