mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ebiten: Bug fix: Source regions should not be passed when not needed
The source region information affects the condition of merging graphics commands. To avoid performance issues by the big number of graphcis commands, do not pass the source region whenever possible. Fixes #1293
This commit is contained in:
parent
95022ff1a5
commit
d4042a5cfa
28
image.go
28
image.go
@ -271,11 +271,15 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
|
|||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
|
|
||||||
var sr driver.Region
|
var sr driver.Region
|
||||||
sr = driver.Region{
|
// Pass the source region only when the shader is used, since this affects the condition of merging graphics
|
||||||
X: float32(bounds.Min.X),
|
// commands (#1293).
|
||||||
Y: float32(bounds.Min.Y),
|
if options.Shader != nil {
|
||||||
Width: float32(bounds.Dx()),
|
sr = driver.Region{
|
||||||
Height: float32(bounds.Dy()),
|
X: float32(bounds.Min.X),
|
||||||
|
Y: float32(bounds.Min.Y),
|
||||||
|
Width: float32(bounds.Dx()),
|
||||||
|
Height: float32(bounds.Dy()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srcs := [graphics.ShaderImageNum]*mipmap.Mipmap{img.mipmap}
|
srcs := [graphics.ShaderImageNum]*mipmap.Mipmap{img.mipmap}
|
||||||
@ -430,11 +434,15 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
|
|||||||
|
|
||||||
var sr driver.Region
|
var sr driver.Region
|
||||||
b := img.Bounds()
|
b := img.Bounds()
|
||||||
sr = driver.Region{
|
// Pass the source region only when the shader is used, since this affects the condition of merging graphics
|
||||||
X: float32(b.Min.X),
|
// commands (#1293).
|
||||||
Y: float32(b.Min.Y),
|
if options.Shader != nil || options.Address != AddressUnsafe {
|
||||||
Width: float32(b.Dx()),
|
sr = driver.Region{
|
||||||
Height: float32(b.Dy()),
|
X: float32(b.Min.X),
|
||||||
|
Y: float32(b.Min.Y),
|
||||||
|
Width: float32(b.Dx()),
|
||||||
|
Height: float32(b.Dy()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var srcs [graphics.ShaderImageNum]*mipmap.Mipmap
|
var srcs [graphics.ShaderImageNum]*mipmap.Mipmap
|
||||||
|
@ -337,8 +337,12 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageNum]*Image, vertices []f
|
|||||||
vertices[i*graphics.VertexFloatNum+2] += oxf
|
vertices[i*graphics.VertexFloatNum+2] += oxf
|
||||||
vertices[i*graphics.VertexFloatNum+3] += oyf
|
vertices[i*graphics.VertexFloatNum+3] += oyf
|
||||||
}
|
}
|
||||||
sourceRegion.X += oxf
|
// sourceRegion can be delibarately empty when this is not needed in order to avoid unexpected
|
||||||
sourceRegion.Y += oyf
|
// performance issue (#1293).
|
||||||
|
if sourceRegion.Width != 0 && sourceRegion.Height != 0 {
|
||||||
|
sourceRegion.X += oxf
|
||||||
|
sourceRegion.Y += oyf
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var offsets [graphics.ShaderImageNum - 1][2]float32
|
var offsets [graphics.ShaderImageNum - 1][2]float32
|
||||||
|
Loading…
Reference in New Issue
Block a user