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 Height float32
} }
const (
InvalidImageID = -1
InvalidShaderID = -1
)
type Graphics interface { type Graphics interface {
Begin() Begin()
End() End()
@ -43,7 +48,6 @@ type Graphics interface {
IsGL() bool IsGL() bool
HasHighPrecisionFloat() bool HasHighPrecisionFloat() bool
MaxImageSize() int MaxImageSize() int
InvalidImageID() ImageID
NewShader(program *shaderir.Program) (Shader, error) 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 var imgs [graphics.ShaderImageNum]driver.ImageID
for i, src := range c.srcs { for i, src := range c.srcs {
if src == nil { if src == nil {
imgs[i] = theGraphicsDriver.InvalidImageID() imgs[i] = driver.InvalidImageID
continue continue
} }
imgs[i] = src.image.ID() imgs[i] = src.image.ID()

View File

@ -413,10 +413,6 @@ func (g *Graphics) genNextImageID() driver.ImageID {
return id return id
} }
func (g *Graphics) InvalidImageID() driver.ImageID {
return -1
}
func (g *Graphics) genNextShaderID() driver.ShaderID { func (g *Graphics) genNextShaderID() driver.ShaderID {
id := g.nextShaderID id := g.nextShaderID
g.nextShaderID++ g.nextShaderID++

View File

@ -79,10 +79,6 @@ func (g *Graphics) genNextImageID() driver.ImageID {
return id return id
} }
func (g *Graphics) InvalidImageID() driver.ImageID {
return -1
}
func (g *Graphics) genNextShaderID() driver.ShaderID { func (g *Graphics) genNextShaderID() driver.ShaderID {
id := g.nextShaderID id := g.nextShaderID
g.nextShaderID++ g.nextShaderID++
@ -391,7 +387,7 @@ func (g *Graphics) DrawShader(dst driver.ImageID, srcs [graphics.ShaderImageNum]
var ts [graphics.ShaderImageNum]textureVariable var ts [graphics.ShaderImageNum]textureVariable
for i, src := range srcs { for i, src := range srcs {
if src == g.InvalidImageID() { if src == driver.InvalidImageID {
continue continue
} }
ts[i].valid = true ts[i].valid = true