mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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,12 +455,7 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
|||||||
}
|
}
|
||||||
|
|
||||||
var offsets [graphics.ShaderImageCount - 1][2]float32
|
var offsets [graphics.ShaderImageCount - 1][2]float32
|
||||||
var s *restorable.Shader
|
|
||||||
var imgs [graphics.ShaderImageCount]*restorable.Image
|
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 {
|
for i, subimageOffset := range subimageOffsets {
|
||||||
src := srcs[i+1]
|
src := srcs[i+1]
|
||||||
if src == nil {
|
if src == nil {
|
||||||
@ -470,16 +465,14 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
|||||||
offsets[i][0] = float32(ox+src.paddingSize()) - oxf + subimageOffset[0]
|
offsets[i][0] = float32(ox+src.paddingSize()) - oxf + subimageOffset[0]
|
||||||
offsets[i][1] = float32(oy+src.paddingSize()) - oyf + subimageOffset[1]
|
offsets[i][1] = float32(oy+src.paddingSize()) - oyf + subimageOffset[1]
|
||||||
}
|
}
|
||||||
s = shader.shader
|
|
||||||
for i, src := range srcs {
|
for i, src := range srcs {
|
||||||
if src == nil {
|
if src == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
imgs[i] = src.backend.restorable
|
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 {
|
for _, src := range srcs {
|
||||||
if src == nil {
|
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
|
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 {
|
for i, img := range srcs {
|
||||||
if img == nil {
|
if img == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
imgs[i] = img.img
|
imgs[i] = img.img
|
||||||
}
|
}
|
||||||
s = shader.shader
|
|
||||||
}
|
|
||||||
|
|
||||||
i.invalidatePixels()
|
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 {
|
type Shader struct {
|
||||||
|
@ -328,10 +328,7 @@ func (c *drawTrianglesCommand) Exec(graphicsDriver graphicsdriver.Graphics, inde
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var shaderID graphicsdriver.ShaderID = graphicsdriver.InvalidShaderID
|
|
||||||
var imgs [graphics.ShaderImageCount]graphicsdriver.ImageID
|
var imgs [graphics.ShaderImageCount]graphicsdriver.ImageID
|
||||||
if c.shader != nil {
|
|
||||||
shaderID = c.shader.shader.ID()
|
|
||||||
for i, src := range c.srcs {
|
for i, src := range c.srcs {
|
||||||
if src == nil {
|
if src == nil {
|
||||||
imgs[i] = graphicsdriver.InvalidImageID
|
imgs[i] = graphicsdriver.InvalidImageID
|
||||||
@ -339,11 +336,8 @@ func (c *drawTrianglesCommand) Exec(graphicsDriver graphicsdriver.Graphics, inde
|
|||||||
}
|
}
|
||||||
imgs[i] = src.image.ID()
|
imgs[i] = src.image.ID()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
imgs[0] = c.srcs[0].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 {
|
func (c *drawTrianglesCommand) numVertices() int {
|
||||||
|
@ -128,14 +128,6 @@ 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
|
// 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.
|
// 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) {
|
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 {
|
|
||||||
panic("graphicscommand: the screen image cannot be the rendering source")
|
|
||||||
}
|
|
||||||
img.resolveBufferedWritePixels()
|
|
||||||
} else {
|
|
||||||
for _, src := range srcs {
|
for _, src := range srcs {
|
||||||
if src == nil {
|
if src == nil {
|
||||||
continue
|
continue
|
||||||
@ -145,7 +137,6 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, offsets [g
|
|||||||
}
|
}
|
||||||
src.resolveBufferedWritePixels()
|
src.resolveBufferedWritePixels()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
i.resolveBufferedWritePixels()
|
i.resolveBufferedWritePixels()
|
||||||
|
|
||||||
theCommandQueue.EnqueueDrawTrianglesCommand(i, srcs, offsets, vertices, indices, mode, dstRegion, srcRegion, shader, uniforms, evenOdd)
|
theCommandQueue.EnqueueDrawTrianglesCommand(i, srcs, offsets, vertices, indices, mode, dstRegion, srcRegion, shader, uniforms, evenOdd)
|
||||||
|
@ -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)
|
i.appendDrawTrianglesHistory(srcs, offsets, vertices, indices, mode, dstRegion, srcRegion, shader, uniforms, evenOdd)
|
||||||
}
|
}
|
||||||
|
|
||||||
var s *graphicscommand.Shader
|
|
||||||
var imgs [graphics.ShaderImageCount]*graphicscommand.Image
|
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 {
|
for i, src := range srcs {
|
||||||
if src == nil {
|
if src == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
imgs[i] = src.image
|
imgs[i] = src.image
|
||||||
}
|
}
|
||||||
s = shader.shader
|
i.image.DrawTriangles(imgs, offsets, vertices, indices, mode, dstRegion, srcRegion, shader.shader, uniforms, evenOdd)
|
||||||
}
|
|
||||||
i.image.DrawTriangles(imgs, offsets, vertices, indices, mode, dstRegion, srcRegion, s, uniforms, evenOdd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// appendDrawTrianglesHistory appends a draw-image history item to the image.
|
// appendDrawTrianglesHistory appends a draw-image history item to the image.
|
||||||
|
Loading…
Reference in New Issue
Block a user