Shader: table reads the code computes mark their heap slots #2820

Open
kais7654 wants to merge 1 commit from upstream-pr/2822 into main
kais7654 commented 2026-11-25 21:29:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-25T21:29:39Z.


A texture at a slot a computed table entry names — the program walks a table at
an offset it computes (a dynamic term in the descriptor's address, or a waterfall
loop's per-lane entry) — kept no read mark: only the reads of the resource heap
itself did. Lowering marked texture_reads for heap-direct sources
(is_heap_direct) and left every table read to the host, which makes the slot for
a fixed entry (the draw's table ranges) but nothing for a computed one — the
placed texture at that slot stays null forever. Fixes #2722 (the issue's analysis
of handle, in emit/lower.rs, names the exact seam — found by reading the code;
the issue author's analysis was assisted by Claude Code).

The gate is now marks_its_reads: a source marks its reads when it is heap-direct,
or when a loaded/fetched leaf's address comes from a Table root and is
computed — dynamic.is_some(), or the load is a waterfall loop's per-lane read
(waterfall::loads). A table read at a fixed offset still marks nothing, for the
draw makes that slot; a computed one lowers its runtime heap index (the index
heap_index already produces for the handle) and marks that, which the host
already materializes from the marks.

Tests: table_texture_reads_at_an_offset_the_code_computes_mark_their_slot
(emit) — a synthetic GFX10 compute program reads a texture through a table at a
fixed offset (marks nothing, as before) and through a table whose offset the code
adds (s_or_b32 s20, s4, 0; s_add_u32 s6, s4, s20, then s_load the descriptor
from s[6:7]): the lowered shader now carries the read mark, DXIL-valid.

  • cargo test -p victory-shader (minus the known #2317 machine failures — gather/
    stride and the device heap_direct_texture_reads AV, reproduced on a clean
    tree): 260 passed, 0 failed.
  • cargo clippy --workspace --all-targets --locked, and with --all-features:
    0 warnings, both.
  • Merge-tree: clean vs 13f91ca (touches only emit/lower.rs and
    emit/memory_tests.rs; #2679's conflicts live in resource.rs, untouched here).

Generated with Mistral Vibe.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6614130442 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2822). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-25T21:29:39Z. --- A texture at a slot a **computed table entry names** — the program walks a table at an offset it computes (a dynamic term in the descriptor's address, or a waterfall loop's per-lane entry) — kept no read mark: only the reads of the resource heap itself did. Lowering marked `texture_reads` for heap-direct sources (`is_heap_direct`) and left every table read to the host, which makes the slot for a **fixed** entry (the draw's table ranges) but nothing for a computed one — the placed texture at that slot stays null forever. Fixes #2722 (the issue's analysis of `handle`, in `emit/lower.rs`, names the exact seam — found by reading the code; the issue author's analysis was assisted by Claude Code). The gate is now `marks_its_reads`: a source marks its reads when it is heap-direct, **or** when a loaded/fetched leaf's address comes from a `Table` root and is computed — `dynamic.is_some()`, or the load is a waterfall loop's per-lane read (`waterfall::loads`). A table read at a fixed offset still marks nothing, for the draw makes that slot; a computed one lowers its runtime heap index (the index `heap_index` already produces for the handle) and marks that, which the host already materializes from the marks. Tests: `table_texture_reads_at_an_offset_the_code_computes_mark_their_slot` (emit) — a synthetic GFX10 compute program reads a texture through a table at a fixed offset (marks nothing, as before) and through a table whose offset the code adds (`s_or_b32 s20, s4, 0; s_add_u32 s6, s4, s20`, then `s_load` the descriptor from `s[6:7]`): the lowered shader now carries the read mark, DXIL-valid. - `cargo test -p victory-shader` (minus the known #2317 machine failures — gather/ stride and the device `heap_direct_texture_reads` AV, reproduced on a clean tree): **260 passed, 0 failed**. - `cargo clippy --workspace --all-targets --locked`, and with `--all-features`: 0 warnings, both. - Merge-tree: clean vs `13f91ca` (touches only `emit/lower.rs` and `emit/memory_tests.rs`; #2679's conflicts live in `resource.rs`, untouched here). Generated with Mistral Vibe.
kotekompotek commented 2026-11-25 22:04:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:57:58Z.

Review: COMMENTED


Right fix for the null-placed-texture gap: a fixed-offset table read is named by the draw's table ranges so the host makes that slot — but a dynamic offset or waterfall per-lane entry has no host-visible name, so it must go through Read marks like a heap-direct read. marks_its_reads keeps the fixed case unmarked (marking would cost without adding info) and the s_load-a-dynamic-term test covers both sides. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065552333 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2822#pullrequestreview-6065552333). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T21:57:58Z. **Review:** COMMENTED --- Right fix for the null-placed-texture gap: a fixed-offset table read is named by the draw's table ranges so the host makes that slot — but a dynamic offset or waterfall per-lane entry has no host-visible name, so it must go through Read marks like a heap-direct read. marks_its_reads keeps the fixed case unmarked (marking would cost without adding info) and the s_load-a-dynamic-term test covers both sides. LGTM.
fuzeofficlal commented 2026-11-25 22:04:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:40:56Z.


Verified 03914d9d on Windows 11 (RTX 5090 + WARP + Windows SDK 10.0.26100.0 dxil.dll):

  • cargo xtask policy: 184 files ok; cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --features host): 0 warnings.
  • emit::memory_tests::table_texture_reads_at_an_offset_the_code_computes_mark_their_slot: passed (with dxil.dll validation); remaining emit::memory_tests (4/4), emit::waterfall_tests (5/5), and emit::lower::tests (27/27) all passed.
  • Code review: marks_its_reads cleanly extends read-mark emission to RootType::Table leaves when a.dynamic.is_some() or the load is in waterfall.loads, while keeping fixed-offset table reads unmarked.
  • Clean git merge-tree against origin/main 13f91ca, #2783, #2816, and #2668 (complementary with #2668, which guards mark_view_read under per-lane EXEC).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7175401697 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2822#issuecomment-7175401697). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:40:56Z. --- Verified `03914d9d` on Windows 11 (RTX 5090 + WARP + Windows SDK `10.0.26100.0` `dxil.dll`): - `cargo xtask policy`: 184 files ok; `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--features host`): 0 warnings. - `emit::memory_tests::table_texture_reads_at_an_offset_the_code_computes_mark_their_slot`: passed (with `dxil.dll` validation); remaining `emit::memory_tests` (4/4), `emit::waterfall_tests` (5/5), and `emit::lower::tests` (27/27) all passed. - Code review: `marks_its_reads` cleanly extends read-mark emission to `RootType::Table` leaves when `a.dynamic.is_some()` or the load is in `waterfall.loads`, while keeping fixed-offset table reads unmarked. - Clean `git merge-tree` against `origin/main` `13f91ca`, #2783, #2816, and #2668 (complementary with #2668, which guards `mark_view_read` under per-lane EXEC).
Marvisak commented 2026-11-26 00:03:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:14:46Z.


Automated triage for the maintainers.

This PR no longer merges cleanly into main: it conflicts in crates/victory-shader/src/emit/memory_tests.rs. Its content will be reviewed once it is rebased onto current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177308873 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2822#issuecomment-7177308873). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:14:46Z. --- <!-- victory-triage v1 head=03914d9de5c469f1a95cb65176a23ea22e5652be verdict=needs-rebase at=2026-11-25T23:13:52Z --> Automated triage for the maintainers. This PR no longer merges cleanly into `main`: it conflicts in `crates/victory-shader/src/emit/memory_tests.rs`. Its content will be reviewed once it is rebased onto current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
futurepro62 commented 2026-11-26 00:03:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-25T23:31:05Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 03914d9 (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: table_texture_reads_at_an_offset_the_code_computes_mark_their_slot.
  • The new test sits next to heap_direct_texture_reads_mark_their_heap_index (#2571), so I also ran that one unskipped at this head: it still ends the victory-shader process with 0xc0000005 (3 of 3 runs), as on main. This PR doesn't change it.
  • --skip leaves out tests that fail on main 842b0cb on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7177671677 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2822#issuecomment-7177671677). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-25T23:31:05Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `03914d9` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **774 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `table_texture_reads_at_an_offset_the_code_computes_mark_their_slot`. - The new test sits next to `heap_direct_texture_reads_mark_their_heap_index` (#2571), so I also ran that one unskipped at this head: it still ends the `victory-shader` process with `0xc0000005` (3 of 3 runs), as on main. This PR doesn't change it. - `--skip` leaves out tests that fail on main `842b0cb` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2822:upstream-pr/2822'
git switch 'upstream-pr/2822'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2822'
git switch 'upstream-pr/2822'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2822'
git switch 'upstream-pr/2822'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2822'
git switch 'main'
git merge --squash 'upstream-pr/2822'
git switch 'main'
git merge --ff-only 'upstream-pr/2822'
git switch 'main'
git merge 'upstream-pr/2822'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2820
No description provided.