render3d: recycle texture and buffer ids, free a released model whole, actor_release
A freed texture or buffer id goes on a spare list the next one takes; tex_note_size keeps sizes by id. model_release frees prims, meshes, material names, the skin and leaves gltf_cached. actor_release takes an actor off the stage and actor_new reuses its record (ECS's Things come and go all day). steady.ludic: an actor round at 0 bytes over 2000. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2fe4018d28
commit
9b482d609a
14 changed files with 208 additions and 39 deletions
|
|
@ -2,7 +2,7 @@
|
|||
# model the first load made, found by comparing the names in place, so asking allocates nothing. For
|
||||
# props a game places while it plays (a fish, a sign an animal leaves); a model whose document is
|
||||
# read after the load (ludic.anim's clips) still goes through gltf_load. A model loaded here is shared
|
||||
# by every actor drawing it, and is never released.
|
||||
# by every actor drawing it; model_release takes it out of the cache as it lets it go.
|
||||
export function gltf_cached(render3d_st: mut Render3dState, dir: string, file: string, node_name: string) -> Model {
|
||||
if render3d_st.gltf_kept == null {
|
||||
render3d_st.gltf_kept = new []Model
|
||||
|
|
@ -21,6 +21,23 @@ export function gltf_cached(render3d_st: mut Render3dState, dir: string, file: s
|
|||
return m
|
||||
}
|
||||
|
||||
# a model let go (model_release) leaves the cache, so the next ask loads it afresh
|
||||
function gltf_cached_forget(render3d_st: mut Render3dState, m: Model) -> void {
|
||||
if render3d_st.gltf_kept == null { return }
|
||||
let kept = render3d_st.gltf_kept
|
||||
let dirs = render3d_st.gltf_kept_dir
|
||||
let files = render3d_st.gltf_kept_file
|
||||
let nodes = render3d_st.gltf_kept_node
|
||||
for i in 0 .. len(kept) {
|
||||
if kept[i] == m {
|
||||
let last = len(kept) - 1
|
||||
kept[i] = kept[last]; dirs[i] = dirs[last]; files[i] = files[last]; nodes[i] = nodes[last]
|
||||
List.pop(kept); List.pop(dirs); List.pop(files); List.pop(nodes)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function gltf_cached_count(render3d_st: Render3dState) -> int {
|
||||
if render3d_st.gltf_kept == null { return 0 }
|
||||
return len(render3d_st.gltf_kept)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue