Skip to content

Review: everything Scarlight adds on top of VIctory so far - #2

Closed
pablogonz12 wants to merge 109 commits into
review/upstream-basefrom
review/scarlight-so-far
Closed

pablogonz12 wants to merge 109 commits into
review/upstream-basefrom
review/scarlight-so-far

Conversation

@pablogonz12

Copy link
Copy Markdown
Owner

Retroactive review. These commits went to main directly before main required PRs. Base = the VIctory commit Scarlight branched from; head = main as of today. Contents: tested open VIctory PRs merged with credit (see INTEGRATION.md), our descriptor-as-data fix, neutral naming. Not meant to be merged; it exists so CodeRabbit reviews the whole difference. Follow-up fixes from the review go in as normal PRs to main.

TG0000 and others added 30 commits November 24, 2026 01:39
Co-Authored-By: GPT 6.2 Sol <noreply@openai.com>
The clamp was HLSL compiled at run time by the system's D3DCompile. Wine's
d3dcompiler_47 rejects it (no Load on RWByteAddressBuffer, no store to a
structured buffer, and the RootSignature attribute is ignored), so under
Wine and Proton clamp() failed and every indirect execution was dropped.

The same shader is now emitted as DXIL by the shader crate
(emit::clamp::argument_clamp) and its root signature is made from a
description, so no shader compiler is needed on any host. For that the
shader builder learns root UAVs (raw buffers), beside root CBVs and SRVs.

