Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
vulkan: Move present queue checking into renderer space
Browse files Browse the repository at this point in the history
  • Loading branch information
nyorain committed Oct 5, 2018
1 parent 35e8734 commit 477d248
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 18 deletions.
5 changes: 4 additions & 1 deletion backend/drm/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ static bool backend_egl_params(struct wlr_backend *wlr_backend,
}

static bool backend_vulkan_queue_check(struct wlr_backend *wlr_backend,
uintptr_t vk_physical_device, uint32_t qfam) {
struct wlr_vk_instance *instance, uintptr_t vk_physical_device,
uint32_t qfam) {
// there is no drm/gbm/kms vulkan wsi so there is no need for
// present queues
return true;
}

Expand Down
5 changes: 4 additions & 1 deletion backend/headless/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ static bool backend_egl_params(struct wlr_backend *wlr_backend,
}

static bool backend_vulkan_queue_check(struct wlr_backend *wlr_backend,
uintptr_t vk_physical_device, uint32_t qfam) {
struct wlr_vk_instance *instance, uintptr_t vk_physical_device,
uint32_t qfam) {
// there is no headless vulkan wsi so there is no need for
// present queues. Done manually
return true;
}

Expand Down
11 changes: 5 additions & 6 deletions backend/wayland/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#include <wlr/config.h>
#include <EGL/egl.h>
#ifdef WLR_HAS_VULKAN
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_wayland.h>
#include <wlr/render/vulkan.h>
#endif
#include "backend/wayland.h"
#include "util/signal.h"
Expand Down Expand Up @@ -150,12 +149,12 @@ static bool backend_egl_params(struct wlr_backend *wlr_backend,
}

static bool backend_vulkan_queue_check(struct wlr_backend *wlr_backend,
uintptr_t vk_physical_device, uint32_t qfam) {
struct wlr_vk_instance *instance, uintptr_t vk_physical_device,
uint32_t qfam) {
#ifdef WLR_HAS_VULKAN
struct wlr_wl_backend *wl = get_wl_backend_from_backend(wlr_backend);
VkPhysicalDevice phdev = (VkPhysicalDevice) vk_physical_device;
return vkGetPhysicalDeviceWaylandPresentationSupportKHR(phdev, qfam,
wl->remote_display);
return wlr_vk_present_queue_supported_wl(instance, vk_physical_device,
qfam, wl->remote_display);
#else
return false;
#endif
Expand Down
11 changes: 5 additions & 6 deletions backend/x11/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#include <xcb/xkb.h>
#endif
#ifdef WLR_HAS_VULKAN
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_xcb.h>
#include <wlr/render/vulkan.h>
#endif
#include "backend/x11.h"
#include "util/signal.h"
Expand Down Expand Up @@ -239,12 +238,12 @@ static bool backend_egl_params(struct wlr_backend *wlr_backend,
}

static bool backend_vulkan_queue_check(struct wlr_backend *wlr_backend,
uintptr_t vk_physical_device, uint32_t qfam) {
struct wlr_vk_instance *instance, uintptr_t vk_physical_device,
uint32_t qfam) {
#ifdef WLR_HAS_VULKAN
struct wlr_x11_backend *x11 = get_x11_backend_from_backend(wlr_backend);
VkPhysicalDevice phdev = (VkPhysicalDevice) vk_physical_device;
return vkGetPhysicalDeviceXcbPresentationSupportKHR(phdev, qfam,
x11->xcb_conn, x11->screen->root_visual);
return wlr_vk_present_queue_supported_xcb(instance, vk_physical_device,
qfam, x11->xcb_conn, x11->screen->root_visual);
#else
return false;
#endif
Expand Down
3 changes: 3 additions & 0 deletions include/wlr/backend/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <wlr/backend.h>
#include <wlr/render/egl.h>

struct wlr_vk_instance;

struct wlr_backend_impl {
bool (*start)(struct wlr_backend *backend);
void (*destroy)(struct wlr_backend *backend);
Expand All @@ -23,6 +25,7 @@ struct wlr_backend_impl {
bool (*egl_params)(struct wlr_backend *backend, EGLenum *platform,
void **remote_display, const EGLint **config_attribs, EGLint *visualid);
bool (*vulkan_queue_family_present_support)(struct wlr_backend *backend,
struct wlr_vk_instance *instance,
uintptr_t vk_physical_device, uint32_t queue_family);
};

Expand Down
9 changes: 6 additions & 3 deletions include/wlr/render/vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <wlr/backend.h>
#include <wlr/render/wlr_renderer.h>

struct wlr_vk_device;
struct wlr_vk_instance;
struct wlr_vk_renderer;

// Creates all vulkan resources (inclusive instance) from scratch.
Expand All @@ -13,8 +13,11 @@ struct wlr_texture *wlr_vk_texture_from_pixels(struct wlr_vk_renderer *renderer,
enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width, uint32_t height,
const void *data);

// struct wlr_texture *wlr_vulkan_texture_from_dmabuf(struct wlr_vulkan *vulkan,
// struct wlr_dmabuf_attributes *attribs);
bool wlr_vk_present_queue_supported_xcb(struct wlr_vk_instance *instance,
uintptr_t vk_physical_device, uint32_t qfam, void *xcb_connection_t,
uint32_t visualid);
bool wlr_vk_present_queue_supported_wl(struct wlr_vk_instance *instance,
uintptr_t vk_physical_device, uint32_t qfam, struct wl_display *remote);

#endif

2 changes: 1 addition & 1 deletion render/vulkan/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ struct wlr_renderer *wlr_vk_renderer_create(struct wlr_backend *backend) {
for (unsigned i = 0u; i < qfam_count; ++i) {
bool graphics = queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT;
bool present = backend->impl->vulkan_queue_family_present_support(
backend, (uintptr_t) phdev, i);
backend, ini, (uintptr_t) phdev, i);
if (present) {
queue_count = 2u;
queues[0].family = i;
Expand Down
30 changes: 30 additions & 0 deletions render/vulkan/vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,33 @@ void wlr_vk_device_destroy(struct wlr_vk_device *dev) {
free(dev->extensions);
free(dev);
}

bool wlr_vk_present_queue_supported_xcb(struct wlr_vk_instance *instance,
uintptr_t vk_physical_device, uint32_t qfam,
void *xcb_connection, uint32_t visualid) {
#ifdef WLR_HAS_X11_BACKEND
if (!vulkan_has_extension(instance->extension_count, instance->extensions,
VK_KHR_XCB_SURFACE_EXTENSION_NAME)) {
return false;
}

VkPhysicalDevice phdev = (VkPhysicalDevice) vk_physical_device;
return vkGetPhysicalDeviceXcbPresentationSupportKHR(phdev, qfam,
xcb_connection, visualid);
#else
return false;
#endif
}

bool wlr_vk_present_queue_supported_wl(struct wlr_vk_instance *instance,
uintptr_t vk_physical_device, uint32_t qfam,
struct wl_display *remote) {
if (!vulkan_has_extension(instance->extension_count, instance->extensions,
VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME)) {
return false;
}

VkPhysicalDevice phdev = (VkPhysicalDevice) vk_physical_device;
return vkGetPhysicalDeviceWaylandPresentationSupportKHR(phdev, qfam,
remote);
}

0 comments on commit 477d248

Please sign in to comment.