diff --git a/internal/graphicsdriver/metal/ca/ca.go b/internal/graphicsdriver/metal/ca/ca.go index 30f44aae5..d7df1a94e 100644 --- a/internal/graphicsdriver/metal/ca/ca.go +++ b/internal/graphicsdriver/metal/ca/ca.go @@ -152,3 +152,7 @@ func (md MetalDrawable) Drawable() unsafe.Pointer { return md.metalDrawable } func (md MetalDrawable) Texture() mtl.Texture { return mtl.NewTexture(C.MetalDrawable_Texture(md.metalDrawable)) } + +func (md MetalDrawable) Release() { + C.MetalDrawable_Release(md.metalDrawable) +} diff --git a/internal/graphicsdriver/metal/ca/ca.h b/internal/graphicsdriver/metal/ca/ca.h index 4190a41f2..435965975 100644 --- a/internal/graphicsdriver/metal/ca/ca.h +++ b/internal/graphicsdriver/metal/ca/ca.h @@ -31,3 +31,4 @@ void MetalLayer_SetDrawableSize(void *metalLayer, double width, double height); void *MetalLayer_NextDrawable(void *metalLayer); void *MetalDrawable_Texture(void *drawable); +void MetalDrawable_Release(void *drawable); diff --git a/internal/graphicsdriver/metal/ca/ca.m b/internal/graphicsdriver/metal/ca/ca.m index b168c8d18..a8a47f195 100644 --- a/internal/graphicsdriver/metal/ca/ca.m +++ b/internal/graphicsdriver/metal/ca/ca.m @@ -89,3 +89,7 @@ void *MetalLayer_NextDrawable(void *metalLayer) { void *MetalDrawable_Texture(void *metalDrawable) { return ((id)metalDrawable).texture; } + +void MetalDrawable_Release(void *metalDrawable) { + [(id)metalDrawable release]; +} diff --git a/internal/graphicsdriver/metal/driver.go b/internal/graphicsdriver/metal/driver.go index 3e1792b5c..e0e898367 100644 --- a/internal/graphicsdriver/metal/driver.go +++ b/internal/graphicsdriver/metal/driver.go @@ -598,6 +598,7 @@ func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode } t = d.screenDrawable.Texture() } else { + d.screenDrawable.Release() d.screenDrawable = ca.MetalDrawable{} t = d.dst.texture }