mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-11 05:00:07 +00:00
macos/vulkan: Fix flickering by setting a smaller image count
MoltenVK uses Metal, and Metal has a limited swapchain ability. Instead of 3, set the minImageCount to 2. Set the Metal layer when we create a new context.
This commit is contained in:
parent
422fa8c9f8
commit
993b204f5e
@ -510,9 +510,11 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
|
||||
.pNext = NULL,
|
||||
.flags = 0,
|
||||
.surface = priv->surface,
|
||||
#ifndef __APPLE__
|
||||
.minImageCount = CLAMP (4,
|
||||
capabilities.minImageCount,
|
||||
capabilities.maxImageCount ? capabilities.maxImageCount : G_MAXUINT32),
|
||||
#endif
|
||||
.imageFormat = priv->formats[priv->current_depth].vk_format.format,
|
||||
.imageColorSpace = priv->formats[priv->current_depth].vk_format.colorSpace,
|
||||
.imageExtent = size,
|
||||
|
@ -37,16 +37,9 @@
|
||||
{
|
||||
if ((self = [super initWithFrame:frame]))
|
||||
{
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
CALayer *layer = [CAMetalLayer layer];
|
||||
[layer setOpaque:NO];
|
||||
#else
|
||||
GdkMacosLayer *layer = [GdkMacosLayer layer];
|
||||
|
||||
[self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawNever];
|
||||
#endif
|
||||
CGSize viewScale = [self convertSizeToBacking: CGSizeMake(1.0, 1.0)];
|
||||
layer.contentsScale = MIN(viewScale.width, viewScale.height);
|
||||
[self setLayer:layer];
|
||||
[self setWantsLayer:YES];
|
||||
}
|
||||
|
@ -42,13 +42,16 @@ gdk_macos_vulkan_context_create_surface (GdkVulkanContext *context,
|
||||
NSView *view = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (gdk_surface));
|
||||
VkMetalSurfaceCreateInfoEXT info;
|
||||
VkResult result;
|
||||
CAMetalLayer *layer;
|
||||
|
||||
g_assert ([[view layer] isKindOfClass:[CAMetalLayer class]]);
|
||||
layer = [CAMetalLayer layer];
|
||||
[layer setOpaque:NO];
|
||||
[view setLayer:layer];
|
||||
|
||||
info.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
|
||||
info.pNext = NULL;
|
||||
info.flags = 0;
|
||||
info.pLayer = (CAMetalLayer *)[view layer];
|
||||
info.pLayer = layer;
|
||||
|
||||
result = GDK_VK_CHECK (vkCreateMetalSurfaceEXT,
|
||||
gdk_vulkan_context_get_instance (context),
|
||||
|
Loading…
Reference in New Issue
Block a user