RX_VK_VRAM_MB and the integrated-GPU cap win over a preset's texture budget #1376

Merged
aquinas22 merged 2 commits from fix/preset-texture-budget-overrides into main 2026-11-10 14:35:22 +00:00
aquinas22 commented 2026-11-09 23:47:46 +00:00 (Migrated from github.com)

What

RX_VK_VRAM_MB and the integrated-GPU texture cap now win over a quality preset's texture budget.

Why

In texture_frame, a preset's vram_mb replaced own outright:

const bool preset_budget = opts.vram_mb > 0 && preset_caps_memory();
uint64_t budget = preset_budget ? ((uint64_t)opts.vram_mb << 20) : own;

own is where RX_VK_VRAM_MB and the 2560 MB cap for integrated GPUs (added in v2.0.11 for the 16 GB Radeon 780M laptop that ran out of RAM) are applied. So with any preset on:

  • RX_VK_VRAM_MB did nothing, with no word in the log. The mirrors' RX_VK_MIRROR_MB does win over the preset (mirror_budget), so the two budgets disagreed.
  • An integrated GPU on Low (6GB) or Balanced (8GB) could get 3.6 or 4.8 GB of textures, past the cap. preset_caps_memory is true there whenever the shared heap is at most the preset's size + 768 MB, and the 75% clamp doesn't help, because what the driver allows is large too.

How

preset_texture_budget(preset_mb, preset_applies, vram_env, integrated, own):

  • RX_VK_VRAM_MB wins over a preset.
  • On an integrated GPU, the preset's budget is at most own.
  • A dedicated card on its preset keeps the preset's budget, unchanged.
  • The preset's 75% clamp still applies only when the preset's budget is used.

Testing

  • tests/test_preset_texture_budget.py extracts the helper and covers six cases: a preset on its card, RX_VK_VRAM_MB with a preset, an integrated GPU on a large and on a small preset, Custom, and a preset for a smaller card. It fails on the old rule (RX_VK_VRAM_MB wins: 2200 MB, expected 1500, integrated GPU capped: 4800 MB, expected 2560).
  • python -I -B tests/run_all.py preset_texture passes. hookshot_vk.dll builds on main (llvm-mingw, RX_VK_ONLY=1).
  • Not run in game: the change is in the budget's arithmetic only, and on a dedicated card on its preset the budget is the same as before.
## What `RX_VK_VRAM_MB` and the integrated-GPU texture cap now win over a quality preset's texture budget. ## Why In `texture_frame`, a preset's `vram_mb` replaced `own` outright: ```cpp const bool preset_budget = opts.vram_mb > 0 && preset_caps_memory(); uint64_t budget = preset_budget ? ((uint64_t)opts.vram_mb << 20) : own; ``` `own` is where `RX_VK_VRAM_MB` and the 2560 MB cap for integrated GPUs (added in v2.0.11 for the 16 GB Radeon 780M laptop that ran out of RAM) are applied. So with any preset on: - `RX_VK_VRAM_MB` did nothing, with no word in the log. The mirrors' `RX_VK_MIRROR_MB` does win over the preset (`mirror_budget`), so the two budgets disagreed. - An integrated GPU on Low (6GB) or Balanced (8GB) could get 3.6 or 4.8 GB of textures, past the cap. `preset_caps_memory` is true there whenever the shared heap is at most the preset's size + 768 MB, and the 75% clamp doesn't help, because what the driver allows is large too. ## How `preset_texture_budget(preset_mb, preset_applies, vram_env, integrated, own)`: - `RX_VK_VRAM_MB` wins over a preset. - On an integrated GPU, the preset's budget is at most `own`. - A dedicated card on its preset keeps the preset's budget, unchanged. - The preset's 75% clamp still applies only when the preset's budget is used. ## Testing - `tests/test_preset_texture_budget.py` extracts the helper and covers six cases: a preset on its card, `RX_VK_VRAM_MB` with a preset, an integrated GPU on a large and on a small preset, Custom, and a preset for a smaller card. It fails on the old rule (`RX_VK_VRAM_MB wins: 2200 MB, expected 1500`, `integrated GPU capped: 4800 MB, expected 2560`). - `python -I -B tests/run_all.py preset_texture` passes. `hookshot_vk.dll` builds on `main` (llvm-mingw, `RX_VK_ONLY=1`). - Not run in game: the change is in the budget's arithmetic only, and on a dedicated card on its preset the budget is the same as before.
hckrman101 (Migrated from github.com) approved these changes 2026-11-10 04:14:33 +00:00
hckrman101 (Migrated from github.com) left a comment

