Improved idle performance in the Cocoa port when using Metal

This commit is contained in:
Lior Halphon 2018-10-11 18:43:31 +03:00
parent 1b049b8f75
commit 9080a23913
3 changed files with 22 additions and 3 deletions

View File

@ -140,9 +140,6 @@
GB_set_clock_multiplier(_gb, clockMultiplier);
}
current_buffer = (current_buffer + 1) % self.numberOfBuffers;
dispatch_async(dispatch_get_main_queue(), ^{
[self setNeedsDisplay:YES];
});
}
- (uint32_t *) pixels

View File

@ -23,4 +23,12 @@
((GBOpenGLView *)self.internalView).openGLContext = context;
}
- (void)flip
{
[super flip];
dispatch_async(dispatch_get_main_queue(), ^{
[self setNeedsDisplay:YES];
});
}
@end

View File

@ -42,6 +42,7 @@ static const vector_float2 rect[] =
MTKView *view = [[MTKView alloc] initWithFrame:self.frame device:(device = MTLCreateSystemDefaultDevice())];
view.delegate = self;
self.internalView = view;
view.paused = YES;
MTLTextureDescriptor *texture_descriptor = [[MTLTextureDescriptor alloc] init];
@ -125,10 +126,14 @@ static const vector_float2 rect[] =
- (void)mtkView:(nonnull MTKView *)view drawableSizeWillChange:(CGSize)size
{
output_resolution = (vector_float2){size.width, size.height};
dispatch_async(dispatch_get_main_queue(), ^{
[(MTKView *)self.internalView draw];
});
}
- (void)drawInMTKView:(nonnull MTKView *)view
{
if (!(view.window.occlusionState & NSWindowOcclusionStateVisible)) return;
[texture replaceRegion:region
mipmapLevel:0
withBytes:[self currentBuffer]
@ -188,4 +193,13 @@ static const vector_float2 rect[] =
[command_buffer commit];
}
- (void)flip
{
[super flip];
dispatch_async(dispatch_get_main_queue(), ^{
[(MTKView *)self.internalView draw];
});
}
@end