2017-01-03 23:14:31 +00:00
|
|
|
/* gdkvulkancontext-wayland.c
|
|
|
|
*
|
|
|
|
* gdkvulkancontext-wayland.c: Wayland specific Vulkan wrappers
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
|
|
|
*
|
2017-01-04 17:14:21 +00:00
|
|
|
* This file is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as
|
2017-01-04 18:02:44 +00:00
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
2017-01-04 17:14:21 +00:00
|
|
|
* License, or (at your option) any later version.
|
2017-01-03 23:14:31 +00:00
|
|
|
*
|
2017-01-04 17:14:21 +00:00
|
|
|
* This file is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2017-01-03 23:14:31 +00:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gdkconfig.h"
|
|
|
|
|
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
|
|
|
|
|
|
#include "gdkvulkancontext-wayland.h"
|
|
|
|
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
#include "gdkwaylanddisplay.h"
|
2018-03-20 10:46:11 +00:00
|
|
|
#include "gdkwaylandsurface.h"
|
2017-01-03 23:14:31 +00:00
|
|
|
#include "gdkprivate-wayland.h"
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GdkWaylandVulkanContext, gdk_wayland_vulkan_context, GDK_TYPE_VULKAN_CONTEXT)
|
|
|
|
|
|
|
|
static VkResult
|
|
|
|
gdk_wayland_vulkan_context_create_surface (GdkVulkanContext *context,
|
2018-03-20 14:14:10 +00:00
|
|
|
VkSurfaceKHR *vr_surface)
|
2017-01-03 23:14:31 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
2017-01-03 23:14:31 +00:00
|
|
|
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
/* This is necessary so that Vulkan sees the Surface.
|
2017-01-03 23:14:31 +00:00
|
|
|
* Usually, vkCreateXlibSurfaceKHR() will not cause a problem to happen as
|
2020-05-28 08:00:03 +00:00
|
|
|
* it just creates resources, but further calls with the resulting surface
|
2017-01-03 23:14:31 +00:00
|
|
|
* do cause issues.
|
|
|
|
*/
|
|
|
|
gdk_display_sync (display);
|
|
|
|
|
|
|
|
return GDK_VK_CHECK (vkCreateWaylandSurfaceKHR, gdk_vulkan_context_get_instance (context),
|
|
|
|
&(VkWaylandSurfaceCreateInfoKHR) {
|
|
|
|
VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
gdk_wayland_display_get_wl_display (display),
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_wl_surface (surface)
|
2017-01-03 23:14:31 +00:00
|
|
|
},
|
|
|
|
NULL,
|
2018-03-20 14:14:10 +00:00
|
|
|
vr_surface);
|
2017-01-03 23:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_vulkan_context_wayland_end_frame (GdkDrawContext *context,
|
2018-04-23 21:26:14 +00:00
|
|
|
cairo_region_t *painted)
|
2017-01-03 23:14:31 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
2017-01-03 23:14:31 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_sync (surface);
|
2018-04-10 13:10:56 +00:00
|
|
|
gdk_wayland_surface_request_frame (surface);
|
2018-03-21 06:08:13 +00:00
|
|
|
|
2018-04-23 21:26:14 +00:00
|
|
|
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_vulkan_context_parent_class)->end_frame (context, painted);
|
2020-09-17 16:20:08 +00:00
|
|
|
|
|
|
|
gdk_wayland_surface_notify_committed (surface);
|
2017-01-03 23:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_vulkan_context_class_init (GdkWaylandVulkanContextClass *klass)
|
|
|
|
{
|
|
|
|
GdkVulkanContextClass *vulkan_context_class = GDK_VULKAN_CONTEXT_CLASS (klass);
|
|
|
|
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
|
|
|
|
|
|
|
|
vulkan_context_class->create_surface = gdk_wayland_vulkan_context_create_surface;
|
|
|
|
draw_context_class->end_frame = gdk_vulkan_context_wayland_end_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_vulkan_context_init (GdkWaylandVulkanContext *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* GDK_RENDERING_VULKAN */
|
|
|
|
|