internal/graphicsdriver/metal: Release objects appropriately

This commit is contained in:
Hajime Hoshi 2021-07-06 14:20:19 +09:00
parent 17d8cb5311
commit ab26312108

View File

@ -744,7 +744,9 @@ func (g *Graphics) draw(rps mtl.RenderPipelineState, dst *Image, dstRegion drive
StencilCompareFunction: mtl.CompareFunctionAlways, 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: case drawWithStencil:
desc := mtl.DepthStencilDescriptor{ desc := mtl.DepthStencilDescriptor{
BackFaceStencil: mtl.StencilDescriptor{ BackFaceStencil: mtl.StencilDescriptor{
@ -760,7 +762,9 @@ func (g *Graphics) draw(rps mtl.RenderPipelineState, dst *Image, dstRegion drive
StencilCompareFunction: mtl.CompareFunctionNotEqual, 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: case noStencil:
desc := mtl.DepthStencilDescriptor{ desc := mtl.DepthStencilDescriptor{
BackFaceStencil: mtl.StencilDescriptor{ BackFaceStencil: mtl.StencilDescriptor{
@ -776,7 +780,9 @@ func (g *Graphics) draw(rps mtl.RenderPipelineState, dst *Image, dstRegion drive
StencilCompareFunction: mtl.CompareFunctionAlways, 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) g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, indexLen, mtl.IndexTypeUInt16, g.ib, indexOffset*2)