Skip to content

Shaders: view-address table for descriptors picked by a computed index - #749

Open
Revens2 wants to merge 2 commits into
fxceless:mainfrom
Revens2:fix/issue-279
Open

Revens2 wants to merge 2 commits into
fxceless:mainfrom
Revens2:fix/issue-279

Conversation

@Revens2

@Revens2 Revens2 commented Nov 25, 2026

Copy link
Copy Markdown

Refs #279 (the pixel programs whose descriptor is "read only as data").

What is in it

  • A program that loads a buffer descriptor at an index it computes, and only uses the descriptor's address as data, was refused with "a descriptor read only as data". The host now keeps one table of the title addresses of the heap's buffer views by heap slot (SLOT_VIEWS, a root SRV like SLOT_STRIDES, 2^21 slots x 16 bytes, so +32 MiB of upload buffer per view heap). It is written where a slot is written; the lowering reads the address, length and stride from it. A computed term in a used descriptor's address takes the same table.
  • Adapted from uiliannn/VItoriaBr (GPL-3.0, this fork's licence), commits b62bbc0 and 77ad907. Found by running translate --validate on the same title pack with both trees: VItoriaBr had no "read only as data" failures, main had 40. The lower.rs, descriptor/host.rs, pipeline/host.rs, emit/mod.rs and emit/shader.rs parts apply unchanged; the draw.rs part is rewritten for the current main (it conflicted).

Tested

  • victory translate <pack> --validate, VICTORY_HOST_WAVE=32, main 8dd30ab against this branch:
main this PR
"a descriptor read only as data" 40 0
vertex and pixel programs validated 14065 14100
compute programs validated 2722 2726
mesh programs validated 8657 8657
  • Other failure classes are unchanged (195 geometry, 71 mesh >32 KB, 40 "chosen by control flow", the signature/interpolation ones, 10 hardware SGPR inputs).
  • cargo build --workspace --locked and cargo test --workspace --locked -- --test-threads=4 on this branch: 526 passed, 0 failed, 10 ignored.

Not tested

  • In game: a run on an RTX 5070 is queued behind another agent's; the result goes in a comment. The 35 programs now translate, nothing says yet that they draw correctly (no picture check).
  • Memory: +32 MiB per view heap was not measured against the 0x8007000E runs.
  • AMD, 64-lane hosts (the translation above is 32-lane only).

AI use

  • Claude Code (Claude Sonnet 5.5) found the gap, adapted the patch and ran the build, the tests and the translation comparison. The original change is uiliannn's (commits b62bbc0 and 77ad907 of their repository).

Regression run

  • none yet (see Not tested).

🤖 Generated with Claude Code

Revens2 referenced this pull request in uiliannn/VItoriaBr Nov 25, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T09:42:33.607334Z 41a3892 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b6b344b07

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/victory-shader/src/emit/lower.rs Outdated
let slot = self.s.op(c, "binary.i32", Attr::ReadNone, i32t, 40, &[slot, last]);
self.s.m.tag(slot, Tag::Clamp);
let three = self.s.m.i32(3);
let byte = self.s.m.bin(c, Bin::Shl, slot, three);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Index view records with their 16-byte stride

For a computed descriptor index above 0, this uses an 8-byte stride even though the host allocates and writes four dwords (16 bytes) per slot. The four-component load therefore reads overlapping records instead of the selected slot, so shader code can use a bogus address when walking the buffer. Shift by 4, or otherwise match the host writer's 16-byte entry size.

Useful? React with 👍 / 👎.

Comment thread crates/victory-shader/src/emit/lower.rs Outdated
self.as_int(stride),
);
let off = a.offset as i32;
let (lo, hi) = self.address_plus(lo, hi, off);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not add the table byte offset to the loaded view address

When the s_load address has a nonzero root-relative descriptor-table offset, heap_index has already used that address to select the absolute heap slot read from SLOT_VIEWS; a.offset is part of the descriptor-table address, not an offset into the selected buffer. Adding it here shifts the returned title pointer (for example, an entry at byte offset 32 yields its buffer address plus 32), so address-based walkers can read unrelated bytes. Leave the fetched address unchanged.

Useful? React with 👍 / 👎.

@ArturoWolff

Copy link
Copy Markdown

Linux offline comparison for the 64-lane question, with a 32-lane control. I built the translator separately at main 8dd30ab, #738 ea40c9a, and this PR 9b6b344. Same hash-checked inputs, direct emit::translate, no shared shader cache; set_host_max_wave(32) and then (64). These are compiler settings, not a test on AMD hardware.

The useful next check for the new pixel shaders is a readback with distinguishable buffer addresses at nonzero descriptor indices and a nonzero table offset. dxv acceptance cannot resolve the stride/offset review findings. No retail launch, GPU execution, or change in visible pixels measured here.

AI-assisted: Hermes Agent ran the local comparisons and validator, checked the byte equality, and wrote this comment on ArturoWolff’s behalf.

@Revens2

Revens2 commented Nov 25, 2026

Copy link
Copy Markdown
Author

