Integrate/shaders2 #414

Closed
github-bot wants to merge 405 commits from gh-pr/414/head into gh-pr/414/base
Owner

@⁠AntoninMichelq on GitHub · 2026-11-24 03:04 UTC · original
AntoninMichelq:integrate/shaders2 → main · +31224 −2127 · 82 files · 405 commits · closed without merging

No description provided.

**@⁠AntoninMichelq** on GitHub · 2026-11-24 03:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/414) `AntoninMichelq:integrate/shaders2` → `main` · +31224 −2127 · 82 files · 405 commits · closed without merging *No description provided.*
GameInput's SetRumbleState (slot 0x50) takes four levels: low and high
frequency, left and right trigger. Only the first two reached the host.
Source::rumble now takes all four as Motors, so a host that can drive
the trigger motors gets them; the XInput host still drops them (it has
none), and the shortcut note moves next to it.

A new test checks the trigger levels reach the host, clamped like the
grip motors.

Not compiled or tested here; static change only.
DispatchMeshX with an indirect address used to be dropped. It now runs as
indirect execution of one mesh dispatch (stride 12), through the same
State::execute_indirect, argument clamp and VICTORY_INDIRECT switch as the
title's ExecuteIndirect; when it does not run it is counted with the other
indirect work dropped. The argument layout is inferred: those of a PC
indirect mesh dispatch, three 32-bit group counts.

A direct mesh dispatch with an empty y or z dimension now runs nothing
instead of its x groups, and y * z no longer overflows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Release at a count of 0 in dstorage, gameinput, media and xg did fetch_sub(1) - 1: a panic in debug builds and, in release builds, a second free. A shared release_ref now keeps the count at 0, frees nothing and warns. One test per module.
mirror() previously dropped the SHADER_HEAPS lock inside shader_slot() before using the returned &Heap, allowing a concurrent Heap::drop to free the heap while mirror() accessed it. Also guards copy_simple() against invalid descriptor kinds, rejects placed heaps whose address+size wraps u64, and checks offset+count*bytes in resolve_queries() against overflow (with a regression test).
Implements the previously stubbed texture-to-buffer path in CopyTextureRegion:

- Add mapped D3D12_HEAP_TYPE_READBACK staging allocation (Host::readback_buffer, HostList::readback) and post-submission copy-back (HostList::defer_readback) that writes completed GPU readbacks into title memory via watch::writing + write_mapped before bottom-of-pipe completion writes.
- Align staging RowPitch to 256 bytes (D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) and copy row by row when a title footprint uses an unaligned row pitch; translate console formats with pc_format and check footprint arithmetic against overflow.
- Upload CPU-written source textures (texture::upload) and transition to COPY_SOURCE before recording CopyTextureRegion.
- Add an end-to-end GPU test in victory-gpu covering 256-aligned readback at a non-zero offset, unaligned packed row_pitch (16 bytes), and partial 2x2 source_box cropping.

