summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/intel/vulkan/anv_wsi.c28
-rw-r--r--src/intel/vulkan/anv_wsi.h3
-rw-r--r--src/intel/vulkan/anv_wsi_wayland.c21
-rw-r--r--src/intel/vulkan/anv_wsi_x11.c22
4 files changed, 35 insertions, 39 deletions
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 514a29f0b5c..89bf780b4ba 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -253,17 +253,21 @@ VkResult anv_CreateSwapchainKHR(
struct anv_wsi_interface *iface =
device->instance->physicalDevice.wsi_device.wsi[surface->platform];
struct anv_swapchain *swapchain;
+ const VkAllocationCallbacks *alloc;
- VkResult result = iface->create_swapchain(surface, device, pCreateInfo,
- pAllocator, &anv_wsi_image_fns,
+ if (pAllocator)
+ alloc = pAllocator;
+ else
+ alloc = &device->alloc;
+ VkResult result = iface->create_swapchain(surface, _device,
+ &device->instance->physicalDevice.wsi_device,
+ pCreateInfo,
+ alloc, &anv_wsi_image_fns,
&swapchain);
if (result != VK_SUCCESS)
return result;
- if (pAllocator)
- swapchain->alloc = *pAllocator;
- else
- swapchain->alloc = device->alloc;
+ swapchain->alloc = *alloc;
for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++)
swapchain->fences[i] = VK_NULL_HANDLE;
@@ -274,18 +278,24 @@ VkResult anv_CreateSwapchainKHR(
}
void anv_DestroySwapchainKHR(
- VkDevice device,
+ VkDevice _device,
VkSwapchainKHR _swapchain,
const VkAllocationCallbacks* pAllocator)
{
+ ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain);
+ const VkAllocationCallbacks *alloc;
+ if (pAllocator)
+ alloc = pAllocator;
+ else
+ alloc = &device->alloc;
for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++) {
if (swapchain->fences[i] != VK_NULL_HANDLE)
- anv_DestroyFence(device, swapchain->fences[i], pAllocator);
+ anv_DestroyFence(_device, swapchain->fences[i], pAllocator);
}
- swapchain->destroy(swapchain, pAllocator);
+ swapchain->destroy(swapchain, alloc);
}
VkResult anv_GetSwapchainImagesKHR(
diff --git a/src/intel/vulkan/anv_wsi.h b/src/intel/vulkan/anv_wsi.h
index 2548e412c12..236133c4252 100644
--- a/src/intel/vulkan/anv_wsi.h
+++ b/src/intel/vulkan/anv_wsi.h
@@ -60,7 +60,8 @@ struct anv_wsi_interface {
uint32_t* pPresentModeCount,
VkPresentModeKHR* pPresentModes);
VkResult (*create_swapchain)(VkIcdSurfaceBase *surface,
- struct anv_device *device,
+ VkDevice device,
+ struct anv_wsi_device *wsi_device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
const struct anv_wsi_image_fns *image_fns,
diff --git a/src/intel/vulkan/anv_wsi_wayland.c b/src/intel/vulkan/anv_wsi_wayland.c
index e56b3befa65..16a96470fa0 100644
--- a/src/intel/vulkan/anv_wsi_wayland.c
+++ b/src/intel/vulkan/anv_wsi_wayland.c
@@ -422,14 +422,6 @@ wsi_wl_surface_get_present_modes(VkIcdSurfaceBase *surface,
return VK_SUCCESS;
}
-static VkResult
-wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *surface,
- struct anv_device *device,
- const VkSwapchainCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- const struct anv_wsi_image_fns *image_fns,
- struct anv_swapchain **swapchain);
-
VkResult anv_CreateWaylandSurfaceKHR(
VkInstance _instance,
const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
@@ -650,7 +642,7 @@ wsi_wl_swapchain_destroy(struct anv_swapchain *anv_chain,
const VkAllocationCallbacks *pAllocator)
{
struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain;
- struct anv_device *device = anv_device_from_handle(chain->base.device);
+
for (uint32_t i = 0; i < chain->image_count; i++) {
if (chain->images[i].buffer)
chain->base.image_fns->free_wsi_image(chain->base.device, pAllocator,
@@ -658,14 +650,15 @@ wsi_wl_swapchain_destroy(struct anv_swapchain *anv_chain,
chain->images[i].memory);
}
- vk_free2(&device->alloc, pAllocator, chain);
+ vk_free(pAllocator, chain);
return VK_SUCCESS;
}
static VkResult
wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
- struct anv_device *device,
+ VkDevice device,
+ struct anv_wsi_device *wsi_device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
const struct anv_wsi_image_fns *image_fns,
@@ -691,12 +684,12 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
num_images = MAX2(num_images, 4);
size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]);
- chain = vk_alloc2(&device->alloc, pAllocator, size, 8,
+ chain = vk_alloc(pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (chain == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- chain->base.device = anv_device_to_handle(device);
+ chain->base.device = device;
chain->base.destroy = wsi_wl_swapchain_destroy;
chain->base.get_images = wsi_wl_swapchain_get_images;
chain->base.acquire_next_image = wsi_wl_swapchain_acquire_next_image;
@@ -719,7 +712,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
chain->images[i].buffer = NULL;
chain->queue = NULL;
- chain->display = wsi_wl_get_display(&device->instance->physicalDevice.wsi_device,
+ chain->display = wsi_wl_get_display(wsi_device,
surface->display);
if (!chain->display) {
result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
diff --git a/src/intel/vulkan/anv_wsi_x11.c b/src/intel/vulkan/anv_wsi_x11.c
index 54fe05701b9..f56df40b498 100644
--- a/src/intel/vulkan/anv_wsi_x11.c
+++ b/src/intel/vulkan/anv_wsi_x11.c
@@ -434,14 +434,6 @@ x11_surface_get_present_modes(VkIcdSurfaceBase *surface,
return VK_SUCCESS;
}
-static VkResult
-x11_surface_create_swapchain(VkIcdSurfaceBase *surface,
- struct anv_device *device,
- const VkSwapchainCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- const struct anv_wsi_image_fns *image_fns,
- struct anv_swapchain **swapchain);
-
VkResult anv_CreateXcbSurfaceKHR(
VkInstance _instance,
const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
@@ -747,20 +739,20 @@ x11_swapchain_destroy(struct anv_swapchain *anv_chain,
const VkAllocationCallbacks *pAllocator)
{
struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
- struct anv_device *device = anv_device_from_handle(chain->base.device);
for (uint32_t i = 0; i < chain->image_count; i++)
x11_image_finish(chain, pAllocator, &chain->images[i]);
xcb_unregister_for_special_event(chain->conn, chain->special_event);
- vk_free2(&device->alloc, pAllocator, chain);
+ vk_free(pAllocator, chain);
return VK_SUCCESS;
}
static VkResult
x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
- struct anv_device *device,
+ VkDevice device,
+ struct anv_wsi_device *wsi_device,
const VkSwapchainCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks* pAllocator,
const struct anv_wsi_image_fns *image_fns,
@@ -784,12 +776,12 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
num_images = MAX2(num_images, 4);
size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]);
- chain = vk_alloc2(&device->alloc, pAllocator, size, 8,
+ chain = vk_alloc(pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (chain == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- chain->base.device = anv_device_to_handle(device);
+ chain->base.device = device;
chain->base.destroy = x11_swapchain_destroy;
chain->base.get_images = x11_get_images;
chain->base.acquire_next_image = x11_acquire_next_image;
@@ -830,7 +822,7 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
uint32_t image = 0;
for (; image < chain->image_count; image++) {
- result = x11_image_init(anv_device_to_handle(device), chain, pCreateInfo, pAllocator,
+ result = x11_image_init(device, chain, pCreateInfo, pAllocator,
&chain->images[image]);
if (result != VK_SUCCESS)
goto fail_init_images;
@@ -847,7 +839,7 @@ fail_init_images:
fail_register:
xcb_unregister_for_special_event(chain->conn, chain->special_event);
- vk_free2(&device->alloc, pAllocator, chain);
+ vk_free(pAllocator, chain);
return result;
}