MacOS Mojave test and fix
This commit is contained in:
parent
dbd882ed22
commit
ffc5f5b503
@ -103,7 +103,7 @@ resize_dst(SWindowData *window_data, uint32_t width, uint32_t height) {
|
||||
window_data->dst_height = (uint32_t) (height * window_data->factor_height);
|
||||
}
|
||||
|
||||
#if !defined(USE_OPENGL_API)
|
||||
#if !defined(USE_OPENGL_API) && !defined(USE_METAL_API)
|
||||
|
||||
//-------------------------------------
|
||||
void
|
||||
|
@ -297,6 +297,7 @@ mfb_update_events(struct mfb_window *window) {
|
||||
|
||||
//-------------------------------------
|
||||
extern double g_time_for_frame;
|
||||
extern bool g_use_hardware_sync;
|
||||
|
||||
bool
|
||||
mfb_wait_sync(struct mfb_window *window) {
|
||||
@ -312,6 +313,10 @@ mfb_wait_sync(struct mfb_window *window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(g_use_hardware_sync) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
SWindowData_OSX *window_data_osx = (SWindowData_OSX *) window_data->specific;
|
||||
if(window_data_osx == 0x0) {
|
||||
|
@ -80,6 +80,10 @@ NSString *g_shader_src = kShader(
|
||||
|
||||
// Setup command queue
|
||||
command_queue = [metal_device newCommandQueue];
|
||||
id<MTLCommandBuffer> commandBuffer = [command_queue commandBuffer];
|
||||
if ([commandBuffer respondsToSelector:@selector(presentDrawable:afterMinimumDuration:)]) {
|
||||
g_use_hardware_sync = true;
|
||||
}
|
||||
|
||||
[self _createShaders];
|
||||
[self _createAssets];
|
||||
@ -169,9 +173,16 @@ NSString *g_shader_src = kShader(
|
||||
//-------------------------------------
|
||||
- (void) drawInMTKView:(nonnull MTKView *) view {
|
||||
if (g_target_fps_changed) {
|
||||
view.preferredFramesPerSecond = (int) (1.0 / g_time_for_frame);
|
||||
// MacOS is ignoring this :()
|
||||
if (g_time_for_frame == 0) {
|
||||
// Contrary to what is stated in the documentation,
|
||||
// 0 means that it does not update.
|
||||
view.preferredFramesPerSecond = 9999;
|
||||
}
|
||||
else {
|
||||
view.preferredFramesPerSecond = (int) (1.0 / g_time_for_frame);
|
||||
}
|
||||
g_target_fps_changed = false;
|
||||
g_use_hardware_sync = true;
|
||||
}
|
||||
|
||||
// Wait to ensure only MaxBuffersInFlight number of frames are getting proccessed
|
||||
|
Loading…
Reference in New Issue
Block a user