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

Closed
github-bot wants to merge 14 commits from github-bot/gh-4422 into main AGit
Owner

@⁠Oierstg on GitHub · 2026-11-30 20:13 UTC · original
Oierstg:perf/sift-bitset-and-batch-scratch → main · +1054 −907 · 32 files · 14 commits · closed without merging

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: #
**@⁠Oierstg** on GitHub · 2026-11-30 20:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4422) `Oierstg:perf/sift-bitset-and-batch-scratch` → `main` · +1054 −907 · 32 files · 14 commits · closed without merging <!-- 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: #
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 20:18:51 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-30 20:13 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-30 20:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4422#pullrequestreview-6119759736) · **reviewed** 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.
Author
Owner

@⁠IRennie74 on GitHub · 2026-11-30 22:38 UTC · original

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 #4489 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 #4533 and #4489 in Batch::flush_all.

**@⁠IRennie74** on GitHub · 2026-11-30 22:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4422#issuecomment-7294111224) `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 #4489 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 #4533 and #4489 in `Batch::flush_all`.
github-bot closed this pull request 2026-12-01 18:43:40 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:41 UTC · original

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.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4422#issuecomment-7321362361) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!4423
No description provided.