Looks right to me. The old line threw away own, so the integrated-GPU cap and RX_VK_VRAM_MB never applied while a preset was on. Now the texture budget goes through the same rule as mirror_budget(): the env var wins, the preset only counts on a card it's meant for, and an iGPU never goes past its 2560 MB. On a dedicated card on its own preset nothing changes, and the 75% clamp is still limited to the preset path. The test runs the real helper, makes sure texture_frame actually calls it, and is picked up by run_all.py's glob, so the ARGS entry is fine.

Checked against #1358 (Custom keeps the preset's budgets via opts.budget): the two don't touch the same files, and they fit together. After #1358, opts.vram_mb stays set in Custom more often, and this PR makes sure that kept budget still gives way to RX_VK_VRAM_MB and the iGPU cap. Either merge order works.

Small things, none blocking:

  • On an iGPU where the preset is bigger than own, preset_budget is still true, so the 75%-of-allowed clamp also runs on own. It can only lower the budget and allowed is big on shared memory, so it makes no practical difference. Just noting it's a small difference from the Custom path.
  • vram_env is checked twice, once in preset_budget and again inside the helper. Both checks are needed: the first keeps the clamp off and the second keeps the test meaningful. A short note at the call site would save the next reader from wondering.

No CI checks ran on this branch, so I'm going by reading the code.

Looks right to me. The old line threw away `own`, so the integrated-GPU cap and `RX_VK_VRAM_MB` never applied while a preset was on. Now the texture budget goes through the same rule as `mirror_budget()`: the env var wins, the preset only counts on a card it's meant for, and an iGPU never goes past its 2560 MB. On a dedicated card on its own preset nothing changes, and the 75% clamp is still limited to the preset path. The test runs the real helper, makes sure `texture_frame` actually calls it, and is picked up by `run_all.py`'s glob, so the `ARGS` entry is fine. Checked against #1358 (Custom keeps the preset's budgets via `opts.budget`): the two don't touch the same files, and they fit together. After #1358, `opts.vram_mb` stays set in Custom more often, and this PR makes sure that kept budget still gives way to `RX_VK_VRAM_MB` and the iGPU cap. Either merge order works. Small things, none blocking: - On an iGPU where the preset is bigger than `own`, `preset_budget` is still true, so the 75%-of-allowed clamp also runs on `own`. It can only lower the budget and `allowed` is big on shared memory, so it makes no practical difference. Just noting it's a small difference from the Custom path. - `vram_env` is checked twice, once in `preset_budget` and again inside the helper. Both checks are needed: the first keeps the clamp off and the second keeps the test meaningful. A short note at the call site would save the next reader from wondering. No CI checks ran on this branch, so I'm going by reading the code.
hckrman101 (Migrated from github.com) commented 2026-11-10 04:14:33 +00:00

Nit: nothing outside this file uses it, so it could be static (or go in one of the anonymous namespaces) to keep it out of mkwvk's external symbols. The test extracts it by text, so it doesn't care either way.

Nit: nothing outside this file uses it, so it could be `static` (or go in one of the anonymous namespaces) to keep it out of `mkwvk`'s external symbols. The test extracts it by text, so it doesn't care either way.
Commenting is not possible because the repository is archived.
No description provided.