internal/graphicscommand: add Shader.id

This commit is contained in:
Hajime Hoshi 2023-12-01 21:31:50 +09:00
parent 6a7688d3ac
commit d91455c0a7
3 changed files with 16 additions and 6 deletions

View File

@ -98,7 +98,7 @@ func (c *drawTrianglesCommand) String() string {
} }
} }
return fmt.Sprintf("draw-triangles: dst: %s <- src: [%s], num of dst regions: %d, num of indices: %d, blend: %s, fill rule: %s", dst, strings.Join(srcstrs[:], ", "), len(c.dstRegions), c.numIndices(), blend, c.fillRule) return fmt.Sprintf("draw-triangles: dst: %s <- src: [%s], num of dst regions: %d, num of indices: %d, blend: %s, fill rule: %s, shader id: %d", dst, strings.Join(srcstrs[:], ", "), len(c.dstRegions), c.numIndices(), blend, c.fillRule, c.shader.id)
} }
// Exec executes the drawTrianglesCommand. // Exec executes the drawTrianglesCommand.

View File

@ -46,11 +46,11 @@ type Image struct {
bufferedWritePixelsArgs []writePixelsCommandArgs bufferedWritePixelsArgs []writePixelsCommandArgs
} }
var nextID = 1 var nextImageID = 1
func genNextID() int { func genNextImageID() int {
id := nextID id := nextImageID
nextID++ nextImageID++
return id return id
} }
@ -62,7 +62,7 @@ func NewImage(width, height int, screenFramebuffer bool) *Image {
width: width, width: width,
height: height, height: height,
screen: screenFramebuffer, screen: screenFramebuffer,
id: genNextID(), id: genNextImageID(),
} }
c := &newImageCommand{ c := &newImageCommand{
result: i, result: i,

View File

@ -19,14 +19,24 @@ import (
"github.com/hajimehoshi/ebiten/v2/internal/shaderir" "github.com/hajimehoshi/ebiten/v2/internal/shaderir"
) )
var nextShaderID = 1
func genNextShaderID() int {
id := nextShaderID
nextShaderID++
return id
}
type Shader struct { type Shader struct {
shader graphicsdriver.Shader shader graphicsdriver.Shader
ir *shaderir.Program ir *shaderir.Program
id int
} }
func NewShader(ir *shaderir.Program) *Shader { func NewShader(ir *shaderir.Program) *Shader {
s := &Shader{ s := &Shader{
ir: ir, ir: ir,
id: genNextShaderID(),
} }
c := &newShaderCommand{ c := &newShaderCommand{
result: s, result: s,