gpu: avoid masked bitset copies in CPU dirty-page checks #2103
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2103
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2103/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tikD1337 on GitHub · 2026-11-04 08:40 UTC · original
tikD1337:codex/bounded-dirty-range→main· +107 −1 · 3 files · 2 commits · closed without mergingChange
RegionManager::ChangeState<DirtySource::Cpu, true>checks for overlapping GPU-dirty pages by constructing a masked 1024-bitRegionBitstemporary and callingAny(). This replaces that predicate withBitArray::AnyInRange(start, end), which checks the requested words directly and stops at the first set bit.The new predicate uses half-open ranges. Empty, reversed and out-of-bounds ranges return false, matching the masked constructor. The CPU/GPU conflict condition, locking, dirty-state updates and page-protection operations are unchanged.
Draft: no game-level benefit has been established. I understand the contribution rules require a concrete game-related result. This is a tested CPU-only candidate awaiting integration and title validation, not a claim of improved FPS or a fix for a reported game bug.
Checked locally
Host: Windows, Intel Core i7-1185G7. Compiler: portable Zig 0.15.2 C++ toolchain, C++20.
BitArrayTests.cppbuilt and passed with both-O2and-O0 -g, using-Wall -Wextra -Werror. These were direct standalone compilations, not full CMake builds or CTest runs.constexprchecks and oversized endpoints, includingSIZE_MAX.static_assert; skipped interior words by the runtime oracle.git diff --checkpassed.Synthetic timing only
Same process and machine; C++20
-O3 -DNDEBUG; 4096 query records; 4,194,304 calls per sample; warmup plus nine samples per implementation with rotated order. Medians in ns/call:These measure standalone predicates in
noinlinewrappers, not the inlinedChangeStatecall site, lock contention, uploads, or frame time. Positive conflict results would terminate the production tracker operation; those workloads exercise the predicate, not representative successful game execution. The actual game benefit may be negligible. Laptop power state and background activity can affect these small timings.Exact standalone benchmark source and command
Save as
range-benchmark.cppoutside the source tree and compile from the repository root:Only
masked_nsandbounded_nscorrespond to this PR's production change.old_nsis a separateFirstRangeFromcomparison; its production callers are unchanged.Still needs testing
clang-cltoolchain.bit_array,memory_trackerandpage_managerCTests on both platforms.No emulator executable, game, GPU correctness test or tracker integration suite has been run locally for this change. No specific title is claimed fixed or accelerated. Related memory-tracker work is already open in #1284 and #1886; this PR does not implement their atomic snapshots, locking changes or upload-generation cache.
AI assistance
AI-assisted: yes. Codex wrote the patch, tests, benchmark and this description, and ran the listed local checks on this PC. A human code review and the unchecked validation above are still needed.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-04 09:05 UTC · original · edited 2026-11-04 09:08 UTC
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
43ac010ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@coderabbitai[bot] on GitHub · 2026-11-04 09:08 UTC · original · edited 2026-11-04 09:14 UTC
No actionable comments were generated in the recent review.
Walkthrough
BitArray<N>addsAnyInRange(start, end)to check for set bits in a half-open range.RegionManager::ChangeStateuses this method to check GPU dirty bits in the requested page range. Tests cover randomized and exhaustive ranges, invalid bounds, and constexpr behavior across 64-, 128-, and 1024-bit arrays.Suggested reviewers:
nmzikChange: Refactor
Merge Risk:
Minimal · up to
6c393The change is mergeable with normal platform and game-level validation follow-up; no actionable code-level risk was identified.
Pre-merge checks:
4 ·
1
Full details: Title check
Explanation
The title names the main change: CPU dirty-page checks in the GPU region manager now avoid a masked bitset copy. The raw summary and objectives confirm that RegionManager::ChangeState swaps the masked RegionBits temporary and Any() call for BitArray::AnyInRange. The title is specific and accurate, and it is a single short sentence.
Full details: Description check
Explanation
The description is related to the changeset. It explains that RegionManager::ChangeState<DirtySource::Cpu, true> now uses BitArray::AnyInRange(start, end) instead of a masked RegionBits temporary with Any(). It also covers half-open range semantics, the local tests and benchmarks, and the validation still pending. The description is detailed and on-topic, so it passes this lenient check.
Full details: Docstring Coverage
Explanation
Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
08276a99-7d5a-4ff2-8f8a-7186120ba86fReviewing files that changed from the base of the PR and between
43ac010b0cand6c393d7f9a.src/common/bitArray.hsrc/graphics/host_gpu/regionManager.htests/BitArrayTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
@Nmzik on GitHub · 2026-11-04 22:23 UTC · original
@tikD1337 credited
Pull request closed