Draw: a table UAV a shader's buffer stores do not name is not written back #3066

Closed
opened 2026-11-29 19:53:19 +00:00 by github-bot · 4 comments
Owner

@⁠Adriwin06 on GitHub · 2026-11-29 19:52 UTC · original

What it changes

A bound table's buffer UAVs were all taken as written whenever the
stage could store to buffers at all, so every one of them was marked
for write-back. The pipeline now works out which used buffer
descriptors a store or atomic names (from the instruction's rsrc / SMEM
base SGPR, when it is known), TablePlan keeps one written flag per
table entry, and a binding is marked written (BINDING_WRITES) only if
one of its stores can reach it. A store whose descriptor is not known
still marks every entry, as before.

Ported from uiliannn/VItoriaBr@6d97bea, GPL-3.0-or-later.

How it was tested

  • GPU and profile: RTX 4070 SUPER, Ryzen 7 5800X. Not measured in the title on these commits by themselves: they come from a fork of mine that carries them with the rest of this set, and the title ran there. What is below is the unit tests on this branch.
  • Before: n/a (no in-title measurement on this branch)
  • After: n/a
  • cargo test passed for the crates it touches:
    • this change: yes, cargo test -p victory-gpu --lib -- draw:: pipeline::: 95 passed
  • cargo clippy --workspace --all-targets --locked: no finding that main does not already have (main has 34 of its own, which is why the Clippy step of CI is red on main itself).
  • cargo xtask policy: no new finding (main fails it on crates/victory-loader/src/heap_sites/frame_users.rs).
  • With all eleven of my pull requests merged together: cargo clippy also with --all-features adds no finding, and cargo test --workspace --locked fails only tests main also fails on this machine: the five shader tests that fail on main here too (WARP's SM 6.2 and the validator) (barycentric_tests::first_half_values_render_on_hardware_and_warp, hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, rect::tests::rectangles_are_drawn_whole, rect::tests::the_rectangle_stage_is_a_geometry_shader) and xtask's repository_passes_policy (frame_users.rs). 2208 passed, including five that fail on main (three BCPack oracle tests, the menu save race, the shader key test).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related:
    None found for per-descriptor UAV write-back.

🤖 Generated with Claude Code

Pull request details or commits were not available from GitHub; kept as an issue.

**@⁠Adriwin06** on GitHub · 2026-11-29 19:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3066) ## What it changes A bound table's buffer UAVs were all taken as written whenever the stage could store to buffers at all, so every one of them was marked for write-back. The pipeline now works out which `used` buffer descriptors a store or atomic names (from the instruction's rsrc / SMEM base SGPR, when it is known), TablePlan keeps one `written` flag per table entry, and a binding is marked written (BINDING_WRITES) only if one of its stores can reach it. A store whose descriptor is not known still marks every entry, as before. Ported from uiliannn/VItoriaBr@6d97bea, GPL-3.0-or-later. ## How it was tested - GPU and profile: RTX 4070 SUPER, Ryzen 7 5800X. Not measured in the title on these commits by themselves: they come from a fork of mine that carries them with the rest of this set, and the title ran there. What is below is the unit tests on this branch. - Before: n/a (no in-title measurement on this branch) - After: n/a - `cargo test` passed for the crates it touches: - this change: yes, `cargo test -p victory-gpu --lib -- draw:: pipeline::`: 95 passed - `cargo clippy --workspace --all-targets --locked`: no finding that main does not already have (main has 34 of its own, which is why the Clippy step of CI is red on main itself). - `cargo xtask policy`: no new finding (main fails it on crates/victory-loader/src/heap_sites/frame_users.rs). - With all eleven of my pull requests merged together: `cargo clippy` also with `--all-features` adds no finding, and `cargo test --workspace --locked` fails only tests main also fails on this machine: the five shader tests that fail on main here too (WARP's SM 6.2 and the validator) (barycentric_tests::first_half_values_render_on_hardware_and_warp, hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, rect::tests::rectangles_are_drawn_whole, rect::tests::the_rectangle_stage_is_a_geometry_shader) and xtask's repository_passes_policy (frame_users.rs). 2208 passed, including five that fail on main (three BCPack oracle tests, the menu save race, the shader key test). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: None found for per-descriptor UAV write-back. 🤖 Generated with [Claude Code](https://claude.com/claude-code) *Pull request details or commits were not available from GitHub; kept as an issue.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 19:53:19 +00:00
github-bot changed title from [pr-performance] Draw: a table UAV a shader's buffer stores do not name is not written back to Draw: a table UAV a shader's buffer stores do not name is not written back 2026-11-29 20:00:22 +00:00
Author
Owner

