From ab26312108516fba7e87d0fc928308ade9d9347a Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 6 Jul 2021 14:20:19 +0900 Subject: [PATCH] internal/graphicsdriver/metal: Release objects appropriately --- internal/graphicsdriver/metal/graphics.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/graphicsdriver/metal/graphics.go b/internal/graphicsdriver/metal/graphics.go index 6c7482e7a..37cc08a30 100644 --- a/internal/graphicsdriver/metal/graphics.go +++ b/internal/graphicsdriver/metal/graphics.go @@ -744,7 +744,9 @@ func (g *Graphics) draw(rps mtl.RenderPipelineState, dst *Image, dstRegion drive StencilCompareFunction: mtl.CompareFunctionAlways, }, } - g.rce.SetDepthStencilState(g.view.getMTLDevice().MakeDepthStencilState(desc)) + ss := g.view.getMTLDevice().MakeDepthStencilState(desc) + g.rce.SetDepthStencilState(ss) + ss.Release() case drawWithStencil: desc := mtl.DepthStencilDescriptor{ BackFaceStencil: mtl.StencilDescriptor{ @@ -760,7 +762,9 @@ func (g *Graphics) draw(rps mtl.RenderPipelineState, dst *Image, dstRegion drive StencilCompareFunction: mtl.CompareFunctionNotEqual, }, } - g.rce.SetDepthStencilState(g.view.getMTLDevice().MakeDepthStencilState(desc)) + ss := g.view.getMTLDevice().MakeDepthStencilState(desc) + g.rce.SetDepthStencilState(ss) + ss.Release() case noStencil: desc := mtl.DepthStencilDescriptor{ BackFaceStencil: mtl.StencilDescriptor{ @@ -776,7 +780,9 @@ func (g *Graphics) draw(rps mtl.RenderPipelineState, dst *Image, dstRegion drive StencilCompareFunction: mtl.CompareFunctionAlways, }, } - g.rce.SetDepthStencilState(g.view.getMTLDevice().MakeDepthStencilState(desc)) + ss := g.view.getMTLDevice().MakeDepthStencilState(desc) + g.rce.SetDepthStencilState(ss) + ss.Release() } g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, indexLen, mtl.IndexTypeUInt16, g.ib, indexOffset*2)