device->compiler->shader_debug_log = compiler_debug_log;
device->compiler->shader_perf_log = compiler_perf_log;
+ anv_init_wsi(device);
+
/* XXX: Actually detect bit6 swizzling */
isl_device_init(&device->isl_dev, device->info, swizzled);
static void
anv_physical_device_finish(struct anv_physical_device *device)
{
+ anv_finish_wsi(device);
ralloc_free(device->compiler);
}
instance->apiVersion = client_version;
instance->physicalDeviceCount = -1;
- memset(instance->wsi, 0, sizeof(instance->wsi));
-
_mesa_locale_init();
VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false));
- anv_init_wsi(instance);
-
*pInstance = anv_instance_to_handle(instance);
return VK_SUCCESS;
anv_physical_device_finish(&instance->physicalDevice);
}
- anv_finish_wsi(instance);
-
VG(VALGRIND_DESTROY_MEMPOOL(instance));
_mesa_locale_fini();
anv_free(parent_alloc, data);
}
+struct anv_wsi_interaface;
+
+#define VK_ICD_WSI_PLATFORM_MAX 5
+
struct anv_physical_device {
VK_LOADER_DATA _loader_data;
struct brw_compiler * compiler;
struct isl_device isl_dev;
int cmd_parser_version;
-};
-
-struct anv_wsi_interaface;
-#define VK_ICD_WSI_PLATFORM_MAX 5
+ struct anv_wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
+};
struct anv_instance {
VK_LOADER_DATA _loader_data;
uint32_t apiVersion;
int physicalDeviceCount;
struct anv_physical_device physicalDevice;
-
- struct anv_wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
};
-VkResult anv_init_wsi(struct anv_instance *instance);
-void anv_finish_wsi(struct anv_instance *instance);
+VkResult anv_init_wsi(struct anv_physical_device *physical_device);
+void anv_finish_wsi(struct anv_physical_device *physical_device);
struct anv_meta_state {
VkAllocationCallbacks alloc;
#include "anv_wsi.h"
VkResult
-anv_init_wsi(struct anv_instance *instance)
+anv_init_wsi(struct anv_physical_device *physical_device)
{
VkResult result;
+ memset(physical_device->wsi, 0, sizeof(physical_device->wsi));
+
#ifdef VK_USE_PLATFORM_XCB_KHR
- result = anv_x11_init_wsi(instance);
+ result = anv_x11_init_wsi(physical_device);
if (result != VK_SUCCESS)
return result;
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
- result = anv_wl_init_wsi(instance);
+ result = anv_wl_init_wsi(physical_device);
if (result != VK_SUCCESS) {
- anv_x11_finish_wsi(instance);
+ anv_x11_finish_wsi(physical_device);
return result;
}
#endif
}
void
-anv_finish_wsi(struct anv_instance *instance)
+anv_finish_wsi(struct anv_physical_device *physical_device)
{
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
- anv_wl_finish_wsi(instance);
+ anv_wl_finish_wsi(physical_device);
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
- anv_x11_finish_wsi(instance);
+ anv_x11_finish_wsi(physical_device);
#endif
}
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
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);
}
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
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);
}
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
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,
pSurfaceFormats);
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
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,
pPresentModes);
{
ANV_FROM_HANDLE(anv_device, device, _device);
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;
VkResult result = iface->create_swapchain(surface, device, pCreateInfo,
ANV_DEFINE_NONDISP_HANDLE_CASTS(_VkIcdSurfaceBase, VkSurfaceKHR)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_swapchain, VkSwapchainKHR)
-VkResult anv_x11_init_wsi(struct anv_instance *instance);
-void anv_x11_finish_wsi(struct anv_instance *instance);
-VkResult anv_wl_init_wsi(struct anv_instance *instance);
-void anv_wl_finish_wsi(struct anv_instance *instance);
+VkResult anv_x11_init_wsi(struct anv_physical_device *physical_device);
+void anv_x11_finish_wsi(struct anv_physical_device *physical_device);
+VkResult anv_wl_init_wsi(struct anv_physical_device *physical_device);
+void anv_wl_finish_wsi(struct anv_physical_device *physical_device);
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 */
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;
}
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);
{
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
{
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);
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;
}
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) {
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;
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);
}
}
};
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;
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;
}
}
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);
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);
}
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");
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);
}
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);
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);
}
}