summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-10-13 05:14:52 +0100
committerDave Airlie <airlied@redhat.com>2016-10-19 10:15:42 +1000
commit7c10258567ca98e28b291b679fde8cd60b719579 (patch)
tree6b23a347c1ca58b16f00afa490325c764d8e668e
parentbe61fff6da32267cb5d463197df22be8d8875ff8 (diff)
anv/wsi: abstract wsi interfaces away from device a bit more.
This is a step towards separating out the wsi code for sharing Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
-rw-r--r--src/intel/vulkan/anv_private.h6
-rw-r--r--src/intel/vulkan/anv_wsi.c12
-rw-r--r--src/intel/vulkan/anv_wsi_wayland.c16
-rw-r--r--src/intel/vulkan/anv_wsi_x11.c18
4 files changed, 28 insertions, 24 deletions
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 8ba03300ce1..62d3300d0ce 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -455,6 +455,10 @@ extern struct anv_dispatch_table dtable;
#define VK_ICD_WSI_PLATFORM_MAX 5
+struct anv_wsi_device {
+ struct anv_wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
+};
+
struct anv_physical_device {
VK_LOADER_DATA _loader_data;
@@ -471,7 +475,7 @@ struct anv_physical_device {
uint32_t eu_total;
uint32_t subslice_total;
- struct anv_wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
+ struct anv_wsi_device wsi_device;
};
struct anv_instance {
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index bd20cedd132..56ed3ec7029 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -28,7 +28,7 @@ anv_init_wsi(struct anv_physical_device *physical_device)
{
VkResult result;
- memset(physical_device->wsi, 0, sizeof(physical_device->wsi));
+ memset(physical_device->wsi_device.wsi, 0, sizeof(physical_device->wsi_device.wsi));
#ifdef VK_USE_PLATFORM_XCB_KHR
result = anv_x11_init_wsi(physical_device);
@@ -79,7 +79,7 @@ VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
- struct anv_wsi_interface *iface = device->wsi[surface->platform];
+ struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
return iface->get_support(surface, device, queueFamilyIndex, pSupported);
}
@@ -91,7 +91,7 @@ VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
- struct anv_wsi_interface *iface = device->wsi[surface->platform];
+ struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
return iface->get_capabilities(surface, pSurfaceCapabilities);
}
@@ -104,7 +104,7 @@ VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR(
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
- struct anv_wsi_interface *iface = device->wsi[surface->platform];
+ struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
return iface->get_formats(surface, device, pSurfaceFormatCount,
pSurfaceFormats);
@@ -118,7 +118,7 @@ VkResult anv_GetPhysicalDeviceSurfacePresentModesKHR(
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
- struct anv_wsi_interface *iface = device->wsi[surface->platform];
+ struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
return iface->get_present_modes(surface, pPresentModeCount,
pPresentModes);
@@ -133,7 +133,7 @@ VkResult anv_CreateSwapchainKHR(
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, pCreateInfo->surface);
struct anv_wsi_interface *iface =
- device->instance->physicalDevice.wsi[surface->platform];
+ device->instance->physicalDevice.wsi_device.wsi[surface->platform];
struct anv_swapchain *swapchain;
VkResult result = iface->create_swapchain(surface, device, pCreateInfo,
diff --git a/src/intel/vulkan/anv_wsi_wayland.c b/src/intel/vulkan/anv_wsi_wayland.c
index 2563dd75692..2c9eecfa64a 100644
--- a/src/intel/vulkan/anv_wsi_wayland.c
+++ b/src/intel/vulkan/anv_wsi_wayland.c
@@ -286,11 +286,11 @@ fail:
}
static struct wsi_wl_display *
-wsi_wl_get_display(struct anv_physical_device *device,
+wsi_wl_get_display(struct anv_wsi_device *wsi_device,
struct wl_display *wl_display)
{
struct wsi_wayland *wsi =
- (struct wsi_wayland *)device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
+ (struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
pthread_mutex_lock(&wsi->mutex);
@@ -327,7 +327,7 @@ VkBool32 anv_GetPhysicalDeviceWaylandPresentationSupportKHR(
{
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
- return wsi_wl_get_display(physical_device, display) != NULL;
+ return wsi_wl_get_display(&physical_device->wsi_device, display) != NULL;
}
static VkResult
@@ -380,7 +380,7 @@ wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface,
{
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
struct wsi_wl_display *display =
- wsi_wl_get_display(device, surface->display);
+ wsi_wl_get_display(&device->wsi_device, surface->display);
uint32_t count = u_vector_length(&display->formats);
@@ -785,7 +785,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
chain->images[i].buffer = NULL;
chain->queue = NULL;
- chain->display = wsi_wl_get_display(&device->instance->physicalDevice,
+ chain->display = wsi_wl_get_display(&device->instance->physicalDevice.wsi_device,
surface->display);
if (!chain->display) {
result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
@@ -856,7 +856,7 @@ anv_wl_init_wsi(struct anv_physical_device *device)
wsi->base.get_present_modes = wsi_wl_surface_get_present_modes;
wsi->base.create_swapchain = wsi_wl_surface_create_swapchain;
- device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = &wsi->base;
+ device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = &wsi->base;
return VK_SUCCESS;
@@ -866,7 +866,7 @@ fail_mutex:
fail_alloc:
vk_free(&device->instance->alloc, wsi);
fail:
- device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
+ device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
return result;
}
@@ -875,7 +875,7 @@ void
anv_wl_finish_wsi(struct anv_physical_device *device)
{
struct wsi_wayland *wsi =
- (struct wsi_wayland *)device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
+ (struct wsi_wayland *)device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
if (wsi) {
_mesa_hash_table_destroy(wsi->displays, NULL);
diff --git a/src/intel/vulkan/anv_wsi_x11.c b/src/intel/vulkan/anv_wsi_x11.c
index 3c9d4bd1f0d..595c9222d89 100644
--- a/src/intel/vulkan/anv_wsi_x11.c
+++ b/src/intel/vulkan/anv_wsi_x11.c
@@ -87,12 +87,12 @@ wsi_x11_connection_destroy(const VkAllocationCallbacks *alloc,
}
static struct wsi_x11_connection *
-wsi_x11_get_connection(struct anv_wsi_interface **wsi_dev,
+wsi_x11_get_connection(struct anv_wsi_device *wsi_dev,
const VkAllocationCallbacks *alloc,
xcb_connection_t *conn)
{
struct wsi_x11 *wsi =
- (struct wsi_x11 *)wsi_dev[VK_ICD_WSI_PLATFORM_XCB];
+ (struct wsi_x11 *)wsi_dev->wsi[VK_ICD_WSI_PLATFORM_XCB];
pthread_mutex_lock(&wsi->mutex);
@@ -242,7 +242,7 @@ VkBool32 anv_GetPhysicalDeviceXcbPresentationSupportKHR(
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
struct wsi_x11_connection *wsi_conn =
- wsi_x11_get_connection(device->wsi, &device->instance->alloc, connection);
+ wsi_x11_get_connection(&device->wsi_device, &device->instance->alloc, connection);
if (!wsi_conn->has_dri3) {
fprintf(stderr, "vulkan: No DRI3 support\n");
@@ -299,7 +299,7 @@ x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
xcb_window_t window = x11_surface_get_window(icd_surface);
struct wsi_x11_connection *wsi_conn =
- wsi_x11_get_connection(device->wsi, &device->instance->alloc, conn);
+ wsi_x11_get_connection(&device->wsi_device, &device->instance->alloc, conn);
if (!wsi_conn)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -934,8 +934,8 @@ anv_x11_init_wsi(struct anv_physical_device *device)
wsi->base.get_present_modes = x11_surface_get_present_modes;
wsi->base.create_swapchain = x11_surface_create_swapchain;
- device->wsi[VK_ICD_WSI_PLATFORM_XCB] = &wsi->base;
- device->wsi[VK_ICD_WSI_PLATFORM_XLIB] = &wsi->base;
+ device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XCB] = &wsi->base;
+ device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XLIB] = &wsi->base;
return VK_SUCCESS;
@@ -944,8 +944,8 @@ fail_mutex:
fail_alloc:
vk_free(&device->instance->alloc, wsi);
fail:
- device->wsi[VK_ICD_WSI_PLATFORM_XCB] = NULL;
- device->wsi[VK_ICD_WSI_PLATFORM_XLIB] = NULL;
+ device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XCB] = NULL;
+ device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XLIB] = NULL;
return result;
}
@@ -954,7 +954,7 @@ void
anv_x11_finish_wsi(struct anv_physical_device *device)
{
struct wsi_x11 *wsi =
- (struct wsi_x11 *)device->wsi[VK_ICD_WSI_PLATFORM_XCB];
+ (struct wsi_x11 *)device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XCB];
if (wsi) {
_mesa_hash_table_destroy(wsi->connections, NULL);