GPU: keep VICTORY_TEXTURE_BUDGET_MB within DXGI video-memory budget (#415) #507

Open
axolotlpriv wants to merge 1 commit from upstream-pr/507 into main
axolotlpriv commented 2026-11-25 01:52:16 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by axolotlpriv on 2026-11-25T01:52:16Z.


What

In resource::room(), setting VICTORY_TEXTURE_BUDGET_MB bypassed the DXGI adapter video-memory budget check and decided solely on KINDS[1] (filled texture copies). On an 8 GB card where buffers, pipelines, and render targets already consume several GiB, setting VICTORY_TEXTURE_BUDGET_MB=6144 still admitted new host texture copies past the adapter's DXGI budget (Issue #415, traced by @Kcaiooooo). Also, mb << 20 could wrap on very large values.

resource::room() now:

  • Uses mb.saturating_mul(1 << 20) when parsing VICTORY_TEXTURE_BUDGET_MB.
  • Delegates to texture_room(...) so a manual VICTORY_TEXTURE_BUDGET_MB cap still respects used < budget / 100 * room_percent() when DXGI video-memory telemetry is available, while preserving fallback to the manual cap if telemetry is unavailable and preserving the default path unchanged.

Addresses the VICTORY_TEXTURE_BUDGET_MB admission check in #415 (does not cover the non-mesh fallback or Agility SDK questions in that issue).

Testing

Added resource::tests::manual_texture_limit_respects_adapter_video_memory_budget covering:

  • manual cap with unavailable DXGI telemetry (None)
  • manual cap with total process VRAM below and above budget / 100 * percent (90% and custom 96%)
  • short-circuiting without querying DXGI once the manual cap is reached

Validated locally on Windows:

  • cargo test -p victory-gpu --locked -- resource::tests (10 passed, 0 failed)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo xtask policy

AI use: written and tested with AI assistance; reviewed before posting. No game files were used.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6595309518 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/507). Originally posted by [axolotlpriv](https://github.com/axolotlpriv) on 2026-11-25T01:52:16Z. --- ## What In `resource::room()`, setting `VICTORY_TEXTURE_BUDGET_MB` bypassed the DXGI adapter video-memory budget check and decided solely on `KINDS[1]` (filled texture copies). On an 8 GB card where buffers, pipelines, and render targets already consume several GiB, setting `VICTORY_TEXTURE_BUDGET_MB=6144` still admitted new host texture copies past the adapter's DXGI budget (Issue #415, traced by @Kcaiooooo). Also, `mb << 20` could wrap on very large values. `resource::room()` now: - Uses `mb.saturating_mul(1 << 20)` when parsing `VICTORY_TEXTURE_BUDGET_MB`. - Delegates to `texture_room(...)` so a manual `VICTORY_TEXTURE_BUDGET_MB` cap still respects `used < budget / 100 * room_percent()` when DXGI video-memory telemetry is available, while preserving fallback to the manual cap if telemetry is unavailable and preserving the default path unchanged. Addresses the `VICTORY_TEXTURE_BUDGET_MB` admission check in #415 (does not cover the non-mesh fallback or Agility SDK questions in that issue). ## Testing Added `resource::tests::manual_texture_limit_respects_adapter_video_memory_budget` covering: - manual cap with unavailable DXGI telemetry (`None`) - manual cap with total process VRAM below and above `budget / 100 * percent` (90% and custom 96%) - short-circuiting without querying DXGI once the manual cap is reached Validated locally on Windows: - `cargo test -p victory-gpu --locked -- resource::tests` (10 passed, 0 failed) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - `cargo xtask policy` **AI use:** written and tested with AI assistance; reviewed before posting. No game files were used.
fladit123 commented 2026-11-25 23:10:00 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by fladit123 on 2026-11-25T23:03:07Z.


While investigating VRAM admission on an 8 GB RTX 4060, I found this PR.

When rebasing, please consider preserving the current main's card_room_kept() and targets_room_kept() accounting, as well as tiles::given_total() in the filled-texture calculation.

Checking only current DXGI usage against the budget could admit textures into memory intended for later buffer and render-target allocations.

It may also be worth coordinating with #605 and #1122 so that the admission changes remain consistent.

This is a static observation; I have not tested the combined implementation yet.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7177089704 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/507#issuecomment-7177089704). Originally posted by [fladit123](https://github.com/fladit123) on 2026-11-25T23:03:07Z. --- While investigating VRAM admission on an 8 GB RTX 4060, I found this PR. When rebasing, please consider preserving the current main's `card_room_kept()` and `targets_room_kept()` accounting, as well as `tiles::given_total()` in the filled-texture calculation. Checking only current DXGI usage against the budget could admit textures into memory intended for later buffer and render-target allocations. It may also be worth coordinating with #605 and #1122 so that the admission changes remain consistent. This is a static observation; I have not tested the combined implementation yet.
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/507:upstream-pr/507'
git switch 'upstream-pr/507'

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/507'
git switch 'upstream-pr/507'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/507'
git switch 'upstream-pr/507'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/507'
git switch 'main'
git merge --squash 'upstream-pr/507'
git switch 'main'
git merge --ff-only 'upstream-pr/507'
git switch 'main'
git merge 'upstream-pr/507'
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
fxceless/victory-fork!507
No description provided.