summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/intel/vulkan/anv_wsi.c8
-rw-r--r--src/intel/vulkan/anv_wsi.h9
-rw-r--r--src/intel/vulkan/anv_wsi_wayland.c17
3 files changed, 27 insertions, 7 deletions
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index bd0a19d6c5e..84edeebf0f1 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -23,6 +23,11 @@
#include "anv_wsi.h"
#include "vk_format_info.h"
+
+static const struct anv_wsi_callbacks anv_wsi_cbs = {
+ .get_phys_device_format_properties = anv_GetPhysicalDeviceFormatProperties,
+};
+
VkResult
anv_init_wsi(struct anv_physical_device *physical_device)
{
@@ -38,7 +43,8 @@ anv_init_wsi(struct anv_physical_device *physical_device)
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
result = anv_wl_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc,
- anv_physical_device_to_handle(physical_device));
+ anv_physical_device_to_handle(physical_device),
+ &anv_wsi_cbs);
if (result != VK_SUCCESS) {
#ifdef VK_USE_PLATFORM_XCB_KHR
anv_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
diff --git a/src/intel/vulkan/anv_wsi.h b/src/intel/vulkan/anv_wsi.h
index 05d03c86d4d..b227c51100b 100644
--- a/src/intel/vulkan/anv_wsi.h
+++ b/src/intel/vulkan/anv_wsi.h
@@ -89,6 +89,12 @@ struct anv_swapchain {
ANV_DEFINE_NONDISP_HANDLE_CASTS(_VkIcdSurfaceBase, VkSurfaceKHR)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_swapchain, VkSwapchainKHR)
+struct anv_wsi_callbacks {
+ void (*get_phys_device_format_properties)(VkPhysicalDevice physicalDevice,
+ VkFormat format,
+ VkFormatProperties *pFormatProperties);
+};
+
VkResult anv_x11_init_wsi(struct anv_wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
void anv_x11_finish_wsi(struct anv_wsi_device *wsi_device,
@@ -96,7 +102,8 @@ void anv_x11_finish_wsi(struct anv_wsi_device *wsi_device,
VkResult anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
const VkAllocationCallbacks *alloc,
- VkPhysicalDevice physical_device);
+ VkPhysicalDevice physical_device,
+ const struct anv_wsi_callbacks *cbs);
void anv_wl_finish_wsi(struct anv_wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
#endif /* ANV_WSI_H */
diff --git a/src/intel/vulkan/anv_wsi_wayland.c b/src/intel/vulkan/anv_wsi_wayland.c
index 5ddc82f95a6..7a4b1cdfdad 100644
--- a/src/intel/vulkan/anv_wsi_wayland.c
+++ b/src/intel/vulkan/anv_wsi_wayland.c
@@ -31,11 +31,13 @@
#define MIN_NUM_IMAGES 2
+struct wsi_wayland;
+
struct wsi_wl_display {
- VkPhysicalDevice physical_device;
struct wl_display * display;
struct wl_drm * drm;
+ struct wsi_wayland *wsi_wl;
/* Vector of VkFormats supported */
struct u_vector formats;
@@ -51,6 +53,8 @@ struct wsi_wayland {
pthread_mutex_t mutex;
/* Hash table of wl_display -> wsi_wl_display mappings */
struct hash_table * displays;
+
+ const struct anv_wsi_callbacks *cbs;
};
static void
@@ -64,8 +68,9 @@ wsi_wl_display_add_vk_format(struct wsi_wl_display *display, VkFormat format)
/* Don't add formats that aren't renderable. */
VkFormatProperties props;
- anv_GetPhysicalDeviceFormatProperties(
- display->physical_device, format, &props);
+
+ display->wsi_wl->cbs->get_phys_device_format_properties(display->wsi_wl->physical_device,
+ format, &props);
if (!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
return;
@@ -249,7 +254,7 @@ wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
memset(display, 0, sizeof(*display));
display->display = wl_display;
- display->physical_device = wsi->physical_device;
+ display->wsi_wl = wsi;
if (!u_vector_init(&display->formats, sizeof(VkFormat), 8))
goto fail;
@@ -759,7 +764,8 @@ fail:
VkResult
anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
const VkAllocationCallbacks *alloc,
- VkPhysicalDevice physical_device)
+ VkPhysicalDevice physical_device,
+ const struct anv_wsi_callbacks *cbs)
{
struct wsi_wayland *wsi;
VkResult result;
@@ -773,6 +779,7 @@ anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
wsi->physical_device = physical_device;
wsi->alloc = alloc;
+ wsi->cbs = cbs;
int ret = pthread_mutex_init(&wsi->mutex, NULL);
if (ret != 0) {
if (ret == ENOMEM) {