Revert "internal/restorable: integrate Shader.Dispose into internal/atlas"

This reverts commit bfa2c460a2.

Updates #3083
This commit is contained in:
Hajime Hoshi 2024-09-06 14:08:47 +09:00
parent 17a5488c49
commit 19d2009a5f
3 changed files with 10 additions and 6 deletions

View File

@ -70,8 +70,7 @@ func (s *Shader) deallocate() {
if s.shader == nil {
return
}
s.shader.Shader.Dispose()
s.shader.Shader = nil
s.shader.Dispose()
s.shader = nil
}

View File

@ -83,7 +83,7 @@ func clearImage(i *graphicscommand.Image, region image.Rectangle) {
vs := make([]float32, 4*graphics.VertexFloatCount)
graphics.QuadVerticesFromDstAndSrc(vs, 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.ShaderSrcImageCount]*graphicscommand.Image{}, vs, is, graphicsdriver.BlendClear, region, [graphics.ShaderSrcImageCount]image.Rectangle{}, clearShader.Shader, nil, graphicsdriver.FillRuleFillAll)
i.DrawTriangles([graphics.ShaderSrcImageCount]*graphicscommand.Image{}, vs, is, graphicsdriver.BlendClear, region, [graphics.ShaderSrcImageCount]image.Rectangle{}, clearShader.shader, nil, graphicsdriver.FillRuleFillAll)
}
// ClearPixels clears the specified region by WritePixels.
@ -133,5 +133,5 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice
}
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)
}

View File

@ -26,16 +26,21 @@ 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