diff --git a/internal/driver/graphics.go b/internal/driver/graphics.go index d512da900..8fcc744ef 100644 --- a/internal/driver/graphics.go +++ b/internal/driver/graphics.go @@ -29,6 +29,11 @@ type Region struct { Height float32 } +const ( + InvalidImageID = -1 + InvalidShaderID = -1 +) + type Graphics interface { Begin() End() @@ -43,7 +48,6 @@ type Graphics interface { IsGL() bool HasHighPrecisionFloat() bool MaxImageSize() int - InvalidImageID() ImageID NewShader(program *shaderir.Program) (Shader, error) diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 4a6cbc658..b9b3c56d5 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -417,7 +417,7 @@ func (c *drawTrianglesCommand) Exec(indexOffset int) error { var imgs [graphics.ShaderImageNum]driver.ImageID for i, src := range c.srcs { if src == nil { - imgs[i] = theGraphicsDriver.InvalidImageID() + imgs[i] = driver.InvalidImageID continue } imgs[i] = src.image.ID() diff --git a/internal/graphicsdriver/metal/graphics.go b/internal/graphicsdriver/metal/graphics.go index b44c68436..9e016d5b2 100644 --- a/internal/graphicsdriver/metal/graphics.go +++ b/internal/graphicsdriver/metal/graphics.go @@ -413,10 +413,6 @@ func (g *Graphics) genNextImageID() driver.ImageID { return id } -func (g *Graphics) InvalidImageID() driver.ImageID { - return -1 -} - func (g *Graphics) genNextShaderID() driver.ShaderID { id := g.nextShaderID g.nextShaderID++ diff --git a/internal/graphicsdriver/opengl/graphics.go b/internal/graphicsdriver/opengl/graphics.go index 074f01d1b..8ed7de348 100644 --- a/internal/graphicsdriver/opengl/graphics.go +++ b/internal/graphicsdriver/opengl/graphics.go @@ -79,10 +79,6 @@ func (g *Graphics) genNextImageID() driver.ImageID { return id } -func (g *Graphics) InvalidImageID() driver.ImageID { - return -1 -} - func (g *Graphics) genNextShaderID() driver.ShaderID { id := g.nextShaderID g.nextShaderID++ @@ -391,7 +387,7 @@ func (g *Graphics) DrawShader(dst driver.ImageID, srcs [graphics.ShaderImageNum] var ts [graphics.ShaderImageNum]textureVariable for i, src := range srcs { - if src == g.InvalidImageID() { + if src == driver.InvalidImageID { continue } ts[i].valid = true