perf(gpu): reuse packed sift bitset and batch scratch in refresh flushes #4422

Closed
Oierstg wants to merge 14 commits from upstream-pr/4422 into main
Oierstg commented 2026-11-30 20:13:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Oierstg on 2026-11-30T20:13:28Z.


Fixes #

What it changes

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing):
  • Before:
  • After:
  • For shader changes, the wave sizes tested (32 and/or 64 lanes):
  • cargo test passed for the crates it touches: yes / no

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5572962035 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4422). Originally posted by [Oierstg](https://github.com/Oierstg) on 2026-11-30T20:13:28Z. --- <!-- Thanks for the pull request. Please label it (pr-fix, pr-feature, pr-performance, pr-diagnostics, pr-refactor, pr-docs or pr-tests, plus the area labels), or put the label in the title, like [pr-fix]. --> Fixes # ## What it changes <!-- What was wrong, and what this does about it. --> ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): - Before: - After: - For shader changes, the wave sizes tested (32 and/or 64 lanes): - `cargo test` passed for the crates it touches: yes / no ## Checked for overlap - [ ] I searched the open pull requests for the same issue and for the files this touches. Related: #
copilot-pull-request-reviewer[bot] commented 2026-11-30 20:13:37 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-30T20:13:37Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6119759736 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4422#pullrequestreview-6119759736). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-30T20:13:37Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
IRennie74 commented 2026-11-30 22:38:24 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by IRennie74 on 2026-11-30T22:38:24Z.


sift_by (crates/victory-gpu/src/host.rs:13617, :13620) is correct only if every callback from wide_each_scoped covers at most 64 items starting at a multiple of 64: mask |= 1u64 << bit and bits[lo >> 6].store(mask). Today that holds. The grain is SIFT_CHUNK, the helpers split exactly by grain, and the inline f(0, len) path runs only when len <= grain (wide_threads() is never 0). Nothing enforces it, though. The per-item AtomicBool it replaces worked with any chunking.

If that ever changes (a larger grain, or a wide_each_scoped that coalesces chunks, which #4488 is reworking now), items past bit 63 would read a stale word from the reused bits. The result would be refreshes silently dropped or kept: stale buffer contents rather than a crash, which is hard to trace back here. A debug_assert!(lo % 64 == 0 && hi - lo <= 64) in the closure, or a loop over 64-item sub-blocks inside it, would pin it.

The PR body is still the empty template. A before/after of the refreshes line would help weigh it. It also conflicts textually with #4532 and #4488 in Batch::flush_all.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7294111224 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4422#issuecomment-7294111224). Originally posted by [IRennie74](https://github.com/IRennie74) on 2026-11-30T22:38:24Z. --- `sift_by` (`crates/victory-gpu/src/host.rs:13617`, `:13620`) is correct only if every callback from `wide_each_scoped` covers at most 64 items starting at a multiple of 64: `mask |= 1u64 << bit` and `bits[lo >> 6].store(mask)`. Today that holds. The grain is `SIFT_CHUNK`, the helpers split exactly by grain, and the inline `f(0, len)` path runs only when `len <= grain` (`wide_threads()` is never 0). Nothing enforces it, though. The per-item `AtomicBool` it replaces worked with any chunking. If that ever changes (a larger grain, or a `wide_each_scoped` that coalesces chunks, which #4488 is reworking now), items past bit 63 would read a stale word from the reused `bits`. The result would be refreshes silently dropped or kept: stale buffer contents rather than a crash, which is hard to trace back here. A `debug_assert!(lo % 64 == 0 && hi - lo <= 64)` in the closure, or a loop over 64-item sub-blocks inside it, would pin it. The PR body is still the empty template. A before/after of the `refreshes` line would help weigh it. It also conflicts textually with #4532 and #4488 in `Batch::flush_all`.
trustno1-coder commented 2026-12-01 18:41:45 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:41:45Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321362361 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4422#issuecomment-7321362361). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:41:45Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!4422
No description provided.