Skip to content

Major swarm update - #3372

Draft
vanya890 wants to merge 134 commits into
Marvisak:mainfrom
vanya890:dev
Draft

vanya890 wants to merge 134 commits into
Marvisak:mainfrom
vanya890:dev

Conversation

@vanya890

Copy link
Copy Markdown

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.

fuzeofficlal and others added 30 commits November 26, 2026 20:53
…nation bounds

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 <new-66@users.noreply.github.com>
…submitted

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 <noreply@anthropic.com>
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 Marvisak#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 <noreply@anthropic.com>
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 Marvisak#3232: batch GPU page-table rebuilds
Import upstream Marvisak#3231: keep KernelWrite leases for pending reads
Import upstream Marvisak#3223: stop XMA streams at PacketSkipCount 0xff
Import upstream Marvisak#3225: implement queue SuspendX and ResumeX
Import upstream Marvisak#3226: avoid empty root-constant slices in shader tests
Import upstream Marvisak#3227: retain fences during queue waits
Import upstream Marvisak#3204: serialize PresentX texture state
Import upstream Marvisak#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 <noreply@anthropic.com>
Import upstream Marvisak#3222: trace geometry signature memory
Import upstream Marvisak#3213: guard bindless texture lifetime
…ent release

Import upstream Marvisak#3234: pin descriptor resources during concurrent release
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
…-focused

gpu: confirm host submission fence completion before readback
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
…c-153

test: make frame tick deadline checks deterministic
gpu: retry host texture creation after transient OOM
…2026

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
…-contention

hle: prove XAsync reuse and waiter lock contention deterministically
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.