mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/restoring: avoid using staleRegions when alwaysReadPixelsFromGPU is true
Updates #2582
This commit is contained in:
parent
965fd4cac8
commit
f04d9d6925
@ -121,6 +121,7 @@ type Image struct {
|
|||||||
|
|
||||||
// staleRegions indicates the regions to restore.
|
// staleRegions indicates the regions to restore.
|
||||||
// staleRegions is valid only when stale is true.
|
// staleRegions is valid only when stale is true.
|
||||||
|
// staleRegions is not used when alwaysReadPixelsFromGPU() returns true.
|
||||||
staleRegions []image.Rectangle
|
staleRegions []image.Rectangle
|
||||||
|
|
||||||
imageType ImageType
|
imageType ImageType
|
||||||
@ -261,6 +262,11 @@ func (i *Image) BasePixelsForTesting() *Pixels {
|
|||||||
func (i *Image) makeStale(rect image.Rectangle) {
|
func (i *Image) makeStale(rect image.Rectangle) {
|
||||||
i.stale = true
|
i.stale = true
|
||||||
|
|
||||||
|
// If ReadPixels always reads pixels from GPU, staleRegions are never used.
|
||||||
|
if alwaysReadPixelsFromGPU() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
i.staleRegions = i.appendRegionsForDrawTriangles(i.staleRegions)
|
i.staleRegions = i.appendRegionsForDrawTriangles(i.staleRegions)
|
||||||
if !rect.Empty() {
|
if !rect.Empty() {
|
||||||
i.staleRegions = append(i.staleRegions, rect)
|
i.staleRegions = append(i.staleRegions, rect)
|
||||||
@ -402,6 +408,9 @@ func (i *Image) appendDrawTrianglesHistory(srcs [graphics.ShaderImageCount]*Imag
|
|||||||
if i.stale || !i.needsRestoring() {
|
if i.stale || !i.needsRestoring() {
|
||||||
panic("restorable: an image must not be stale or need restoring at appendDrawTrianglesHistory")
|
panic("restorable: an image must not be stale or need restoring at appendDrawTrianglesHistory")
|
||||||
}
|
}
|
||||||
|
if alwaysReadPixelsFromGPU() {
|
||||||
|
panic("restorable: appendDrawTrianglesHistory must not be called when alwaysReadPixelsFromGPU() returns true")
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Would it be possible to merge draw image history items?
|
// TODO: Would it be possible to merge draw image history items?
|
||||||
const maxDrawTrianglesHistoryCount = 1024
|
const maxDrawTrianglesHistoryCount = 1024
|
||||||
|
Loading…
Reference in New Issue
Block a user