Skip to content

Vulkan: a janela de constant buffers lê uma cópia por submissão, não o heap no lugar - #453

Merged
mamcjr merged 1 commit into
mamcjr:mainfrom
HallanBR:fix/cbwin-copy-per-submission
Nov 18, 2026
Merged

mamcjr merged 1 commit into
mamcjr:mainfrom
HallanBR:fix/cbwin-copy-per-submission

Conversation

@HallanBR

Copy link
Copy Markdown
Contributor

O que muda

Com LARECOMP_CB_WINDOW=1, o cbwin_bind ligava o buffer de 64 KB no lugar do heap. Com o Sync lag a CPU já
escreve ali as linhas do quadro seguinte enquanto a GPU lê: água branca, "cortinas" no terreno, espinhos em objetos
distantes - o motivo de a janela estar desligada desde 27/10.

Agora o resto do buffer vem de uma cópia por submissão (cache próprio por endereço / tamanho / vk_pending_seq()).
As linhas que as atualizações escrevem continuam vindo do patch buffer da janela, então as atualizações não invalidam
essa cópia - diferente do guest_copy normal, invalidado a cada CMD_UPDATE_UNIFORM_BUFFER, que por isso copiava 64 KB
por draw.

LARECOMP_CBWIN_SNAPSHOT=0: leitura no lugar, como antes. Chave A/B cbsnap. A janela continua desligada por padrão;
este PR só a deixa segura para quem a liga (e para o autor decidir ligá-la por padrão).

Medido

LARECOMP_CB_WINDOW=1, A/B cbwin, LARECOMP_LOG_CBUF_BYTES=1:

cópias de constant buffer thread de render potência
janela + cópia por submissão ~92 MB / 2 s 19,7 ms 5,58 W
cópia por draw (padrão atual) ~1.200 MB / 2 s 20,0 ms 5,64 W

13× menos bytes copiados (~15 → ~1,1 MB por quadro). O tempo cai pouco aqui (o memcpy deste SoC é rápido), mas é
tráfego de memória a menos. Água conferida em jogo: normal; terreno, horizonte e nuvens sem artefatos.

Aparelho e método

  • POCO F7 Pro (Snapdragon 8 Gen 3, Adreno 750, 12 GB), HyperOS 3 / Android 16
  • Driver Turnip "Gen8 V37" (Mesa 26.3-devel); jogo 1.8.2, modo Nativo
  • 30 e 40 fps, saída 720p, SGSR 1, sem AA; celular na bateria; adb por Wi-Fi

🤖 Generated with Claude Code

@mamcjr

mamcjr commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Obrigado. Faz sentido: lido no próprio heap, o resto do buffer mostrava ao GPU as linhas que a CPU já tinha escrito para o quadro seguinte, e a cópia por submissão resolve isso. Como a janela de constant buffers em si continua desligada por padrão (LARECOMP_CB_WINDOW=1), isso não muda nada para quem joga hoje.

Mesclo depois de testar aqui no 1.9.0 com LARECOMP_CB_WINDOW=1 (água branca, "cortinas" no terreno), já que as suas medições foram no 1.8.2.

…he heap in place

LARECOMP_CB_WINDOW bound the 64 KB buffer in place, where with the sync lag the CPU already writes the next frame's
rows: white water, terrain curtains (off since 2026-10-27). The rest of the buffer now comes from one copy per
submission; the updated rows still come from the patch buffer, so the updates don't drop that copy. Copies 1200 ->
92 MB per 2 s (LARECOMP_LOG_CBUF_BYTES), water checked in game on an Adreno 750. LARECOMP_CBWIN_SNAPSHOT=0: in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@HallanBR

Copy link
Copy Markdown
Contributor Author

Obrigado. Fiz rebase sobre o main atual para facilitar o teste; o código não mudou.

Só temos a 1.8.2 para testar, então o teste no 1.9.0 fica mesmo com você. Na 1.8.2, com LARECOMP_CB_WINDOW=1, a água e o terreno ficaram normais: sem água branca nem "cortinas".

@HallanBR
HallanBR force-pushed the fix/cbwin-copy-per-submission branch from 324ecf1 to 998fb27 Compare November 17, 2026 23:29
HallanBR added a commit to HallanBR/BOTWRecompAndroid that referenced this pull request Nov 18, 2026
…t helped and what didn't

Each change with its PR and state (mamcjr#452 and mamcjr#456 merged, mamcjr#453 mamcjr#454 mamcjr#455 mamcjr#457 proposed), the 40 / 45 fps section on
the JNI version of mamcjr#455, and the code that only existed in the test build (present thread, shadow cascades, the 30 fps
rate hint, kgsl, affinity) in its own "Testado fora do repositório" section, saying its variables aren't in the app.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mamcjr

mamcjr commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks for rebasing. I'll test it on 1.9.0 with LARECOMP_CB_WINDOW=1 (white water, terrain curtains) and merge.

@mamcjr

mamcjr commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks! On the POCO with 1.9.0 and LARECOMP_CB_WINDOW=1 (the heap placed on the GPU), the Plateau's ponds and terrain look right: no white water, no curtains. Merging.

@mamcjr
mamcjr merged commit ac3ff59 into mamcjr:main Nov 18, 2026
Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 20, 2026
… support

Builds on mamcjr#453 per-submission cbwin snapshots by adding a 64-slot 4-way CbwinBaseCache (invalidated only on guest writes outside the patched window or async write-back/gcopy retires via atomic gcopy_gen) and active-prefix CbpatchDedupe, enabling cbwin safely by default on Mali gcopy_mode while preserving LARECOMP_CBWIN_SNAPSHOT=0 and AB(cbsnap) behavior on gmem_placed GPUs.
Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 20, 2026
… support

Builds on mamcjr#453 per-submission cbwin snapshots by adding a 64-slot 4-way CbwinBaseCache (invalidated only on guest writes outside the patched window or async write-back/gcopy retires via atomic gcopy_gen) and active-prefix CbpatchDedupe, enabling cbwin safely by default on Mali gcopy_mode while preserving LARECOMP_CBWIN_SNAPSHOT=0 and AB(cbsnap) behavior on gmem_placed GPUs.
Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 20, 2026
… support

Reconciles cbwin (mamcjr#453) with Android gcopy_mode GPUs (ARM Mali), cuts redundant per-draw full-UBO transient copies via a submission-scoped base snapshot cache, isolates async writeback/retire seqlock synchronization via cbwin-private cbwin_retire_{gen,writing,armed} (zero gcopy_gen churn on non-cbwin GPUs), and shrinks per-draw CBP patch uploads with CbpatchDedupe.
HallanBR added a commit to HallanBR/BOTWRecompAndroid that referenced this pull request Nov 24, 2026
…mamcjr#457 merged; how each one landed

The status table and the section titles say merged. Sections 3-6 describe the code as it landed instead of the
proposal: mamcjr#454 queues the slots on every device (LARECOMP_SLOT_DRAIN=1 waits), with the 60 fps numbers of the merged
version; mamcjr#455 says its first version had no effect on Android (SDL lists only the current mode) and the merged one asks
Android through JNI, rechecked on 0.4.13 (40 fps on a 120 Hz screen); mamcjr#453 notes the window stays off by default on
Adreno and mamcjr#506 took the snapshot cache to Mali.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants