summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/anv_wsi_x11.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-05-15 22:21:24 -0700
committerJason Ekstrand <[email protected]>2016-05-17 12:17:22 -0700
commiteb6baa31746b55d48892b0c57f0e0076b91efdeb (patch)
tree64af02ac95978dcdd05688c6f0938f2449a0366e /src/intel/vulkan/anv_wsi_x11.c
parent2ad9d6237a510ec2acd0d416c34fe6e231460182 (diff)
anv/wsi: Make WSI per-physical-device rather than per-instance
This better maps to the Vulkan object model and also allows WSI to at least know the hardware generation which is useful for format checks.
Diffstat (limited to 'src/intel/vulkan/anv_wsi_x11.c')
-rw-r--r--src/intel/vulkan/anv_wsi_x11.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/intel/vulkan/anv_wsi_x11.c b/src/intel/vulkan/anv_wsi_x11.c
index 9ef02961a93..de56ca7f3d6 100644
--- a/src/intel/vulkan/anv_wsi_x11.c
+++ b/src/intel/vulkan/anv_wsi_x11.c
@@ -44,13 +44,14 @@ struct wsi_x11 {
};
static struct wsi_x11_connection *
-wsi_x11_connection_create(struct anv_instance *instance, xcb_connection_t *conn)
+wsi_x11_connection_create(struct anv_physical_device *device,
+ xcb_connection_t *conn)
{
xcb_query_extension_cookie_t dri3_cookie, pres_cookie;
xcb_query_extension_reply_t *dri3_reply, *pres_reply;
struct wsi_x11_connection *wsi_conn =
- anv_alloc(&instance->alloc, sizeof(*wsi_conn), 8,
+ anv_alloc(&device->instance->alloc, sizeof(*wsi_conn), 8,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (!wsi_conn)
return NULL;
@@ -63,7 +64,7 @@ wsi_x11_connection_create(struct anv_instance *instance, xcb_connection_t *conn)
if (dri3_reply == NULL || pres_reply == NULL) {
free(dri3_reply);
free(pres_reply);
- anv_free(&instance->alloc, wsi_conn);
+ anv_free(&device->instance->alloc, wsi_conn);
return NULL;
}
@@ -77,17 +78,18 @@ wsi_x11_connection_create(struct anv_instance *instance, xcb_connection_t *conn)
}
static void
-wsi_x11_connection_destroy(struct anv_instance *instance,
+wsi_x11_connection_destroy(struct anv_physical_device *device,
struct wsi_x11_connection *conn)
{
- anv_free(&instance->alloc, conn);
+ anv_free(&device->instance->alloc, conn);
}
static struct wsi_x11_connection *
-wsi_x11_get_connection(struct anv_instance *instance, xcb_connection_t *conn)
+wsi_x11_get_connection(struct anv_physical_device *device,
+ xcb_connection_t *conn)
{
struct wsi_x11 *wsi =
- (struct wsi_x11 *)instance->wsi[VK_ICD_WSI_PLATFORM_XCB];
+ (struct wsi_x11 *)device->wsi[VK_ICD_WSI_PLATFORM_XCB];
pthread_mutex_lock(&wsi->mutex);
@@ -99,14 +101,14 @@ wsi_x11_get_connection(struct anv_instance *instance, xcb_connection_t *conn)
pthread_mutex_unlock(&wsi->mutex);
struct wsi_x11_connection *wsi_conn =
- wsi_x11_connection_create(instance, conn);
+ wsi_x11_connection_create(device, conn);
pthread_mutex_lock(&wsi->mutex);
entry = _mesa_hash_table_search(wsi->connections, conn);
if (entry) {
/* Oops, someone raced us to it */
- wsi_x11_connection_destroy(instance, wsi_conn);
+ wsi_x11_connection_destroy(device, wsi_conn);
} else {
entry = _mesa_hash_table_insert(wsi->connections, conn, wsi_conn);
}
@@ -236,7 +238,7 @@ VkBool32 anv_GetPhysicalDeviceXcbPresentationSupportKHR(
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
struct wsi_x11_connection *wsi_conn =
- wsi_x11_get_connection(device->instance, connection);
+ wsi_x11_get_connection(device, connection);
if (!wsi_conn->has_dri3) {
fprintf(stderr, "vulkan: No DRI3 support\n");
@@ -262,7 +264,7 @@ x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
VkIcdSurfaceXcb *surface = (VkIcdSurfaceXcb *)icd_surface;
struct wsi_x11_connection *wsi_conn =
- wsi_x11_get_connection(device->instance, surface->connection);
+ wsi_x11_get_connection(device, surface->connection);
if (!wsi_conn)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -835,12 +837,12 @@ fail_register:
}
VkResult
-anv_x11_init_wsi(struct anv_instance *instance)
+anv_x11_init_wsi(struct anv_physical_device *device)
{
struct wsi_x11 *wsi;
VkResult result;
- wsi = anv_alloc(&instance->alloc, sizeof(*wsi), 8,
+ wsi = anv_alloc(&device->instance->alloc, sizeof(*wsi), 8,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (!wsi) {
result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -872,31 +874,31 @@ anv_x11_init_wsi(struct anv_instance *instance)
wsi->base.get_present_modes = x11_surface_get_present_modes;
wsi->base.create_swapchain = x11_surface_create_swapchain;
- instance->wsi[VK_ICD_WSI_PLATFORM_XCB] = &wsi->base;
+ device->wsi[VK_ICD_WSI_PLATFORM_XCB] = &wsi->base;
return VK_SUCCESS;
fail_mutex:
pthread_mutex_destroy(&wsi->mutex);
fail_alloc:
- anv_free(&instance->alloc, wsi);
+ anv_free(&device->instance->alloc, wsi);
fail:
- instance->wsi[VK_ICD_WSI_PLATFORM_XCB] = NULL;
+ device->wsi[VK_ICD_WSI_PLATFORM_XCB] = NULL;
return result;
}
void
-anv_x11_finish_wsi(struct anv_instance *instance)
+anv_x11_finish_wsi(struct anv_physical_device *device)
{
struct wsi_x11 *wsi =
- (struct wsi_x11 *)instance->wsi[VK_ICD_WSI_PLATFORM_XCB];
+ (struct wsi_x11 *)device->wsi[VK_ICD_WSI_PLATFORM_XCB];
if (wsi) {
_mesa_hash_table_destroy(wsi->connections, NULL);
pthread_mutex_destroy(&wsi->mutex);
- anv_free(&instance->alloc, wsi);
+ anv_free(&device->instance->alloc, wsi);
}
}