summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-09-07 13:29:55 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2015-09-08 10:57:25 -0700
commit11a8f4a0ca991444a5eb4c6135ea46f565cdbf99 (patch)
treec3d01ac0067b6be02cfd156c030cb37d643bb565
parent6158bb2051f2602ca83b504be015bdbac8b2b49f (diff)
compositor-x11: Add support for the Vulkan renderer
-rw-r--r--src/compositor-x11.c64
1 files changed, 59 insertions, 5 deletions
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 3922669e..b7da8c55 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -51,6 +51,7 @@
#include "compositor.h"
#include "gl-renderer.h"
+#include "vulkan-renderer.h"
#include "pixman-renderer.h"
#include "shared/config-parser.h"
#include "shared/helpers.h"
@@ -68,6 +69,7 @@ static int option_count;
enum x11_renderer {
X11_RENDERER_PIXMAN,
X11_RENDERER_GL,
+ X11_RENDERER_VULKAN,
};
struct x11_backend {
@@ -134,6 +136,7 @@ struct window_delete_data {
};
struct gl_renderer_interface *gl_renderer;
+struct vulkan_renderer_interface *vk_renderer;
static struct xkb_keymap *
x11_backend_get_keymap(struct x11_backend *b)
@@ -366,8 +369,8 @@ x11_output_start_repaint_loop(struct weston_output *output)
}
static int
-x11_output_repaint_gl(struct weston_output *output_base,
- pixman_region32_t *damage)
+x11_output_repaint_GLorVk(struct weston_output *output_base,
+ pixman_region32_t *damage)
{
struct x11_output *output = (struct x11_output *)output_base;
struct weston_compositor *ec = output->base.compositor;
@@ -514,6 +517,9 @@ x11_output_destroy(struct weston_output *output_base)
case X11_RENDERER_GL:
gl_renderer->output_destroy(output_base);
break;
+ case X11_RENDERER_VULKAN:
+ vk_renderer->output_destroy(output_base);
+ break;
}
xcb_destroy_window(backend->conn, output->window);
@@ -891,7 +897,8 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,
case X11_RENDERER_PIXMAN:
output->base.repaint = x11_output_repaint_shm;
case X11_RENDERER_GL:
- output->base.repaint = x11_output_repaint_gl;
+ case X11_RENDERER_VULKAN:
+ output->base.repaint = x11_output_repaint_GLorVk;
}
output->base.destroy = x11_output_destroy;
output->base.assign_planes = NULL;
@@ -942,6 +949,31 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,
return NULL;
break;
}
+
+ case X11_RENDERER_VULKAN: {
+ VkPlatformHandleXcbWSI platform;
+ platform.connection = b->conn;
+ platform.root = 0;
+
+ VkSurfaceDescriptionWindowWSI window;
+ window.sType = VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI;
+ window.pNext = NULL;
+ window.platform = VK_PLATFORM_XCB_WSI;
+ window.pPlatformHandle = &platform;
+ window.pPlatformWindow = (void *)(uintptr_t)output->window;
+
+ VkFormat formats[] = {
+ VK_FORMAT_R8G8B8A8_UNORM,
+ VK_FORMAT_R8G8B8_UNORM,
+ VK_FORMAT_R5G6B5_UNORM,
+ };
+
+ ret = vk_renderer->output_create(&output->base, &window,
+ formats, 3);
+ if (ret < 0)
+ return NULL;
+ break;
+ }
}
loop = wl_display_get_event_loop(b->compositor->wl_display);
@@ -1534,6 +1566,26 @@ init_gl_renderer(struct x11_backend *b)
return ret;
}
+
+static int
+init_vulkan_renderer(struct x11_backend *b)
+{
+ int ret;
+
+ vk_renderer = weston_load_module("vulkan-renderer.so",
+ "vulkan_renderer_interface");
+ if (!vk_renderer)
+ return -1;
+
+ VkPlatformHandleXcbWSI handle;
+ handle.connection = b->conn;
+ handle.root = 0;
+
+ ret = vk_renderer->create(b->compositor, VK_PLATFORM_XCB_WSI, &handle);
+
+ return ret;
+}
+
static struct x11_backend *
x11_backend_create(struct weston_compositor *compositor,
int fullscreen,
@@ -1592,8 +1644,10 @@ x11_backend_create(struct weston_compositor *compositor,
}
b->renderer = X11_RENDERER_PIXMAN;
weston_log("Using pixman renderer\n");
- }
- else if (init_gl_renderer(b) >= 0) {
+ } else if (init_vulkan_renderer(b) >= 0) {
+ b->renderer = X11_RENDERER_VULKAN;
+ weston_log("Using Vulkan renderer\n");
+ } else if (init_gl_renderer(b) >= 0) {
b->renderer = X11_RENDERER_GL;
weston_log("Using GL renderer\n");
} else {