anv/wsi: split out surface creation to avoid instance API
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
parent
954cd09e66
commit
507722b882
|
@ -422,20 +422,14 @@ wsi_wl_surface_get_present_modes(VkIcdSurfaceBase *surface,
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult anv_CreateWaylandSurfaceKHR(
|
static VkResult anv_create_wl_surface(const VkAllocationCallbacks *pAllocator,
|
||||||
VkInstance _instance,
|
const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
|
||||||
const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
|
VkSurfaceKHR *pSurface)
|
||||||
const VkAllocationCallbacks* pAllocator,
|
|
||||||
VkSurfaceKHR* pSurface)
|
|
||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_instance, instance, _instance);
|
|
||||||
|
|
||||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR);
|
|
||||||
|
|
||||||
VkIcdSurfaceWayland *surface;
|
VkIcdSurfaceWayland *surface;
|
||||||
|
|
||||||
surface = vk_alloc2(&instance->alloc, pAllocator, sizeof *surface, 8,
|
surface = vk_alloc(pAllocator, sizeof *surface, 8,
|
||||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
|
|
||||||
|
@ -448,6 +442,24 @@ VkResult anv_CreateWaylandSurfaceKHR(
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkResult anv_CreateWaylandSurfaceKHR(
|
||||||
|
VkInstance _instance,
|
||||||
|
const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
|
||||||
|
const VkAllocationCallbacks* pAllocator,
|
||||||
|
VkSurfaceKHR* pSurface)
|
||||||
|
{
|
||||||
|
ANV_FROM_HANDLE(anv_instance, instance, _instance);
|
||||||
|
const VkAllocationCallbacks *alloc;
|
||||||
|
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR);
|
||||||
|
|
||||||
|
if (pAllocator)
|
||||||
|
alloc = pAllocator;
|
||||||
|
else
|
||||||
|
alloc = &instance->alloc;
|
||||||
|
|
||||||
|
return anv_create_wl_surface(alloc, pCreateInfo, pSurface);
|
||||||
|
}
|
||||||
|
|
||||||
struct wsi_wl_image {
|
struct wsi_wl_image {
|
||||||
VkImage image;
|
VkImage image;
|
||||||
VkDeviceMemory memory;
|
VkDeviceMemory memory;
|
||||||
|
|
|
@ -434,20 +434,14 @@ x11_surface_get_present_modes(VkIcdSurfaceBase *surface,
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult anv_CreateXcbSurfaceKHR(
|
static VkResult anv_create_xcb_surface(const VkAllocationCallbacks *pAllocator,
|
||||||
VkInstance _instance,
|
const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
|
||||||
const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
|
VkSurfaceKHR *pSurface)
|
||||||
const VkAllocationCallbacks* pAllocator,
|
|
||||||
VkSurfaceKHR* pSurface)
|
|
||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_instance, instance, _instance);
|
|
||||||
|
|
||||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR);
|
|
||||||
|
|
||||||
VkIcdSurfaceXcb *surface;
|
VkIcdSurfaceXcb *surface;
|
||||||
|
|
||||||
surface = vk_alloc2(&instance->alloc, pAllocator, sizeof *surface, 8,
|
surface = vk_alloc(pAllocator, sizeof *surface, 8,
|
||||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
|
|
||||||
|
@ -456,7 +450,43 @@ VkResult anv_CreateXcbSurfaceKHR(
|
||||||
surface->window = pCreateInfo->window;
|
surface->window = pCreateInfo->window;
|
||||||
|
|
||||||
*pSurface = _VkIcdSurfaceBase_to_handle(&surface->base);
|
*pSurface = _VkIcdSurfaceBase_to_handle(&surface->base);
|
||||||
|
return VK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
VkResult anv_CreateXcbSurfaceKHR(
|
||||||
|
VkInstance _instance,
|
||||||
|
const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
|
||||||
|
const VkAllocationCallbacks* pAllocator,
|
||||||
|
VkSurfaceKHR* pSurface)
|
||||||
|
{
|
||||||
|
ANV_FROM_HANDLE(anv_instance, instance, _instance);
|
||||||
|
const VkAllocationCallbacks *alloc;
|
||||||
|
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR);
|
||||||
|
|
||||||
|
if (pAllocator)
|
||||||
|
alloc = pAllocator;
|
||||||
|
else
|
||||||
|
alloc = &instance->alloc;
|
||||||
|
|
||||||
|
return anv_create_xcb_surface(alloc, pCreateInfo, pSurface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VkResult anv_create_xlib_surface(const VkAllocationCallbacks *pAllocator,
|
||||||
|
const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
|
||||||
|
VkSurfaceKHR *pSurface)
|
||||||
|
{
|
||||||
|
VkIcdSurfaceXlib *surface;
|
||||||
|
|
||||||
|
surface = vk_alloc(pAllocator, sizeof *surface, 8,
|
||||||
|
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||||
|
if (surface == NULL)
|
||||||
|
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
|
|
||||||
|
surface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
|
||||||
|
surface->dpy = pCreateInfo->dpy;
|
||||||
|
surface->window = pCreateInfo->window;
|
||||||
|
|
||||||
|
*pSurface = _VkIcdSurfaceBase_to_handle(&surface->base);
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,23 +497,16 @@ VkResult anv_CreateXlibSurfaceKHR(
|
||||||
VkSurfaceKHR* pSurface)
|
VkSurfaceKHR* pSurface)
|
||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_instance, instance, _instance);
|
ANV_FROM_HANDLE(anv_instance, instance, _instance);
|
||||||
|
const VkAllocationCallbacks *alloc;
|
||||||
|
|
||||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR);
|
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR);
|
||||||
|
|
||||||
VkIcdSurfaceXlib *surface;
|
if (pAllocator)
|
||||||
|
alloc = pAllocator;
|
||||||
|
else
|
||||||
|
alloc = &instance->alloc;
|
||||||
|
|
||||||
surface = vk_alloc2(&instance->alloc, pAllocator, sizeof *surface, 8,
|
return anv_create_xlib_surface(alloc, pCreateInfo, pSurface);
|
||||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
|
||||||
if (surface == NULL)
|
|
||||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
|
||||||
|
|
||||||
surface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
|
|
||||||
surface->dpy = pCreateInfo->dpy;
|
|
||||||
surface->window = pCreateInfo->window;
|
|
||||||
|
|
||||||
*pSurface = _VkIcdSurfaceBase_to_handle(&surface->base);
|
|
||||||
|
|
||||||
return VK_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct x11_image {
|
struct x11_image {
|
||||||
|
|
Loading…
Reference in New Issue