summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/anv_wsi_wayland.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_wayland.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_wayland.c')
-rw-r--r--src/intel/vulkan/anv_wsi_wayland.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/intel/vulkan/anv_wsi_wayland.c b/src/intel/vulkan/anv_wsi_wayland.c
index 6f25eaf43ea..0c21029a56d 100644
--- a/src/intel/vulkan/anv_wsi_wayland.c
+++ b/src/intel/vulkan/anv_wsi_wayland.c
@@ -43,7 +43,7 @@ struct wsi_wl_display {
struct wsi_wayland {
struct anv_wsi_interface base;
- struct anv_instance * instance;
+ struct anv_physical_device * physical_device;
pthread_mutex_t mutex;
/* Hash table of wl_display -> wsi_wl_display mappings */
@@ -226,14 +226,14 @@ wsi_wl_display_destroy(struct wsi_wayland *wsi, struct wsi_wl_display *display)
anv_vector_finish(&display->formats);
if (display->drm)
wl_drm_destroy(display->drm);
- anv_free(&wsi->instance->alloc, display);
+ anv_free(&wsi->physical_device->instance->alloc, display);
}
static struct wsi_wl_display *
wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
{
struct wsi_wl_display *display =
- anv_alloc(&wsi->instance->alloc, sizeof(*display), 8,
+ anv_alloc(&wsi->physical_device->instance->alloc, sizeof(*display), 8,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (!display)
return NULL;
@@ -278,10 +278,11 @@ fail:
}
static struct wsi_wl_display *
-wsi_wl_get_display(struct anv_instance *instance, struct wl_display *wl_display)
+wsi_wl_get_display(struct anv_physical_device *device,
+ struct wl_display *wl_display)
{
struct wsi_wayland *wsi =
- (struct wsi_wayland *)instance->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
+ (struct wsi_wayland *)device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
pthread_mutex_lock(&wsi->mutex);
@@ -318,7 +319,7 @@ VkBool32 anv_GetPhysicalDeviceWaylandPresentationSupportKHR(
{
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
- return wsi_wl_get_display(physical_device->instance, display) != NULL;
+ return wsi_wl_get_display(physical_device, display) != NULL;
}
static VkResult
@@ -372,7 +373,7 @@ wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface,
{
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
struct wsi_wl_display *display =
- wsi_wl_get_display(device->instance, surface->display);
+ wsi_wl_get_display(device, surface->display);
uint32_t count = anv_vector_length(&display->formats);
@@ -775,7 +776,8 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
chain->images[i].buffer = NULL;
chain->queue = NULL;
- chain->display = wsi_wl_get_display(device->instance, surface->display);
+ chain->display = wsi_wl_get_display(&device->instance->physicalDevice,
+ surface->display);
if (!chain->display)
goto fail;
@@ -801,19 +803,19 @@ fail:
}
VkResult
-anv_wl_init_wsi(struct anv_instance *instance)
+anv_wl_init_wsi(struct anv_physical_device *device)
{
struct wsi_wayland *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);
goto fail;
}
- wsi->instance = instance;
+ wsi->physical_device = device;
int ret = pthread_mutex_init(&wsi->mutex, NULL);
if (ret != 0) {
@@ -840,7 +842,7 @@ anv_wl_init_wsi(struct anv_instance *instance)
wsi->base.get_present_modes = wsi_wl_surface_get_present_modes;
wsi->base.create_swapchain = wsi_wl_surface_create_swapchain;
- instance->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = &wsi->base;
+ device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = &wsi->base;
return VK_SUCCESS;
@@ -848,24 +850,24 @@ 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_WAYLAND] = NULL;
+ device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
return result;
}
void
-anv_wl_finish_wsi(struct anv_instance *instance)
+anv_wl_finish_wsi(struct anv_physical_device *device)
{
struct wsi_wayland *wsi =
- (struct wsi_wayland *)instance->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
+ (struct wsi_wayland *)device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
if (wsi) {
_mesa_hash_table_destroy(wsi->displays, NULL);
pthread_mutex_destroy(&wsi->mutex);
- anv_free(&instance->alloc, wsi);
+ anv_free(&device->instance->alloc, wsi);
}
}