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.
This commit is contained in:
@@ -149,6 +149,8 @@ anv_physical_device_init(struct anv_physical_device *device,
|
|||||||
device->compiler->shader_debug_log = compiler_debug_log;
|
device->compiler->shader_debug_log = compiler_debug_log;
|
||||||
device->compiler->shader_perf_log = compiler_perf_log;
|
device->compiler->shader_perf_log = compiler_perf_log;
|
||||||
|
|
||||||
|
anv_init_wsi(device);
|
||||||
|
|
||||||
/* XXX: Actually detect bit6 swizzling */
|
/* XXX: Actually detect bit6 swizzling */
|
||||||
isl_device_init(&device->isl_dev, device->info, swizzled);
|
isl_device_init(&device->isl_dev, device->info, swizzled);
|
||||||
|
|
||||||
@@ -162,6 +164,7 @@ fail:
|
|||||||
static void
|
static void
|
||||||
anv_physical_device_finish(struct anv_physical_device *device)
|
anv_physical_device_finish(struct anv_physical_device *device)
|
||||||
{
|
{
|
||||||
|
anv_finish_wsi(device);
|
||||||
ralloc_free(device->compiler);
|
ralloc_free(device->compiler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,14 +275,10 @@ VkResult anv_CreateInstance(
|
|||||||
instance->apiVersion = client_version;
|
instance->apiVersion = client_version;
|
||||||
instance->physicalDeviceCount = -1;
|
instance->physicalDeviceCount = -1;
|
||||||
|
|
||||||
memset(instance->wsi, 0, sizeof(instance->wsi));
|
|
||||||
|
|
||||||
_mesa_locale_init();
|
_mesa_locale_init();
|
||||||
|
|
||||||
VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false));
|
VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false));
|
||||||
|
|
||||||
anv_init_wsi(instance);
|
|
||||||
|
|
||||||
*pInstance = anv_instance_to_handle(instance);
|
*pInstance = anv_instance_to_handle(instance);
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
@@ -297,8 +296,6 @@ void anv_DestroyInstance(
|
|||||||
anv_physical_device_finish(&instance->physicalDevice);
|
anv_physical_device_finish(&instance->physicalDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
anv_finish_wsi(instance);
|
|
||||||
|
|
||||||
VG(VALGRIND_DESTROY_MEMPOOL(instance));
|
VG(VALGRIND_DESTROY_MEMPOOL(instance));
|
||||||
|
|
||||||
_mesa_locale_fini();
|
_mesa_locale_fini();
|
||||||
|
@@ -532,6 +532,10 @@ anv_free2(const VkAllocationCallbacks *parent_alloc,
|
|||||||
anv_free(parent_alloc, data);
|
anv_free(parent_alloc, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct anv_wsi_interaface;
|
||||||
|
|
||||||
|
#define VK_ICD_WSI_PLATFORM_MAX 5
|
||||||
|
|
||||||
struct anv_physical_device {
|
struct anv_physical_device {
|
||||||
VK_LOADER_DATA _loader_data;
|
VK_LOADER_DATA _loader_data;
|
||||||
|
|
||||||
@@ -544,12 +548,10 @@ struct anv_physical_device {
|
|||||||
struct brw_compiler * compiler;
|
struct brw_compiler * compiler;
|
||||||
struct isl_device isl_dev;
|
struct isl_device isl_dev;
|
||||||
int cmd_parser_version;
|
int cmd_parser_version;
|
||||||
|
|
||||||
|
struct anv_wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct anv_wsi_interaface;
|
|
||||||
|
|
||||||
#define VK_ICD_WSI_PLATFORM_MAX 5
|
|
||||||
|
|
||||||
struct anv_instance {
|
struct anv_instance {
|
||||||
VK_LOADER_DATA _loader_data;
|
VK_LOADER_DATA _loader_data;
|
||||||
|
|
||||||
@@ -558,12 +560,10 @@ struct anv_instance {
|
|||||||
uint32_t apiVersion;
|
uint32_t apiVersion;
|
||||||
int physicalDeviceCount;
|
int physicalDeviceCount;
|
||||||
struct anv_physical_device physicalDevice;
|
struct anv_physical_device physicalDevice;
|
||||||
|
|
||||||
struct anv_wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VkResult anv_init_wsi(struct anv_instance *instance);
|
VkResult anv_init_wsi(struct anv_physical_device *physical_device);
|
||||||
void anv_finish_wsi(struct anv_instance *instance);
|
void anv_finish_wsi(struct anv_physical_device *physical_device);
|
||||||
|
|
||||||
struct anv_meta_state {
|
struct anv_meta_state {
|
||||||
VkAllocationCallbacks alloc;
|
VkAllocationCallbacks alloc;
|
||||||
|
@@ -24,20 +24,22 @@
|
|||||||
#include "anv_wsi.h"
|
#include "anv_wsi.h"
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
anv_init_wsi(struct anv_instance *instance)
|
anv_init_wsi(struct anv_physical_device *physical_device)
|
||||||
{
|
{
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
|
memset(physical_device->wsi, 0, sizeof(physical_device->wsi));
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||||
result = anv_x11_init_wsi(instance);
|
result = anv_x11_init_wsi(physical_device);
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
return result;
|
return result;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||||
result = anv_wl_init_wsi(instance);
|
result = anv_wl_init_wsi(physical_device);
|
||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
anv_x11_finish_wsi(instance);
|
anv_x11_finish_wsi(physical_device);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -46,13 +48,13 @@ anv_init_wsi(struct anv_instance *instance)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
anv_finish_wsi(struct anv_instance *instance)
|
anv_finish_wsi(struct anv_physical_device *physical_device)
|
||||||
{
|
{
|
||||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||||
anv_wl_finish_wsi(instance);
|
anv_wl_finish_wsi(physical_device);
|
||||||
#endif
|
#endif
|
||||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||||
anv_x11_finish_wsi(instance);
|
anv_x11_finish_wsi(physical_device);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +77,7 @@ VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
|
|||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
||||||
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
||||||
struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
|
struct anv_wsi_interface *iface = device->wsi[surface->platform];
|
||||||
|
|
||||||
return iface->get_support(surface, device, queueFamilyIndex, pSupported);
|
return iface->get_support(surface, device, queueFamilyIndex, pSupported);
|
||||||
}
|
}
|
||||||
@@ -87,7 +89,7 @@ VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
|
|||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
||||||
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
||||||
struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
|
struct anv_wsi_interface *iface = device->wsi[surface->platform];
|
||||||
|
|
||||||
return iface->get_capabilities(surface, device, pSurfaceCapabilities);
|
return iface->get_capabilities(surface, device, pSurfaceCapabilities);
|
||||||
}
|
}
|
||||||
@@ -100,7 +102,7 @@ VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR(
|
|||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
||||||
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
||||||
struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
|
struct anv_wsi_interface *iface = device->wsi[surface->platform];
|
||||||
|
|
||||||
return iface->get_formats(surface, device, pSurfaceFormatCount,
|
return iface->get_formats(surface, device, pSurfaceFormatCount,
|
||||||
pSurfaceFormats);
|
pSurfaceFormats);
|
||||||
@@ -114,7 +116,7 @@ VkResult anv_GetPhysicalDeviceSurfacePresentModesKHR(
|
|||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
||||||
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
||||||
struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
|
struct anv_wsi_interface *iface = device->wsi[surface->platform];
|
||||||
|
|
||||||
return iface->get_present_modes(surface, device, pPresentModeCount,
|
return iface->get_present_modes(surface, device, pPresentModeCount,
|
||||||
pPresentModes);
|
pPresentModes);
|
||||||
@@ -128,7 +130,8 @@ VkResult anv_CreateSwapchainKHR(
|
|||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, pCreateInfo->surface);
|
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, pCreateInfo->surface);
|
||||||
struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
|
struct anv_wsi_interface *iface =
|
||||||
|
device->instance->physicalDevice.wsi[surface->platform];
|
||||||
struct anv_swapchain *swapchain;
|
struct anv_swapchain *swapchain;
|
||||||
|
|
||||||
VkResult result = iface->create_swapchain(surface, device, pCreateInfo,
|
VkResult result = iface->create_swapchain(surface, device, pCreateInfo,
|
||||||
|
@@ -72,7 +72,7 @@ struct anv_swapchain {
|
|||||||
ANV_DEFINE_NONDISP_HANDLE_CASTS(_VkIcdSurfaceBase, VkSurfaceKHR)
|
ANV_DEFINE_NONDISP_HANDLE_CASTS(_VkIcdSurfaceBase, VkSurfaceKHR)
|
||||||
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_swapchain, VkSwapchainKHR)
|
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_swapchain, VkSwapchainKHR)
|
||||||
|
|
||||||
VkResult anv_x11_init_wsi(struct anv_instance *instance);
|
VkResult anv_x11_init_wsi(struct anv_physical_device *physical_device);
|
||||||
void anv_x11_finish_wsi(struct anv_instance *instance);
|
void anv_x11_finish_wsi(struct anv_physical_device *physical_device);
|
||||||
VkResult anv_wl_init_wsi(struct anv_instance *instance);
|
VkResult anv_wl_init_wsi(struct anv_physical_device *physical_device);
|
||||||
void anv_wl_finish_wsi(struct anv_instance *instance);
|
void anv_wl_finish_wsi(struct anv_physical_device *physical_device);
|
||||||
|
@@ -43,7 +43,7 @@ struct wsi_wl_display {
|
|||||||
struct wsi_wayland {
|
struct wsi_wayland {
|
||||||
struct anv_wsi_interface base;
|
struct anv_wsi_interface base;
|
||||||
|
|
||||||
struct anv_instance * instance;
|
struct anv_physical_device * physical_device;
|
||||||
|
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
/* Hash table of wl_display -> wsi_wl_display mappings */
|
/* 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);
|
anv_vector_finish(&display->formats);
|
||||||
if (display->drm)
|
if (display->drm)
|
||||||
wl_drm_destroy(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 *
|
static struct wsi_wl_display *
|
||||||
wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
|
wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
|
||||||
{
|
{
|
||||||
struct wsi_wl_display *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);
|
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
||||||
if (!display)
|
if (!display)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -278,10 +278,11 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct wsi_wl_display *
|
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 *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);
|
pthread_mutex_lock(&wsi->mutex);
|
||||||
|
|
||||||
@@ -318,7 +319,7 @@ VkBool32 anv_GetPhysicalDeviceWaylandPresentationSupportKHR(
|
|||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
|
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
|
static VkResult
|
||||||
@@ -372,7 +373,7 @@ wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface,
|
|||||||
{
|
{
|
||||||
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
|
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
|
||||||
struct wsi_wl_display *display =
|
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);
|
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->images[i].buffer = NULL;
|
||||||
chain->queue = 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)
|
if (!chain->display)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@@ -801,19 +803,19 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
anv_wl_init_wsi(struct anv_instance *instance)
|
anv_wl_init_wsi(struct anv_physical_device *device)
|
||||||
{
|
{
|
||||||
struct wsi_wayland *wsi;
|
struct wsi_wayland *wsi;
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
wsi = anv_alloc(&instance->alloc, sizeof(*wsi), 8,
|
wsi = anv_alloc(&device->instance->alloc, sizeof(*wsi), 8,
|
||||||
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
||||||
if (!wsi) {
|
if (!wsi) {
|
||||||
result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
wsi->instance = instance;
|
wsi->physical_device = device;
|
||||||
|
|
||||||
int ret = pthread_mutex_init(&wsi->mutex, NULL);
|
int ret = pthread_mutex_init(&wsi->mutex, NULL);
|
||||||
if (ret != 0) {
|
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.get_present_modes = wsi_wl_surface_get_present_modes;
|
||||||
wsi->base.create_swapchain = wsi_wl_surface_create_swapchain;
|
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;
|
return VK_SUCCESS;
|
||||||
|
|
||||||
@@ -848,24 +850,24 @@ fail_mutex:
|
|||||||
pthread_mutex_destroy(&wsi->mutex);
|
pthread_mutex_destroy(&wsi->mutex);
|
||||||
|
|
||||||
fail_alloc:
|
fail_alloc:
|
||||||
anv_free(&instance->alloc, wsi);
|
anv_free(&device->instance->alloc, wsi);
|
||||||
fail:
|
fail:
|
||||||
instance->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
|
device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 *wsi =
|
||||||
(struct wsi_wayland *)instance->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
|
(struct wsi_wayland *)device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
|
||||||
|
|
||||||
if (wsi) {
|
if (wsi) {
|
||||||
_mesa_hash_table_destroy(wsi->displays, NULL);
|
_mesa_hash_table_destroy(wsi->displays, NULL);
|
||||||
|
|
||||||
pthread_mutex_destroy(&wsi->mutex);
|
pthread_mutex_destroy(&wsi->mutex);
|
||||||
|
|
||||||
anv_free(&instance->alloc, wsi);
|
anv_free(&device->instance->alloc, wsi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,13 +44,14 @@ struct wsi_x11 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct wsi_x11_connection *
|
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_cookie_t dri3_cookie, pres_cookie;
|
||||||
xcb_query_extension_reply_t *dri3_reply, *pres_reply;
|
xcb_query_extension_reply_t *dri3_reply, *pres_reply;
|
||||||
|
|
||||||
struct wsi_x11_connection *wsi_conn =
|
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);
|
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
||||||
if (!wsi_conn)
|
if (!wsi_conn)
|
||||||
return NULL;
|
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) {
|
if (dri3_reply == NULL || pres_reply == NULL) {
|
||||||
free(dri3_reply);
|
free(dri3_reply);
|
||||||
free(pres_reply);
|
free(pres_reply);
|
||||||
anv_free(&instance->alloc, wsi_conn);
|
anv_free(&device->instance->alloc, wsi_conn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,17 +78,18 @@ wsi_x11_connection_create(struct anv_instance *instance, xcb_connection_t *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wsi_x11_connection_destroy(struct anv_instance *instance,
|
wsi_x11_connection_destroy(struct anv_physical_device *device,
|
||||||
struct wsi_x11_connection *conn)
|
struct wsi_x11_connection *conn)
|
||||||
{
|
{
|
||||||
anv_free(&instance->alloc, conn);
|
anv_free(&device->instance->alloc, conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wsi_x11_connection *
|
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 *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);
|
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);
|
pthread_mutex_unlock(&wsi->mutex);
|
||||||
|
|
||||||
struct wsi_x11_connection *wsi_conn =
|
struct wsi_x11_connection *wsi_conn =
|
||||||
wsi_x11_connection_create(instance, conn);
|
wsi_x11_connection_create(device, conn);
|
||||||
|
|
||||||
pthread_mutex_lock(&wsi->mutex);
|
pthread_mutex_lock(&wsi->mutex);
|
||||||
|
|
||||||
entry = _mesa_hash_table_search(wsi->connections, conn);
|
entry = _mesa_hash_table_search(wsi->connections, conn);
|
||||||
if (entry) {
|
if (entry) {
|
||||||
/* Oops, someone raced us to it */
|
/* Oops, someone raced us to it */
|
||||||
wsi_x11_connection_destroy(instance, wsi_conn);
|
wsi_x11_connection_destroy(device, wsi_conn);
|
||||||
} else {
|
} else {
|
||||||
entry = _mesa_hash_table_insert(wsi->connections, conn, wsi_conn);
|
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);
|
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
||||||
|
|
||||||
struct wsi_x11_connection *wsi_conn =
|
struct wsi_x11_connection *wsi_conn =
|
||||||
wsi_x11_get_connection(device->instance, connection);
|
wsi_x11_get_connection(device, connection);
|
||||||
|
|
||||||
if (!wsi_conn->has_dri3) {
|
if (!wsi_conn->has_dri3) {
|
||||||
fprintf(stderr, "vulkan: No DRI3 support\n");
|
fprintf(stderr, "vulkan: No DRI3 support\n");
|
||||||
@@ -262,7 +264,7 @@ x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
|
|||||||
VkIcdSurfaceXcb *surface = (VkIcdSurfaceXcb *)icd_surface;
|
VkIcdSurfaceXcb *surface = (VkIcdSurfaceXcb *)icd_surface;
|
||||||
|
|
||||||
struct wsi_x11_connection *wsi_conn =
|
struct wsi_x11_connection *wsi_conn =
|
||||||
wsi_x11_get_connection(device->instance, surface->connection);
|
wsi_x11_get_connection(device, surface->connection);
|
||||||
if (!wsi_conn)
|
if (!wsi_conn)
|
||||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
|
|
||||||
@@ -835,12 +837,12 @@ fail_register:
|
|||||||
}
|
}
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
anv_x11_init_wsi(struct anv_instance *instance)
|
anv_x11_init_wsi(struct anv_physical_device *device)
|
||||||
{
|
{
|
||||||
struct wsi_x11 *wsi;
|
struct wsi_x11 *wsi;
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
wsi = anv_alloc(&instance->alloc, sizeof(*wsi), 8,
|
wsi = anv_alloc(&device->instance->alloc, sizeof(*wsi), 8,
|
||||||
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
||||||
if (!wsi) {
|
if (!wsi) {
|
||||||
result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
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.get_present_modes = x11_surface_get_present_modes;
|
||||||
wsi->base.create_swapchain = x11_surface_create_swapchain;
|
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;
|
return VK_SUCCESS;
|
||||||
|
|
||||||
fail_mutex:
|
fail_mutex:
|
||||||
pthread_mutex_destroy(&wsi->mutex);
|
pthread_mutex_destroy(&wsi->mutex);
|
||||||
fail_alloc:
|
fail_alloc:
|
||||||
anv_free(&instance->alloc, wsi);
|
anv_free(&device->instance->alloc, wsi);
|
||||||
fail:
|
fail:
|
||||||
instance->wsi[VK_ICD_WSI_PLATFORM_XCB] = NULL;
|
device->wsi[VK_ICD_WSI_PLATFORM_XCB] = NULL;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 *wsi =
|
||||||
(struct wsi_x11 *)instance->wsi[VK_ICD_WSI_PLATFORM_XCB];
|
(struct wsi_x11 *)device->wsi[VK_ICD_WSI_PLATFORM_XCB];
|
||||||
|
|
||||||
if (wsi) {
|
if (wsi) {
|
||||||
_mesa_hash_table_destroy(wsi->connections, NULL);
|
_mesa_hash_table_destroy(wsi->connections, NULL);
|
||||||
|
|
||||||
pthread_mutex_destroy(&wsi->mutex);
|
pthread_mutex_destroy(&wsi->mutex);
|
||||||
|
|
||||||
anv_free(&instance->alloc, wsi);
|
anv_free(&device->instance->alloc, wsi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user