wayland: Add support for Vulkan renderer
Mirror what's done with the X11 Vulkan renderer implementation, with the addition of the extra Wayland window synchronization on end_paint() override.
This commit is contained in:
committed by
Benjamin Otte
parent
38d6e45b32
commit
3887548d55
@@ -56,6 +56,8 @@ libgdk_wayland_la_SOURCES = \
|
||||
gdkscreen-wayland.c \
|
||||
gdkseat-wayland.h \
|
||||
gdkselection-wayland.c \
|
||||
gdkvulkancontext-wayland.c \
|
||||
gdkvulkancontext-wayland.h \
|
||||
gdkwindow-wayland.c \
|
||||
gdkwayland.h \
|
||||
gdkprivate-wayland.h \
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define VK_USE_PLATFORM_WAYLAND_KHR
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@@ -41,6 +43,7 @@
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
#include "gdkglcontext-wayland.h"
|
||||
#include "gdkvulkancontext-wayland.h"
|
||||
#include "gdkwaylandmonitor.h"
|
||||
#include "pointer-gestures-unstable-v1-client-protocol.h"
|
||||
#include "tablet-unstable-v2-client-protocol.h"
|
||||
@@ -918,6 +921,12 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
|
||||
object_class->finalize = gdk_wayland_display_finalize;
|
||||
|
||||
display_class->window_type = gdk_wayland_window_get_type ();
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
display_class->vk_context_type = GDK_TYPE_WAYLAND_VULKAN_CONTEXT;
|
||||
display_class->vk_extension_name = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
|
||||
#endif
|
||||
|
||||
display_class->get_name = gdk_wayland_display_get_name;
|
||||
display_class->get_default_screen = gdk_wayland_display_get_default_screen;
|
||||
display_class->beep = gdk_wayland_display_beep;
|
||||
|
||||
90
gdk/wayland/gdkvulkancontext-wayland.c
Normal file
90
gdk/wayland/gdkvulkancontext-wayland.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/* gdkvulkancontext-wayland.c
|
||||
*
|
||||
* gdkvulkancontext-wayland.c: Wayland specific Vulkan wrappers
|
||||
*
|
||||
* Copyright (C) 2017 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* 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"
|
||||
#include "gdkwaylandwindow.h"
|
||||
#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,
|
||||
VkSurfaceKHR *surface)
|
||||
{
|
||||
GdkWindow *window = gdk_draw_context_get_window (GDK_DRAW_CONTEXT (context));
|
||||
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
|
||||
|
||||
/* This is necessary so that Vulkan sees the Window.
|
||||
* Usually, vkCreateXlibSurfaceKHR() will not cause a problem to happen as
|
||||
* it just creates resources, but futher calls with the resulting surface
|
||||
* 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),
|
||||
gdk_wayland_window_get_wl_surface (window)
|
||||
},
|
||||
NULL,
|
||||
surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_vulkan_context_wayland_end_frame (GdkDrawContext *context,
|
||||
cairo_region_t *painted,
|
||||
cairo_region_t *damage)
|
||||
{
|
||||
GdkWindow *window = gdk_draw_context_get_window (GDK_DRAW_CONTEXT (context));
|
||||
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_vulkan_context_parent_class)->end_frame (context, painted, damage);
|
||||
|
||||
gdk_wayland_window_sync (window);
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
61
gdk/wayland/gdkvulkancontext-wayland.h
Normal file
61
gdk/wayland/gdkvulkancontext-wayland.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* gdkvulkancontext-wayland.h
|
||||
*
|
||||
* gdkvulkancontext-wayland.h: Wayland specific Vulkan wrappers
|
||||
*
|
||||
* Copyright (C) 2017 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_WAYLAND_VULKAN_CONTEXT__
|
||||
#define __GDK_WAYLAND_VULKAN_CONTEXT__
|
||||
|
||||
#include "gdkconfig.h"
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
|
||||
#define VK_USE_PLATFORM_WAYLAND_KHR
|
||||
|
||||
#include "gdkvulkancontextprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_WAYLAND_VULKAN_CONTEXT (gdk_wayland_vulkan_context_get_type ())
|
||||
#define GDK_WAYLAND_VULKAN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_WAYLAND_VULKAN_CONTEXT, GdkWaylandVulkanContext))
|
||||
#define GDK_IS_WAYLAND_VULKAN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_WAYLAND_VULKAN_CONTEXT))
|
||||
#define GDK_WAYLAND_VULKAN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_VULKAN_CONTEXT, GdkWaylandVulkanContextClass))
|
||||
#define GDK_IS_WAYLAND_VULKAN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_VULKAN_CONTEXT))
|
||||
#define GDK_WAYLAND_VULKAN_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_VULKAN_CONTEXT, GdkWaylandVulkanContextClass))
|
||||
|
||||
typedef struct _GdkWaylandVulkanContext GdkWaylandVulkanContext;
|
||||
typedef struct _GdkWaylandVulkanContextClass GdkWaylandVulkanContextClass;
|
||||
|
||||
struct _GdkWaylandVulkanContext
|
||||
{
|
||||
GdkVulkanContext parent_instance;
|
||||
};
|
||||
|
||||
struct _GdkWaylandVulkanContextClass
|
||||
{
|
||||
GdkVulkanContextClass parent_class;
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GType gdk_wayland_vulkan_context_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* !GDK_RENDERING_VULKAN */
|
||||
|
||||
#endif /* __GDK_WAYLAND_VULKAN_CONTEXT__ */
|
||||
Reference in New Issue
Block a user