In-game check (RTX 5070 12 GB, driver 32.0.16.2124, Series X profile, VICTORY_RELAY=2, same key script, 420 s, release build; another agent's game was running alongside in the first run):

tree run result
main 8dd30ab 1 ran 420 s, 3 fps (338-340 ms/frame, ~4,950 draws/frame), 0 device removed
this PR 1 title access violation (0xC0000005) at t=181 s during loading, 0 device removed
this PR 2 ran 420 s, 4 fps (247 ms/frame, ~5,000 draws/frame), 0 device removed
this PR 3 ran 420 s, 3 fps (321 ms/frame, ~4,800 draws/frame), 0 device removed

The 7 refused compute pipelines ("Paramètre incorrect") appear on main too. One crash in three on the branch against one run on main is too few to say whether the PR changes crash odds (0xC0000005 during loading is already reported in #416/#453); the fps difference is within run-to-run spread. Not checked: any picture difference for the 35 programs that now translate.

A program that loads a buffer descriptor at an index it computes, and only
uses the descriptor's address as data, found no root view to ask and was
refused ("a descriptor read only as data"). The host now keeps one table of
the title addresses of the heap's buffer views by heap slot (SLOT_VIEWS, a
root SRV like SLOT_STRIDES, 2^21 slots x 16 bytes), filled where a slot is
written, and the lowering reads the address, length and stride from it.
A computed term in a used descriptor's address takes the same table.

Adapted from uiliannn/VItoriaBr commits b62bbc0 and 77ad907 (GPL-3.0, the
fork's own licence); the draw.rs part is rewritten for the current main,
the rest applies unchanged.

Co-authored-by: uiliannn <uiliaannn@gmail.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…dress

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Revens2

Revens2 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Thanks for the review. Both findings are fixed in 41a3892, and the branch is rebased on main a26859f.

  • P1 (stride): the host writes four dwords (16 bytes) per slot. The shader now indexes the SLOT_VIEWS table by a shift of 4. The shift comes from a shared constant, SLOT_VIEWS_RECORD_BYTES = 16, which the host allocation also uses. The SLOT_VIEWS doc comment said "two dwords per slot" and is corrected.
  • P2 (offset): view_address_indexed no longer adds the table byte offset to the loaded address. That offset is already part of the slot index, so the address read from the table is returned unchanged.

Tests: cargo build --workspace --locked is clean. cargo test --workspace --locked -- --test-threads=4 gives 535 passed, 0 failed, 10 ignored. Two new unit tests, one per finding: the record stride is 16 and the shift matches it, and view_address_indexed does not offset the loaded address.

The P2 test is a source check on the function body (no address_plus call). It is not a readback. As @ArturoWolff noted, a readback with nonzero descriptor indices and a nonzero table offset is the check that settles this. No in-game run yet, so that stays "not tested".

@ArturoWolff

Copy link
Copy Markdown

I checked the nonzero-index/nonzero-offset case against 41a3892 and its direct parent a1855ac. The emitted shader selects the intended record and returns its address unchanged on 41a3892. This is a CPU interpretation of the DXIL, not a device readback. Both versions pass dxv, so validation alone would miss the difference.

The same synthetic one-thread compute shader used a table base of 32 bytes, dynamic index 4, and immediate table offset 32 bytes (expected slot 6). Eight 16-byte host records had distinct addresses and stride tags. The shader returned the address and tag; it did not dereference the address.

Revision Table read Selected record (tag) Record address → shader output
a1855ac byte 48 3 (16) 0x280 → 0x2a0
41a3892 byte 96 6 (28) 0x400 → 0x400

The tag identifies the record independently of the returned address: the parent both selected the wrong record and added 32 after loading it. Neither error occurred on your fix. Unlike my earlier puddle-shader translation comparison, this checks the values produced by the emitted operations. The isolated lavapipe attempt timed out during initialization, before dispatch; actual host binding, device output, and in-game pixels remain unverified.

AI disclosure: Hermes Agent built the synthetic fixture, validated the DXIL, reran the CPU/IR comparison, and wrote this follow-up on ArturoWolff’s behalf.

e4glevlr pushed a commit to e4glevlr/victory-fork that referenced this pull request Nov 25, 2026
…ograms

Ported in part from ea40c9a (fxceless#738).

A mask that holds lanes outside EXEC where it is written is the ballot
of every lane where every lane of the wave runs that block. That was
known only for two exchanging host waves; a native compute program's
wave is the console's, so its lane branches (all_lane_blocks) tell too.
A compute program refused with MASK_ELSEWHERE is now retried wide, as
one refused with LANE_MASK is.

Port notes: only the mask part of fxceless#738 is taken. Its buffer-address
table (SLOT_VIEW_ADDRESSES, t252) does what fxceless#749's SLOT_VIEWS does, which
this branch has, and t252 is this fork's SLOT_VIEW_MARKS.
e4glevlr added a commit to e4glevlr/victory-fork that referenced this pull request Nov 25, 2026
…s its address from SLOT_VIEWS

fxceless#738's case (the ray-tracing shadow-mask programs), which fxceless#749's view
table covers on this branch.

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

Revens2 commented Nov 25, 2026

Copy link
Copy Markdown
Author

@ArturoWolff thanks for checking the emitted DXIL on 41a3892 and for pinning the bad parent (a1855ac). The in-game and device-readback side is still unverified on our end; we will report a run on this head when the queue reaches it.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41a3892c9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

l.SetGraphicsRootShaderResourceView(param, gpu);
}
},
None => once!("a shader reads view addresses of a heap that is not set"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Drop draws when the view-address table is unavailable

If the 32 MiB views upload allocation fails, HostHeap::new leaves views unset and heap_views returns None. This arm only warns and continues, so the draw or dispatch still runs without a valid SLOT_VIEWS root SRV; the shader's raw loads then read zero or undefined addresses. Refuse the submission when this required table cannot be bound.

Useful? React with 👍 / 👎.

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.

2 participants