Two GPU tests run the clamp over records of each kind and compare with
the bounds written out in Rust, and check that records past the list's
budget run empty.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
With a16 the address VGPRs were read as one run of 16-bit pairs. The
hardware (and image_addr_dwords, which counts them) gives each extra word
(texel offsets, bias, comparison value) a whole VGPR, pads each direction
of an odd number of gradients to whole VGPRs and begins the coordinates
in a new VGPR. image_address_place now places each address that way, so
a16 biased samples translate (the bias is the f16 in its word's low half)
and a16 gathers with an offset word read their coordinates from the right
VGPR.

image_sample_d_cl lowers to sampleGrad with the clamp that follows the
coordinates.

In a census of the title's shaders these stopped 108 ("a biased image
sample with 16-bit coordinates") and 27 (image_sample_d_cl) programs.
…a reasons

- ds_read_{u,i}{8,16}, ds_write_b{8,16} and their _d16/_d16_hi forms
  read and write within their dword: reads shift and zero- or
  sign-extend (d16 keeps the VGPR's other half), writes clear then set
  their bits with two atomics so lanes writing other bytes of the same
  dword keep theirs.
- image_sample_o, image_sample_lz_o and image_sample_l_o pass a constant
  offset word as the sample's immediate offsets (each 6-bit offset
  within -8..7; a computed word or a wider offset stops the program with
  its own reason). image_sample_l(_o) reads its level after the extra
  words.
- A buffer descriptor read as data and by s_buffer_load is sized from
  its raw SRV. The other ways a scalar memory read as data stops now
  have their own reasons, to tell apart the 573 programs a census of
  the title stopped with "a scalar memory read as data".

Tests: LDS byte/half reads and writes run on the hardware device (one
wave with LDS takes the console's wave size, which WARP lacks); a new
image_tests module samples a 4x4 texture on hardware and WARP with
offsets, an a16 extra word, and gradients with a clamp.
… views from the journal

A submission's refreshes of one host copy were merged into the single
range covering them all. Two small ranges at the low and high ends of a
big shared buffer then had the whole untouched middle asked for written
pages (and its stale pages copied). The batch now keeps each copy's ranges
and merges only those whose 64 KiB pages overlap or touch, at the flush.

`watch::writes` for guarded memory asks the kernel first, which fails for
views, and then `guard` queries the view. When every block of the range
is already guarded and clean, nothing was written there: the journal
answers without either system call. `JOURNAL` is still taken before
`GUARDS`; nothing takes them the other way round.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

SV_Barycentrics is left unpacked (no row, packing location -1), like
other non-packed system values: the DXIL validator refuses it in a row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
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.

The translate command's tally counts Interp::Weighted as interpolated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Allow an incoming raw barycentric value to remain undefined only when an unguarded indexed move is proven to initialize the register before any use. Preserve the loop-carried register and reject incomplete or ambiguous initialization.

Refs: #97
…ld 1.0.2.1)

The title ends the process on purpose when its main thread has not advanced
for about 30 one-second ticks (a write to address 0 at +0x23cf683, with a
second one at +0x2215c35 right after the handler call). On a host much slower
than the console a long load can exceed that window.

With VICTORY_NO_WATCHDOG=1 the loader jumps over the abort site and makes the
handler's fault a NOP. Each patch is applied only if the original BLAKE3
starts with the 1.0.2.1 identity and the exact original bytes are at the
offset; otherwise it logs a warning and does nothing. Off by default.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A root SRV is a bare GPU address: nothing bounds what a shader reads
through it. Vertex fetch reads its stream through a root SRV with no
record limit, and a mesh shader read past the end of the buffer's host
copy into memory the host had already freed (the "inside freed texture"
device removal after the fix for #59: the fault lay just past the copy's
end, in the gap where released textures had been).

Each root SRV is now a one-descriptor table holding a raw view of the
host copy from the root address to the copy's end, made once per address
per list in the heap's dynamic slots; reads past the end return zero, as
for any bounded view. A root SRV the title did not set, or one with no
host copy, gets a null raw view (an unset table is undefined). Addresses
not on 16 bytes, which a raw view cannot start at, read zeros and are
logged once. VICTORY_ROOT_SRV_DIRECT=1 restores root descriptors.
ds_read_{u8,i8,u16,i16} and ds_write_{b8,b16} were refused ("an LDS
read/write of bytes or halves"), with their _d16/_d16_hi forms. LDS is
an array of dwords here; such an access now works on the dword holding
it, at bit 8 * (address & 3):

- reads shift and mask, or sign-extend the i8/i16 forms; _d16 fills the
  register's low half (_d16_hi its high half) and keeps the other;
- writes clear the bits with an atomic and, then set them with an
  atomic or, so lanes writing other bytes of the same dword keep
  theirs; _d16_hi takes the data's high half.

translate --validate on shaders.rpf: compute 1670 -> 1686 validated;
both errors are gone from the list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A diagnostics switch for 32-lane hosts: VICTORY_SKIP_WAVE64=mesh,compute
drops draws and dispatches whose pipeline has a program of a listed stage
written for 64-lane waves, so testers can tell whether those programs
cause a GPU hang without listing shader hashes one by one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… black frame

Four diagnostics-build switches:
- VICTORY_PRODUCERS=1: when a draw or dispatch is dropped, keep what it would
  have written (its table UAVs, resolved from the console shader's own
  used-resource list, and its render targets); forget a range when work that runs
  writes it; log once per pair a running draw that reads one: reader, dropped
  writer, what. Points at the shaders a stalled pass waits on.
- VICTORY_SHOW_TARGET=<n>|busiest: present the frame's n-th written target, or
  the busiest 16:9 colour target (a G-buffer layer in the world), instead of the
  title's picture; target lists are logged at power-of-two frames.
- VICTORY_CAPTURE_BUSY=<draws>[,<count>]: capture (and with VICTORY_DUMP_TARGETS
  dump) the frame after one that ran more than <draws> draws: world frames,
  whose numbers vary run to run.
- VICTORY_DUMP_FAILED=<dir>: keep each shader that does not translate, for
  victory shader-info --disasm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t signature

The diagnostics build stopped with E0061: one call still passed a slice of
planes. Reported by LAKSHYA-cmd-tech and fuzeofficlal in review.

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

A buffer read whose element stride is not known at translation takes a
raw handle and a byte offset from the runtime stride table. The handle
was of the slot the title's view is in, and a raw handle over a
structured or typed view is undefined in D3D12: for the load of
[index 2, offset 4] an RTX 5070 reads dword 21 of a structured view of
12 bytes (dword 7 asked for) and dword 36 of one of 16 bytes or a typed
RGBA32F one (dword 9 asked for), where a Radeon and WARP read the bytes
asked for. No handle of another kind is right everywhere either: with a
structured handle whose declared stride differs from the view's, the RTX
5070 addresses by the view's stride and the Radeon and WARP by the
declared one.

The table's entry per slot is now a StrideEntry of two dwords: the
stride, and the heap slot holding a raw view of the bytes the slot's
view reads (none: the slot's own view is raw), with the bytes from that
raw view's start to the view's first byte (raw views start on 16 bytes
on the host). The shader reads, stores and runs atomics through a raw
handle of the slot named, so the handle's kind always matches the view.
RawWindow gives the host the raw view for a byte range.

The GPU side writes the new entries without raw slots yet, which reads
as before.

The test binds raw, structured (12, 16, 20 bytes) and typed (RGBA32F,
R32_UINT) views, as shader views for the load and as unordered access
views for the store and the atomics, with their raw views beside them,
on the hardware adapter and WARP; a second one takes the descriptor
from a join of two loads.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The programs that read a buffer without a known stride pick its heap
slot at run time, so the runtime stride table has to be looked up by the
slot the shader computes, and the view in it can differ from one thread
group to the next.

A new test loads the heap slot from a buffer per thread group (a scalar
load whose offset is the loaded value), with a structured view of 12
bytes in one slot and one of 16 bytes in the other: the four lanes of
each group read the bytes of the view their group chose, in one dispatch
and again with the choice swapped. A lane reading past the three
elements of the first view reads zero, not the buffer's next bytes.

The test host's raw views now cover a window of the buffer (as
RawWindow gives the host for a view's elements) rather than all of it,
which is what ends the read there; the view kinds test takes its raw
views and entries from the same function, with views starting 4 and 12
bytes into their raw views.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ide reads

A shader that reads a buffer without knowing its stride takes a raw
handle of the slot the runtime stride table names. The host heap now
makes that slot: when it makes a structured or typed buffer view (for a
shader or for unordered access), it also makes a raw view of the same
bytes of the same host copy in a pool of 65,536 slots after the dynamic
ones, and writes the slot, the stride and the bytes from the raw view's
start to the view's first byte (raw views start on 16 bytes) into the
slot's entry. A raw view keeps its own slot. The raw view ends with the
view's last element, so reads past it give zeros.

The entry and the raw view are written wherever the slot's descriptor
is (tables made for a draw, title slots a draw reads through a table,
slots made null), so they are as current as the descriptor; a slot made
again reuses its raw view slot, and one made null, raw or constant, or
a dynamic slot given back, returns it to the pool. Views the host
cannot make raw (starting off a dword of the copy, or with the pool
full) point at a null raw view and are logged once.

The test makes placed structured, typed and raw views in a host heap
and runs the translated program of victory-shader's run-time slot test
on it: each thread group reads the bytes of the view in the slot it
chose, zeros past the view's end, and the new view's bytes after the
slots are made again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A 16-bit LDS access at byte 3 of a dword was taken as aligned: a read
returned only the dword's last byte (Dathinel's readback on #571:
0x0082 for the reference 0x9882) and a write would have lost its high
byte. The next dword now joins in, as native RDNA2 reads an odd-address
ds_read_u16: reads shift the two dwords as one 64-bit value, writes
clear and set bits in both (no-ops on the next dword when nothing
straddles). The next index is clamped to the last LDS dword.

translate --validate on shaders.rpf unchanged (compute 1686 validated
with this PR).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main moved under #193 and this branch. One conflict, in
HostHeap::new (descriptor/host.rs): #336 tries the heap with DYNAMIC
dynamic slots, then with MIN_DYNAMIC, then capped, and records the range it
got in `dynamic`; this branch puts ALIASES raw-view slots after the dynamic
ones. Both kept: each attempt asks for the alias slots too, the capped
count leaves room for them, the lease bitmap has `extra` entries as on
main, and `alias_base` stays `count + extra`. A merge rather than a rebase
so #193's commits keep their ids.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…clamps, and non-multiple-of-4 stride refusal
main now has CI (clippy with -D warnings, then the workspace's tests). No
conflict; both of CI's clippy commands are clean on the result.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
#193 moved: buffer views are clamped to what is left of the host copy, a
shader that reads the stride table without a host view heap is not run,
and a known stride that is no multiple of four is refused. Conflicts were
with main, not with this branch's change: `bind` already returns whether
the draw may run (#336), with its doc comment and the dropped counter, and
main already renamed the second test module in host.rs. main's side kept
in all three; #193's `return false` in the stride-table branch is in.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
`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 <noreply@anthropic.com>
pablogonz12 and others added 26 commits November 24, 2026 12:23
…descriptor data

# Conflicts:
#	crates/victory-shader/src/emit/lower.rs
#	crates/victory-shader/src/emit/mod.rs
#	crates/victory-shader/src/emit/valu_tests.rs
The three tests in emit/mod.rs that dispatch through `hosts()` ran
without `valu_tests::ONE_AT_A_TIME`, so with WARP they could dispatch
at the same time as another module's GPU test. Two GPU tests at once on
WARP can end the test process with an access violation; that is how
the shader test process died with 0xc0000005 on CI for 505d5b1.

Locally, `VICTORY_WARP=1 cargo test -p victory-shader --lib` at the
default thread count crashed 2 of 4 runs without this change, and
passed 6 of 6 with it.

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

Programs that fetch a descriptor-table entry and only copy its dwords out
as numbers (no image/buffer/scalar-buffer access) were refused with 'a
descriptor read only as data'. They now get a raw view: dword 2 is the
record count from the host view's size, the others are zero.

Offline: 816 of 820 such programs translate; world shader set 681 -> 684
of 751; 1,500 translations valid SPIR-V (dxil-spirv master, spirv-val).
Written with an AI assistant.
…ents and docs

Based on VIctory (GPL-3.0), history and credits kept. Internal names (victory-* crates,
binary, env vars) unchanged so upstream fixes keep merging.
…ecks -35% per world frame on RX 9070 XT/Wine (2 runs each)
# Conflicts:
#	crates/victory-gpu/src/draw.rs
#	crates/victory-gpu/src/pipeline/host.rs
#	crates/victory-shader/src/emit/lower.rs
#	crates/victory-shader/src/emit/shader.rs
…er stride; world shaders 684 -> 692 of 751
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4dbccf16-36b3-4a61-90f5-909d54da471e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@pablogonz12

Copy link
Copy Markdown
Owner Author

Superseded by the unified core (#88); branch kept for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.