internal/driver: Define InvalidImageID / InvalidShaderID

This commit is contained in:
Hajime Hoshi 2021-07-01 13:56:42 +09:00
parent 586130b96c
commit 73bf1f36e5
4 changed files with 7 additions and 11 deletions

View File

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

View File

@ -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()

View File

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

View File

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