anv/wsi/wl: stop using device in more places
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
parent
507722b882
commit
4392de6771
|
@ -37,7 +37,8 @@ anv_init_wsi(struct anv_physical_device *physical_device)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||||
result = anv_wl_init_wsi(physical_device);
|
result = anv_wl_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc,
|
||||||
|
anv_physical_device_to_handle(physical_device));
|
||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||||
anv_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
|
anv_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
|
||||||
|
@ -53,7 +54,7 @@ void
|
||||||
anv_finish_wsi(struct anv_physical_device *physical_device)
|
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(physical_device);
|
anv_wl_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
|
||||||
#endif
|
#endif
|
||||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||||
anv_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
|
anv_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
|
||||||
|
|
|
@ -93,7 +93,10 @@ VkResult anv_x11_init_wsi(struct anv_wsi_device *wsi_device,
|
||||||
const VkAllocationCallbacks *alloc);
|
const VkAllocationCallbacks *alloc);
|
||||||
void anv_x11_finish_wsi(struct anv_wsi_device *wsi_device,
|
void anv_x11_finish_wsi(struct anv_wsi_device *wsi_device,
|
||||||
const VkAllocationCallbacks *alloc);
|
const VkAllocationCallbacks *alloc);
|
||||||
VkResult anv_wl_init_wsi(struct anv_physical_device *physical_device);
|
|
||||||
void anv_wl_finish_wsi(struct anv_physical_device *physical_device);
|
|
||||||
|
|
||||||
|
VkResult anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
|
||||||
|
const VkAllocationCallbacks *alloc,
|
||||||
|
VkPhysicalDevice physical_device);
|
||||||
|
void anv_wl_finish_wsi(struct anv_wsi_device *wsi_device,
|
||||||
|
const VkAllocationCallbacks *alloc);
|
||||||
#endif /* ANV_WSI_H */
|
#endif /* ANV_WSI_H */
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#define MIN_NUM_IMAGES 2
|
#define MIN_NUM_IMAGES 2
|
||||||
|
|
||||||
struct wsi_wl_display {
|
struct wsi_wl_display {
|
||||||
struct anv_physical_device *physical_device;
|
VkPhysicalDevice physical_device;
|
||||||
struct wl_display * display;
|
struct wl_display * display;
|
||||||
struct wl_drm * drm;
|
struct wl_drm * drm;
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ struct wsi_wl_display {
|
||||||
struct wsi_wayland {
|
struct wsi_wayland {
|
||||||
struct anv_wsi_interface base;
|
struct anv_wsi_interface base;
|
||||||
|
|
||||||
struct anv_physical_device * physical_device;
|
const VkAllocationCallbacks *alloc;
|
||||||
|
VkPhysicalDevice 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 */
|
||||||
|
@ -64,7 +65,7 @@ wsi_wl_display_add_vk_format(struct wsi_wl_display *display, VkFormat format)
|
||||||
/* Don't add formats that aren't renderable. */
|
/* Don't add formats that aren't renderable. */
|
||||||
VkFormatProperties props;
|
VkFormatProperties props;
|
||||||
anv_GetPhysicalDeviceFormatProperties(
|
anv_GetPhysicalDeviceFormatProperties(
|
||||||
anv_physical_device_to_handle(display->physical_device), format, &props);
|
display->physical_device, format, &props);
|
||||||
if (!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
|
if (!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -233,14 +234,14 @@ wsi_wl_display_destroy(struct wsi_wayland *wsi, struct wsi_wl_display *display)
|
||||||
u_vector_finish(&display->formats);
|
u_vector_finish(&display->formats);
|
||||||
if (display->drm)
|
if (display->drm)
|
||||||
wl_drm_destroy(display->drm);
|
wl_drm_destroy(display->drm);
|
||||||
vk_free(&wsi->physical_device->instance->alloc, display);
|
vk_free(wsi->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 =
|
||||||
vk_alloc(&wsi->physical_device->instance->alloc, sizeof(*display), 8,
|
vk_alloc(wsi->alloc, sizeof(*display), 8,
|
||||||
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
||||||
if (!display)
|
if (!display)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -756,20 +757,22 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
anv_wl_init_wsi(struct anv_physical_device *device)
|
anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
|
||||||
|
const VkAllocationCallbacks *alloc,
|
||||||
|
VkPhysicalDevice physical_device)
|
||||||
{
|
{
|
||||||
struct wsi_wayland *wsi;
|
struct wsi_wayland *wsi;
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
wsi = vk_alloc(&device->instance->alloc, sizeof(*wsi), 8,
|
wsi = vk_alloc(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->physical_device = device;
|
wsi->physical_device = physical_device;
|
||||||
|
wsi->alloc = alloc;
|
||||||
int ret = pthread_mutex_init(&wsi->mutex, NULL);
|
int ret = pthread_mutex_init(&wsi->mutex, NULL);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
if (ret == ENOMEM) {
|
if (ret == ENOMEM) {
|
||||||
|
@ -795,7 +798,7 @@ anv_wl_init_wsi(struct anv_physical_device *device)
|
||||||
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;
|
||||||
|
|
||||||
device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = &wsi->base;
|
wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = &wsi->base;
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
|
|
||||||
|
@ -803,24 +806,25 @@ fail_mutex:
|
||||||
pthread_mutex_destroy(&wsi->mutex);
|
pthread_mutex_destroy(&wsi->mutex);
|
||||||
|
|
||||||
fail_alloc:
|
fail_alloc:
|
||||||
vk_free(&device->instance->alloc, wsi);
|
vk_free(alloc, wsi);
|
||||||
fail:
|
fail:
|
||||||
device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
|
wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
anv_wl_finish_wsi(struct anv_physical_device *device)
|
anv_wl_finish_wsi(struct anv_wsi_device *wsi_device,
|
||||||
|
const VkAllocationCallbacks *alloc)
|
||||||
{
|
{
|
||||||
struct wsi_wayland *wsi =
|
struct wsi_wayland *wsi =
|
||||||
(struct wsi_wayland *)device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
|
(struct wsi_wayland *)wsi_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);
|
||||||
|
|
||||||
vk_free(&device->instance->alloc, wsi);
|
vk_free(alloc, wsi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue