Two things:
-
sokol_app.h should provide a function sapp_visible() which returns true if at least part of the window is currently visible, idea being that the frame callback may decide to skip certain things when the window is fully obscured or minified. This is an 'optional' feature, some platforms may always return true. It should be legal to skip the entire frame when sapp_visible() returns false, most importantly the application isn't required to call sg_commit() (but only when it didn't call any other sokol-gfx functions except maybe creating and destroying resources):
void frame(void) {
if (!sapp_visible()) {
return;
}
// ... regular frame code
sg_commit();
}
-
sokol_gfx.h: sg_swapchain should get an .invalid boolean. When this is true all rendering in the pass should be silently skipped. This is for situations where the swapchain system cannot provide a valid drawable for the current frame.
After this is implemented:
- in sokol_app.h macos+metal:
- don't call
nextDrawable when window is obscured or minified (e.g. when the CADisplayLink is deactivated)
sapp_visible() returns false when window is obscured or minifed (e.g. when CADisplayLink is deactivated)
- reduce the 'obscured frame rate' from 60Hz to smth like 10Hz
- in the Vulkan backend: implement the error code path for
vkAcquireNextImage failure (this should set sg_swapchain.invalid to true so that the next render frame is skipped)
- in chips-test: fully deactivate the emulator when
sapp_visible() returns false (e.g. skip the entire frame callback)
- ...?
Two things:
sokol_app.h should provide a function
sapp_visible()which returns true if at least part of the window is currently visible, idea being that the frame callback may decide to skip certain things when the window is fully obscured or minified. This is an 'optional' feature, some platforms may always return true. It should be legal to skip the entire frame whensapp_visible()returns false, most importantly the application isn't required to callsg_commit()(but only when it didn't call any other sokol-gfx functions except maybe creating and destroying resources):sokol_gfx.h:
sg_swapchainshould get an.invalidboolean. When this is true all rendering in the pass should be silently skipped. This is for situations where the swapchain system cannot provide a valid drawable for the current frame.After this is implemented:
nextDrawablewhen window is obscured or minified (e.g. when the CADisplayLink is deactivated)sapp_visible()returns false when window is obscured or minifed (e.g. when CADisplayLink is deactivated)vkAcquireNextImagefailure (this should setsg_swapchain.invalidto true so that the next render frame is skipped)sapp_visible()returns false (e.g. skip the entire frame callback)