render3d/vk: a buffer re-filled every frame ping-pongs between two instead of being made again

With one frame in flight, a buffer filled every frame (the interface's vertex
buffer, ov_vbo) was still being read by the frame on the GPU when the next
frame filled it, so gvk_buf_reserve released it and made a new VkBuffer and
its memory every frame - and every new buffer took a prime submit of its own.
Each handle now keeps a second buffer (gvk_bsp_*): a busy one swaps with it
when it is free, else the busy one becomes the second and one new buffer is
made; releasing a handle lets both go.

The launcher window (--launcher-ui, R3D_VK_PROF, per 120 frames): buffers
made/destroyed 120/120 -> 0/0, command buffers 240 -> 120 (one a frame). Its
footprint does not move with it (358 MB at 40 s, both): the churn was work,
not memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 14:45:02 +03:00
parent 5297996640
commit 2bb7ae1883
2 changed files with 81 additions and 1 deletions

View file

@ -382,6 +382,11 @@ export state Render3dState {
gvk_buf_size: []int = null
gvk_buf_map: []pointer = null # host-visible buffers stay mapped for their whole life
gvk_buf_used: []int = null # the frame (gvk_frame_no) a draw last bound the buffer in
gvk_bsp_buf: []long = null # per handle, a second buffer a re-filled one swaps with (gvk_buf_reserve)
gvk_bsp_mem: []long = null
gvk_bsp_size: []int = null
gvk_bsp_map: []pointer = null
gvk_bsp_used: []int = null
gvk_frame_no: int = 1
@max(4096) gvk_retired_buf: []long = null
@max(4096) gvk_retired_mem: []long = null