make vsync differences between win32 and macos explicit in runtime.c
This commit is contained in:
parent
6ae129022e
commit
5a7182a3b9
|
@ -2405,36 +2405,35 @@ void oc_vsync_init(void)
|
||||||
void oc_vsync_wait(oc_window window)
|
void oc_vsync_wait(oc_window window)
|
||||||
{
|
{
|
||||||
// TODO figure out why this causes stuttering with triple buffering
|
// TODO figure out why this causes stuttering with triple buffering
|
||||||
|
oc_window_data* windowData = oc_window_ptr_from_handle(window);
|
||||||
|
if(!windowData)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// oc_window_data* windowData = oc_window_ptr_from_handle(window);
|
OCWindow* ocWindow = (OCWindow*)windowData->osx.nsWindow;
|
||||||
// if(!windowData)
|
|
||||||
// {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// OCWindow* ocWindow = (OCWindow*)windowData->osx.nsWindow;
|
CVReturn ret;
|
||||||
|
|
||||||
// CVReturn ret;
|
if((ret = CVDisplayLinkCreateWithActiveCGDisplays(&ocWindow->displayLink)) != kCVReturnSuccess)
|
||||||
|
{
|
||||||
|
oc_log_error("CVDisplayLinkCreateWithActiveCGDisplays error: %d\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
// if((ret = CVDisplayLinkCreateWithActiveCGDisplays(&ocWindow->displayLink)) != kCVReturnSuccess)
|
CGDirectDisplayID mainDisplay = CGMainDisplayID();
|
||||||
// {
|
|
||||||
// oc_log_error("CVDisplayLinkCreateWithActiveCGDisplays error: %d\n", ret);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// CGDirectDisplayID mainDisplay = CGMainDisplayID();
|
if((ret = CVDisplayLinkSetCurrentCGDisplay(ocWindow->displayLink, mainDisplay)) != kCVReturnSuccess)
|
||||||
|
{
|
||||||
|
oc_log_error("CVDisplayLinkSetCurrentCGDisplay ret: %d\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
// if((ret = CVDisplayLinkSetCurrentCGDisplay(ocWindow->displayLink, mainDisplay)) != kCVReturnSuccess)
|
if((ret = CVDisplayLinkSetOutputCallback(ocWindow->displayLink, oc_display_link_callback, ocWindow)) != kCVReturnSuccess)
|
||||||
// {
|
{
|
||||||
// oc_log_error("CVDisplayLinkSetCurrentCGDisplay ret: %d\n", ret);
|
oc_log_error("CVDisplayLinkSetOutputCallback ret: %d\n", ret);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if((ret = CVDisplayLinkSetOutputCallback(ocWindow->displayLink, oc_display_link_callback, ocWindow)) != kCVReturnSuccess)
|
if((ret = CVDisplayLinkStart(ocWindow->displayLink)) != kCVReturnSuccess)
|
||||||
// {
|
{
|
||||||
// oc_log_error("CVDisplayLinkSetOutputCallback ret: %d\n", ret);
|
oc_log_error("CVDisplayLinkStart ret: %d\n", ret);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if((ret = CVDisplayLinkStart(ocWindow->displayLink)) != kCVReturnSuccess)
|
|
||||||
// {
|
|
||||||
// oc_log_error("CVDisplayLinkStart ret: %d\n", ret);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,10 +148,7 @@ oc_surface oc_surface_create_for_window(oc_window window, oc_surface_api api)
|
||||||
if(surface)
|
if(surface)
|
||||||
{
|
{
|
||||||
surfaceHandle = oc_surface_handle_alloc(surface);
|
surfaceHandle = oc_surface_handle_alloc(surface);
|
||||||
// On windows, we do a manual wait for vsync in runtime.c so just turn all the swap intervals off
|
oc_surface_swap_interval(surfaceHandle, 1);
|
||||||
#if OC_PLATFORM_WINDOWS
|
|
||||||
oc_surface_swap_interval(surfaceHandle, 0);
|
|
||||||
#endif
|
|
||||||
oc_surface_select(surfaceHandle);
|
oc_surface_select(surfaceHandle);
|
||||||
}
|
}
|
||||||
return (surfaceHandle);
|
return (surfaceHandle);
|
||||||
|
|
|
@ -209,6 +209,8 @@ i32 orca_surface_callback(void* user)
|
||||||
data->surface = oc_surface_create_for_window(data->window, data->api);
|
data->surface = oc_surface_create_for_window(data->window, data->api);
|
||||||
|
|
||||||
#if OC_PLATFORM_WINDOWS
|
#if OC_PLATFORM_WINDOWS
|
||||||
|
//NOTE(martin): on windows we set all surfaces to non-synced, and do a single "manual" wait here.
|
||||||
|
// on macOS each surface is individually synced to the monitor refresh rate but don't block each other
|
||||||
oc_surface_swap_interval(data->surface, 0);
|
oc_surface_swap_interval(data->surface, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -839,7 +841,11 @@ i32 orca_runloop(void* user)
|
||||||
|
|
||||||
oc_arena_clear(oc_scratch());
|
oc_arena_clear(oc_scratch());
|
||||||
|
|
||||||
|
#if OC_PLATFORM_WINDOWS
|
||||||
|
//NOTE(martin): on windows we set all surfaces to non-synced, and do a single "manual" wait here.
|
||||||
|
// on macOS each surface is individually synced to the monitor refresh rate but don't block each other
|
||||||
oc_vsync_wait(app->window);
|
oc_vsync_wait(app->window);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(exports[OC_EXPORT_TERMINATE])
|
if(exports[OC_EXPORT_TERMINATE])
|
||||||
|
|
Loading…
Reference in New Issue