Skip to content

Commit

Permalink
internal/ui: skip rendering onto the final framebuffer only for OpenGL
Browse files Browse the repository at this point in the history
This was reverted at a049acd but now
I've confirmed this is not problematic only with OpenGL.

Updates #2341
Updates #2342
  • Loading branch information
hajimehoshi committed Jan 2, 2023
1 parent 6b4c696 commit bbc82ef
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions internal/ui/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,20 @@ func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics, forceDraw boo
c.skipCount = 0
}

// TODO: If the offscreen is not updated and the framebuffers don't have to be updated, skip rendering to save GPU power
// (#2341, #2342). The condition would be `c.skipCount < maxSkipCount`.
// However, Metal (and maybe DirectX) cannot vsync without swapping the buffer by rendering the screen framebuffer (#2520).
if graphicsDriver.NeedsClearingScreen() {
// This clear is needed for fullscreen mode or some mobile platforms (#622).
c.screen.clear()
}
// TODO: Metal (and maybe DirectX) cannot vsync without swapping the buffer by rendering the screen framebuffer (#2520).
// Implement this skipping appropriately for Metal and DirectX.
if c.skipCount < maxSkipCount && graphicsDriver.IsGL() {
if graphicsDriver.NeedsClearingScreen() {
// This clear is needed for fullscreen mode or some mobile platforms (#622).
c.screen.clear()
}

c.game.DrawFinalScreen(c.screenScaleAndOffsets())
c.game.DrawFinalScreen(c.screenScaleAndOffsets())

// The final screen is never used as the rendering source.
// Flush its buffer here just in case.
c.screen.flushBufferIfNeeded()
// The final screen is never used as the rendering source.
// Flush its buffer here just in case.
c.screen.flushBufferIfNeeded()
}

return nil
}
Expand Down

0 comments on commit bbc82ef

Please sign in to comment.