@⁠Copilot on GitHub · 2026-11-29 19:57 UTC · original

This assignment can leave BINDING_WRITES false, but the shared-table allocation-failure fallback calls readable at lines 5844 and 5855 without updating it. With shared and same-table reuse enabled, a writable UAV in a later table can inherit that false value and lose its write-back. Reset the flag to STORES at the start of each snapshot-table group, or propagate per-entry flags through both fallback loops.

**@⁠Copilot** on GitHub · 2026-11-29 19:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3066#discussion_r4732925838) This assignment can leave `BINDING_WRITES` false, but the shared-table allocation-failure fallback calls `readable` at lines 5844 and 5855 without updating it. With shared and same-table reuse enabled, a writable UAV in a later table can inherit that false value and lose its write-back. Reset the flag to `STORES` at the start of each snapshot-table group, or propagate per-entry flags through both fallback loops.
Author
Owner

@⁠Copilot on GitHub · 2026-11-29 19:57 UTC · original

lower_bound is a logical shader register (victory-shader/src/native.rs:431–432), not the physical SGPR in code. If u0's descriptor is loaded into s[12:15] and u12 is also declared, this comparison marks u12 written and leaves u0 unwritten without triggering the unknown fallback, suppressing u0's write-back. Trace the descriptor's origin to its table slot/offset; until that mapping is available, keep the unknown-write fallback even when these numbers match.

**@⁠Copilot** on GitHub · 2026-11-29 19:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3066#discussion_r4732925862) `lower_bound` is a logical shader register (`victory-shader/src/native.rs:431–432`), not the physical SGPR in `code`. If u0's descriptor is loaded into s[12:15] and u12 is also declared, this comparison marks u12 written and leaves u0 unwritten without triggering the unknown fallback, suppressing u0's write-back. Trace the descriptor's origin to its table slot/offset; until that mapping is available, keep the unknown-write fallback even when these numbers match.
Author
Owner

@⁠Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original

Fixed in a84e210b: both fallback loops now set BINDING_WRITES before readable. The entries' loop sets each entry's own flag from group.written, and the selected views' loop sets the stage's STORES, the same as the snapshot loop.

**@⁠Adriwin06** on GitHub · 2026-11-30 01:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3066#discussion_r4734087224) Fixed in a84e210b: both fallback loops now set `BINDING_WRITES` before `readable`. The entries' loop sets each entry's own flag from `group.written`, and the selected views' loop sets the stage's `STORES`, the same as the snapshot loop.
Author
Owner

@⁠Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original

Right, the SGPR number is no guide. Fixed in 0452ddf2: written_used now traces each buffer store's descriptor with resource::track, the way picked.rs and the translator's used_kind do. A load from a table at a fixed offset names that entry, and a root descriptor names its own. Anything else (a computed offset, the heap, a built descriptor, a scalar store, or a program that needs the structure pass) is unknown, so every writable UAV is written back. Regression test: pipeline::tests::a_store_names_the_entry_its_descriptor_was_loaded_from (u0's descriptor in s[20:23] beside a declared u20).

**@⁠Adriwin06** on GitHub · 2026-11-30 01:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3066#discussion_r4734087364) Right, the SGPR number is no guide. Fixed in 0452ddf2: `written_used` now traces each buffer store's descriptor with `resource::track`, the way `picked.rs` and the translator's `used_kind` do. A load from a table at a fixed offset names that entry, and a root descriptor names its own. Anything else (a computed offset, the heap, a built descriptor, a scalar store, or a program that needs the structure pass) is unknown, so every writable UAV is written back. Regression test: `pipeline::tests::a_store_names_the_entry_its_descriptor_was_loaded_from` (u0's descriptor in s[20:23] beside a declared u20).
This discussion has been locked. Commenting is limited to contributors.
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/trustno1-coder--VIctory-NVIDIA#3066
No description provided.