gpu: destroy_shader/buffer/texture on the GPU protocol (issue-0029)
Three new method signatures on the GPU protocol. Metal backend sends `release` to the MTLTexture/Buffer/RenderPipelineState and nulls the slot in its backing List so the handle becomes inert; handles are not re-used. glyph_cache.grow() now destroys the old atlas before allocating its replacement, eliminating the per-grow leak the file's comment had been flagging since Session 62.
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
// issue-0029: Feature — add explicit destructors to the GPU protocol so
|
||||
// resources can be freed without leaking.
|
||||
//
|
||||
// ── Proposed additions to library/modules/gpu/api.sx ──────────────────────
|
||||
//
|
||||
// destroy_shader :: (h: ShaderHandle);
|
||||
// destroy_buffer :: (h: BufferHandle);
|
||||
// destroy_texture :: (h: TextureHandle);
|
||||
//
|
||||
// ── Why ────────────────────────────────────────────────────────────────────
|
||||
//
|
||||
// Today, library/modules/ui/glyph_cache.sx's `grow()` method recreates
|
||||
// the atlas texture at a larger size but has no way to release the old
|
||||
// one — see the comment in metal.sx that explicitly notes the leak. The
|
||||
// GL path uses glDeleteTextures(1, @self.texture_id); the GPU protocol
|
||||
// has no equivalent yet.
|
||||
//
|
||||
// ── Implementation notes ──────────────────────────────────────────────────
|
||||
//
|
||||
// Metal backend: send `release` to the MTLTexture / MTLBuffer /
|
||||
// MTLRenderPipelineState (or call CFRelease, since these are
|
||||
// CFTypeRef-compatible). Clear the corresponding slot in
|
||||
// MetalGPU.textures / buffers / shaders to `null` / 0.
|
||||
//
|
||||
// GL backend (future): glDeleteTextures / glDeleteBuffers / glDeleteProgram.
|
||||
//
|
||||
// Handle lifecycle: after destroy, the slot in the backend List is freed.
|
||||
// New allocations can take that slot or grow the list. Caller's handles
|
||||
// remain valid until destroy. Don't aggressively re-use slots in MVP;
|
||||
// keep handles append-only with a `null` marker for destroyed entries
|
||||
// (matches the current shape).
|
||||
//
|
||||
// ── Touch points ──────────────────────────────────────────────────────────
|
||||
//
|
||||
// library/modules/gpu/api.sx — add 3 protocol method signatures
|
||||
// library/modules/gpu/metal.sx — implement them (release + null
|
||||
// the slot)
|
||||
// library/modules/ui/glyph_cache.sx — call destroy_texture(old_handle)
|
||||
// in grow() before creating the
|
||||
// new atlas
|
||||
//
|
||||
// ── Syntax constraint ─────────────────────────────────────────────────────
|
||||
//
|
||||
// None — straight protocol-method addition.
|
||||
|
||||
#import "modules/std.sx";
|
||||
main :: () -> s32 { 0; }
|
||||
Reference in New Issue
Block a user