Co-authored-by: BlueKaiman <[email protected]>
The console's GPU allows uses of some formats that other host GPUs do
not. On an RTX 4070 two 2560x1440 textures failed to create with
E_INVALIDARG (vkd3d-proton: "Requested resource flags #5, but no format
in cast list supports it"): format 86 (BGRA8) with unordered access, and
format 115 (B4G4R4A4) as a render target.

When creation fails, try again without unordered access, then without
render-target use, as is already done for depth targets that ask for
unordered access. The views the host cannot make are skipped. A clear
value is only passed while the texture is still a render target or
depth target, since the host refuses it otherwise.

Not checked: whether the title draws to or writes these textures in a
way that now goes missing.

Tested: Linux (Wine 11.21, vkd3d-proton 3.1), i7-12700K, RTX 4070. The
two textures are created and the title runs on.
In GFX10/RDNA2 MIMG instructions with a16=1, offset (_o), bias (_b) and z-compare (_c) remain full 32-bit VGPRs at the start of vaddr, while gradients, coordinates, LOD and clamp are packed in 16-bit pairs starting after them (matching gfx10::fields::image_addr_dwords).

- Split address reading into full 32-bit prefix VGPRs and a16-packed trailing components, removing the a16+image_sample_b bailout.
- Support _cl LOD-clamp variants (image_sample_cl, image_sample_b_cl, image_sample_d_cl, image_sample_c_cl) by passing the trailing clamp component to DXIL's clamp parameter.
- Check unsupported cube sample modes before reading coordinates so cube gradient samples report the right error instead of an out-of-bounds address.
These read f16 sources with the f32 bits of an inline constant, whose low half is 0 (1.0 became 0.0). Use the f16 value, as half_src and packed_src do.
A title sampler heap larger than D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE
(2,048) made HostHeap::new return None, which Descriptor::host() cached for
good: the heap was left out of SetDescriptorHeaps and every draw through it
read no samplers.

Such a heap is now capped at 2,048 slots: the title's first 1,792 and 256
dynamic ones. Tables reaching past the title slots kept are made afresh in
the dynamic slots, as tables past a capped view heap already are (#21).
Dynamic slots are counted per heap, and a table larger than them is
reported once instead of dropped silently.

Fixes #65

Co-authored-by: Cursor <[email protected]>
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 <[email protected]>
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 <[email protected]>
Addresses review feedback on #67: console formats 118..=120 (3-byte D16_UNORM_S8_UINT and its typeless views) map to 4-byte PC substitutes (45..=47). Check element(pc_format(format)) == element(format) before staging a texture-to-buffer readback so mismatched formats are skipped with a warning rather than mis-sizing the staging buffer or writing the wrong texel layout, and cover format 118 in the readback test.

Co-authored-by: BlueKaiman <[email protected]>
These were decoded but refused. The low bits of a sum, difference or product do not depend on the sign, so they lower as their unsigned twins; the 16-bit forms use the existing 16-bit path, which already sign-extends _i16 operands. Clamp, abs and neg are still refused.
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 <[email protected]>
The cap warning only said how many descriptors the host made, so a capped
NVIDIA heap gave no clue how many title slots were lost. Report what the
title asked for, what the host made, and the difference.

This replaces the earlier per-read report: main now logs the highest
past-heap slot in mirror() and #21 remaps the root tables that reach it,
so a second report of the same reads would only overlap.

docs/view-heap-limit.md is updated for #21 landing: root tables are
remapped, State::tables makes tables afresh for a CBV or a past-cap entry
(no descriptor-count rule), and #16 is an RTX 5070 Ti. The sampler heap's
2,048 limit is left as a separate issue.

Verified with cargo check -p victory-gpu --all-targets and cargo test
-p victory-gpu (36 passed).
A frame that ends in a packet where no frame begins (the tail of a frame that crossed packets, then padding) left the next frame pointing into that padding, which ended the stream early. Now the next frame is found by following each packet's skip to the next packet with frames.
A wave reduction that reads a row total with v_permlane16_b32 left the value unknown, so the wave operation was not recognised. It now picks within the lane own row, like v_permlanex16_b32 picks from the other row, and both only with every lane active (fi and bound_ctrl decide what an inactive lane reads).
descriptor_data refused a cube view (dim 3) although image_get_resinfo and cube sampling handle it, so a shader that sizes a cube from descriptor bits failed to translate.
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.
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 <[email protected]>
ds_read_{u,i}{8,16}, their _d16/_d16_hi forms, and ds_write_b{8,16}
(and _d16_hi) went untranslated. Reads load the dword holding the data,
shift it down and extend it; the d16 forms fill one half of the VGPR and
keep the other, which the IR now records as a read of the destination.
Writes clear the bytes and set them with two atomics, so lanes writing
other bytes of the same dword at once keep theirs.

Synthetic GFX10 compute programs check every form against a model of
the console's LDS on the host GPU and WARP, including 64 lanes writing
neighbouring bytes of shared dwords.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Our own completions looked their call up again by block address: after a
provider's DoWork returned, after a cancel, after a failed begin, and when
queued DoWork ran. A provider usually ends its call itself (XAsyncComplete
from DoWork or Cancel), and once it has, the title may begin a new call on
the same block, from its completion routine or from a thread that polls
the status. The lookup then found that new call:

- the old call's DoWork result (S_OK, size 0) or cancel (E_ABORT) ended
  the new call before it had done anything, ran its cleanup and fired the
  completion routine a second time;
- DoWork still queued for a canceled call ran the new call's DoWork.

Each queued DoWork now carries the call that scheduled it and runs only
while that call is still the block's, and DoWork, cancel and begin
complete that call. A call that is already over ignores a second
complete, so nothing reaches the next call. XAsyncComplete itself still
goes by block, as providers name their call by its block.
XAsyncComplete held the call's `done` lock while the title's provider
ran OP_CLEANUP. A cleanup that waits for a worker thread which is itself
completing the same call (it took the call before the cleanup removed
it) deadlocked: the worker blocks on `done`. The first completion now
claims the call with an atomic flag and runs unlocked; the status is
still published after the cleanup, while the block is valid, and `done`
is set only for the waiters.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fail when a requested scan root cannot be opened. Report traversal errors below a readable root alongside the other skipped inputs.
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.
Co-Authored-By: GPT 6.2 Sol <[email protected]>
These decode and are tracked in ir.rs but the lowering had no case for them, so any shader using one failed to translate with Unsupported.
Ask Windows for the live allocation type before guarding physical-page views. Keep the existing VirtualQuery fallback for unknown region flags and query failures. This avoids walking a long run of read-only pages solely to learn its memory type.

Validate ordinary mapped files, executable images, private stack memory and free addresses alongside the existing pagefile guard and write-watch tests.
A raw buffer view on the host must start on a multiple of 16 bytes; the
console needs only 4. buffer_srv and buffer_uav move a view's first
element by where its memory sits in the host copy, so a title's raw view
could land on 4, 8 or 12 bytes past a 16-byte boundary. The host then
refuses CreateShaderResourceView (or CreateUnorderedAccessView), and the
device is removed (0x887A0001). A user report from the world:

  CreateShaderResourceView: When creating a RAW Shader Resource View, the
  offset of the first element from the start of the buffer must be a
  multiple of 16 bytes. Thus, FirstElement (42261210) must be a multiple
  of 4 since each element is 4 bytes.

Such a view is now refused like one that is not on an element: the slot
gets a null view of its kind (reads zeros) and a warning is logged once.
Starting the view 16 bytes lower would need the shader to add the
difference.

Type-checked and clippy-clean for x86_64-pc-windows-msvc (cross-checked
from Linux with -Zbuild-std); not run against the title.
# Conflicts:
#	crates/victory-shader/src/emit/mod.rs
Bools::vars kept the nodes and variables it had seen in lists and scanned
them for every node, quadratic in the diagram's size; it now uses a set
that scans a short list while it is small and hashes once it grows.
Bools::given cofactored the diagram once per decided atom, each walk with
a fresh table; cofactors of different variables commute, so it now
replaces every decided atom in one walk. Equal functions are equal nodes,
so the results are the same nodes as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A callback submitted with a delay waited on a thread of its own and was
delivered when the delay ran out, whether or not the queue had been
terminated meanwhile. XTaskQueueTerminate only canceled what was already
in the ports, so a pending delayed callback was not canceled: it ran
later as live work (canceled = false), after the termination callback,
by which time a title may have freed what the callback uses.

The queue now keeps its delayed callbacks in a list until their delay
runs out. Terminate cancels them along with the queued ones, before it
calls the termination callback, and a delay that runs out after that
finds nothing to deliver. A submit racing Terminate checks `terminated`
under the list's lock, so the callback is either canceled or refused.
`victory run GTA6.exe`, run from the game folder, gives an exe path with
an empty parent, and that empty folder was mounted as G:. An empty path
cannot be made absolute, so the root stayed empty and G:\x64\a.rpf
became \x64\a.rpf: the root of the current drive. The title then found
none of its files.

An empty root is now the current directory, which is what an empty
folder means everywhere else (`Path::new("").join("x")` is `x` in the
current directory). Passing a path with a folder in it is unaffected.
AI-assisted (Claude Code)
Copy only the rows, columns and depth slices written into the staging footprint. Preserve surrounding texels for boxed and whole-subresource copies into larger destinations.

Refs: Marvisak/VIctory#67
SetEventOnCompletion(value, NULL) must block until the fence reaches the
value. It answered E_NOTIMPL at once (from when no GPU work ran), so a
title that waits this way went on before the value was reached.

A command list's bottom-of-pipe write at a fence's GPU address moved the
value without setting the events waiting for it. Live fences are now
registered by value address; Written::write wakes the fence it touched.

Blocking waits re-check the value every 100 ms and warn every 5 s while
stuck. New tests cover both paths; three of them fail on the old code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ID3D12CommandQueue::Wait did nothing, so work submitted after a wait for a value another queue signals later ran too early. Each queue now has a timeline that Wait, Signal and ExecuteCommandLists go through in order. Not held back, work runs on the submitting thread as before; behind a wait not reached yet, the call returns and the work runs on the thread that moves the fence. A list reset or dropped while a submission of it is still to run keeps its host list and upload memory until that submission completes. One synthetic two-queue test.
A present on a queue held back by a wait ran immediately, before the work preceding it. present() now reads its plane parameters at call time, holds a reference to the presented resource via a shared object::Held wrapper (also reused by fence::Held), and submits the present through the queue's timeline. One synthetic two-queue test.
CopyPageMappingsBatchX previously ran immediately even on a queue held back behind a fence wait, updating page mappings ahead of earlier queued work. It now snapshots the caller's batch and range arrays at submission time (with checked address arithmetic) and runs through the queue's timeline. One synthetic two-queue test.
Previously, moving a fence's value via a direct write to its GPU address (outside Signal or Written::write) only woke blocking null-event waits; registered Win32 events stayed unset and held-back queues waited until their next submission. A lazy background watcher thread (victory-fence-watch) now polls live fences every 10 ms only while at least one event or queue wait is pending and parks on a condvar when idle. Also switches aligned Written::write stores to atomic Release stores. Two new synthetic tests.
Detached HostLists whose submissions finished on a held-back queue are now returned to a bounded pool on Host (up to 64) and reused on subsequent list creations or pending resets. Dropping or resetting a list while a submission of it is still queued now transfers both its allocate_upload blocks and dynamic descriptor slots to the pending HostList until execution completes, and reset failure no longer resets an in-flight HostList. One new synthetic test.
The indirect clamp added every record's cost to the list's budget even
past BUDGET. With the largest costs (2^26) the 32-bit count wrapped after
about 64 garbage records, and every record after the wrap ran again: a
list of thousands of garbage records ran for seconds, which is what the
budget was meant to stop (PR #40 fixes the same inside a larger change
that does not merge with main today). The count now only grows up to BUDGET
(compare-exchange); a record that does not fit runs empty.

Direct dispatches and mesh dispatches past 65,535 groups in a dimension
are undefined on the host; they are now dropped and logged once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSD61BBk7E79WkryEQA
A buffer_load/store/atomic with idxen through a descriptor the code builds
around a root SRV took its stride from the container's used-resource
entry. Root descriptors carry no stride there (0), so the access stopped
with "a structured buffer of unknown stride", and a nonzero one asked for a
structured root view the host cannot bind.

The stride is a constant the code ORs into dword 1 (bits 16-29) when it
builds the descriptor. GFX10 addresses such an access at base + offset +
stride * index with swizzling off, so the index now becomes that byte
offset into the raw root view. A swizzled descriptor (dword 1 bit 31) or
one that adds the lane id to the index (dword 3 bit 23) stops instead.
Descriptors loaded from tables or heaps are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
An address such as a table plus a root constant (a byte offset), or a
table or root descriptor moved by s_addk_i32 or s_sub_u32 of a constant
(with s_subb_u32 into the high half), failed with "an address not from a
root parameter" and the draw was dropped. A root constant is now a
computed term, not a base, and those instructions add a constant.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
- Texture staging buffers (upload heaps, one per texture ever sampled)
  are kept within a budget (VICTORY_STAGING_BUDGET_MB, 1 GiB default):
  the least recently used ones no list holds are released and made
  again on their next use.
- Watched textures read their memory into one buffer per thread instead
  of keeping a copy the size of each texture for its lifetime.
- The shadow snapshot pool keeps at most 512 MiB (it could keep 8
  snapshots of the world's 174 MB heap, about 1.4 GB, for good).
- DirectStorage counts the zlib intermediate and physical-page
  destinations against its staging budget, not only the source.
- The runner drops its two in-memory copies of the title's exe once the
  image is loaded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSCvCZuokASx7f59sAG
Two kinds of s_load_dword* whose results the code reads as numbers had
no lowering, so a branch or export on them failed the whole program.

Constants the code reads through scalar memory from a root CBV or SRV
(an address computed from the root descriptor's user SGPRs) stopped
with "a scalar memory read as data". They now read through the root
view, as s_buffer_load and global_load already do: a constant buffer's
rows, or a raw buffer's dwords when the root signature says it is an
SRV. The address's two low bits are ignored, as on the hardware.

A descriptor loaded whole for an image or buffer instruction and loaded
again a dword or two at a time for its size stopped with "a descriptor
read only as data": only the load the instruction used was matched. A
load from the same base and offset registers whose first dword falls in
the used descriptor now takes that descriptor's view and rebuilt size
dwords.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: GPT 6.2 Sol <[email protected]>
# Conflicts:
#	crates/victory-shader/src/emit/lower.rs
# Conflicts:
#	crates/victory-shader/src/emit/lower.rs
# Conflicts:
#	crates/victory-shader/src/emit/lower.rs
MapViewOfFile3 with MEM_REPLACE_PLACEHOLDER replaces exactly one
placeholder: the range must be the placeholder's own. map() split the
placeholder around the range and mapped one view over it, so it worked
only when the range lay in a single placeholder. Every mapping leaves its
reservation split at its ends and unmapping does not join the pieces, so
after a partial unmap, a scattered mapping or a shorter earlier run, a
run over those pages failed with ERROR_INVALID_ADDRESS and
XMemMapPhysicalPages returned NULL, its range already unmapped.

map() now splits only at the run's two ends and gives each placeholder in
the range a view of its part. Placeholders are never coalesced: the host
also coalesces placeholders of separate reservations, and pieces a title
split itself would stay joined after the unmap. If a view fails, those
made before it become placeholders again. The split call also frees
memory that replaced a placeholder back to one, committed pages
included, so split_at() splits only where everything below the split
point is reserved.

New tests: a run remapped after a partial unmap, a run from one
placeholder into the next, a title-split piece kept through a map and an
unmap, and a failed run that is rolled back without touching committed
memory next to it. The first three fail on main (XMemMapPhysicalPages
returns NULL). cargo test --workspace passes on Windows 11. Wine's
virtual.c splits placeholders into separate views and reports them the
same way (AllocationBase, region end, exact MEM_REPLACE_PLACEHOLDER
match); not run under Wine.
A cube image's explicit gradients are those of its two face coordinates,
so image_sample_d and image_sample_d_cl carry two per direction there,
not three. cube_direction is linear in the face coordinates, so the
gradients of the direction the host wants are twice each, signed per
face, and zero along the face's own axis.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
These write SCC, but their lowering gave no SCC value, so the generic
"result is not zero" stood in. The ISA sets it otherwise:

- s_min_i32/u32, s_max_i32/u32: SCC = 1 when src0 is the value chosen
  (src0 < src1 for min, src0 > src1 for max).
- s_lshl1..4_add_u32: SCC = 1 when (src0 << n) + src1 overflows 32
  bits, through bits shifted out of src0 or the add's carry.

So s_min_u32(5, 3) left SCC = 1 (3 is not zero) where the hardware
leaves 0, and s_lshl1_add_u32(1, 0xFFFFFFFE) left 0 where it leaves 1;
an s_cselect or s_cbranch_scc after them took the wrong side.
# Conflicts:
#	crates/victory-shader/src/emit/lower.rs
# Conflicts:
#	crates/victory-shader/src/emit/lower.rs
# Conflicts:
#	crates/victory-gpu/src/list.rs
The d16 forms of the typed buffer loads return each channel as 16 bits,
two per VGPR, low half first; the decoder already sizes their data that
way. The lowering only treated `buffer_` names as d16, so a
tbuffer_load_format_d16_* went through the 32-bit path: the first VGPR
got channel x as a 32-bit value (the f32 bits of 1.0 instead of the f16
pair (1.0, 2.0)) and the other channels were dropped.

The format path now packs its channels for d16: integer formats keep
their low 16 bits, the other formats become f16 (as the MUBUF d16 path
converts them).
With indirect execution on, the world takes more dynamic descriptor
slots than a view heap has (65,536): a frame binds thousands of tables
holding constant buffers, each made afresh. When `HostHeap::dynamic`
found none, `State::tables` left the table unmade and the draw ran
anyway, its shaders indexing the title's own slots for that table.
Those hold whatever was mirrored there, not what the shader expects,
and the host GPU page-faulted at a low address about a second after
the "no free dynamic descriptor slots" warning (device removed,
DXGI_ERROR_DEVICE_HUNG).

- A draw, mesh dispatch, dispatch or indirect execution whose bind
  could not make a table is dropped, counted with the other dropped
  draws.
- Dynamic slots per view heap go from 2^16 to 2^19, so the world's
  frames fit. On a host that caps view heaps at 1,000,000 views this
  leaves fewer slots mirroring the title's (475,712 instead of
  934,464).
Each import the title binds, and each GetProcAddress on a host module,
went through registry::lookup: every module lower-cased the DLL name into
a fresh String to test its patterns, then every export of the serving
modules was compared by name. A miss, which every import we leave to the
host is, paid for all of it.

The registry is now indexed once by export name, in registry order, with
the first export of a name in each module. A lookup hashes the name (FNV,
the keys are our own export names), and only the modules exporting it test
their patterns, case-insensitively and without allocating. The first
serving module and its first export still win, as in the scan.

Release, one core, every registry export under each DLL name that serves
it plus one host-only miss per name (605 lookups, best of 5, 3 runs):
scan 444-489 ns, index 41-46 ns per import (10.3x-11.8x).

Tests: the index against the old scan for every DLL pattern (as written,
upper-cased, versioned API sets) by every export name and misses, on the
registry and on overlapping synthetic modules; pattern matching against
HleModule::serves; registry patterns are lower case; 300 modules sharing
a name keep registry order; an ignored throughput benchmark.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	crates/victory-shader/src/emit/lower.rs
Textures in memory with no write watch (the physical-page views of the
texture pool) were checked with committed() and then read directly,
twice (hash, detile). A title unmapping those pages in between, for
example evicting a texture a big descriptor table still lists, faulted
on the read, and the vectored handler takes only writes. The memory is
now read through copy_mapped (ReadProcessMemory, zeros for unmapped
pages), as the watched path already does, into a per-thread scratch
buffer reused between textures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Six scalar instructions the emitter refused by name:

- s_bcnt0_i32_b32/_b64: the count of clear bits, as the set bits of the complement; SCC = result != 0.
- s_ff0_i32_b32/_b64: the lowest clear bit (-1 for none), as s_ff1 of the complement.
- s_flbit_i32_b64, s_flbit_i32_i64: the first bit from the top of the pair (for the signed form, the first
  that differs from the sign), counted from bit 63, -1 for none. The high dword answers unless it has no such
  bit; then the low dword is searched for a bit that differs from it.

On plain data only; a lane mask as the source is still refused, as before.

AI-assisted (Claude Code).
Reads of a null view give zeros and its atomics return zero, so a compute
pass that loops on a counter or flag kept there (a work queue, a spin
wait) never sees it move: every lane runs to the translator's loop limit
(2^20), seconds of GPU time, and Windows resets the display driver. The
world hangs this way about a minute in (DXGI_ERROR_DEVICE_HUNG on an
RX 7600); the device-removed data named a compute dispatch with two null
views in its table.

Binding now notes a used unordered access entry with no view behind it,
and such dispatches (direct and indirect) are dropped, logged once per
pipeline. VICTORY_NULL_UAV_DISPATCH=1 runs them as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSD61BBk7E79WkryEQA
A DualSense is not an XInput device, so the title never saw one even though
GameInput reports pads. Read the pad's HID input reports on a thread and
expose them in the shape the XInput source returns, on slot 0 when no XInput
pad answers there.

USB input reports (0x01, 64 bytes) and Bluetooth reports (0x31, 78 bytes)
place the buttons and triggers at different offsets. Read the fields through
Windows' HID parser (HidP_GetUsages/HidP_GetUsageValue) by declared usage
instead of by fixed offsets, so both transports and the DualSense Edge share
one mapping. Square, cross, circle and triangle become X, A, B and Y;
shoulders, create/options, stick clicks and the hat map to their pad bits;
sticks are centered and Y is inverted. Touchpad, gyro and lightbar have no
pad surface in the title and rumble is not sent back yet.

The keyboard also plays Circle on O, next to Enter's Cross.

Tests: cargo test -p victory-hle --lib dualsense, cargo test -p victory-hle,
cargo build --release -p victory. Verified live on Windows: the title
registered a gamepad callback (kind 0x40000), pad 0 connected, and presses
and analog triggers arrived.
Threads created without a stack size take the executable's default
reserve, 1 MiB from the linker. vkd3d-proton's and the driver's own
threads compiling the title's large world shaders overflowed it under
Wine on an RTX 4070 (four threads at one driver address during the world
load). Reserve 16 MiB for MSVC targets; pages are committed only as used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Synthesize one compute fixture per opcode table entry and run the translation passes. Diagnose refused instructions even when their results are unused, and identify opcode panics or timeouts in an isolated test process.

List the refused set and provide an opt-in report grouped by encoding and reason. An opcode that stops lowering fails the regular test; one that starts lowering only makes its line stale, so changes that lower opcodes need not touch the list. The baseline covers 1,233 entries without game data.
Image samples and gathers now lower by their form (comparison,
derivatives, coarse or 16-bit derivatives, level, level 0, bias, level
clamp, texel offset) instead of a fixed list of opcodes. The address
dwords follow LLVM's ImageDimIntrinsics and Mesa's ac_build_image_opcode:
offset, bias and reference a dword each, then the derivatives (16-bit
ones two per dword, each direction its own), the coordinates and the
level or clamp. The decoder counted 32-bit derivatives for the _g16
forms; it now counts them packed.

Newly lowered:
- every texel-offset form of the samples above; DXIL immediates when the
  offset word is a constant in -8..7, else (past -8..7, or per lane) the
  coordinates move by offset / size at a level known at translation;
- _cl (the DXIL clamp argument), _cd (as _d), _g16;
- image_sample_c, _c_cl and their _o forms in compute as well as pixel
  shaders; image_sample_c_l(_o) with a level, image_sample_c_b(_cl)(_o)
  with a bias known to be 0;
- image_gather4_l(_o) with a level known to be 0, image_gather4_c_lz(_o),
  image_gather4_c_l(_o) at level 0 (textureGatherCmp);
- a16 biased samples (the bias an f16 in its dword's low half) and a16
  comparisons;
- image_store of some channels: the data VGPRs are the dmask's channels,
  the others are written as 0.
Still refused, each with its reason: gathers at an implicit level or with
a bias, comparisons with derivatives, at a level or with a bias not known
to be 0 (SM 6.7/6.8 operations), and offsets past -8..7 or per lane at a
level not known at translation.

Tests: hand-assembled compute programs on the RTX 5070 against texels
worked out on the CPU (offsets known, past -8..7 and per lane; levels,
gradients, g16, bias and clamp through compute quads; comparisons and
comparison gathers per texel; partial stores, d16 too), every newly
accepted form through the validator, and the refusal reasons. On
upstream/main all of them fail ("... is not supported").

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add scalar bit counts, searches, field and packing operations, and vector integer multiply-adds, SADs, dot products and saturating conversions. Use IEEE bits for frexp, class and double compares so NaNs, signed zeros and denormals survive.

Add synthetic compute tests with live DXIL results compared against CPU references. Validate the shaders with the Windows SDK validator and run them on the RTX 5070. The opcode audit moves 106 mnemonics from refused to lowered.
Lower LDS counters, reverse subtraction, masked OR, wrap and separate exchanges. Use one shared i64 allocation when a shader needs native 64-bit atomics so dword accesses still alias it. Translate buffer bytes and halves, including split halfwords and D16, and use native integer atomics or compare-exchange loops according to the RDNA 2 ISA. Support traced root SRV/CBV loads and global D16 reads.

An opt-in opcode probe records refusals. Synthetic compute tests compare both the returned and stored values with CPU references, check contention and out-of-bounds behavior, and validate and dispatch on the host D3D12 device. Floating atomics still require the console MODE state.
A hand-built pixel program (two table descriptors, one MIMG, an export)
goes through every stage to DXIL for image_sample_d and
image_sample_d_cl on a 2D image and on a cube. Without the cube support
it stops at the cube case with the old refusal.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: GPT 6.2 Sol <[email protected]>
The high dword of the 48-bit product whose low dword v_mul_u32_u24 and v_mul_i32_i24 already give: the low
24 bits of each operand, zero- or sign-extended, through the existing mul_hi.

The test module gets lowers_valu, a one-thread compute program with root constants in v1..v4 and a buffer
store of v0, so a vector instruction can be checked for lowering without a GPU.

AI-assisted (Claude Code).
Ten VALU instructions the translator refused, so any shader using one
dropped its draws or dispatches:

- v_mul_hi_u32_u24 / v_mul_hi_i32_i24: the high 32 bits of the 48-bit
  product, with the operands taken as v_mul_u32_u24 takes them;
- v_cvt_pk_u16_u32 / v_cvt_pk_i16_i32: both sources saturated to 16 bits
  and packed (src0 low);
- v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_i32_i8, v_dot4_u32_u8,
  v_dot8_u32_u4: products of the packed fields summed into src2,
  wrapping; clamp and operand selects are refused;
- v_ldexp_f32: src0 * 2^src1 as three exact power-of-two factors whose
  exponents stay in the normal range (src1 clamped to +-375, past which
  every finite nonzero src0 has over- or underflowed).

Found by lowering every GFX10 ALU opcode alone in a pixel shader whose
export depends on it. The formulas were checked against the ISA
definitions on random inputs (0 differences; ldexp differs only where a
result turns denormal before the last factor, noted as a shortcut).

Tests: packing_dot_and_ldexp_instructions_translate (each one goes
through the whole translation; fails without this change), and GPU tests
in valu_tests comparing every instruction with its definition on edge
values. The GPU tests were type-checked and clippy-clean for
x86_64-pc-windows-msvc but not run (no Windows machine here).
Reserve a new staging path and clean it up if writing or publishing fails. Cover a failed publication with a synthetic destination directory.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
src2 plus the sum of the unsigned differences |a - b| of the operands' bytes (v_sad_u8), halves (v_sad_u16)
or whole dwords (v_sad_u32), wrapping at 32 bits. v_sad_hi_u8 adds the byte sum shifted to the high half;
v_msad_u8 leaves out a byte whose mask byte (src1) is 0.

AI-assisted (Claude Code).
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 <[email protected]>
imdct_half worked out every pre- and post-rotation with sin_cos on each
call (n of them per subframe) and ran its FFT on two fresh Vecs. The
rotations, the bit-reversed order and the butterfly rotations now come
from a table built once for 128, 256 and 512 samples; the work buffers
live on the stack. Every value is computed with the same expression (the
butterflies with the same running product), so the output is bit for
bit what it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
frame::wait marked the tick it waited for as taken (LAST) only after
the sleep, outside the clock's lock, so two threads waiting for one
event kind at once both got the same tick and both returned on it,
against the module's once-per-tick rule (an origin wait then begins two
frames in one interval). next_tick now takes the tick under the clock's
lock when the wait comes within its time-out; a time-out takes none, as
before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Co-Authored-By: GPT 6.2 Sol <[email protected]>
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: GPT 6.2 Sol <[email protected]>
A descriptor reloaded in each waterfall loop of a non-uniform index is
read for its size bits by one load and used by another, so the first
had no resource use and the program stopped. Its view kind now comes
from a twin load: same opcode and offset, same base values, and the
same register offset or a v_readfirstlane_b32 of the same VGPR value.

image_sample and image_sample_b outside pixel shaders were emitted as
sample/sampleBias, which validator 1.6 rejects there. The console takes
the level from each quad of lanes, so they become sampleGrad with
coarse gradients from the quad (a bias scales them by 2^bias).

Over shaders.rpf: compute validated 1,662 -> 1,758 of 2,581, vertex and
pixel 12,172 -> 12,183, none lost.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Programs whose root parameters do not all fit in user SGPRs get a pointer to the spilled user data in an input SGPR pair and load the parameters through it (the Xbox BVH builder's compute programs: s[0:1], the parameters from user data 16 on at 4 * (user_data - 16)). Such a load reads values the host root signature already passes, so unspill rewrites it into the user SGPRs the layout names, which resource tracking and lowering read as root parameters. Loads that do not fit (other pointers, padding dwords that are read, registers already arriving with a value) are left unchanged.

Over the 52 BVH builder programs, 'an address in an SGPR that is no root parameter' goes from 52 to 2; the rest now stop at later steps (address not from a root parameter, root UAVs, select on an untracked mask).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	crates/victory-gpu/src/host.rs
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.
A path on a virtual drive was handed to the host as the host folder
followed by the title's tail, so the host resolved `..` against the host
folder: `X:\..\f` named a file beside the drive's folder, where on a
drive of its own `..` stops at the root and the path is `X:\f`. Long
paths (the `\?\` form) already resolved `..` here and stopped at the
root, so the same title path named different files depending on its
length.

A tail with a `..` part is now resolved here in the short form too, with
the clean-up the long form uses. Other paths are passed on as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Decoder::decode took the caller's bit count as the end of the frame. Past
the data the bit reader returns zeros, and a stereo tile header reading
only zeros gives the subframe to no channel, so it never moves on; with a
count beyond the data it never overreads either, and looped for good.
Clamp the end to the bits the data holds. A frame from read_frame always
holds its bits, so its decoding does not change.

Add deterministic noise tests (xorshift64, fixed seeds, as BCPack's):
buffers of noise packets, streams of noise frames with clean and damaged
headers, frames in mono and stereo at each sample rate, bit counts past the
data, and read_frame and packet at any offset. Every walk is bounded and
every decode must give one frame of samples. The bit-count test hangs
without the fix; the others pass on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GetModuleFileNameA/W on the host clears the thread's last error when
the name fits, and code tells a truncated name from a whole one by it
(grow the buffer while the last error is ERROR_INSUFFICIENT_BUFFER; or
fail if it is, also when the name filled the buffer exactly). Our
answer for a title image set the error when the name was cut and left
it alone otherwise, so after one call with too small a buffer, or
after any earlier call on the thread that left 122, a whole name still
read as truncated.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The static TLS redirect tested the whole 9-byte `mov r64, gs:[0x58]`
pattern at every byte of every executable section. It now skips with
SSE2 compares to the offsets that hold `gs`, `8B` two bytes on and `25`
four bytes on, and tests the full pattern only there. Offsets without
those three bytes cannot match, so the patched bytes and the count are
the same as before.

A test checks the new scan against the old byte-at-a-time one on random
code with loads, near misses and overlaps, at every word alignment. An
ignored release benchmark (tls_scan_speed) times both on 1, 16 and
128 MiB of synthetic code: 8-9x faster.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
When a frame ended a loop, decode cut it at the loop's end subframe, set
the loop's skip (the subframes of the loop's first frame that lie before
the loop) and then took that skip out of the frame in hand: the loop's
last. So the head of the last frame was dropped instead, and the first
frame played from its start, with the audio before the loop in it. The
number of samples came out the same; the seam did not.

The pending skip is still applied to the frame in hand, and the loop's
skip is set after it, for the frame decoded next.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: GPT 6.2 Sol <[email protected]>
A submission ran all its lists in one ExecuteCommandLists. Windows resets
the device when one submission runs for about 2 s, and the world's
frames take a second or more over dozens of lists: the world hangs about
50 s in, on a submission of 30 lists (DXGI_ERROR_DEVICE_HUNG, RX 7600).
Each run (prelude and list) is now a submission of its own, so the
scheduler gets a boundary between lists; there is still one signal and
one wait at the end. VICTORY_GPU_TIMING keeps waiting for and timing each
list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSD61BBk7E79WkryEQA
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.
# Conflicts:
#	crates/victory-shader/src/emit/lower.rs
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A 'victory::memory' line every VICTORY_MEMORY_LOG_SECS seconds (5 by
default, 0 turns it off): the process's commit and its peak, committed
memory by kind (private, mapped, image) and the 8 largest private
allocations, physical pages and their sections, and what the GPU side
holds (title heaps, buffer copies, texture staging, snapshots) with the
driver's video and system memory use. To tell the title's own memory
from ours when loading the world nears the commit limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSCvCZuokASx7f59sAG
A buffer inside another (the world's views of its 174 MB heap) used to
get a host copy of its own next to the outer buffer's: it now uses a
copy already made of a buffer holding it, and only gets its own when
none is made. Loose memory reuses any window copy holding the range,
not only one of the same start and length (a range crossing a window's
end copied the same bytes a second time).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSCvCZuokASx7f59sAG
<width>x<height>:<format>[:<n>] picks the n-th texture of that size and DXGI format the frame renders to or writes, so a pass the final image does not show (the G-buffer while lighting is still black) can be watched live. Diagnostics builds only; frames without such a texture present as usual.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pixel programs that use the I/J VGPRs as plain values (custom
interpolation, math on the weights) failed with "barycentrics read
directly". They are now channels y and z of an SV_Barycentrics input
(SM 6.1+, the emitter targets 6.6) declared with the interpolation mode
of their kind (perspective/linear, center/centroid/sample), one element
per mode (semantic index 0 and 1), with the Barycentrics shader flag and
SFI0 feature. GFX10 interpolates P0 + i (P1 - P0) + j (P2 - P0) with P0
the provoking vertex, which the host's barycentrics weight as vertex 0,
so i = y and j = z.

The VGPRs are loaded on first use as a value, so programs that only feed
them to v_interp_* declare nothing new. A console signature's own
SV_Barycentrics row (D3D name 23) is parsed and reused. Pull-model
barycentrics stay unsupported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Whether a crash is a missing instruction depends on the CPU (Intel CPUs
lack some of the console's AMD-only instructions), and which D3D12
runtime there is depends on the Windows build, yet a report carries
neither, so every report has needed a follow-up question.

Unhandled exceptions, panics and host GPU failures now end with a
"host:" line naming the CPU's brand string and the real Windows
version (RtlGetVersion), read once when the crash log is set up.
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 <[email protected]>
A title buffer view becomes a view of its host copy with the first element
moved by the view's offset in the copy (offset / stride). A structured view
whose start in the copy is not a multiple of its stride (a 32-byte stride,
16 bytes past an element: logged as "buffer view not on an element of its
host copy" on the way to the menus) cannot be expressed there, so its slot
was left null: shaders read zeros through it and their writes were lost.

Such a view is now made as the raw view of the same bytes (R32_TYPELESS,
raw flag, first element and count in dwords) when its start is 16-byte
aligned; the host removes the device for raw views that are not, so other
starts stay refused. It is a view of the same shared host copy, so what
shaders write through it lands where the other views of that memory read,
and is copied back to title memory as before. Translated shaders read heap
buffer views raw unless they index them; one that indexes it declares it
structured, which D3D12 leaves undefined over a raw view (an RTX 5080 and
WARP read and write the right bytes).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A synthetic compute program loads a 2D image UAV as four floats and then
runs image_atomic_umin on it in the same block. The atomic must get its
own one-U32 annotation next to the load's four-float one. Test builds
record each annotation's property words so the test can read them.

Fails on the handle cache keyed on the first property word only; passes
with the element type in the key.
The source resolver's rule (local files only) knew a share as `\..`,
`//..` or `file://server/..`. The host knows more spellings: any two
leading separators (`/\server\share`), the object manager's prefix
(`\??\UNC\server\share`), and a `file:` URL with no host whose path
starts with two separators (`file:////server/share`,
`file:\server\share`, also percent-encoded). Those fell through as
relative paths or drive-less local files and went to the host's
resolver unchanged.

They are refused now, naming the server. Paths with one leading
separator, a drive after the slashes or the prefix, and the path of a
URL that names this machine pass as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Keep the kind-21 enable flag in the graphics state and pipeline cache
key. Use DEPTH_STENCIL1 for vertex and mesh streams that request the
test when the host supports it. Unsupported hosts fall back to the
plain depth-stencil state and warn once.

Forward the title's depth bounds to the host command list and replay
them when binding a graphics pipeline, including after the indirect
clamp. New and reset lists start with D3D12's 0..1 default.

Synthetic title draws and mesh dispatches on an RTX 5070 and WARP
kept excluded pixels at the cleared depth of 0.5 and wrote 0.25 to
included pixels. Fresh and reset lists also wrote 0.25. A forced
unsupported run drew all pixels, and the stream reader regression
failed with the upstream reader. The console subobject layout and
call signature still need title-side verification.
No query ran on the host GPU: BeginQuery/EndQuery did nothing and
ResolveQueryData wrote stand-ins (every occlusion query 2^20 samples,
every binary one visible, statistics zeros, timestamps the clock after
the submission), so nothing a title decides by a query was real.

Now:
- A title query heap of a type the host has (occlusion, timestamp,
  pipeline statistics; at most 2^18 queries) gets a host heap of its
  size on first use.
- BeginQuery/EndQuery record into the list's host list, in order with
  its draws. Following D3D12's rules: timestamps only end; a query
  running in the list already does not begin again; an end without its
  begin in the same list is dropped; queries still running when the
  list closes are ended there.
- ResolveQueryData resolves on the host the queries whose last run
  there was of the type resolved. Occlusion and statistics results go
  into the title buffer's host copy at the resolve's offset (declared as
  a GPU write, so the submission's copy-back puts them in title memory,
  and later commands read the copy). Timestamps go through read-back
  memory and are put on the title's GPU clock (100 MHz since the first
  use, as GetTimestampFrequency and bottom-of-pipe timestamps say) from
  the queue's clock calibration against the performance counter, never
  past the time they were read.
- Everything else keeps the stand-ins: queries not run on the host, a
  heap of another type, indices past the heap's end, destinations not
  8-byte aligned in their copy, the console's other query types, and no
  host GPU. The resolve's bounds check no longer overflows on offsets
  near u64::MAX (as open PR #52 does).

Tests drive the title's list, queue and heap methods on the host GPU
(RTX 5070), skipping without one; the draws come from a small host
pipeline recorded into the title list's host list, since title
pipelines need translated console shaders:
- a full-screen 64x64 triangle counts 4096 samples and is visible; one
  scissored away counts 0 and is not; its statistics are 3 vertices, 1
  primitive, at least 4096 pixel shader runs; the bytes around the
  results stay; the host copy holds the results;
- two timestamps around 64 draws come out in order, between the GPU
  clock before (less 1 ms) and after the submission;
- queries not run, of the wrong heap, past the heap or the buffer, or of
  unknown types keep the stand-in values (with or without a host).
The query tests are clean under the debug layer and GPU-based
validation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With real occlusion queries, a title draw the host does not run (its
pipeline is not ready yet, its shader does not translate, an indirect
execution that cannot run) left the query counting too few samples,
often none, and a title culls by that what the draw would have shown.
While most of the world's draws are still dropped that would hide more,
not less.

A host list now marks the queries running in it when a draw, mesh
dispatch or indirect execution is not run, and such an occlusion or
binary occlusion query is ended on the host but not taken as measured:
its resolve writes the stand-in (2^20 samples, visible) as before host
queries. Pipeline statistics keep what the host counted.

Test (RTX 5070): a title DrawInstanced with nothing bound inside
occlusion and binary occlusion queries resolves to the stand-ins, a
query begun after it measures 0, statistics measure the host draw. It
fails without the marking (0 samples instead of 2^20).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The address tracer gave up on "an address from a phi": a pointer the code
advances in a loop (a phi of the base and base + stride) or picks by a
uniform branch between two offsets from the same root parameter.

Such a phi is now traced when every argument is the same root parameter's
address plus offsets, or goes back around the phi (or another such phi),
and its high half stays the parameter's (0 for a table) through phis,
carries and borrows. The varying part is no value of the program, so the
Address keeps the phi itself as the computed term and says so with the new
`includes_base`: the byte offset is the phi minus the parameter's address,
plus the constant.

Descriptor loads from tables and heaps already compute the heap index from
the absolute pointer, so they translate as they are. Data reads subtract
the parameter's user-data value; a pointer into a root descriptor (whose
address the translation does not have) or into the program's code table
stops with a reason instead of reading at the wrong offset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
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 <[email protected]>
- 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 #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.
Values a whole-wave section leaves were unknown when the section used a
step the simulation did not model ("a whole-wave section step the
simulation does not follow"). The simulation now also follows:

- v_writelane_b32 (a constant or known-uniform lane takes the scalar,
  whatever EXEC holds): the exclusive prefix sum that carries lane 15 into
  lane 16 (and 31/47 into 32/48 on Wave64) with v_readlane/v_writelane.
- scalar ALU on uniforms: s_mov_b32 copies, and s_add/min/max/and/or/xor
  combining two v_readlane results (the halves of a Wave64 reduction read
  at lanes 0 and 32); s_mov copies of a mask derived from the saved EXEC.
- v_readlane_b32 with an SGPR lane the simulation knows, lane bits masked
  to the wave size, and v_readfirstlane_b32 (the first lane EXEC holds).

A lane's own value of a VGPR from before the section moved to another
lane (DPP, v_permlane16/x16, v_readlane) was still taken as the reading
lane's own value; it is now unknown.

The lowering computes a value the simulation found no shape for, when the
steps that make it read no other lane (scalar code and loads scheduled
into the section, lane-local vector code without DPP, permutes or lane
reads/writes, and no EXEC operand), as it would outside a section: the
lanes active on entry compute it as under their own EXEC.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	crates/victory-hle/src/modules/dstorage.rs
XGameSaveCreateContainer, XGameSaveCreateUpdate and
XGameSaveInitializeProviderResult left the title's handle untouched when
they failed. The GDK documents those handles as null on failure, and
its own sample closes them on that basis ("if (containerContext)
XGameSaveCloseContainer(...)" on a variable it never initialized), so
a failed call made the title close whatever was on its stack: a heap
corruption far from the failure that caused it.

Each of the three now nulls the handle before anything can fail.
Accept XApuProcessType 2 and 3 with their documented output lengths and convert input with a portable streaming resampler. Deinterleaved input and output, PCM frame counts and pitch ramps follow the XAPU API. Add unit tests for the resampler and Windows tests for both conversion kinds.
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.
A compute shader that reads other lanes declares the console's wave
size. NVIDIA runs waves of 32 lanes only (D3D12 reports 32..32), so a
console wave64 program of that kind was refused at pipeline creation
and its dispatches were dropped without saying why.

The host's wave range (D3D12 options 1) now goes into translation as
`emit::Target`. A shader that needs a wave size the host does not run
stops there with the reason, the shader cache keys entries by the range,
and the run logs the range once with a warning when 64-lane waves are
missing. `victory translate --host-lanes 32-32` counts these shaders
without a GPU.

This is the first step towards running these programs as two 32-lane
waves on such hosts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Stack dumps (VICTORY_STACKS, diagnostics builds) read another thread's
TEB right after NtQueryInformationThread and suspended it only later: a
thread exiting in between frees its TEB, and the read faults. The
thread is now suspended first and resumed on every way out.

The dump times went through Duration::from_secs_f64, which panics on
`inf` or `1e20`, killing the dump thread (the crash hook logs it as a
crash). They are parsed by `schedule` now, which leaves out NaN and
times no Duration holds. 1 new test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Issue #23 asks for a check at startup: a host whose paging file cannot
take the 99,776 64 KiB pages (6.1 GiB) the title maps in one call on its
first boot stops the title a few seconds in, and until #51 only the bare
failure reached the log.

`xmem::commit_headroom` reads the system commit limit and what is left of
it through `K32GetPerformanceInfo`, the call `commit_limit_message` already
makes. `victory run` prints both in the startup block, next to the 6.1 GiB
the first boot asks for, and adds a line when the headroom is short.

Bug reports paste the startup block, so every one of them now carries the
host's commit state beside the build hash and the console mode.

Verified on Windows 11 x64 (AMD RX 7600), Rust 1.98.1: cargo test
--workspace 265 passed, 0 failed, 4 ignored; clippy clean on victory-hle
and victory, --all-targets; rustfmt --edition 2024 clean. The line itself
needs a title to be seen, which this host has no dump for; the numbers
behind it are covered by `commit_headroom_is_within_the_limit`.

The `PERFORMANCE_INFORMATION` initializer in `commit` is fixed here as
clippy asks, since it is the same struct and its warning was the crate's
only one.
Decouple title-written texture CopyTextureRegion recording from
command-list record time so unchanged textures are no longer DMA-copied
over PCIe on every command list every frame:

- At record time (`texture::upload`), register the texture's `Staging`
  and `Arc<HostTexture>` with the `HostList` (still skipping
  `host_written` textures and deduplicating per list) without
  transitioning to `COPY_DEST` or unconditionally recording
  `CopyTextureRegion` on the main command list.
- At submission time (`Host::execute`), `Staging::refresh()` returns
  whether title memory actually changed (including first-time upload)
  via either write-watch or blake3 hashing.
- Only when `refresh()` reports dirty contents does `HostList::prelude`
  transition the host texture to `COPY_DEST`, record `CopyTextureRegion`
  for every subresource from the staging buffer, and transition it into
  the main command list's expected initial state. Clean frames record
  zero GPU texture copies and zero redundant barriers.
- Add D3D12 WARP tests in `crates/victory-gpu/src/texture.rs` verifying
  initial upload pixel readback, zero GPU copies on unchanged subsequent
  frames (both hash-checked and `MEM_WRITE_WATCH` paths, across multiple
  and reused lists), fresh single-copy re-upload on CPU modification,
  and `host_written` protection.
pending_with runs its work (a text-entry dialog) on a thread of its own
and lets the call complete when the work returns. Canceling ends the
call at once: the call is completed with E_ABORT and its state freed,
while the work goes on. When it returned, the thread wrote the result
into the freed state and completed the block, which by then might hold
the title's next call: that call ended with the old call's result.

The thread now shares the state (an Arc) instead of borrowing it, and
completes only its own call, while it is still the block's.
A descriptor dword the code loads again alone (for an image's size bits)
was matched with the load the image op uses only when both loads read
the same base registers' values. The console compiler often builds the
table pointer {table, 0} again before the second load (a copy in other
registers, or the high half set to 0 again after the registers held
scratch), so the size load found no use and failed with "a descriptor
read only as data". Loads now also match when their traced addresses are
the same parameter and computed term a whole number of dwords apart, and
the rebuilt dwords' handle is computed from the size load's own address.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Eliminate DirectStorage kernel file-lock serialization and xmem per-chunk
TLB shootdowns during asset streaming:

- dstorage: open archive files with FILE_FLAG_OVERLAPPED and issue
  concurrent positioned overlapped reads via thread-local manual-reset
  Win32 events, handling partial reads and EOF/errors in a loop.
- dstorage: lower worker thread priority to THREAD_PRIORITY_BELOW_NORMAL,
  reuse per-worker scratch buffers (trimmed above 8 MiB), and replace
  unconditional notify_all() wakeups with targeted notify_one() and
  waiter-aware notifications.
- xmem: keep a persistent host-VA linear mapping (placed above 2^40 when
  possible) and a per-page atomic committed bitmap on each physical
  Section, so page_window and write_physical commit each page at most
  once and never call transient MapViewOfFile/UnmapViewOfFile during
  streaming (preserving Wine's whole-section SEC_COMMIT behavior).
- xmem: coalesce contiguous runs in XMemMapPhysicalPagesScatter and
  map_alias (with placeholder-boundary fallback), guard zero-length
  unmap/map calls, and drop freed sections outside the PHYSICAL lock.
- tests: add unit tests for concurrent overlapped reads, scratch
  reuse/trimming, persistent section commit/drop cleanup across bitmap
  words, and coalesced scatter/alias + zero-length operations.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSCvCZuokASx7f59sAG
How one console wave64 runs as two 32-lane host waves under our
per-lane structurisation, what has to cross halves, why exchanges need
uniform regions, how to test on a machine with both GPU kinds, and the
order of the remaining steps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`emit::host::Host::on(name)` and `VICTORY_ADAPTER` choose a hardware
adapter by part of its description, and `adapters()` lists them, so a
machine with an AMD and an NVIDIA GPU can run a test on each: the
native wave64 form as the reference on the one with 64-lane waves, the
32-lane form on the other. A new test checks on every adapter that a
wave64 program reading other lanes translates exactly when the adapter
runs 64-lane waves, and that the adapter then takes it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On a host without 64-lane waves (NVIDIA), a console wave64 compute
program whose lanes read only their own 32-lane half (DPP, ds_swizzle)
now declares WaveSize(32) instead of failing to translate. It must
read no mask whole, test no bit of a mask held as a number, have no
whole-wave sections and use no LDS. Every other wave64 program that
depends on the lane layout still stops with the reason from the
previous step. Mask ballots, wave reductions and lane-bit tests refuse
the split form as a safety net.

New GPU tests run hand-assembled programs on every hardware adapter
and check each lane against the console's layout. On an RTX 5070 the
split form is exact for 1-D groups of 32, 64 and 128 threads and for
3-D groups up to 8x8x4. A Radeon iGPU runs the same programs natively
as the reference, and a read across halves (v_readlane 40) still needs
64-lane waves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A console wave64 program that reads masks whole or lanes of the other
half now runs on a host without 64-lane waves when its group is one
console wave (64 threads or fewer, no LDS). It runs as the console
does ("console flow"):

- `structure::structure_console` never resolves mask joins from what
  the lanes arriving know (every lane arrives); `Structured::execs`
  gives each vector instruction's EXEC bit.
- Vector instructions are guarded by EXEC. Branches are the console's
  s_cbranch_*: EXEC, VCC and mask-operation SCC tests are the console
  wave's, from both halves' ballots exchanged through group-shared
  memory between group barriers, which every thread reaches since both
  halves branch alike.
- Masks read whole are the exchanged ballots. v_readlane and
  v_readfirstlane read the owning half; v_writelane, v_mbcnt and mask
  bit tests use the console lane.

The per-lane form is tried first; a program that needs the console
flow is lowered again from the console structure.

GPU tests on an RTX 5070 are exact against the console: s_bcnt1 over
both halves (64, 48 and 32 threads), v_readlane 40, an exchange inside
a branch only the lower half takes, and a loop the halves leave at
different iterations with a lane read in each. The last one shows that
the per-lane form, which hosts with 64-lane waves get, is wrong for it
(on a Radeon iGPU): noted in docs/wave64-on-wave32.md, not changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wave64 program split over two 32-lane waves took the DPP row index
from the host lane, so the upper half (console rows 2 and 3) read
row_mask bits 0 and 1. The row now comes from the console lane there.
New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only,
exact on an RTX 5070 (split) and a Radeon iGPU (native).

Found in review against #189 and #192, which both get this right.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The title's descriptor writes and texture releases reach the host at
once, from its own threads, while the host runs a submission for most of
a second in the world. A descriptor slot rewritten then dropped the
resource it held, and a released title texture dropped its host copy,
while the running submission still read them: device-removed data showed
a page fault inside a freed 1024x1024 BC7 texture, about 65 s into the
world (DXGI_ERROR_DEVICE_HUNG, RX 7600).

Those objects now go to a retired list tagged with the submission count
and are dropped when that submission has been waited for (at once if
none is running).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSD61BBk7E79WkryEQA
v_interp_p1/p2 (and the f16 forms) fed with an i or j that is not the
loaded input VGPR now evaluate each half as the hardware does: P0 + i
(P1 - P0) for the first, the old dst + j (P2 - P0) for the second, with
the vertex values read by attributeAtVertex. That needs the element
declared constant, so every other interpolation of the same attribute
row is weighed from its vertices with SV_Barycentrics of its mode, and
flat reads stay loadInput of the provoking vertex. v_interp_mov of P10
and P20 reads P1 - P0 and P2 - P0 the same way when the program also
interpolates the attribute (so the hardware holds the deltas); alone it
is still refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
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.
Direct draws expand each three-vertex rectangle into two triangles on the CPU; an indirect draw's vertex range is only known on the GPU, so those were dropped (about 256 per frame in the world). A compute shader of ours now expands every rectangle of each per-vertex buffer the pipeline reads (fourth corner v0 + v2 - v1 for the formats the CPU path knows) into a buffer the list keeps, and rewrites the draw records (vertex count and first vertex times two) into another; the draw then runs from those. Indexed rectangle lists, unaligned buffers and more than 12 elements per slot are still dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- xasync.rs & xgamesave.rs: run `pending_with` work on the shared `xasync`
  thread pool with `Arc`-owned state and a cancel guard (preventing UAF on
  cancellation and avoiding per-call OS thread creation). Offload all
  `xgamesave` `*Async` methods (`initialize_async`, `quota_async`,
  `delete_async`, `read_async`, `submit_async`) onto `xasync::pending_with`,
  snapshotting caller handles/buffers synchronously before returning `S_OK`
  and preserving strict FIFO ordering and crash-safe atomic commits.
- apu.rs: move Opus decoders and a lazily grown per-stream reusable PCM
  scratch `Vec<f32>` out of `Connection::state` into per-stream mutexes so
  decoding neither allocates 46 KiB per packet nor blocks `XApuDequeueResult`,
  `XApuGetResultCount`, or other streams.
- audio.rs: replace `HEAP` `Mutex` with `RwLock`, remove the unbounded-lifetime
  `heap_bytes` slice in favor of `Heap::slice`/`Heap::ptr` tied to a single
  read guard per `pump()` pass (preventing concurrent `ApuFree` UAF and
  eliminating per-256-byte relocking), and reuse `Voice::scratch` across XMA
  frame decodes and flushes.
- gameinput.rs & xgameui.rs: decouple `set_rumble` from `Hub::source` using
  lock-free per-pad `AtomicU64` pending rumble slots flushed by `Hub::poll`;
  track open modal `xgameui` dialogs with a RAII `DialogGuard` counter so
  `gameinput::host::focused()` suppresses keyboard/fallback-pad forwarding
  while a modal text-entry dialog is active.
- Add unit tests covering `pending_with` cancel safety, offloaded FIFO
  `xgamesave` calls, `apu` scratch reuse & lock decoupling, `audio` `RwLock`
  free-pinning & XMA scratch reuse, and `gameinput` non-blocking rumble &
  modal dialog focus suppression.
Read indirect arguments and optional countBuffer via read-only ByteAddressBuffer SRVs and write clamped active records (0..min(max, count)) into a reusable per-HostList DEFAULT-heap scratch buffer at offset 0. Prevents inactive tail slots from exhausting the per-list budget, avoids 32-bit unsigned budget wraparound, preserves full record strides, and leaves shared Shadow buffers untouched in COMMON/GENERIC_READ.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSCvCZuokASx7f59sAG
The console supplies reverb impulse responses as partitioned frequency-domain complex pairs. Decode that layout into a portable partitioned convolver so convolution streams return wet audio instead of silence. FFT/IFFT streams still return silence. Add seven unit tests for the convolver and an end-to-end test through XDspActivate and XDspSubmitCommand.
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
GFX10.3 sizes the derivatives of an image sample by its opcode (the _g16
forms hold them two per dword, each direction starting a dword) and the
coordinates and the level by a16, independently. The decoder and the
lowering took a16 to make the derivatives 16-bit too, so an a16 sample
with 32-bit derivatives had too few address dwords and read its
derivatives and coordinates from the wrong halves.

After LLVM's SITargetLowering::lowerImage where hasG16 (the opcode's
gradients are packed only for G16; "Don't compress addresses for G16"),
and its MC test gfx10_asm_mimg.s: image_sample_d ... 2D a16 has five
address dwords (four derivatives and the packed coordinates),
image_sample_d_cl ... 2D a16 six.

Tests: the decoder's address counts for image_sample_d, _d_cl, _d_g16
and _d_cl_o with a16 (5, 6, 3, 7); on the RTX 5070, image_sample_d with
a16 and 32-bit derivatives samples the level its derivatives pick at the
packed f16 coordinates. With the old sizing that case reads level 3 at
texel 0 for a lane that should read level 0.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
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 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Short of SGPRs, the console compiler spills a dword into one lane of a
VGPR (v_writelane_b32) and reloads it later with v_readlane_b32 at the
same constant lane. Lane masks are spilled like this too, and the reload
is used as a mask again (s_andn2_b64 vcc, exec, sM; s_and_saveexec;
EXEC restores; s_and + s_cselect(exec, 0) + s_cbranch_vccnz). The spill
read the mask as a number (failing with "a lane mask holding lanes
elsewhere read as data" for an else-mask), and the reload was an opaque
cross-lane read the lane-mask analysis no longer knew as that mask.

New pass sgpr_spill::forward, run after unspill (and again after jump
threading, whose renaming from registers undoes it): every read of a
reload whose VGPR lane provably holds one scalar value (through other
lanes' writes and agreeing joins, lane bits masked to the wave size, the
value available wherever the reload runs) reads that value directly, so
structure tracks the reloaded mask as the same mask. sgpr_spill::dead
names the reloads and spills nothing reads any more; lowering leaves
them out (and out of the console-lane and whole-wave-section scans).

Also:
- SCC of a scalar mask operation read as data (s_cselect on it) is
  "some lane is set": the mask's ballot is not zero, where masks may be
  read as data (compute). Was "a lane mask read as data".
- A whole-wave section ends at the EXEC write reading the saved mask
  from any register, so a forwarded reload of a spilled saved EXEC
  closes it.

Based on the spill resolution in #54 by alessiodeia.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
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.
Fixes #181.

Concurrent WARP (d3d10warp.dll) usage across threads crashes with
0xC0000005 on Windows 11, both when creating/tearing down separate
WARP devices and when compiling pipelines or executing work concurrently
on a single shared WARP device.

Keep one process-wide WARP ID3D12Device in Host::new (for explicit
warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter
has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature
creation, pipeline compilation, draws, and dispatches behind a
process-wide mutex. Hardware D3D12 devices remain unserialized.

Route diff_tests's direct CreateRootSignature calls through
Host::root_signature_bytes so they share the same serialization, and
add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws).
Calls are filed by their block's address, and a call that succeeded with
a result stays filed until XAsyncGetResult takes it. XAsyncBegin refused
any block whose address had a call filed. So when a title never took a
result and freed the block, the next block it was given at that address
could not begin a call: E_INVALIDARG, every time, with the old call's
provider never cleaned up.

A zeroed block is a new one: the block of a result left behind holds the
result's size, so it never reads zero. XAsyncBegin now ends a finished
call filed under the address of a zeroed block (its provider gets its
cleanup) and begins the new one. A call still in flight keeps its
address, and a block still holding a result is refused as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A join of registers that held a descriptor on one edge and data on
another failed the whole program ("a scalar memory read as data" or "a
descriptor read only as data"): the dwords now enter the phi as undef on
the descriptor edge. An eight-dword descriptor whose only reads are its
size bits, with no access in the program, is taken as a 2D texture for
getDimensions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The validator wants SV_Barycentrics at packing location -1. translate's
tallies now cover Interp::Weighted, Source::Fetched and Source::Lanes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Retirement now waits for both the submissions running at retire time
and KEEP_FRAMES presented frames. A dynamic table holding constants that
finds no slots drops the draw; other tables still fall back to the
title's slots. DYNAMIC grows to 1<<19 (1<<16 when the heap is capped).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
scratch_load_* and scratch_store_* were refused ("flat memory"), so any
program that keeps a local array with a dynamic index, or spills to
memory, failed to translate and its draws or dispatches were dropped.

Each lane's private memory is now an alloca of i32 in the entry block, as
DXC makes local arrays. A FLAT scratch address (a VGPR, an SGPR or
neither, plus the 12-bit signed offset) is a byte offset into the lane's
own memory: the hardware interleaves the lanes' dwords itself (RDNA 2 ISA,
"Scratch"; LLVM AMDGPUUsage, "Private Segment"; Mesa ACO uses these
instructions on GFX9+ the same way), so no lane index enters the address.
Lowered: dword x1-x4 loads and stores, ubyte/sbyte/ushort/sshort loads,
byte/short stores, and the _d16 / _d16_hi forms (one half of the VGPR
written, the other kept; stores of the high half). Loads write under the
lane guard; stores run under it.

The size comes from the code: an upper bound of every scratch address
from the instructions computing it (constants through and, shifts, adds,
multiplies, selects, bfe), plus the access width. Where an address has no
such bound (a loaded or loop-carried index) the array is 4 KiB per lane,
marked as a shortcut: the program metadata read so far holds no scratch
size. At most 64 KiB, the D3D11 limit of indexable temporaries. Accesses
past the end read 0 and drop writes; the index is checked, never wrapped.

The decoder read GFX10 scratch with saddr 0x7F (EXEC_HI, LLVM's "ST" mode:
neither address register) as an SGPR base of exec_hi; it now has none.
The bitcode writer gains alloca (INST_ALLOCA, explicit type).

Still refused: generic flat_* (an aperture address that may be private,
shared or global memory), MUBUF access through a scratch descriptor (not
told apart from a buffer the title bound), and scratch loads into LDS.

Tests (emit/scratch_tests.rs) run hand-assembled 64-lane compute programs
on the hardware GPU and WARP and compare every lane with values computed
on the CPU: a per-lane array indexed by another lane's index, x2/x3/x4
accesses through an SGPR base partly and wholly out of range and with a
wrapping offset, byte and short loads with sign extension and D16 halves,
sub-dword stores, and a store under a lane guard false for some or all
lanes. Each program also passes dxil.dll validation. Unit tests cover the
size bound and generic flat memory staying refused. On main every GPU test
fails in lower with "flat memory".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The SRV's coherency range (PR #185) is computed before the view is
rewritten; the 16-byte raw-start check stays on the in-element path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
When a program reads an image descriptor as data, descriptor_data
rebuilt word 3 from getDimensions' level count even when nothing reads
that word. vkd3d-proton turns the query into OpImageQueryLevels, and on
a 3D image inside a loop NVIDIA's Vulkan compiler crashes on it
(vkCreateComputePipelines, 0xc0000005 under Wine). Query the level
count only when word 3's register is read as data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Folds the branch's own READ thread-local into the PR's with_tiled_copy
(SCRATCH), keeping the branch's drop of one-off reads over 64 MiB and
the staging budget/eviction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The console runs a divergent loop until its last lane leaves, and each path
of a divergent branch that some lane takes, with one set of scalar
registers. After the loop or the join every lane reads the scalars the last
iteration or path left. The lowering ran scalar code per lane, so each lane
left with its own path's values: a loop's exit mask or a scalar counter read
after the loop came out as 1, 2, 3, ... across a 64-lane wave instead of 64,
with no error.

For compute programs (their host waves are the console's):
- Scalar set operations on lane masks (s_and/or/xor/andn2/orn2/nand/nor/
  xnor/not/mov) get their value as a number from their sources' numbers,
  instead of stopping with "a lane mask read as data". A mask grown inside a
  branch no longer stops with "a lane mask holding lanes elsewhere read as
  data".
- Entering the single exit block of a loop, the scalars the loop wrote and
  code after it reads take the value of the lanes with the highest iteration
  count (the loop counters LOOP_LIMIT already keeps).
- Entering a join that is not a loop header, its scalar phis take the value
  of the lanes that came the latest path in code order.

Pixel, vertex and mesh programs are unchanged: their host waves need not be
the console's, so a host wave's value could mix console waves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
create_staging keeps the branch's staging budget: it takes the kept map
(None in the PR's tests) to evict before allocating. HostTexture's
memstat bytes field is pub(crate) so the PR's tests can build one; the
PR's second tests module is renamed read_tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Already covered by PR #135's merge (DYNAMIC 1<<19, drop on unmade
table): the branch's resolution is kept. Constant tables that find no
slots drop the draw, and other tables fall back to the title's slots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
This reverts commit 86fd46978f, reversing
changes made to 0a59417b7f.
This reverts commit b0d137b0fa, reversing
changes made to cfd7736e85.
This reverts commit d803006a66, reversing
changes made to be19d0122e.
This reverts commit 8570386335, reversing
changes made to fd4b2fcc85.
This reverts commit 431f0a4db9, reversing
changes made to a75e2906b6.
This reverts commit ef71bc8b28, reversing
changes made to 231213c94a.
This reverts commit c811c22b2f, reversing
changes made to edeb2e1463.
This reverts commit d8f3a6cc98, reversing
changes made to 70137888fe.
This reverts commit 9e4752358b, reversing
changes made to aadd87a610.
This reverts commit 1d6039c399, reversing
changes made to c7deab0331.
This reverts commit b94ba80c37, reversing
changes made to b0d137b0fa.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
This reverts commit a75e2906b6, reversing
changes made to 01c3a5a9fc.
The opcode tables come from Mesa's GFX10 column, which shares opcode
numbers between GFX10.1 and GFX10.3 and keeps the older names: VOP2
0x006 and VOP3 0x140 were v_mac_legacy_f32 and v_mad_legacy_f32. On
GFX10.3 (RDNA2) those opcodes are v_fmac_legacy_f32 and
v_fma_legacy_f32, fused multiply-adds with the D3D9 rule that a zero
factor gives a zero product (AMD's RDNA2 ISA; LLVM's gfx1030 tables and
assembler tests). They were lowered as a multiply rounded on its own,
then an add.

Both are now named for RDNA2 and lowered as one FMad (the driver may
fuse it, as for v_fma_f32), unless a factor is zero, when the result
is the addend.
All guards are kept. The clamp writes into the list's scratch buffer, the
budget saturates, and its CAS loop stays bounded to 256 tries (the
branch's hang guard). A record that cannot settle runs empty. The
branch's indirect rectangle-list expansion now reads the clamped scratch
records, not the title's buffer. The null-UAV dispatch skip and the
dispatch group-limit drop are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The PR's indirect_on() gate (off unless VICTORY_INDIRECT in diagnostics
builds) is kept as a function but returns true: the branch had already
turned indirect execution on by default (35b054e) behind the clamp and
budget guards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The depth-bounds feature query moves into Host::from_device (PR #230) so
the WARP test hosts query it too. The PR's test calls execute with
&HostList (the branch's list reuse made new_list return Arc).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Brings in #159's base commit too (occlusion, statistics and timestamp
queries on the host). Query resolves use the branch's
HostList::readback(host, size), not a second readback helper. An
indirect mesh dispatch that does not run marks the list's queries
missed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The validator rebuilds ISG1/OSG1/PSG1 from the module's signature
metadata and compares bytes ("Container part 'Program Input Signature'
does not match expected for module", 29 + 25 programs). Follow DXC's
DxilProgramSignatureWriter for validator 1.6: rows sorted by register,
then name offset (element order), not by column (the row-only sort is
from PR #136's signature fixes); mask and read/write mask of unallocated
elements counted from column 0; canonical system value names; and pixel
inputs the interpretation table marks NotInSig (SV_Coverage,
SV_InnerCoverage, SV_CullPrimitive) named but not listed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
report_crashes keeps the branch's host line and first-chance breakpoint
switch inside the PR's install-once block. Both page-end tests stay
(instruction_bytes and emulation).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
A pack2 fp16 pixel input with row2 == row (attr1 row 3 mask 0x3 in the 180
pixel shaders failing with "a packed input half no element holds") is two
dwords of halves: dword 0 holds its own half2 row, dword 1 the partner, a
16-bit row of the input signature that no input entry names (row 6 there,
the gap between rows 5 and 7), as half_outputs pairs them on the vertex
side. interp() took row2 == row as "no partner", so dword 1's halves found
no element.

Ports half_inputs from upstream PR #176 ("pair packed fp16 pixel inputs
with unlisted signature rows", by Yaekai, both commits incl. its review
follow-up) onto this branch, and adds an end-to-end test that translates a
pixel program with that stage data (inputs, input_addr 4866,
db_shader_control 80) and a signature with half2 rows 3 and 6, reading
attr1.x high, attr1.y and attr1.y high through v_interp_p1ll_f16 /
v_interp_p2_f16. Without the port it fails with the same error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
xmem: the PR's Section (a persistent view and a commit bitmap) keeps the
branch's SECTION_BYTES accounting. map() keeps the branch's
multi-placeholder split and all-or-nothing behaviour; each view now
commits through Section::ensure_committed, which still goes through
commit() and its commit-limit crash report. The PR's warn_on_fail flag
is threaded through. Both sides' tests are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
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 <[email protected]>
apu: the PR's per-stream locks and reusable PCM scratch are applied to the
branch's APU, keeping its resampler, ConvertPCM and DecodeConvertOpus
streams. Both decode paths reuse the scratch.
audio: the branch's loop-skip logic now reads from the PR's scratch
buffer.
gameinput: pending rumble is a per-pad Mutex<Option<Motors>> flushed on
poll (not the PR's 2x16-bit pack), so trigger motors are kept. The
branch's trigger test polls between rumbles.
xasync: pending_with runs on the pool (PR) and completes only if the call
is still the block's (branch) and was not canceled (PR).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
A waterfall loop's descriptor is often held in VGPRs that phis join:
carried unchanged through a loop (through copies the phis do not see
through), loaded in the branches of an if/else on EXEC, or reloaded in
some passes of an outer loop. Tracing stopped there ("a descriptor read
from the first lane of a phi").

The tracer now follows VGPR phis. A phi whose arguments all come to one
dword (through other phis and v_mov copies, ignoring self-references and
VGPRs no instruction wrote on some path) is that dword. Other joins
become Source::Paths: one source per predecessor, chosen by the path each
lane takes into the block (EXEC branches are per-lane branches after
structurisation), with Source::Carried for a loop's back edge back to the
join being traced and Source::Unset for VGPRs never written on a path.
Unwritten VGPRs taken as undefined are listed in Waterfall::unset; the
lowering refuses them if the hardware loads them. Untraceable arguments
fail with their own reason (LDS read, input VGPR, ...).

Lowering gives Paths a DXIL phi of each predecessor's heap index computed
at its end (filled after all blocks for back edges), used through
createHandleFromHeap with nonUniformIndex. A per-lane descriptor loaded
under a partial EXEC (a guarded global load, as in an if/else without
s_cbranch_execz) now fails instead of giving every lane the loaded index.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The inner loop's exit runs inside the outer loop's body, and the outer
loop's next iteration reads the inner loop's final value through its
header phi. On main each lane reads its own outer times inner count
(1, 2, ... 16); with the loop exit values every lane reads the wave's 16.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
This reverts commit 5da8aaf41d.
This reverts commit 2645fcd902.
This reverts commit e1dd56bdfb.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The validator rejects a pixel shader writing SV_DepthGreaterEqual or
SV_DepthLessEqual whose SV_Position input is not noperspective centroid
or sample (14 programs). Declare it centroid, as PR #136 does, and per
sample when the program runs per sample (an SV_SampleIndex input or a
per-sample interpolation).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
DXIL wants every element packed into a row to share its interpolation
mode (45 programs rejected: TEXCOORD/NORMAL/COLOR/SV_IsFrontFace). Rows
keep the console's registers, which the host links stages by, so instead
of moving elements:

- integer pixel inputs (primitive id, array indices) are constant, like
  the front face;
- a pixel row holding a constant element (an integer, the front face, a
  provoking-vertex read) next to an interpolated read is made constant
  as a whole, its interpolations weighed from the vertices with
  SV_Barycentrics, as the attributeAtVertex path already does;
- after lowering, unread floats take their row's mode (vertex and mesh
  outputs: the mode of the row's integers); a pixel row still read two
  ways fails as unsupported rather than emitting an invalid shader.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
calculateLOD takes the texture size's dimensions only (DXC's
GetNumDimensionsForCalcLOD); an image_get_lod on a 1D or 2D array passed
its slice coordinate as well, which the validator rejects as "out of
bound coord must be undef" (3 programs). Sample and gather coordinates
already match the resource kind's coordinate count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The validator rejects a mesh shader whose vertex plus primitive outputs
(components times the 32-aligned maximum vertex or primitive count, four
bytes each) exceed 32768 bytes (53 programs): the console allows more.
The signatures link to the title's pixel shader, so rather than drop
elements, fail such programs as unsupported with a clear reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSBxDqVj9hkkx1h63yx
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Fixes 5 shader emission and DXIL container/validator issues in `victory-shader`,
raising validated shaders across the test corpus from 21,983 to 22,159 (+176;
100% of emitted VS/PS/CS shaders now validate cleanly):

1. Biased 16-bit image samples (`emit/lower.rs`):
   - Remove the `a16` rejection on `image_sample_b` and separate 32-bit prefix
     operands (offsets, bias, comparison reference) from `a16`-packed tail
     operands (gradients, coordinates, explicit LOD) starting at `regs[first]`,
     matching GFX10 MIMG hardware operand layout.

2. Conservative depth `SV_Position` interpolation (`emit/mod.rs`):
   - Declare `SV_Position` with `linear_noperspective_centroid` (5) instead of
     `linear_noperspective` (4) in pixel shaders outputting `SV_DepthLessEqual`
     or `SV_DepthGreaterEqual` (kinds 18/19).

3. Per-row interpolation mode consistency (`emit/mod.rs`, `emit/lower.rs`):
   - Add `harmonize_row_interp()` so elements sharing a signature row always
     declare the same interpolation mode: rows containing integer attributes or
     `SV_IsFrontFace` propagate `nointerpolation` (1) to sibling elements, and
     after pixel-shader lowering unread siblings inherit the actual read mode
     of sibling elements in the same row.

4. Container signature row ordering (`emit/container.rs`):
   - Sort `ISG1`/`OSG1` rows stably by register only (`row`) rather than
     `(row, col)`, preserving DXIL element-ID order within a row so the
     container signature matches DXIL validator expectations byte for byte.

5. SM 6.6 compute-shader implicit derivatives (`emit/shader.rs`, `emit/container.rs`, `emit/lower.rs`):
   - Track compute shaders emitting implicit-derivative sampling ops and emit
     `dx.valver = 1.8` with `PSVRuntimeInfo3` (52 bytes, carrying
     `EntryFunctionName`), enabling validation and D3D12 compute PSO creation.

Adds 5 unit + `dxil.dll` validation (+ D3D12 compute PSO) tests in `emit::tests`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Shader PRs 136, 163, 164, 160, 176, 193, 177, 180, 138, 139, 145, 154,
156, 157, 162, 166, 168, 169, 179, 200, 226 and 25.

#193's runtime stride table is combined with the runtime PRs:
- descriptor/host.rs keeps #135's retire-on-keep, dynamic pool and
  sampler cap, #185's Slots (made + directly indexed SRVs) and #206's
  raw fallback for structured views off their host copy's elements. The
  stride table still holds the title view's element stride: a raw view
  made by #206 starts at the same byte (raw_window never rounds), so the
  shader's index * stride + offset reads the same bytes.
- Slots #193 did not know about now write their stride: a directly
  indexed SRV (#185) when its record changes, and make_null_kind's
  typed null views (0).
- draw.rs keeps bind() returning whether it bound (with the stride table
  root SRV set inside it) and the bounded indirect argument copy.
- pipeline/host.rs keeps the per-stage subobject stream; the stride
  table root parameter merges cleanly.
- depth_bounds_test's HostShader gains stride_table: false.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
resource.rs: the Tracer keeps both the address-sum cache (sums) and the
per-lane join state (lane_joins, unset).

Includes 77eed44 (translate: tally per-lane descriptors joined by paths)
so the app's match over Source covers Paths, Carried and Unset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
- container.rs: the signature parts are written as the validator
  rebuilds them (listed elements, rows then name offsets), which keeps
  the integration's row-first order.
- lower.rs: the level-of-detail query passes lod_dims' coordinates
  (lc); the integration's spatial-count arguments did the same, so one
  implementation is kept, the tested one.
- mod.rs: the integration's PSV0 interpolation modes stay, with the
  conservative-depth centroid position both sides declare; lower's
  settle_position_mode and settle_row_modes then run on the result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
On the console v_readlane and v_writelane ignore EXEC, and a wave runs a
loop while any of its lanes does. The per-lane form runs branches and
loops per lane, so a lane that left a loop or skipped a branch is not
there to be read or written, and never sees the scalars set inside
(#225):

- a loop lane t runs t times, reading lane L in each iteration: 12 of
  32 lanes wrong in waves of 32 (RTX 5070, Radeon iGPU), 24 of 64 in
  waves of 64 (Radeon);
- v_writelane to lane 40 inside a branch only lanes below 20 take: lane
  40 was never written.

A compute program with v_readlane or v_writelane, a branch that is not
uniform, no ds_(b)permute and no whole-wave sections now runs in the
console flow on every host. Where the host runs the console's wave
size, one host wave is the console wave: ballots are the wave's own and
nothing is exchanged, so any group size and LDS are fine. A program the
console flow cannot lower keeps the per-lane form
(`Parts::per_lane_only`), so nothing that translated before is refused.

Both cases are now exact on an RTX 5070 (wave32 natively, wave64 in two
halves) and on a Radeon iGPU (both natively).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
fix/packed-half ports upstream #176, which integrate/shaders already
merged: its lower.rs is identical to the integration's, so that copy is
kept. What it adds is the end-to-end test of a pixel program whose
packed fp16 input has row2 == row (partner on the unlisted row 6).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
A waterfall loop whose lanes read their descriptors with buffer_load_dword*
(offen) through a buffer descriptor built around a table or heap address
stopped at "a descriptor read from the first lane of a buffer load". The
lane's byte address (the buffer's address plus the VGPR offset, soffset
and immediate) is traced like a global load's, and lowers to a
non-uniform heap index. Buffers of descriptors not built around a table
or heap still fail, now naming that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSCjQg3k68DgWdMwQCJ
The loop form compilers emit keeps the lanes that are done in an exit
mask that starts as 0 (s_mov_b64 s[2:3], 0; in the loop s_or_b64
s[2:3], vcc, s[2:3] and s_andn2_b64 exec, exec, s[2:3]). In the console
flow every mask join is a phi, and its incoming values had to be masks
derived from EXEC or a VALU result, so such a loop stopped with "a
lane-mask join of an untracked mask".

`Structured::others` gives the lane's bit of the other values read as
masks (constants, uniform selects, opaque ones), and the console flow's
mask joins take them. The per-lane form is unchanged.

New test: a loop in that form with a lane read in every iteration and
the exit mask counted afterwards. It was refused on an RTX 5070 before
and is exact there (in two halves) and on a Radeon iGPU now.

Found through the test report on #233 that tried #269's programs.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The FSSM root layout gives each parameter a user-data byte and an SGPR
count, and resource tracking turns them into registers with
HwStage::user_sgpr (index + 8 as u8 for merged and mesh stages) and, for
a root descriptor, that plus one. A byte of 248 or more in a merged-stage
record overflowed that add: a panic in debug builds, a wrapped register
that misattributes inputs in release. Reject, when the record is read, a
parameter whose SGPRs run past s105 (the last before VCC).
The corrupt-blob test only checked that native_programs fails, so a
check could stop firing while an earlier one caught the same bytes.
Each XDAT, XBCH, FSSM, record and stage-data refusal now has a case that
expects its own message, with the boundaries that still pass (256
VGPRs, a patch ending at the code's last dword, out-of-range entries
of other kinds).
COMPUTE_PGM_RSRC2.TIDIG_COMP_CNT is a 2-bit field, and
ComputeIo::thread_id_vgprs returned it plus one: 4 for a value of 3.
io::raise then labelled v3 as Input::ThreadIdInGroup(3), and lowering
asks DXIL's threadIdInGroup for component 3, which does not exist (the
console-lanes path quietly treats it as z instead).

A thread id has only x, y and z, so clamp the field to 2 before adding
one: v0-v2 are the thread id and v3 stays an ordinary VGPR. A unit test
covers the field at 3.
- UNORM buffer formats give exactly 1.0 for their largest value: DXIL's
  division gave 0.99999994 on AMD, which a d16 load turned into 0x3BFF.
- image_gather4_l of a 2D texture is translated now (four loads), so the
  refusal test no longer lists it.
- The depth bounds test fetches the host list again after Reset: a list
  whose host list is still referenced records on into a fresh one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Drivers create pipelines from some modules the DXIL validator refuses
(D3D12 checks only the container hash we write). The hand-assembled
split and console-flow programs now go through dxil.dll's validator
before pipeline creation, where one is installed. All of them pass.

Prompted by a report on #233 of pipelines created from modules that
fail validation.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Build B crashed in the menus about 50 s after launch: the title read an
address that was reserved but not yet committed, before commit on demand
ran. Stack A without #234 never did this, so the PR comes out until it is
proven on the RX 7600.

This reverts merge 5cd3c93.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Raising a native vertex shader loads input channel c from
Reg::V(vgpr + c), with vgpr a byte read straight from the stage data.
An input at v253 or above with a later channel enabled overflowed that
u8 add: a panic in debug builds, and in release a wrapped register that
labels a low VGPR as the attribute. Reject, when the stage data is read,
an input whose last enabled channel lies past v255.
Reverts the merges of PRs 31, 88, 96, 111, 114, 122, 132, 141, 172, 182,
183, 186, 194, 209, 216, 218, 219, 221, 224, 228, 229, 236, 237, 239, 240
and 247: audio/XMA, saves, XAsync/XTaskQueue, path and PE checks, loader
hardening and a start-up report. None of them is known to change what
the RX 7600 shows or whether the game stays up, and each is one more
thing that can break, as #234 did.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The descriptor words are placed by the load's skew on our side, so word 3 is found through the skew instead of the PR's first dword; read_as_data sits next to load_skew.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Kept our worklist liveness in bitcode.rs and gave it the new Alloca op; the scratch helpers sit beside inline_f16; the scratch test fills HostShader's stride_table.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Both sides' arms and tests kept. Waterfall loops are left out of the wave-wide scalars (each lane runs them once with its own descriptor), and a set operation's mask gets a number only where the program reads one (mask_numbers), so if/else masks take no ballots nothing reads. The spilled else-mask test now expects the unforwarded program to translate too: its number comes from the set operation's sources.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Merged cleanly.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Our div_scale/div_fmas/div_fixup arms stay before the renamed multiply-add arm.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Git matched the PR's test against two of ours; ours are kept whole and the PR's test is appended to the module.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Merged cleanly.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Already covered by the 64-bit texture atomics of #48 (which also sets the heap-atomics feature and returns the old value under the guard), so the code is ours unchanged; only the PR's test is taken, and it passes against our lowering.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Its fixes are already here (a16 biased samples from #138/#160, the centroid position under conservative depth, one interpolation mode per packed row, signature parts in the validator's order), and compute samples take quad gradients (#180) instead of validator 1.8. The code stays ours; three of the PR's tests are taken (conservative depth, signature order within a row, the a16 biased sample) and pass. Its tests of harmonize_row_interp and of dx.valver 1.8 test code that is not taken.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Our descriptor data (skewed loads, twin loads, the six faces of a cube, the level query only when word 3 is read) stays; the multisampled dimensions, their type codes and their level-less size query are taken from the PR, with its test.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Kept both sides in Lower:🆕 the instructions that decide the wave size are the live ones (dead SGPR spills through VGPR lanes do not ask for the console flow), quad derivatives count as in-half reads and numeric selects as whole-wave reads. The console and split forms of a mask ballot moved into our mask_ballot; a waterfall loop's first-lane read stays the lane's own before the console flow's arm; the wave-size checks open lower_ir; emit's threading retry passes the target on. Our tests name Target::ANY. Outside the shader crate the PR needs victory-gpu's host.rs (target()), pipeline.rs and shader_cache.rs (cache key by wave range), apps/victory main.rs and translate.rs (--host-lanes) and docs/wave64-on-wave32.md.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The code merged cleanly; git matched the PR's test against ours, so ours are kept whole and the PR's test is appended (its Parts name the target).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Our descriptor data keeps its skewed and twin loads and the runtime stride table of #193; the PR's new case (a four-dword structured buffer the program only counts the records of) joins our image-only case in the branch for descriptors nothing else uses. Parts gains psv; the PR's emit-based test helper replaces the hand-built one in valu_tests and names the target.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Already here: our store reads the dmask's channels in order and writes the others as 0 with the full write mask the validator asks of typed stores, so the code stays ours. The PR's test is taken and passes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Merged cleanly.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Taken with our rule for typed stores: the channels the opcode leaves out are written as 0 under the full write mask (the validator refuses a partial mask on a typed UAV), and a store whose offset is computed is still refused. The PR's test is appended.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:02:57 +00:00
github-bot closed this pull request 2026-11-26 04:02:57 +00:00
Author
Owner

@⁠Raxstreams on GitHub · 2026-11-24 03:20 UTC · original

Tested d3917df offline on an RTX 3080 Ti with the adapter's reported 32-lane target. I replayed 273 distinct shader containers that a previous Series S integration had failed to translate or create a pipeline for. With this PR, 90 passed both DXIL validation and host pipeline creation. Of those, 69 were ray-tracing material resolve compute shaders. The indirect-light primary shading shader 2fe078146e7045ff also passed. This verifies pipeline creation. I am still checking the visible result in the opening scene.

**@⁠Raxstreams** on GitHub · 2026-11-24 03:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/414#issuecomment-7120991259) Tested d3917df offline on an RTX 3080 Ti with the adapter's reported 32-lane target. I replayed 273 distinct shader containers that a previous Series S integration had failed to translate or create a pipeline for. With this PR, 90 passed both DXIL validation and host pipeline creation. Of those, 69 were ray-tracing material resolve compute shaders. The indirect-light primary shading shader 2fe078146e7045ff also passed. This verifies pipeline creation. I am still checking the visible result in the opening scene.

Pull request closed

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!414
No description provided.