internal/atlas: reduce the access to (*restorable.Shader).Unit

This commit is contained in:
Hajime Hoshi 2024-10-27 00:46:03 +09:00
parent 2437ad8248
commit 00fade9dcf
2 changed files with 11 additions and 3 deletions

View File

@ -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 {

View File

@ -24,6 +24,7 @@ import (
type Shader struct {
ir *shaderir.Program
shader *restorable.Shader
unit shaderir.Unit
name string
}
@ -32,6 +33,7 @@ func NewShader(ir *shaderir.Program, name string) *Shader {
return &Shader{
ir: ir,
name: name,
unit: ir.Unit,
}
}
@ -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(),
}
)