mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
all: remove unused conditions
Now Kage shaders are always used. The situtation is different from when we fixed for #1355, so we removed the fast path for #1335. We have to re-check the current performance. Updates #1355
This commit is contained in:
parent
534d82c17d
commit
72983d966b
@ -455,31 +455,24 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
||||
}
|
||||
|
||||
var offsets [graphics.ShaderImageCount - 1][2]float32
|
||||
var s *restorable.Shader
|
||||
var imgs [graphics.ShaderImageCount]*restorable.Image
|
||||
if shader == nil {
|
||||
// Fast path for rendering without a shader (#1355).
|
||||
imgs[0] = srcs[0].backend.restorable
|
||||
} else {
|
||||
for i, subimageOffset := range subimageOffsets {
|
||||
src := srcs[i+1]
|
||||
if src == nil {
|
||||
continue
|
||||
}
|
||||
ox, oy, _, _ := src.regionWithPadding()
|
||||
offsets[i][0] = float32(ox+src.paddingSize()) - oxf + subimageOffset[0]
|
||||
offsets[i][1] = float32(oy+src.paddingSize()) - oyf + subimageOffset[1]
|
||||
for i, subimageOffset := range subimageOffsets {
|
||||
src := srcs[i+1]
|
||||
if src == nil {
|
||||
continue
|
||||
}
|
||||
s = shader.shader
|
||||
for i, src := range srcs {
|
||||
if src == nil {
|
||||
continue
|
||||
}
|
||||
imgs[i] = src.backend.restorable
|
||||
ox, oy, _, _ := src.regionWithPadding()
|
||||
offsets[i][0] = float32(ox+src.paddingSize()) - oxf + subimageOffset[0]
|
||||
offsets[i][1] = float32(oy+src.paddingSize()) - oyf + subimageOffset[1]
|
||||
}
|
||||
for i, src := range srcs {
|
||||
if src == nil {
|
||||
continue
|
||||
}
|
||||
imgs[i] = src.backend.restorable
|
||||
}
|
||||
|
||||
i.backend.restorable.DrawTriangles(imgs, offsets, vertices, indices, mode, dstRegion, srcRegion, s, uniforms, evenOdd)
|
||||
i.backend.restorable.DrawTriangles(imgs, offsets, vertices, indices, mode, dstRegion, srcRegion, shader.shader, uniforms, evenOdd)
|
||||
|
||||
for _, src := range srcs {
|
||||
if src == nil {
|
||||
|
@ -156,24 +156,16 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
||||
}
|
||||
}
|
||||
|
||||
var s *atlas.Shader
|
||||
var imgs [graphics.ShaderImageCount]*atlas.Image
|
||||
if shader == nil {
|
||||
// Fast path for rendering without a shader (#1355).
|
||||
img := srcs[0]
|
||||
imgs[0] = img.img
|
||||
} else {
|
||||
for i, img := range srcs {
|
||||
if img == nil {
|
||||
continue
|
||||
}
|
||||
imgs[i] = img.img
|
||||
for i, img := range srcs {
|
||||
if img == nil {
|
||||
continue
|
||||
}
|
||||
s = shader.shader
|
||||
imgs[i] = img.img
|
||||
}
|
||||
|
||||
i.invalidatePixels()
|
||||
i.img.DrawTriangles(imgs, vertices, indices, mode, dstRegion, srcRegion, subimageOffsets, s, uniforms, evenOdd)
|
||||
i.img.DrawTriangles(imgs, vertices, indices, mode, dstRegion, srcRegion, subimageOffsets, shader.shader, uniforms, evenOdd)
|
||||
}
|
||||
|
||||
type Shader struct {
|
||||
|
@ -328,22 +328,16 @@ func (c *drawTrianglesCommand) Exec(graphicsDriver graphicsdriver.Graphics, inde
|
||||
return nil
|
||||
}
|
||||
|
||||
var shaderID graphicsdriver.ShaderID = graphicsdriver.InvalidShaderID
|
||||
var imgs [graphics.ShaderImageCount]graphicsdriver.ImageID
|
||||
if c.shader != nil {
|
||||
shaderID = c.shader.shader.ID()
|
||||
for i, src := range c.srcs {
|
||||
if src == nil {
|
||||
imgs[i] = graphicsdriver.InvalidImageID
|
||||
continue
|
||||
}
|
||||
imgs[i] = src.image.ID()
|
||||
for i, src := range c.srcs {
|
||||
if src == nil {
|
||||
imgs[i] = graphicsdriver.InvalidImageID
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
imgs[0] = c.srcs[0].image.ID()
|
||||
imgs[i] = src.image.ID()
|
||||
}
|
||||
|
||||
return graphicsDriver.DrawTriangles(c.dst.image.ID(), imgs, c.offsets, shaderID, c.nindices, indexOffset, c.mode, c.dstRegion, c.srcRegion, c.uniforms, c.evenOdd)
|
||||
return graphicsDriver.DrawTriangles(c.dst.image.ID(), imgs, c.offsets, c.shader.shader.ID(), c.nindices, indexOffset, c.mode, c.dstRegion, c.srcRegion, c.uniforms, c.evenOdd)
|
||||
}
|
||||
|
||||
func (c *drawTrianglesCommand) numVertices() int {
|
||||
|
@ -128,23 +128,14 @@ func (i *Image) InternalSize() (int, int) {
|
||||
// If the source image is not specified, i.e., src is nil and there is no image in the uniform variables, the
|
||||
// elements for the source image are not used.
|
||||
func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, offsets [graphics.ShaderImageCount - 1][2]float32, vertices []float32, indices []uint16, mode graphicsdriver.CompositeMode, dstRegion, srcRegion graphicsdriver.Region, shader *Shader, uniforms [][]float32, evenOdd bool) {
|
||||
if shader == nil {
|
||||
// Fast path for rendering without a shader (#1355).
|
||||
img := srcs[0]
|
||||
if img.screen {
|
||||
for _, src := range srcs {
|
||||
if src == nil {
|
||||
continue
|
||||
}
|
||||
if src.screen {
|
||||
panic("graphicscommand: the screen image cannot be the rendering source")
|
||||
}
|
||||
img.resolveBufferedWritePixels()
|
||||
} else {
|
||||
for _, src := range srcs {
|
||||
if src == nil {
|
||||
continue
|
||||
}
|
||||
if src.screen {
|
||||
panic("graphicscommand: the screen image cannot be the rendering source")
|
||||
}
|
||||
src.resolveBufferedWritePixels()
|
||||
}
|
||||
src.resolveBufferedWritePixels()
|
||||
}
|
||||
i.resolveBufferedWritePixels()
|
||||
|
||||
|
@ -387,21 +387,14 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, offsets [g
|
||||
i.appendDrawTrianglesHistory(srcs, offsets, vertices, indices, mode, dstRegion, srcRegion, shader, uniforms, evenOdd)
|
||||
}
|
||||
|
||||
var s *graphicscommand.Shader
|
||||
var imgs [graphics.ShaderImageCount]*graphicscommand.Image
|
||||
if shader == nil {
|
||||
// Fast path for rendering without a shader (#1355).
|
||||
imgs[0] = srcs[0].image
|
||||
} else {
|
||||
for i, src := range srcs {
|
||||
if src == nil {
|
||||
continue
|
||||
}
|
||||
imgs[i] = src.image
|
||||
for i, src := range srcs {
|
||||
if src == nil {
|
||||
continue
|
||||
}
|
||||
s = shader.shader
|
||||
imgs[i] = src.image
|
||||
}
|
||||
i.image.DrawTriangles(imgs, offsets, vertices, indices, mode, dstRegion, srcRegion, s, uniforms, evenOdd)
|
||||
i.image.DrawTriangles(imgs, offsets, vertices, indices, mode, dstRegion, srcRegion, shader.shader, uniforms, evenOdd)
|
||||
}
|
||||
|
||||
// appendDrawTrianglesHistory appends a draw-image history item to the image.
|
||||
|
Loading…
Reference in New Issue
Block a user