feat(gpu): pré-drena texturas na fila durante telas de loading (low-draw) e adiciona VICTORY_TEXTURE_PASS_MB #125

Closed
ItzMeGamer wants to merge 0 commits from upstream-pr/125 into main
ItzMeGamer commented 2026-11-26 15:31:15 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by ItzMeGamer on 2026-11-26T15:31:15Z.


Resumo

Acelera o esvaziamento da fila textures picked by index durante as próprias telas de loading e menus 2D (< 150 draws/frame), evitando que milhares de texturas (como pele/rosto de personagens em interiores e LODs) fiquem acumuladas por centenas de quadros após entrar no mundo 3D.

O que foi corrigido e implementado (crates/victory-gpu)

  1. Pré-drenagem automática em telas de loading (draw.rs, descriptor/host.rs, resource.rs):
    • Em quadros com poucos draws (< 150 draws/frame) quando há slots vencidos (due) na fila textures picked by index, State::early_textures eleva automaticamente o orçamento de upload por quadro de 12 ms / 64 MiB para 400 ms / 256 MiB (limitado a 1500 ms abaixo do TDR de 2 s do Windows e respeitando o saldo restante de VICTORY_TEXTURE_BUDGET_MB).
    • Corrige também a marcação prematura de EARLY_FRAME antes de verificar se o draw possui view heap vinculado.
  2. Correção da margem PER_TEXTURE_BUDGET em heap_textures (draw.rs):
    • Escala a margem de segurança (PER_TEXTURE_BUDGET.min(bytes_at_most / 4)) para que passes de <= 64 MiB não interrompam o loop após subir apenas uma única textura.
  3. Variáveis de ambiente (VICTORY_TEXTURE_PASS_MB e VICTORY_LOADING_DRAIN):
    • VICTORY_TEXTURE_PASS_MB: permite definir explicitamente o limite de bytes por quadro nos passes de upload de texturas.
    • VICTORY_LOADING_DRAIN=0: permite desativar o boost automático em telas de loading (ativado por padrão).

Testes e Validação

  • Novos testes unitários em crates/victory-gpu/src/draw.rs (loading_screen_boosts_pass_budget_when_due_and_low_draw e pass_budget_respects_env_overrides_and_tdr_and_texture_budget).
  • cargo test -p victory-gpu -> 207 passed, 0 failed.

(Assistido por IA com Antigravity).
@uiliannn

