Skip to content

Commit

Permalink
Revert "internal/restorable: integrate Shader.Dispose into internal/a…
Browse files Browse the repository at this point in the history
…tlas"

This reverts commit bfa2c46.

Updates #3083
  • Loading branch information
hajimehoshi committed Sep 6, 2024
1 parent 4f06b7b commit bc334e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 1 addition & 2 deletions internal/atlas/shader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions internal/restorable/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
9 changes: 7 additions & 2 deletions internal/restorable/shader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc334e1

Please sign in to comment.