Skip to content

Merge current main into #185 (3 conflicts resolved) - #4

Open
desplmfao wants to merge 136 commits into
aycow:fix/direct-indexed-buffer-coherencyfrom
desplmfao:fix/185-merge-main
Open

desplmfao wants to merge 136 commits into
aycow:fix/direct-indexed-buffer-coherencyfrom
desplmfao:fix/185-merge-main

Conversation

@desplmfao

@desplmfao desplmfao commented Nov 24, 2026 •

Copy link
Copy Markdown

Merges current Marvisak/VIctory main (58fed37, Marvisak#706) into Marvisak#185's branch (a6367ba), so Marvisak#185 stops showing conflicts. Separate from #3, nothing else changed.

Conflicts

file main Marvisak#185 resolution
descriptor.rs Marvisak#365: publish the host heap only after replaying pending writes host heap stored as Arc<HostHeap> main's order and comment, wrapped in Arc::new
draw.rs Marvisak#336: bind() returns false when a table it reads can't be made bind() is pub(crate) for host/tests/shader_usage.rs pub(crate) fn bind(...) -> bool
host.rs Marvisak#87: copy_stats_frames counts every presented frame for copystat::log diagnostic_frames, the same fix main's kept; Marvisak#185's duplicate field, initializer and increment removed

One break without a conflict marker, fixed in the second commit: main's new s_bitcmp lowering test (3c86053) calls lowers(&words), while Marvisak#185 gave lowers a second argument (rsrc2). It now passes 0, like the other tests.

Checked

Windows target, cross-built on Linux, tests under proton-cachyos with vkd3d-proton (RTX 5080):

Main is moving quickly, so this may need another merge soon; I'll add it as a new commit.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

jeremygold02 and others added 30 commits November 23, 2026 19:21
ADVANCE_XMA_READ added the title's block count to the 5-bit read block
in u32 before taking it modulo the ring size, so a count near u32::MAX
overflowed (a panic in debug builds). The count is reduced modulo the
ring first; the result is the same for every count that did not
overflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kernel_will_write (fread's size times count, saturated) and
title_memory_remapped added the length to the address unchecked, so a
huge fread count overflowed (a panic in debug builds). The end now
saturates at the top of the address space.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each rANS symbol scanned all of its model's bucket starts to find the slot's
bucket, then rebuilt the symbol's frequency and start from the symbol. A
per-model table of the bucket at each 256-slot window's first slot now starts
the search, which steps over the few buckets that begin inside the window; the
symbol, frequency and remainder come straight from that bucket. The lane loop
also keeps the record offset instead of dividing by the symbols per block on
every symbol.

Synthetic streams, release, one core (median of 3 runs, 16384 blocks):
BC1 177 -> 128 ns/block, BC4 184 -> 128, BC7 591 -> 452.

Tests: the window lookup against the scan for every slot of every model
(shipped tables, uniform tables, one-slot buckets); a payload step against the
first version's arithmetic on the shipped tables; every format's lane layout
round trips at 1 to 1000 blocks; an ignored throughput benchmark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CreateFileA, GetFileAttributesA, fopen, fopen_s and the narrow
std::_Fiopen turn the title's virtual-drive path into a host path and
then passed it to our own wide wrapper, which looked it up a second time.
When the host path starts with a letter that is itself mounted, it was
rewritten again: with the game on a host G: drive (say G:\GTA6), the
title's G:\x64\a.rpf became G:\GTA6\x64\a.rpf and then
G:\GTA6\GTA6\x64\a.rpf, so every narrow open of a title file failed.
The same happens for T: when the data folder is on a host T: drive.

They now call the host's wide function directly, as DeleteFileA,
SetCurrentDirectoryA, _open, _stat64i32 and remove already do.
…passes

Module::write dropped unread phis by sweeping every instruction until a
sweep changed nothing, allocating an operand Vec per instruction per
sweep. A chain of merges needs one sweep per merge, so the cost grew with
instructions x merges. A worklist now visits each instruction once and
reads operands through a callback; the block DFS, latch folding and the
call/phi/gep records stop allocating too. The written bytes are the same
(pinned by a test against the previous writer's output).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scalar bit tests decode and are tracked in ir.rs (they write SCC) but the lowering had no case for them, so any shader using one failed to translate with Unsupported.
Reserve a new staging path and clean it up if writing or publishing fails. Cover a failed publication with a synthetic destination directory.
XMemMapPhysicalPages with a count of 0, and the GPU's page-mapping copy
of a zero-length range, went into unmap with an empty range. Its search
for views starting inside asked the view map for a range that runs
backwards, which BTreeMap panics on once any view exists; in an
extern "system" function that aborts the process. Without that panic
the view holding the address would have been unmapped and mapped again
as two.

unmap now returns at once for a length of 0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An illegal or privileged instruction is reported by its address only,
which does not say which instruction it was. On an Intel host that is
the question every such report raises (clwb, clzero, rdpru, an SSE4a
form...), and reporters have had to guess or dump the bytes by hand.

The report's first line now ends with up to 15 bytes at the faulting
address, as hex, read no further than the end of that page, so the
report names the instruction by itself.
An access violation is reported with the address it touched and
nothing else, so a read of free memory, a write to memory that was
reserved but whose commit failed, a stack guard page and a write to
code or constants all look the same in a report.

The report now adds what VirtualQuery says is at that address: nothing,
reserved but never committed, a guard page, or the page's protection,
with the module for an image's pages.
When the host cannot make an unordered-access view (no host texture, a
format the host does not allow, a placed texture not mirrored), null_for()
wrote a 2D null UAV whatever the title asked for. A shader that writes a
3D texture through it then has a dimension mismatch: GPU-based validation
reports it ("UAV Dimension Expected: TEXTURE3D, UAV Dimension In
Descriptor: TEXTURE2D") for the world's wind field
(WindNew:CS_CopyWindFieldBeforeUpdateWithSmooth, compute 5bb23d336331db1d,
image_load/image_store dim:SQ_RSRC_IMG_3D). Shader views already get a
null view of the title's dimension (null_like); unordered views did not.

Null texture UAVs now keep the title's dimension: 1D, 1D and 2D arrays,
3D (WSize -1). Multisampled and unnamed dimensions stay 2D. With this,
the validation error is gone on an RTX 5070.

Tests: the dimension mapping, and a null 3D UAV made on the real device
leaves it alive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…guration's folder

A provider's folder is the user's folder plus the configuration id as a
file name. An empty id gave the user's folder itself, where the other
configurations' folders are. Opening the provider converts containers
of the old layout, which are folders without a `~` or a dot in their
name, as a configuration's folder is: each was taken for one, an empty
container was committed in its place and the folder was removed with
every save in it.

An empty id is now treated as no id (the default configuration).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
WinHttpGetProxySettingsEx is absent from Windows 10's winhttp.dll, so the
host-presence assertion panicked there. The HLE supplies it itself; skip it
only when the host lacks it, keeping the check for every other export.

Fixes Marvisak#118
XUserGetGamertag returned the name for every component, the modern
suffix included. The GDK documents the suffix as empty when there is
none, and a title that shows "name#suffix" whenever the suffix is not
empty showed "Player#Player".

The modern suffix (component 2) is now empty; the classic, modern and
unique modern components are still the name.
An unimplemented import with the default Trap policy printed its name
and aborted. abort() is a fast fail: it skips the exception handlers
and the panic hook, which are what append to crashes.log, so the most
common bring-up crash left nothing there, not even which import it was.

The trap now reports through log_crash, which prints the same line,
appends it to the crash log and adds the title's last debug output.
XTaskQueueDispatch with an infinite timeout waited until a callback was
queued. Terminating the queue refuses new callbacks and drained the
queued ones without waking anyone, so a dispatcher thread's loop
(`while (XTaskQueueDispatch(queue, port, INFINITE));`, which ends by
terminating the queue) stayed in its wait for good, and so did whoever
joined that thread. A dispatch begun after the termination did the same.

A dispatch now also ends, returning false, when its queue is
terminated: the termination wakes the port's waiters after draining it.
The flag is the queue's, so a dispatch on another queue that shares the
port waits on.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The SOPP table had s_ttracedata_imm at 0x26, as Mesa's opcode list
does; RDNA2 encodes it at 0x28 (AMD's RDNA2 ISA, LLVM's GFX10 tables
and disassembler tests). A shader with the thread-trace marker decoded
it as an unknown opcode and failed to translate, though the IR drops
the marker as harmless.
…value

f32_to_half rounds to nearest by adding half an ulp to the mantissa,
then or-ed the shifted mantissa into the exponent field. When the
rounding carried out of the mantissa, that carry is the exponent's low
bit: or-ed into an odd exponent it was lost, so values just below a
power of two came out at the power below (2 - 2^-12 gave 1.0, not 2.0).
Rectangle lists use it for the fourth corner of half-float elements.

The carry is now added into the exponent.
The device answers QueryInterface for ID3D12Device and for its newer
levels (Grand Theft Auto VI creates it as ID3D12Device11). A device
child's GetDevice and the DXGI device's QueryInterface knew only the
first: asked for the device by the interface the title holds, they
answered E_NOINTERFACE with a null pointer.

Both now ask the device's own test (is_device).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Reading and loading a title DLL report its path when they fail;
preparing it, in between, did not. A DLL the PE parser refuses ended
the run with just "malformed image: ..." (or the like), without saying
which of the title's DLLs it was.

The prepare step now adds "preparing <path>" like its neighbours.
Typed buffer loads in the 10_11_11, 11_11_10 and 10_10_10_2 families
(GFX10 unified formats 30-49) were refused, failing the shader. Fill in
their channel layouts and decode the unsigned 11- and 10-bit floats by
shifting them into half position for legacyF16ToF32, which is exact for
denormals, infinities and NaNs. Format numbers from LLVM's UfmtGFX10,
channel order from Mesa's ac_formats.c.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A descriptor picked without a branch, as the compiler does when it
hoists both loads (invariant memory) and turns the if/else into a
select, reaches the resource instruction through s_cselect_b64 per half
(or s_cselect_b32 / s_cmov per dword). None of its dwords is then a
load, so tracking stopped with "a descriptor neither loaded nor built"
and the whole program, and every draw using it, was dropped.

Such words are now split by the SCC value they all read: what each is
when SCC is set (S0) and when it is clear (S1, or the old destination
for s_cmov), with words not selected the same on both sides, and each
side traced on its own into a new Source::Select. Selections with
different conditions stop, and a choice that mixes two descriptors
still stops as "a descriptor changed after loading". The lowering picks
the heap index of the two loaded descriptors by SCC and creates one
heap handle, as a phi of loaded descriptors already does per edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
A descriptor held in VGPRs is used through a waterfall loop: each pass
reads the first active lane's dwords with v_readfirstlane_b32, compares
them with every lane's own (v_cmp_eq), runs the access with the lanes
that match and repeats for the rest. Tracing stopped at the readfirstlane
results ("a descriptor neither loaded nor built").

The tracer now follows the read lanes' dwords to where each lane gets its
own: global_load_dword* from a table or heap at a per-lane address (an
image descriptor's two x4 loads lined up), or a v_cndmask_b32 choice per
lane between such sources (e.g. two s_load descriptors). Other sources
fail naming them (LDS read, buffer load, phi, input, computed VGPRs).
The loop's compares of those reads with their own dwords are recorded.

Lowering gives the access each lane's heap index (its load address over
the descriptor size, or a per-lane select of indices) with
createHandleFromHeap's nonUniformIndex set, lowers the recorded
readfirstlanes as the lane's own dword and their compares as true, so
the loop runs once with all lanes. Wave32 and wave64 are tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
RtlVirtualUnwind and RtlCaptureContext want a 16-byte aligned CONTEXT,
and windows-sys 0.61 declares the x64 CONTEXT without align(16). In a
debug build the by-value copy in unwind_into, and the test's stack
context, landed 8 bytes off (an address ending in ...838), so
unwinds_like_the_system_walk crashed the whole victory-loader test binary
with a stack-overflow message and STATUS_ACCESS_VIOLATION. Aligning only
the test's context was not enough: the copy in unwind_into, which the
crash handler and stacks.rs also unwind with, faulted as well.

unwind_into now copies its context into an Aligned16 wrapper and unwinds
that; the test captures into one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When HostHeap::dynamic ran out, State::tables skipped the fresh table and
the stage's user data fell back to the title's table offset. Constant
buffer tables are always made fresh and never mirrored, so the shader read
whatever host descriptor sat at those slots as a constant buffer; on AMD a
texture or null descriptor read as a buffer gives a wild base address and
the device is removed (Marvisak#59: faults at 0x7000037xxxxx, 0x8000037xxxxx,
0x33c4000, a different pipeline every run, about 60 s in).

bind now reports that a table could not be made, and the draw, mesh
dispatch, dispatch or indirect execution is dropped. The dynamic range grows
from 2^16 to 2^18 slots, which the world did not exhaust on an RX 9070 XT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Marvisak and others added 12 commits November 24, 2026 09:20
…u-texture-source

GPU: upload CPU-written textures before full and region copies
…rivate-links

Docs: rustdoc builds the loader, GPU and shader crates without warnings
…pload-128

GPU: use the host upload path for texture staging copies
…ull-unbind

GPU: unbind vertex buffer slots for null view arrays
…fg-windows

Shaders: gate the constant_color test helper to Windows
…o-link

Docs: drop the private intra-doc link to MICRO in texture.rs
Shaders: v_cmp_lg is ordered on AMD hosts too (olt | ogt, not fcmp one)
Three conflicts:
- descriptor.rs: main (Marvisak#365) publishes the host heap only after replaying
  pending writes; Marvisak#185 stores it as an Arc. Main's order, wrapped in Arc.
- draw.rs: main (Marvisak#336) makes bind() return false when a table cannot be
  made; Marvisak#185 makes it pub(crate) for its tests. Both.
- host.rs: main (Marvisak#87) and Marvisak#185 both fixed the copy statistics' frame
  denominator (copy_stats_frames vs diagnostic_frames). Main's kept,
  Marvisak#185's duplicate counter removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's s_bitcmp test (3c86053) calls lowers() with one argument; Marvisak#185
gave it a second (rsrc2). Zero, as in the other tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Audio, watch: no overflow on huge title sizes (XMA read advance, fread)
BCPack: find a slot's bucket from a window table
watch.rs: main (Marvisak#88, ec0d155) saturates the end of announced writes and
remaps; Marvisak#185 had restructured title_memory_remapped around a checked
end that returned on overflow. Marvisak#185's structure with main's saturating
end, so a remap past the top of the address space still covers up to
it. Both sides' new tests kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@desplmfao

desplmfao commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

Main moved again (c7a5f49), so I added another merge commit, no rewrite. One conflict in watch.rs: main's Marvisak#88 (ec0d155) makes title_memory_remapped saturate the end instead of overflowing, while Marvisak#185 had restructured it around checked_add returning early. I kept Marvisak#185's structure with main's saturating end, so a remap past the top of the address space still covers up to it, and kept both sides' new tests. victory-gpu tests: 92 passed, including main's ranges_past_the_address_space_end_do_not_overflow; the same two environment failures as before.

AI-assisted (Claude Code).

Marvis and others added 2 commits November 24, 2026 09:55
A Windows job on the pinned toolchain: clippy with -D warnings on the
default and the --all-features (diagnostics) build, then cargo test
--workspace, which includes the asset-policy test.

main did not build its tests: scalar_bit_tests_lower called lowers()
without the rsrc2 argument a parallel change added (0, no input
registers). Also drops a double parenthesis clippy flagged in an xasync
test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main now has CI (clippy with -D warnings, then the workspace's tests) and
three new tests that call `resource::track`, which this branch gives a
fourth argument. No textual conflict, but the test target did not build:
those three calls (emit/lower.rs, twice in emit/mod.rs) now structure the
program first and pass it, as this branch's other callers do. Both of
CI's clippy commands are clean on the result.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e VALU tests

The four tests of emit/waterfall_tests.rs each dispatch on the hardware
adapter and on WARP. Run in parallel, the test process sometimes died of
an access violation (7 of 24 runs of these four tests on an integration
branch; an image test beside a VALU test does the same on WARP). They now
take the VALU tests' lock, which moves out of `run_cases` to be shared.
With it: 340 workspace tests pass with VICTORY_WARP=1, as on a CI runner,
and the shader tests pass on the RTX 5070.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Marvis and others added 3 commits November 24, 2026 10:53
Shaders: per-lane descriptors chosen by control flow (stacked on Marvisak#307)
The console compiler loops over a per-lane descriptor by reading the
first active lane's table offset (v_readfirstlane_b32), narrowing EXEC
to the lanes with the same one (v_cmpx_eq_u32), loading that entry
(s_load_dwordx8) and dropping those lanes (s_andn2_wrexec). Such a load
now goes through the waterfall proof; when it holds, each lane loads its
own entry through a non-uniform handle. Unproven, the offset stays the
first lane's, as before.

Translation census over the title's 26,096 programs: none lost, 108 get
past these loops to a later refusal. The 249 programs behind Marvisak#736 also
need per-lane size queries in loops without an access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two conflicts:
- lower.rs: main adds test-only fields (nonuniform_handles, wave_ops)
  next to Marvisak#185's heap_buffer_srvs. Both kept.
- shader.rs heap_handle(): main passes a nonuniform flag through;
  Marvisak#185 records heap buffer SRV indices there. Both: Marvisak#185's recording,
  then main's nonuniform handling.

Main's new nonuniform parameter is passed as false in Marvisak#185's
heap_buffer_srv tests, as those handles were uniform before, and
main's new waterfall test gets Marvisak#185's heap_buffer_srvs field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@desplmfao

desplmfao commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

Main moved again (ffe310e); merged as a new commit (4740e19). Two small conflicts in victory-shader: lower.rs (both sides add fields; kept both) and heap_handle() in shader.rs, where main passes a new nonuniform flag and Marvisak#185 records heap buffer SRV indices. Kept both. Marvisak#185's heap buffer SRV tests now pass nonuniform: false, and main's new waterfall test gets the heap_buffer_srvs field. victory-gpu 92 passed and victory-shader 110 passed, with the same three environment failures as before.

AI-assisted (Claude Code).

A texture UAV read as float and used atomically in the same program got
the float handle for its atomic: dxil-spirv then emitted OpAtomicOr on a
float texel pointer (invalid SPIR-V), and the NVIDIA compiler crashed in
vkCreateComputePipelines when GTA VI entered its world (two programs:
c12c1f7296419a5b, 8358f9eef7931421). With the type in the key the atomic
gets its own uint handle; all dumped SPIR-V validates.

(cherry picked from commit e55eb69)
@aycow

aycow commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@desplmfao Thanks for the main integration. Upstream Marvisak#185 now includes your exact 4740e19 merge, preserving authorship. AMD, NVIDIA and WARP passed the focused readback matrix with full GPU-based validation. A follow-up type alias in 68c8f20 passes both strict workspace Clippy commands. The subsequent handle-typing commit has a separate shader scope and remains on this fork PR.

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.