render3d: gvk_read_screen reads back into one buffer kept in the state
Every read of the screen made bytes(screen_w * screen_h * 4) and dropped it: the user's manual play left 22,970,368 B unreachable (exactly 3024x1898x4) at gpu_vk_draw.ludic:1673 - one per photograph (shots' ph_grab, through gpu_read_screen_bytes). The read-back is now gvk_read_px, made once and made again (the old one freed) only when the screen's size changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
28ad6f62ea
commit
87587b00b6
2 changed files with 11 additions and 1 deletions
|
|
@ -1670,7 +1670,15 @@ function gvk_blit(render3d_st: mut Render3dState, w: int, h: int, mask: int) ->
|
|||
@alloc_ok("asked for by the player or a tool, not by the frame")
|
||||
function gvk_read_screen(render3d_st: mut Render3dState, w: int, h: int, out: pointer) -> void {
|
||||
gvk_present(render3d_st)
|
||||
let px = bytes(render3d_st.gvk_screen_w * render3d_st.gvk_screen_h * 4)
|
||||
# one read-back buffer, kept and replaced only when the screen's size changes: a buffer the size of
|
||||
# the screen was made on every read and dropped (23 MB a photograph at 3024x1898)
|
||||
let need = render3d_st.gvk_screen_w * render3d_st.gvk_screen_h * 4
|
||||
if render3d_st.gvk_read_px == null or render3d_st.gvk_read_cap != need {
|
||||
if render3d_st.gvk_read_px != null { free(render3d_st.gvk_read_px) }
|
||||
render3d_st.gvk_read_px = bytes(need)
|
||||
render3d_st.gvk_read_cap = need
|
||||
}
|
||||
let px = render3d_st.gvk_read_px
|
||||
if not gvk_tex_read(render3d_st, render3d_st.gvk_screen_color, GL_RGBA8, render3d_st.gvk_screen_w, render3d_st.gvk_screen_h, GL_RGBA, GL_UNSIGNED_BYTE, px) { return }
|
||||
let dst: pointer = out
|
||||
for y in 0 .. h {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue