Files
iss_pc/docs/PRE_AQUECIMENTO.md
e7b467e992 Advanced launcher screen, bounded wait for compiling shaders, region trace and shader index (#100)
* Test: BC 1D on NVIDIA (TLG_BC_TINY=auto, promoted BC 1D answers dimension queries as 1D)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* Test script: occlusion and BP09 variants

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* Launcher: Advanced screen with the GPU/runtime tuning parameters (switches, numbers, lists)

31 environment-only parameters (synchronisation, threads, readbacks, pipelines, image
workarounds, diagnostics) with bilingual descriptions, Automatic/default handling, search,
restore defaults and a copyable combination. Choices live in tlg.ini (adv_<name>) and reach the
game as ISS_<name> only when changed; the Config: log block shows them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* Test tools: one-round runner, monitor and analyzer for the parameter study

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* GPU: bounded wait for a compiling pipeline (TLG_ASYNC_WAIT_MS) and a faster driver cache save

A draw whose pipeline is still compiling in the background used to be skipped at once (missing
ground or effects while the shader cache is cold). With TLG_ASYNC_WAIT_MS=N (default 0 = off)
it first waits up to N ms for the compile, and the waits of one GPU frame add up to at most
TLG_ASYNC_WAIT_FRAME_MS (default 8). The log gets an 'Async wait (total)' line every 5 s.
The driver cache is saved every 60 s (TLG_DRIVER_CACHE_SAVE_S, was 180).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* GPU: bounded wait for a compiling pipeline (TLG_ASYNC_WAIT_MS) and a faster driver cache save

A draw whose pipeline is still compiling in the background used to be skipped at once (missing
ground or effects while the shader cache is cold). With TLG_ASYNC_WAIT_MS=N (default 0 = off)
it first waits up to N ms for the compile, and the waits of one GPU frame add up to at most
TLG_ASYNC_WAIT_FRAME_MS (default 8). The log gets an 'Async wait (total)' line every 5 s.
The driver cache is saved every 60 s (TLG_DRIVER_CACHE_SAVE_S, was 180).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* Launcher Advanced: async wait and driver cache save parameters

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* Tools: shader_index.py, an index of the OrbShdr shaders in the player's own dump

Streaming scan of art/cache (.xpps, KCAP + OrbShdr), SQLite index hash -> file/offset/size/stage,
lookup, verify against existing shader caches, stats. Reads the dump only; nothing of the game
is copied or committed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* GPU: region trace (TLG_REGION_TRACE=1), step A of the per-region pre-warm

Writes region_trace.tsv in the GPU user folder: every .xpps package the game opens (O) and
the first request of each graphics/compute pipeline (P), on one monotonic clock, so an offline
pass can tell which pipelines each region needs before anything is built on top of it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* GPU: the bounded wait also covers a shader still being translated

A new shader is the usual reason for a skipped draw (its pipeline is only queued once the shader
is translated), so GetProgram waits too, within the same per-draw and per-frame budget.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* GPU: region trace records whether a pipeline was ready; the async wait tally is a warning

The log keeps warnings and above, so the 'Async wait (total)' line never showed. The region trace's
P lines get a fifth column: r = the pipeline existed at its first request, m = it was missing.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* Docs and polish: Advanced screen, pre-warm notes, region trace parameter, test variant 8

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

* Restore the third_party submodule entries (a worktree's symlinks had been committed)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BGrrT8Atu6mshYBUh1H1Mm

---------

Co-authored-by: HayatoG <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
2026-10-15 21:19:49 -03:00

2.1 KiB

Pré-aquecimento de shaders: o que sabemos e o que existe

Nota de trabalho (15/10/2026). O jogo traduz os shaders do PS4 (GCN) para Vulkan em tempo de execução; enquanto um shader ou pipeline novo compila em segundo plano, o desenho que dependia dele é pulado. É o chão, os prédios e os efeitos que somem por alguns quadros, principalmente com o cache de shaders frio.

O que o projeto faz hoje

  • Cache em disco de pipelines e shaders, com a chave incluindo um hash dos fontes do recompilador, e um aquecimento em segundo plano no boot (quase 6000 pipelines em ~6 s).
  • BP07 (desligado): desenhos importantes compilam na hora em vez de serem pulados.
  • Espera curta (ASYNC_WAIT_MS, desligada): um desenho cujo shader ou pipeline ainda compila espera até N ms (e no máximo ASYNC_WAIT_FRAME_MS por quadro) antes de ser pulado. O log mostra a linha Async wait (total) a cada 5 s.
  • Cache do driver salvo a cada 60 s (DRIVER_CACHE_SAVE_S).

O que descobrimos

  • O port do God of War III (mesma base) tem o mesmo mecanismo e admite o mesmo problema no README; não há pré-compilação nem ferramenta de aquecimento nele.
  • Os shaders do jogo ficam sem compressão nos pacotes .xpps de art/cache (contêiner KCAP, cabeçalho OrbShdr). tools/shader_index.py indexa todos (10 374 únicos no jogo 1.07), e o hash do índice é o mesmo que o port usa. Tudo só na máquina do jogador; nada do jogo é copiado.
  • Uma pré-tradução completa sem o jogo rodando não é possível: cada shader vira várias versões conforme o estado do desenho, e esse estado só aparece em jogo.
  • O jogo abre pacotes bNN.xpps por região, e logo depois pedem-se rajadas de pipelines. O rastreio (TLG_REGION_TRACE=1) grava isso em region_trace.tsv para estudar o que cada região precisa.

Próximos passos (propostos)

  1. Medir com o rastreio e a espera ligados em áreas novas.
  2. Priorizar no aquecimento os pipelines vistos em cada região, no cache local do jogador.
  3. Só então, um manifesto de estados por região e tradução sem o jogo (trabalho grande e arriscado).