Major swarm update #3372

Open
github-bot wants to merge 134 commits from github-bot/gh-3372 into main AGit
Owner

@⁠vanya890 on GitHub · 2026-11-26 20:44 UTC · original
vanya890:dev → main · +12964 −897 · 56 files · 134 commits · draft

These changes were introduced by my swarm of agents. I’m not sure if this will be useful to anyone, but I’ve directed them to focus on consolidating existing pull requests from the original project. It would be great if your own agents could examine these options and if they prove helpful to you.

**@⁠vanya890** on GitHub · 2026-11-26 20:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/3372) `vanya890:dev` → `main` · +12964 −897 · 56 files · 134 commits · draft These changes were introduced by my swarm of agents. I’m not sure if this will be useful to anyone, but I’ve directed them to focus on consolidating existing pull requests from the original project. It would be great if your own agents could examine these options and if they prove helpful to you.
copy_texture_region and read_back previously forwarded title locations, subresource indices, source boxes, and destination coordinates directly to ID3D12GraphicsCommandList::CopyTextureRegion without validating D3D12's copy contract:

- Out-of-bounds subresource indices (including 3D textures where DepthOrArraySize is depth rather than array slices, and multi-plane depth/stencil formats), wrong CopyLocation::kind values, zero-sized PlacedFootprint extents, source boxes extending past source bounds, destination coordinates extending past destination bounds, or unaligned block-compressed (BC) coordinates/boxes cause ID3D12GraphicsCommandList::Close to fail with E_INVALIDARG even on retail D3D12 (without the Debug Layer) on both hardware and WARP, aborting HostList::close.
- Invalid copies also allocated upload/readback buffers, emitted state transitions, and marked host_writes before failing.

Query D3D12_FEATURE_FORMAT_INFO for each format's exact PlaneCount, compute block-aligned mip extents (preserving valid BC 1x1/2x2 tail mips, cross-format block-compatible copies, 3D z-slices, and 2-plane depth/stencil copies), treat empty or inverted source boxes as legal D3D12 no-ops, and validate T2T, B2T, and T2B (read_back) transfers before allocating staging buffers, emitting barriers, or marking host_writes.
Lower the six scalar and vector shift opcodes using pairs of 32-bit DXIL values. Preserve the six-bit counts and check both result dwords in the synthetic SFI0 and runtime tests.

NEW-66. AI-assisted.

Co-authored-by: new-66 <[email protected]>
queue::present previously swapped each presented texture's HostTexture::state to COPY_SOURCE before calling Host::present and swapped it back afterward, all outside Host::submitted. Host::present also recorded p.copy using that pre-call state snapshot before Host::execute acquired Host::submitted.

Any concurrent Host::execute running between the pre-present swap and present completion observed a phantom COPY_SOURCE state (emitting D3D12 resource barrier mismatches), raced with p.copy's stale before-state transitions, and had its resulting HostTexture::state overwritten back to the pre-present snapshot once PresentX returned.

Pass tracked HostTexture references directly to Host::present_planes, acquire Host::submitted before reading their live states and recording p.copy's transition barriers, and execute p.copy under that same submission lock via Host::execute_locked. Because p.copy restores every presented texture to its original GPU state before releasing Host::submitted, HostTexture::state never needs unsynchronized mutation in queue::present.
OMSetRenderTargets snapshots CPU-only RTV and DSV descriptors at call time, so
a title may legally overwrite the CPU descriptor slots or release transient CPU
RTV/DSV descriptor heaps immediately afterwards.

Previously, Fixed::targets stored only the raw guest CPU descriptor handle
addresses and State::cut called set_targets again when Wait32BitValueX or
Wait64BitValueX split a command list into a new host segment. That re-read the
guest CPU descriptor heap memory at the time of the cut, silently binding
overwritten render/depth targets or dereferencing freed heap memory and
dropping targets on subsequent segments.

Snapshot the resolved target resource pointers and view descriptions in
Fixed::targets when OMSetRenderTargets runs, and replay those snapshots in
State::cut without touching guest CPU descriptor memory again.
Grand Theft Auto VI's GS_VoxelizeGeneric programs (all 195 of them)
keep the pointer to their root signature memory in user data 0-1 —
their first user SGPRs (s[8:9]) — and load through it like a compute
program's s[0:1]. spill_loads only ran for compute, so the very first
s_load at 0x44 failed with "an SGPR that is no root parameter" and
every one of them was refused.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
In the XMA2 packet header format (`XMA2PACKET::PacketSkipCount`), values
`0x00..=0xfe` give the number of interleaved packets of other streams to
skip before this stream's next packet, while `0xff` (255) is reserved as
the end-of-stream sentinel indicating that no further packets belong to
this stream.

