diff --git a/internal/atlas/shader.go b/internal/atlas/shader.go index 8861d14c7..addb3188c 100644 --- a/internal/atlas/shader.go +++ b/internal/atlas/shader.go @@ -68,7 +68,8 @@ func (s *Shader) deallocate() { if s.shader == nil { return } - s.shader.Dispose() + s.shader.Shader.Dispose() + s.shader.Shader = nil s.shader = nil } diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 08ef389b9..6f2908c4a 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -91,7 +91,7 @@ func quadVertices(dx0, dy0, dx1, dy1, sx0, sy0, sx1, sy1, cr, cg, cb, ca float32 func clearImage(i *graphicscommand.Image, region image.Rectangle) { vs := quadVertices(float32(region.Min.X), float32(region.Min.Y), float32(region.Max.X), float32(region.Max.Y), 0, 0, 0, 0, 0, 0, 0, 0) is := graphics.QuadIndices() - i.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{}, vs, is, graphicsdriver.BlendClear, region, [graphics.ShaderImageCount]image.Rectangle{}, clearShader.shader, nil, graphicsdriver.FillAll) + i.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{}, vs, is, graphicsdriver.BlendClear, region, [graphics.ShaderImageCount]image.Rectangle{}, clearShader.Shader, nil, graphicsdriver.FillAll) } // ClearPixels clears the specified region by WritePixels. @@ -141,5 +141,5 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [ } imgs[i] = src.Image } - i.Image.DrawTriangles(imgs, vertices, indices, blend, dstRegion, srcRegions, shader.shader, uniforms, fillRule) + i.Image.DrawTriangles(imgs, vertices, indices, blend, dstRegion, srcRegions, shader.Shader, uniforms, fillRule) } diff --git a/internal/restorable/shader.go b/internal/restorable/shader.go index e46504f1c..426a6216e 100644 --- a/internal/restorable/shader.go +++ b/internal/restorable/shader.go @@ -26,21 +26,16 @@ import ( ) type Shader struct { - shader *graphicscommand.Shader + Shader *graphicscommand.Shader } func NewShader(ir *shaderir.Program) *Shader { s := &Shader{ - shader: graphicscommand.NewShader(ir), + Shader: graphicscommand.NewShader(ir), } return s } -func (s *Shader) Dispose() { - s.shader.Dispose() - s.shader = nil -} - var ( NearestFilterShader *Shader NearestFilterShaderIR *shaderir.Program