mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-10-05 07:57:10 +08:00
internal/ui: optimize GPU usages when the screen doesn't have to be updated
This change skips rendering when 1) the screen is not cleared every frame (`SetScreenClearedEveryFrame(false)`) and 2) Draw doesn't draw anything onto the screen. The GPU usages decreased on some machines (e.g. GPU usage was 10% with an empty Ebitengine project and became 2-3 % on a Windows machine). Updates #2341
This commit is contained in:
@@ -168,7 +168,8 @@ func (q *commandQueue) Flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
|
||||
|
||||
// flush must be called the main thread.
|
||||
func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bool) (err error) {
|
||||
if len(q.commands) == 0 {
|
||||
// If endFrame is true, Begin/End should be called to ensure the framebuffer is swapped.
|
||||
if len(q.commands) == 0 && !endFrame {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user