vulkan: Make gdk_display_create_vulkan_context() take a surface

This is so we can deprecate gdk_surface_create_vulkan_context() which is
public API in the next commit.
This commit is contained in:
Benjamin Otte 2024-01-07 13:54:49 +01:00
parent 6bac377fa5
commit 3ac50b81f2
3 changed files with 24 additions and 12 deletions

View File

@ -1267,12 +1267,14 @@ gdk_display_get_keymap (GdkDisplay *display)
/*<private> /*<private>
* gdk_display_create_vulkan_context: * gdk_display_create_vulkan_context:
* @self: a `GdkDisplay` * @self: a `GdkDisplay`
* @surface: (nullable): the `GdkSurface` to use or %NULL for a surfaceless
* context
* @error: return location for an error * @error: return location for an error
* *
* Creates a new `GdkVulkanContext` for use with @display. * Creates a new `GdkVulkanContext` for use with @display.
* *
* The context can not be used to draw to surfaces, it can only be * If @surface is NULL, the context can not be used to draw to surfaces,
* used for custom rendering or compute. * it can only be used for custom rendering or compute.
* *
* If the creation of the `GdkVulkanContext` failed, @error will be set. * If the creation of the `GdkVulkanContext` failed, @error will be set.
* *
@ -1281,9 +1283,11 @@ gdk_display_get_keymap (GdkDisplay *display)
*/ */
GdkVulkanContext * GdkVulkanContext *
gdk_display_create_vulkan_context (GdkDisplay *self, gdk_display_create_vulkan_context (GdkDisplay *self,
GdkSurface *surface,
GError **error) GError **error)
{ {
g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL); g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
g_return_val_if_fail (surface == NULL || GDK_IS_SURFACE (surface), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (gdk_display_get_debug_flags (self) & GDK_DEBUG_VULKAN_DISABLE) if (gdk_display_get_debug_flags (self) & GDK_DEBUG_VULKAN_DISABLE)
@ -1300,11 +1304,22 @@ gdk_display_create_vulkan_context (GdkDisplay *self,
return FALSE; return FALSE;
} }
return g_initable_new (GDK_DISPLAY_GET_CLASS (self)->vk_context_type, if (surface)
NULL, {
error, return g_initable_new (GDK_DISPLAY_GET_CLASS (self)->vk_context_type,
"display", self, NULL,
NULL); error,
"surface", surface,
NULL);
}
else
{
return g_initable_new (GDK_DISPLAY_GET_CLASS (self)->vk_context_type,
NULL,
error,
"display", self,
NULL);
}
} }
gboolean gboolean

View File

@ -236,6 +236,7 @@ void gdk_display_init_dmabuf (GdkDisplay *self);
gboolean gdk_display_has_vulkan_feature (GdkDisplay *self, gboolean gdk_display_has_vulkan_feature (GdkDisplay *self,
GdkVulkanFeatures feature); GdkVulkanFeatures feature);
GdkVulkanContext * gdk_display_create_vulkan_context (GdkDisplay *self, GdkVulkanContext * gdk_display_create_vulkan_context (GdkDisplay *self,
GdkSurface *surface,
GError **error); GError **error);
GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display); GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display);

View File

@ -89,11 +89,7 @@ gsk_vulkan_renderer_create_context (GskGpuRenderer *renderer,
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer); GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
GdkVulkanContext *context; GdkVulkanContext *context;
if (surface) context = gdk_display_create_vulkan_context (display, surface, error);
context = gdk_surface_create_vulkan_context (surface, error);
else
context = gdk_display_create_vulkan_context (display, error);
if (context == NULL) if (context == NULL)
return NULL; return NULL;