`Cursor::bit` and `next_frame` previously added `0xff` literally as a
255-packet skip, so in any multi-stream XMA2 buffer longer than 256
packets a stream ending with `skip == 0xff` jumped 256 packets forward
into another stream's packets instead of stopping.

Add `Packet::next` to stop on `END_OF_STREAM` (`0xff`) and use it in
both `Cursor::bit` and `next_frame` while preserving all valid skips
`0x00..=0xfe` and decoding every frame within the final packet.
A shader with no user data gets user_data_dwords() == 0, so tests pass
Root::Constants(vec![]) while root_signature_for still declares one
value. An empty slice's pointer is dangling (0x4), and NVIDIA's driver
reads it even for a count of 0: SetComputeRoot32BitConstants faults in
nvwgf2umx with an access violation at 0x4, taking the whole
victory-shader test process down (first at
memory_tests::heap_direct_texture_reads_mark_their_heap_index). WARP
tolerates it.

The test host now sets one zero where the data is empty, matching the
declared parameter, at its three root-constant call sites. The runtime
(victory-gpu pipeline/host.rs) leaves the parameter out when a shader
has no user data, so it is not affected.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Grand Theft Auto VI's suspend routine calls the command queue's
SuspendX(0) at 0xb8, which had no method: every window close or
relaunch logged "method not implemented" for the command queue and the
call answered E_NOTIMPL (noted in #1080). SuspendX and ResumeX now
succeed. On the console they stop and restart the queue's GPU work; here
submissions have run when Execute returns, work held for a wait runs
once the wait is met, and a suspended title is never resumed, so there
is nothing to stop.

They sit at 0xa8/0xb0 in the older queue layout, so newer queues have
them at 0xb8/0xc0, where the title calls them.

New test: queue::tests::queues_suspend_and_resume.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ID3D12CommandQueue::Wait keeps an internal reference to the fence until the
wait is satisfied, so a title may legally release its own fence reference right
after calling Wait (including after pairing it with a queued Signal on another
queue, or when satisfying the fence later via a GPU bottom-of-pipe write to its
GPU virtual address).

Previously, queue::wait pushed Item::FenceWait(fence as usize, value) without
calling fence::keep, and Held::pump popped Item::FenceWait without releasing
any reference. Once the title released the fence (and any queued Signal dropped
its own reference), the very next FenceWait check in Held::pump or the held
work timer dereferenced freed Fence memory (use-after-free).

Parameterize hold::Item, hold::Held, and hold::World over a fence token type
(defaulting to usize) and store an RAII KeptFence guard in queue::Holding that
calls fence::keep on creation and fence::let_go on Drop. Both Item::Signal and
Item::FenceWait now retain and release their fence references automatically on
every completion or drop path without leaks or double-frees, and queue::wait
evaluates the fence value under the held lock before enqueuing.
Import upstream #3232: batch GPU page-table rebuilds
Import upstream #3231: keep KernelWrite leases for pending reads
Import upstream #3223: stop XMA streams at PacketSkipCount 0xff
Import upstream #3225: implement queue SuspendX and ResumeX
Import upstream #3226: avoid empty root-constant slices in shader tests
Import upstream #3227: retain fences during queue waits
Import upstream #3204: serialize PresentX texture state
Import upstream #3217: snapshot RTV and DSV targets
`<from>-<to>:<key>` holds a key for a span, `<from>-<to>/<every>:<key>`
presses it for 0.2 s every `<every>` seconds, and `/<every>+<hold>` holds
each press `<hold>` seconds (0 < hold < every), e.g. `2-200/3+2.5:Enter`
steps through menus and holds through hold-to-skip cutscenes.
VICTORY_KEYS_FILE presses keys named on lines appended to a file, so a
script watching the log can press exactly when a screen is ready.
Plain `<seconds>:<key>` lists parse as before; still behind the
`diagnostics` feature. Unit test: scripts_repeat_and_hold.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Import upstream #3222: trace geometry signature memory
Import upstream #3213: guard bindless texture lifetime
Import upstream #3234: pin descriptor resources during concurrent release
resource::alias_source previously looked up a GPU-written aliased texture under TEXTURES_AT, dropped the Arc<HostTexture> and lock, and returned a raw *const Object (This) with no COM reference. If another thread legally called ID3D12Resource::Release() on the aliased source texture before texture::alias_copy ran, alias_copy dereferenced the freed Box<Resource> (or a recycled allocation at the same address) in resource::host_resource and list::ensure_state.

Return Option<Arc<HostTexture>> cloned while holding TEXTURES_AT, route pinned host-texture transitions (including depth twins) through HostList::transition_copy and list::ensure_copy_state, and pin the destination HostTexture once inside texture::alias_copy so concurrent eviction cannot split destination identity across GetDesc, host_writes, state tracking and CopyTextureRegion.
`Shadow::copy_back_marked` read the title's bytes of each page shaders
marked into a fresh `vec![0u8; n]` of 64 KiB: thousands of pages a world
frame (about 12,700 on an RTX 2080), each allocation zero-filled and its
pages faulted in again. The buffer is now one per thread, resized to the
page's length; every byte up to it is read from the title before use.

RTX 2080, warm caches, in the world: reading the title's pages for
marked copy-backs 132 -> 100 ms a frame (median of 12 frame reports).

Test: shadow::tests::a_partial_marked_page_after_a_whole_one_takes_none_of_its_bytes
(a whole page the shaders filled goes back, then the copy's last page,
held in part, which a shader and the title both wrote: it keeps both
writers' bytes and none of the first page's).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
Import upstream #3239: scripted key holds and repeat triggers
Import upstream #3207: fail DirectStorage startup without workers
Import upstream #3194: validate CopyTextureRegion bounds
Import upstream #3208: bound PE data directories by optional header size
Loader: skip overflowing DIR64 relocation entries
Import upstream #3202: lower 64-bit shifts without DXIL INT64
Import upstream #3245: pin aliased HostTexture across copy
Merge the pump-local wait-word cache with final blocked-state reporting and regression coverage for later-pass releases and pending fence waits.
Import upstream #3246: reuse per-thread marked-page copy-back buffer
Clear the per-pump wait-word cache when a satisfied FenceWait is popped. A completed fence may publish memory writes from external work; following segments must re-read affected wait words instead of reusing a pre-fence cached value.

Add a deterministic cross-queue regression.
Adapt upstream #3258 to the fork's #3245 pinned-copy helpers. Cache immutable resource flags, use one retained HostTexture for upload/staging/state, and add flag parity and repeated-read regression coverage.
Add a read-only scheduled/manual/push-triggered upstream PR triage workflow with exact ref pinning, non-mutating merge-tree checks, duplicate evidence, overlap hints, and JSON/Markdown artifacts. The workflow never checks out or executes candidate PR code.
Port upstream #3265: batch contiguous shader-visible descriptor mirroring with a single heap lookup, bounded sync batches, and the original per-handle fallback for cross-heap or incompatible ranges. Preserve overlapping-copy and self-copy semantics. Isolate the descriptor preparation test hook per thread.
Apply a 500 ms retry backoff only after CreateHeap returns E_OUTOFMEMORY. Existing free ranges remain available during the backoff, non-OOM errors are not delayed, and successful growth after expiry clears the retry state.

Add regression coverage for repeated OOM, deadline retry, free-range reuse, non-OOM errors and successful growth.
Correct GFX10 VOP3 and VOPC-SDWA v_cmpx decoding: the encoded VOP3 vdst is ignored, and both forms write EXEC. Preserve the explicit scalar destination for ordinary v_cmp SDWA.

Add Wave32/Wave64 decode and formatting tests with a non-EXEC control.
Treat buffer_gl0_inv and buffer_gl1_inv as operandless cache invalidations: no implicit EXEC read and no generic MUBUF resource, offset or data dependencies. Keep the existing instruction lowering behavior.

Add exact encoding, negative-control and Wave32/Wave64 CFG tests.
Read DRED breadcrumb history through bounded, page-wise ReadProcessMemory calls rather than constructing a slice from runtime-owned pointer/count data. Stop at the first unreadable page, cap diagnostics at 64 MiB, check address arithmetic and handle allocation failure without panicking.

Add regressions for inaccessible pages, truncation and pointer overflow.
Recognize the console resource-waterfall loop only when v_readfirstlane_b32 feeds a matching v_cmpx_eq that writes EXEC, no later instruction overwrites EXEC before s_andn2_wrexec, the loop branches back on EXEC, and the loop limit cannot cut off 64 lanes. Fold only the exiting SCC to false; preserve Missing(LANE_MASK) for other writes.

Add one-lane and 32-lane/multi-key regressions.
Apply VOP3 abs[2] and neg[2] to the destination accumulator in v_fmac_f32 before FMA. Limit the change to the opcode with a measured RDNA2 oracle; leave v_mac_f32 and v_mac_legacy_f32 unchanged pending independent measurement.

Add the 16-row oracle regression covering signed zero, infinities, NaNs, denormals and cancellation.
Retry staging allocations with progressively smaller 64 KiB-aligned chunks down to the request size, reset growth after recycling, and retain the largest 16 chunks so full-size capacity returns after memory pressure subsides. Add deterministic allocator regressions for allocation ceilings, recovery, retention ordering and non-overlapping suballocations.
* gpu: add opt-in direct queue timeout switch

* docs: explain direct queue no-TDR diagnostic switch
* rebase: port safe PresentX format handling onto current dev

* rebase: port safe PresentX format handling onto current dev

* rebase: port safe PresentX format handling onto current dev

* rebase: port safe PresentX format handling onto current dev

* rebase: port safe PresentX format handling onto current dev

* gpu: read typed RTV format from the pinned HostTexture

* gpu: keep PresentX format lookup tied to its pinned host copy

* fix: gate host RTV format lookup to Windows

* test: verify bound typed RTV format is retained for PresentX

* fix: use recorded RTV formats only for typeless or converted host textures

* gpu: expose typeless color format predicate to resource views

* docs: clarify when PresentX can infer a typed view format

* fix: use correctly typed null depth-view pointer in RTV metadata test

* fix: initialize the tracked RTV format atomic explicitly

* test: isolate compositor-creation failure from shared presenter cache

* fix: close command list before resetting typed-RTV metadata test

* fix: pass actual COM resource pointers to CopyTextureRegion

* fix: store COM resource interfaces in texture copy locations

* fix: release temporary COM references after texture copy recording

* fix: remove redundant nested unsafe around COM reference release
* Shaders: preserve old VGPR values across guarded interpolation

* Shaders: isolate guarded interpolation value preservation

* Shaders: test guarded interpolation preserves inactive lanes

* Shaders: gate GPU interpolation regression to Windows
Port the texture row-copy optimization with reusable run descriptors and bounds-checked row slices. Add regression coverage for exact bounds, partial runs, and pitch padding.
Co-authored-by: Copilot App <[email protected]>
loader: allow prebuilt probe fixture in integration test
test(gpu): verify buffer address after descriptor rebinding
gpu: read saved write-watch pages into uninitialized buffers
gpu: confirm host submission fence completion before readback
DirectStorage: stage rejected raw reads
shader: gate native gather check on selected adapter
shader: apply DPP to reverse integer source 1
gpu: count evictable host textures and skip empty census
test: make frame tick deadline checks deterministic
gpu: retry host texture creation after transient OOM
hle: synchronize lifecycle callback unregister
gpu: pin queues while HELD retains pending work
hle: harden append-only scripted key input
test(shader): use raw view for byte-offset gather reads
hle: control Windows efficiency throttling for console timers
hle: prove XAsync reuse and waiter lock contention deterministically
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:49:21 +00:00
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 23:40 UTC · original

Windows 11, 63bcca4 + this PR ("Major swarm update", 56 files), the CI job's three commands:

  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • cargo test --workspace --locked: 985 passed / 0 failed across 30 suites (unpatched 63bcca4 here: 872).
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.

So on Windows the whole workspace builds both ways and every test passes, including the hardware-backed ones on the RX 7900 XTX. I did not try to attribute individual tests to individual constituent changes — this is a statement about the union.

Synthetic only. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 23:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/3372#issuecomment-7205755693) Windows 11, `63bcca4` + this PR ("Major swarm update", 56 files), the CI job's three commands: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo test --workspace --locked`: **985 passed / 0 failed** across 30 suites (unpatched `63bcca4` here: 872). - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean. So on Windows the whole workspace builds both ways and every test passes, including the hardware-backed ones on the RX 7900 XTX. I did not try to attribute individual tests to individual constituent changes — this is a statement about the union. Synthetic only. AI-assisted.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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