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.

View File

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

View File

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