<!-- greyfinch-sync:uiliannn/VItoriaBr:issue:5512836985 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VitoriaBr2.0/pull/125). Originally posted by [ItzMeGamer](https://github.com/ItzMeGamer) on 2026-11-26T15:31:15Z. --- ## Resumo Acelera o esvaziamento da fila `textures picked by index` **durante as próprias telas de loading e menus 2D** (`< 150` draws/frame), evitando que milhares de texturas (como pele/rosto de personagens em interiores e LODs) fiquem acumuladas por centenas de quadros após entrar no mundo 3D. ### O que foi corrigido e implementado (`crates/victory-gpu`) 1. **Pré-drenagem automática em telas de loading (`draw.rs`, `descriptor/host.rs`, `resource.rs`)**: - Em quadros com poucos draws (`< 150` draws/frame) quando há slots vencidos (`due`) na fila `textures picked by index`, `State::early_textures` eleva automaticamente o orçamento de upload por quadro de `12 ms / 64 MiB` para **`400 ms / 256 MiB`** (limitado a `1500 ms` abaixo do TDR de 2 s do Windows e respeitando o saldo restante de `VICTORY_TEXTURE_BUDGET_MB`). - Corrige também a marcação prematura de `EARLY_FRAME` antes de verificar se o draw possui view heap vinculado. 2. **Correção da margem `PER_TEXTURE_BUDGET` em `heap_textures` (`draw.rs`)**: - Escala a margem de segurança (`PER_TEXTURE_BUDGET.min(bytes_at_most / 4)`) para que passes de `<= 64 MiB` não interrompam o loop após subir apenas uma única textura. 3. **Variáveis de ambiente (`VICTORY_TEXTURE_PASS_MB` e `VICTORY_LOADING_DRAIN`)**: - `VICTORY_TEXTURE_PASS_MB`: permite definir explicitamente o limite de bytes por quadro nos passes de upload de texturas. - `VICTORY_LOADING_DRAIN=0`: permite desativar o boost automático em telas de loading (ativado por padrão). ### Testes e Validação - Novos testes unitários em `crates/victory-gpu/src/draw.rs` (`loading_screen_boosts_pass_budget_when_due_and_low_draw` e `pass_budget_respects_env_overrides_and_tdr_and_texture_budget`). - `cargo test -p victory-gpu` -> **207 passed, 0 failed**. *(Assistido por IA com Antigravity).* @uiliannn
ItzMeGamer commented 2026-11-26 16:02:37 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by ItzMeGamer on 2026-11-26T16:02:37Z.


Nota sobre uso de RAM em sistemas de 16 GB + HDD: Como a pré-drenagem em telas de loading envia mais texturas simultaneamente (256 MiB / 400 ms), nos testes em sistema com 16 GB de RAM + HDD o uso total de RAM chegou a 95–98% durante a carga (sem crash quando combinado com #107 + #111 e pagefile manual no SSD). Em máquinas com pouca RAM livre, pode-se reduzir o teto via VICTORY_TEXTURE_PASS_MB (ex.: 64 ou 128) ou desativar o boost com VICTORY_LOADING_DRAIN=0.
@uiliannn

<!-- greyfinch-sync:uiliannn/VItoriaBr:comment:7197101602 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/125#issuecomment-7197101602). Originally posted by [ItzMeGamer](https://github.com/ItzMeGamer) on 2026-11-26T16:02:37Z. --- **Nota sobre uso de RAM em sistemas de 16 GB + HDD:** Como a pré-drenagem em telas de loading envia mais texturas simultaneamente (`256 MiB / 400 ms`), nos testes em sistema com **16 GB de RAM + HDD** o uso total de RAM chegou a **95–98%** durante a carga (sem crash quando combinado com **#107** + **#111** e pagefile manual no SSD). Em máquinas com pouca RAM livre, pode-se reduzir o teto via `VICTORY_TEXTURE_PASS_MB` (ex.: `64` ou `128`) ou desativar o boost com `VICTORY_LOADING_DRAIN=0`. @uiliannn
fladit123 commented 2026-11-26 19:54:52 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by fladit123 on 2026-11-26T19:54:52Z.

Review: CHANGES_REQUESTED


Reviewed HEAD 4bfbf98e139643ab93996f79c069efe996e013a5 against the current main.

The loading-screen texture pre-drain is an interesting approach, especially for 8 GB GPUs. However, I found three points worth addressing before enabling this behavior by default.

1. Existing early-pass disable semantics

compute_early_pass_budget() can select the 400 ms loading-drain path even when VICTORY_EARLY_TEXTURES_MS=0 and VICTORY_BAKE_TEXTURES_MS=0.

Previously, these settings disabled early texture passes. Please preserve the existing opt-out behavior, or explicitly document the changed semantics and add a regression test for this configuration.

2. Active-world texture starvation

The active-3D cap reduces the regular texture upload budget from 192 MiB to 32 MiB, and a catch-up pass can fall from 576 MiB to 32 MiB.

This may improve frame times while extending the time needed to drain a large texture backlog. It would be useful to measure queue depth, texture readiness, time to drain, visual correctness and frame-time percentiles together.

3. TDR and memory pressure

A CPU preparation-time budget below 2 seconds does not guarantee that GPU execution remains below the TDR threshold.

The reported 95–98% RAM utilization on a 16 GB machine also suggests that memory-pressure-aware admission may be safer than relying exclusively on draw counts and fixed upload budgets.

I would recommend retaining the previous defaults until the loading-drain behavior has been independently qualified, or keeping the new policy opt-in initially.

Static source review only. No local build or gameplay validation performed.

AI-assisted review using OpenAI ChatGPT.

<!-- greyfinch-sync:uiliannn/VItoriaBr:review:6079831076 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/125#pullrequestreview-6079831076). Originally posted by [fladit123](https://github.com/fladit123) on 2026-11-26T19:54:52Z. **Review:** CHANGES_REQUESTED --- Reviewed HEAD `4bfbf98e139643ab93996f79c069efe996e013a5` against the current main. The loading-screen texture pre-drain is an interesting approach, especially for 8 GB GPUs. However, I found three points worth addressing before enabling this behavior by default. **1. Existing early-pass disable semantics** `compute_early_pass_budget()` can select the 400 ms loading-drain path even when `VICTORY_EARLY_TEXTURES_MS=0` and `VICTORY_BAKE_TEXTURES_MS=0`. Previously, these settings disabled early texture passes. Please preserve the existing opt-out behavior, or explicitly document the changed semantics and add a regression test for this configuration. **2. Active-world texture starvation** The active-3D cap reduces the regular texture upload budget from 192 MiB to 32 MiB, and a catch-up pass can fall from 576 MiB to 32 MiB. This may improve frame times while extending the time needed to drain a large texture backlog. It would be useful to measure queue depth, texture readiness, time to drain, visual correctness and frame-time percentiles together. **3. TDR and memory pressure** A CPU preparation-time budget below 2 seconds does not guarantee that GPU execution remains below the TDR threshold. The reported 95–98% RAM utilization on a 16 GB machine also suggests that memory-pressure-aware admission may be safer than relying exclusively on draw counts and fixed upload budgets. I would recommend retaining the previous defaults until the loading-drain behavior has been independently qualified, or keeping the new policy opt-in initially. Static source review only. No local build or gameplay validation performed. AI-assisted review using OpenAI ChatGPT.

Pull request closed

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
uiliannn/VItoriaBr!125
No description provided.