Skip to content

Commit

Permalink
internal/atlas: reduce the access to (*restorable.Shader).Unit
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Oct 26, 2024
1 parent 2437ad8 commit 00fade9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/atlas/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice
vertices[i+2] += oxf
vertices[i+3] += oyf
}
if shader.ensureShader().Unit() == shaderir.Texels {
if shader.unit == shaderir.Texels {
sw, sh := srcs[0].backend.restorable.InternalSize()
swf, shf := float32(sw), float32(sh)
for i := 0; i < n; i += graphics.VertexFloatCount {
Expand Down
12 changes: 10 additions & 2 deletions internal/atlas/shader.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
type Shader struct {
ir *shaderir.Program
shader *restorable.Shader
unit shaderir.Unit
name string
}

Expand All @@ -32,6 +33,7 @@ func NewShader(ir *shaderir.Program, name string) *Shader {
return &Shader{
ir: ir,
name: name,
unit: ir.Unit,
}
}

Expand Down Expand Up @@ -77,6 +79,12 @@ func (s *Shader) deallocate() {
}

var (
NearestFilterShader = &Shader{shader: restorable.NearestFilterShader}
LinearFilterShader = &Shader{shader: restorable.LinearFilterShader}
NearestFilterShader = &Shader{
shader: restorable.NearestFilterShader,
unit: restorable.NearestFilterShader.Unit(),
}
LinearFilterShader = &Shader{
shader: restorable.LinearFilterShader,
unit: restorable.LinearFilterShader.Unit(),
}
)

0 comments on commit 00fade9

Please sign in to comment.