fix(render3d): three leaks in Vulkan play - sampler keys, mip blits, a program per actor
- gvk_sampler built a key string on every call it was reached (a texture read two ways in turn misses its per-texture cache each time); samplers are found by their seven numbers instead - gvk_tex_mips_into allocated a VkImageBlit per level, every frame (the exposure measure's chain); it comes from the scratch ring, as does gvk_tex_grow_mips's copy - gvk_program_new made a new program - modules, pipelines - on every call, and every actor asks for one; a variant is now made once and shared (a program is immutable), and one that cannot be made stays 0 for every later asker Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9a4137e9da
commit
6ee496ab1c
3 changed files with 29 additions and 11 deletions
|
|
@ -1416,15 +1416,26 @@ function gvk_open(render3d_st: mut Render3dState, w: int, h: int, title: string)
|
|||
return true
|
||||
}
|
||||
|
||||
# a program handle for a variant; the key is gpu_program's, so gpu_program_key works on both
|
||||
# A variant is made once and shared: a program is immutable here, so every actor asking for the
|
||||
# one it wants (actor.ludic, one per actor) gets the same handle, not its own modules and pipelines.
|
||||
function gvk_program_new(render3d_st: mut Render3dState, vs: string, fs: string, defines: string) -> int {
|
||||
render3d_st.gvk_prog_counter += 1
|
||||
let p = render3d_st.gvk_prog_counter
|
||||
let key = `{vs}|{fs}|{Text.replace(defines, "\n", ";")}`
|
||||
if render3d_st.gpu_prog_ids == null { render3d_st.gpu_prog_ids = new []int; render3d_st.gpu_prog_keys = new []string }
|
||||
for i in 0 .. len(render3d_st.gpu_prog_keys) {
|
||||
if render3d_st.gpu_prog_keys[i] == key {
|
||||
free(key)
|
||||
return render3d_st.gpu_prog_ids[i]
|
||||
}
|
||||
}
|
||||
render3d_st.gvk_prog_counter += 1
|
||||
let p = render3d_st.gvk_prog_counter
|
||||
push(render3d_st.gpu_prog_ids, p)
|
||||
push(render3d_st.gpu_prog_keys, key)
|
||||
if not gvk_program(render3d_st, p, key, render3d_st.gvk_spv_dir) { return 0 }
|
||||
# a variant that cannot be made stays 0 for everyone who asks for it later
|
||||
if not gvk_program(render3d_st, p, key, render3d_st.gvk_spv_dir) {
|
||||
render3d_st.gpu_prog_ids[len(render3d_st.gpu_prog_ids) - 1] = 0
|
||||
return 0
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue