gpu: make texture pool block size configurable #1968

Open
tharun-37 wants to merge 2 commits from upstream-pr/1968 into main
tharun-37 commented 2026-11-29 04:38:10 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tharun-37 on 2026-11-29T04:38:10Z.


Addresses part of #1576 (pool block size configurability).

Adds \VICTORY_POOL_BLOCK_MB\ environment variable (16, 32, 64, 128, 256 MiB) to configure the texture pool block size. Default remains 64 MiB. The block size is read once at startup and cached.

The 64 MiB default works well for larger VRAM cards, but on 8 GB cards it causes internal fragmentation (hundreds of MiB to >2 GiB trapped in partially-filled 64 MiB heaps). Users can now set \VICTORY_POOL_BLOCK_MB=16\ or \32\ to reduce fragmentation on smaller VRAM cards.

Tests use \TEST_BLOCK\ constant (64 MiB) and \set_test_block_size()\ helper to ensure deterministic test behavior regardless of environment.

Validation: \cargo test -p victory-gpu --locked\ (589 tests pass); \cargo check --workspace --locked; \cargo xtask policy\ (pre-existing lower.rs size violation unrelated to this change).

AI-assisted (OpenCode).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5547600350 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1968). Originally posted by [tharun-37](https://github.com/tharun-37) on 2026-11-29T04:38:10Z. --- Addresses part of #1576 (pool block size configurability). Adds \VICTORY_POOL_BLOCK_MB\ environment variable (16, 32, 64, 128, 256 MiB) to configure the texture pool block size. Default remains 64 MiB. The block size is read once at startup and cached. The 64 MiB default works well for larger VRAM cards, but on 8 GB cards it causes internal fragmentation (hundreds of MiB to >2 GiB trapped in partially-filled 64 MiB heaps). Users can now set \VICTORY_POOL_BLOCK_MB=16\ or \32\ to reduce fragmentation on smaller VRAM cards. Tests use \TEST_BLOCK\ constant (64 MiB) and \set_test_block_size()\ helper to ensure deterministic test behavior regardless of environment. Validation: \cargo test -p victory-gpu --locked\ (589 tests pass); \cargo check --workspace --locked\; \cargo xtask policy\ (pre-existing lower.rs size violation unrelated to this change). AI-assisted (OpenCode).
ANDREANIADS commented 2026-11-29 04:48:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ANDREANIADS on 2026-11-29T04:48:49Z.


Test isolation at 1df1412dbdb5e946d428dc7dcd5859f14416556e: pieces_never_overlap_and_rest_before_they_are_used_again reaches block_size() through take → take_ripe → cut without setting the override. If it initializes the cache first, the later setter in the census test cannot change the value.

I compiled the getter and setter alone with rustc --cfg test and ran two fresh processes with VICTORY_POOL_BLOCK_MB=32. Reading once, setting the 64 MiB override, and reading again returned 32 then 32 MiB. Setting the override before the first read returned 64 then 64 MiB. In the first order, the census test’s initial 32 MiB request exceeds its 16 MiB half-block cutoff.

Could pool unit tests use a fixed getter under cfg(test), with the production parser tested separately on explicit inputs? Passing the size into each test pool would also remove the ordering dependency. Only the configuration functions were executed in this reproduction.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7250876910 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1968#issuecomment-7250876910). Originally posted by [ANDREANIADS](https://github.com/ANDREANIADS) on 2026-11-29T04:48:49Z. --- Test isolation at `1df1412dbdb5e946d428dc7dcd5859f14416556e`: `pieces_never_overlap_and_rest_before_they_are_used_again` reaches `block_size()` through `take → take_ripe → cut` without setting the override. If it initializes the cache first, the later setter in the census test cannot change the value. I compiled the getter and setter alone with `rustc --cfg test` and ran two fresh processes with `VICTORY_POOL_BLOCK_MB=32`. Reading once, setting the 64 MiB override, and reading again returned 32 then 32 MiB. Setting the override before the first read returned 64 then 64 MiB. In the first order, the census test’s initial 32 MiB request exceeds its 16 MiB half-block cutoff. Could pool unit tests use a fixed getter under `cfg(test)`, with the production parser tested separately on explicit inputs? Passing the size into each test pool would also remove the ordering dependency. Only the configuration functions were executed in this reproduction.
kibagami-nc commented 2026-11-29 05:18:23 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-29T05:18:23Z.


A heads-up on the clippy.toml: clippy rejects it. With this file at the root, every clippy run stops at once:

error: error reading Clippy's configuration file: unknown field `clippy`, expected one of
           absolute-paths-allowed-crates
           …

That's on cargo clippy -p victory-core --locked, with the same file in a checkout of main. clippy.toml only sets lints' options (thresholds, lists), not whether a lint is allowed. Lint levels go in attributes or in [workspace.lints] in Cargo.toml. So with it, CI's clippy step fails for every PR, instead of passing.

The failures on main that CI shows already have fixes in open PRs, and together they make both clippy builds clean (1,306 tests passing on the set):

  • #1517: the two errors in lower.rs, including manual_checked_ops;
  • #1459: dropping_references in host.rs. Those drop(&guard) calls left a mutex held, a real bug, so allowing that lint workspace-wide would hide exactly that kind of mistake;
  • #665: the rest of victory-gpu's findings (dead_code on pool::let_go and others, too_many_arguments, manual_is_multiple_of, the test lints);
  • #1493: the file-size limit lower.rs crosses.

Dropping clippy.toml and the two #[allow]s from this PR keeps it to the pool block size, and CI turns green once those four are in.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7251175335 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1968#issuecomment-7251175335). Originally posted by [kibagami-nc](https://github.com/kibagami-nc) on 2026-11-29T05:18:23Z. --- A heads-up on the `clippy.toml`: clippy rejects it. With this file at the root, every clippy run stops at once: ``` error: error reading Clippy's configuration file: unknown field `clippy`, expected one of absolute-paths-allowed-crates … ``` That's on `cargo clippy -p victory-core --locked`, with the same file in a checkout of main. `clippy.toml` only sets lints' options (thresholds, lists), not whether a lint is allowed. Lint levels go in attributes or in `[workspace.lints]` in `Cargo.toml`. So with it, CI's clippy step fails for every PR, instead of passing. The failures on main that CI shows already have fixes in open PRs, and together they make both clippy builds clean (1,306 tests passing on the set): - #1517: the two errors in `lower.rs`, including `manual_checked_ops`; - #1459: `dropping_references` in `host.rs`. Those `drop(&guard)` calls left a mutex held, a real bug, so allowing that lint workspace-wide would hide exactly that kind of mistake; - #665: the rest of victory-gpu's findings (`dead_code` on `pool::let_go` and others, `too_many_arguments`, `manual_is_multiple_of`, the test lints); - #1493: the file-size limit `lower.rs` crosses. Dropping `clippy.toml` and the two `#[allow]`s from this PR keeps it to the pool block size, and CI turns green once those four are in.
ANDREANIADS commented 2026-11-29 05:35:20 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ANDREANIADS on 2026-11-29T05:35:20Z.


Small diagnostic fix at 51c281803db5b9648a21a2f1eb46335bf111085b: stats_on() checks VICTORY_POOL_STATS=1, but the texture stats header suggests VICTORY_POOL_BLOCK_MB=1. The size parser rejects 1 and falls back to 64 MiB. Setting it alone leaves stats disabled. Could the header keep VICTORY_POOL_STATS=1 and print the effective block_size() >> 20 in MiB alongside the count? A short scope note would also help: the same setting sizes texture blocks, staging blocks, and both CPU buffer heap pools (upload and shared).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7251342288 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1968#issuecomment-7251342288). Originally posted by [ANDREANIADS](https://github.com/ANDREANIADS) on 2026-11-29T05:35:20Z. --- Small diagnostic fix at `51c281803db5b9648a21a2f1eb46335bf111085b`: `stats_on()` checks `VICTORY_POOL_STATS=1`, but the texture stats header suggests `VICTORY_POOL_BLOCK_MB=1`. The size parser rejects 1 and falls back to 64 MiB. Setting it alone leaves stats disabled. Could the header keep `VICTORY_POOL_STATS=1` and print the effective `block_size() >> 20` in MiB alongside the count? A short scope note would also help: the same setting sizes texture blocks, staging blocks, and both CPU buffer heap pools (upload and shared).
ANDREANIADS commented 2026-11-29 06:32:23 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ANDREANIADS on 2026-11-29T06:32:23Z.


At 53c0cbb, the return in nv05d1_native_readlane_gpu_reference exits the seven-case loop. In a control-flow simulation, None on the first readback reached IR/lowering for 1 of 7 cases. None on the fourth reached 4 of 7. The remaining cases also miss optional DXIL validation when the validator is installed.

Could all seven CPU checks run independently of readback? dispatched_words returns None both when host initialization fails and when an existing device rejects pipeline creation. Distinct outcomes would let the test skip unavailable hardware and report a pipeline rejection with its wave/lane case. Alternatively, this reference-test change could go into a separate PR. Only the loop was simulated.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7251915926 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1968#issuecomment-7251915926). Originally posted by [ANDREANIADS](https://github.com/ANDREANIADS) on 2026-11-29T06:32:23Z. --- At `53c0cbb`, the `return` in `nv05d1_native_readlane_gpu_reference` exits the seven-case loop. In a control-flow simulation, `None` on the first readback reached IR/lowering for 1 of 7 cases. `None` on the fourth reached 4 of 7. The remaining cases also miss optional DXIL validation when the validator is installed. Could all seven CPU checks run independently of readback? `dispatched_words` returns `None` both when host initialization fails and when an existing device rejects pipeline creation. Distinct outcomes would let the test skip unavailable hardware and report a pipeline rejection with its wave/lane case. Alternatively, this reference-test change could go into a separate PR. Only the loop was simulated.
tharun-37 commented 2026-11-29 07:08:29 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tharun-37 on 2026-11-29T07:08:29Z.


Addressed the review. This PR is back to pool.rs only.

  • Test isolation: lock_size() is now a fixed 64 MiB under cfg(test). The environment parser is a separate parse_block_mb(&str) covered by an explicit-input test, and the mutable override plus its call sites are gone. No test can poison the cache for another.
  • Stats line: the header now names VICTORY_POOL_STATS=1 and prints the effective lock_size() >> 20 in MiB. The getter docs note the same setting sizes texture blocks, staging blocks, and both CPU buffer heap pools (upload and shared).
  • Dropped the clippy.toml, the workspace lint allowances, the asset-policy limit bump and the NV05D1 test change. Those belong with #1517, #1459, #665 and #1493 as noted; in particular dropping_references stays denied so #1459's mutex fix is not masked.

cargo test -p victory-gpu --locked: 590 passed, 0 failed.

AI-assisted (OpenCode).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7252286901 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1968#issuecomment-7252286901). Originally posted by [tharun-37](https://github.com/tharun-37) on 2026-11-29T07:08:29Z. --- Addressed the review. This PR is back to pool.rs only. - Test isolation: lock_size() is now a fixed 64 MiB under cfg(test). The environment parser is a separate parse_block_mb(&str) covered by an explicit-input test, and the mutable override plus its call sites are gone. No test can poison the cache for another. - Stats line: the header now names VICTORY_POOL_STATS=1 and prints the effective lock_size() >> 20 in MiB. The getter docs note the same setting sizes texture blocks, staging blocks, and both CPU buffer heap pools (upload and shared). - Dropped the clippy.toml, the workspace lint allowances, the asset-policy limit bump and the NV05D1 test change. Those belong with #1517, #1459, #665 and #1493 as noted; in particular dropping_references stays denied so #1459's mutex fix is not masked. cargo test -p victory-gpu --locked: 590 passed, 0 failed. AI-assisted (OpenCode).
pickles976 commented 2026-11-29 07:18:20 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by pickles976 on 2026-11-29T07:18:20Z.


Adapted the pool-size option from 83a8fa1d8f onto our older Wine performance branch, preserving its existing pool ownership, alignment, submission-age and retirement rules: github.com/pickles976/VIctory-NVIDIA@c2bc938a6c . This is an adaptation, not an exact-head test.

Wine 11 / Linux 6.17 / RTX 4060 Laptop 8 GiB / NVIDIA 590.48.1 / 16 GiB RAM, with the stock assertion-enabled vkd3d 2576c0b4adfae4a pair supplied app-local. Fresh intended-tree test build: 18.57 s. Separate 16 and 64 MiB processes each passed 11/11 pool tests (0 ignored), 0.79/0.64 s. The added required-device fixture checks actual native heap and staging-buffer sizes, then checks all 16,384 output words from two neighboring textures across two CPU-upload/GPU-copy/readback rounds. Existing reuse, delayed retirement, allocation-failure backoff and submission-age cases also pass.

Unlike the current PR test getter, this adaptation tests the configured production size; model stimuli scale with that size rather than introducing a mutable override. The parser still rejects unsupported values and the default remains 64 MiB.

Motivation: our preceding 64 MiB title run rendered a cutscene but hit the unchanged global 6000 MiB GPU guard at 6009 MiB. Its last pool accounting had 385 MiB free in texture blocks; this is not proof all those bytes are reclaimable. No title VRAM saving or frame-time improvement from smaller blocks has been measured yet. Smaller blocks may increase heap-allocation overhead; no safety limits or shader work were changed.

Local evidence: verify-nvidia-configurable-pool-build-20261129T071504Z, verify-nvidia-pool-16-stock-20261129T071613Z, verify-nvidia-pool-64-stock-20261129T071615Z. No game assets or images published.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7252390272 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1968#issuecomment-7252390272). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-29T07:18:20Z. --- Adapted the pool-size option from 83a8fa1d8fccfc09d1e5acbe98cf4a765a6de31d onto our older Wine performance branch, preserving its existing pool ownership, alignment, submission-age and retirement rules: https://github.com/pickles976/VIctory-NVIDIA/commit/c2bc938a6c762134d0bb09a37bedead30c1ced91 . This is an adaptation, not an exact-head test. Wine 11 / Linux 6.17 / RTX 4060 Laptop 8 GiB / NVIDIA 590.48.1 / 16 GiB RAM, with the stock assertion-enabled vkd3d 2576c0b4adfae4a pair supplied app-local. Fresh intended-tree test build: 18.57 s. Separate 16 and 64 MiB processes each passed 11/11 pool tests (0 ignored), 0.79/0.64 s. The added required-device fixture checks actual native heap and staging-buffer sizes, then checks all 16,384 output words from two neighboring textures across two CPU-upload/GPU-copy/readback rounds. Existing reuse, delayed retirement, allocation-failure backoff and submission-age cases also pass. Unlike the current PR test getter, this adaptation tests the configured production size; model stimuli scale with that size rather than introducing a mutable override. The parser still rejects unsupported values and the default remains 64 MiB. Motivation: our preceding 64 MiB title run rendered a cutscene but hit the unchanged global 6000 MiB GPU guard at 6009 MiB. Its last pool accounting had 385 MiB free in texture blocks; this is not proof all those bytes are reclaimable. No title VRAM saving or frame-time improvement from smaller blocks has been measured yet. Smaller blocks may increase heap-allocation overhead; no safety limits or shader work were changed. Local evidence: verify-nvidia-configurable-pool-build-20261129T071504Z, verify-nvidia-pool-16-stock-20261129T071613Z, verify-nvidia-pool-64-stock-20261129T071615Z. No game assets or images published.
pickles976 commented 2026-11-29 07:24:53 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by pickles976 on 2026-11-29T07:24:53Z.


Guarded title follow-through on the disclosed older-lineage adaptation: 16 MiB blocks did not clear this laptop’s VRAM wall. The unchanged global 6000 MiB guard stopped at 6025 MiB after ~154 s; kernel interval empty, native telemetry calls all returned, no OOM. The preceding 64 MiB run stopped at 6009 MiB after ~195 s. Different title progress/cache/OS conditions mean neither stop-time nor FPS differences are a causal regression comparison.

Last 16 MiB census: 132 blocks / 2112 MiB, 1762 MiB held, 347 MiB free in 2101 ranges, 2 MiB resting, zero empty blocks. More importantly, 15724 textures potentially fit in 276 MiB at 4 KiB alignment but occupy 1052 MiB under the retained 64 KiB-alignment policy. That is allocation-info potential, not a safe/runtime-verified 776 MiB saving. We have not enabled the historically fault-prone small-placement path.

Nine high-draw reports had a 2.3 host-FPS median; the last actual window capture was the dimming flamingo artwork, not controllable gameplay. Scope peaked at 9 GiB with 154 max events and no OOM; native query maximum 1031.6 ms. I am retaining the 64 MiB default, not recommending 16 MiB as an established performance improvement. No guard or shader behavior was weakened. Local evidence: nvidia-fork-trial-20261129T072030Z/verified-summary.json and matching guarded console/resources; stopped exact-inode/unheld backing cleanup completed.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7252458019 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1968#issuecomment-7252458019). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-29T07:24:53Z. --- Guarded title follow-through on the disclosed older-lineage adaptation: 16 MiB blocks did not clear this laptop’s VRAM wall. The unchanged global 6000 MiB guard stopped at 6025 MiB after ~154 s; kernel interval empty, native telemetry calls all returned, no OOM. The preceding 64 MiB run stopped at 6009 MiB after ~195 s. Different title progress/cache/OS conditions mean neither stop-time nor FPS differences are a causal regression comparison. Last 16 MiB census: 132 blocks / 2112 MiB, 1762 MiB held, 347 MiB free in 2101 ranges, 2 MiB resting, zero empty blocks. More importantly, 15724 textures potentially fit in 276 MiB at 4 KiB alignment but occupy 1052 MiB under the retained 64 KiB-alignment policy. That is allocation-info potential, not a safe/runtime-verified 776 MiB saving. We have not enabled the historically fault-prone small-placement path. Nine high-draw reports had a 2.3 host-FPS median; the last actual window capture was the dimming flamingo artwork, not controllable gameplay. Scope peaked at 9 GiB with 154 max events and no OOM; native query maximum 1031.6 ms. I am retaining the 64 MiB default, not recommending 16 MiB as an established performance improvement. No guard or shader behavior was weakened. Local evidence: nvidia-fork-trial-20261129T072030Z/verified-summary.json and matching guarded console/resources; stopped exact-inode/unheld backing cleanup completed.
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/1968:upstream-pr/1968'
git switch 'upstream-pr/1968'

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/1968'
git switch 'upstream-pr/1968'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1968'
git switch 'upstream-pr/1968'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1968'
git switch 'main'
git merge --squash 'upstream-pr/1968'
git switch 'main'
git merge --ff-only 'upstream-pr/1968'
git switch 'main'
git merge 'upstream-pr/1968'
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
trustno1-coder/VIctory-NVIDIA!1968
No description provided.