static const VkExtensionProperties global_extensions[] = {
{
.extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
- .specVersion = 24,
+ .specVersion = 25,
},
{
.extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
struct isl_device isl_dev;
};
+struct anv_wsi_interaface;
+
+#define VK_ICD_WSI_PLATFORM_MAX 5
+
struct anv_instance {
VK_LOADER_DATA _loader_data;
int physicalDeviceCount;
struct anv_physical_device physicalDevice;
- void * wayland_wsi;
+ struct anv_wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
};
VkResult anv_init_wsi(struct anv_instance *instance);
}
void anv_DestroySurfaceKHR(
- VkInstance instance,
+ VkInstance _instance,
VkSurfaceKHR _surface,
const VkAllocationCallbacks* pAllocator)
{
- ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
+ ANV_FROM_HANDLE(anv_instance, instance, _instance);
+ ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
- surface->destroy(surface, pAllocator);
+ anv_free2(&instance->alloc, pAllocator, surface);
}
VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
VkBool32* pSupported)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
- ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
+ ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
+ struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
- return surface->get_support(surface, device, queueFamilyIndex, pSupported);
+ return iface->get_support(surface, device, queueFamilyIndex, pSupported);
}
VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
- ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
+ ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
+ struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
- return surface->get_capabilities(surface, device, pSurfaceCapabilities);
+ return iface->get_capabilities(surface, device, pSurfaceCapabilities);
}
VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR(
VkSurfaceFormatKHR* pSurfaceFormats)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
- ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
+ ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
+ struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
- return surface->get_formats(surface, device, pSurfaceFormatCount,
- pSurfaceFormats);
+ return iface->get_formats(surface, device, pSurfaceFormatCount,
+ pSurfaceFormats);
}
VkResult anv_GetPhysicalDeviceSurfacePresentModesKHR(
VkPresentModeKHR* pPresentModes)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
- ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
+ ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
+ struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
- return surface->get_present_modes(surface, device, pPresentModeCount,
- pPresentModes);
+ return iface->get_present_modes(surface, device, pPresentModeCount,
+ pPresentModes);
}
VkResult anv_CreateSwapchainKHR(
VkSwapchainKHR* pSwapchain)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- ANV_FROM_HANDLE(anv_wsi_surface, surface, pCreateInfo->surface);
+ ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, pCreateInfo->surface);
+ struct anv_wsi_interface *iface = device->instance->wsi[surface->platform];
struct anv_swapchain *swapchain;
- VkResult result = surface->create_swapchain(surface, device, pCreateInfo,
- pAllocator, &swapchain);
+ VkResult result = iface->create_swapchain(surface, device, pCreateInfo,
+ pAllocator, &swapchain);
if (result != VK_SUCCESS)
return result;
struct anv_swapchain;
-struct anv_wsi_surface {
- struct anv_instance *instance;
-
- void (*destroy)(struct anv_wsi_surface *surface,
- const VkAllocationCallbacks *pAllocator);
- VkResult (*get_support)(struct anv_wsi_surface *surface,
+struct anv_wsi_interface {
+ VkResult (*get_support)(VkIcdSurfaceBase *surface,
struct anv_physical_device *device,
uint32_t queueFamilyIndex,
VkBool32* pSupported);
- VkResult (*get_capabilities)(struct anv_wsi_surface *surface,
+ VkResult (*get_capabilities)(VkIcdSurfaceBase *surface,
struct anv_physical_device *device,
VkSurfaceCapabilitiesKHR* pSurfaceCapabilities);
- VkResult (*get_formats)(struct anv_wsi_surface *surface,
+ VkResult (*get_formats)(VkIcdSurfaceBase *surface,
struct anv_physical_device *device,
uint32_t* pSurfaceFormatCount,
VkSurfaceFormatKHR* pSurfaceFormats);
- VkResult (*get_present_modes)(struct anv_wsi_surface *surface,
+ VkResult (*get_present_modes)(VkIcdSurfaceBase *surface,
struct anv_physical_device *device,
uint32_t* pPresentModeCount,
VkPresentModeKHR* pPresentModes);
- VkResult (*create_swapchain)(struct anv_wsi_surface *surface,
+ VkResult (*create_swapchain)(VkIcdSurfaceBase *surface,
struct anv_device *device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
uint32_t image_index);
};
-ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_wsi_surface, VkSurfaceKHR)
+ANV_DEFINE_NONDISP_HANDLE_CASTS(_VkIcdSurfaceBase, VkSurfaceKHR)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_swapchain, VkSwapchainKHR)
VkResult anv_x11_init_wsi(struct anv_instance *instance);
#define MIN_NUM_IMAGES 2
-struct wsi_wl_surface {
- struct anv_wsi_surface base;
-
- struct wl_display *display;
- struct wl_surface *surface;
-};
-
struct wsi_wl_display {
struct wl_display * display;
struct wl_drm * drm;
};
struct wsi_wayland {
+ struct anv_wsi_interface base;
+
struct anv_instance * instance;
pthread_mutex_t mutex;
static struct wsi_wl_display *
wsi_wl_get_display(struct anv_instance *instance, struct wl_display *wl_display)
{
- struct wsi_wayland *wsi = instance->wayland_wsi;
+ struct wsi_wayland *wsi =
+ (struct wsi_wayland *)instance->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
pthread_mutex_lock(&wsi->mutex);
}
static VkResult
-wsi_wl_surface_get_support(struct anv_wsi_surface *surface,
+wsi_wl_surface_get_support(VkIcdSurfaceBase *surface,
struct anv_physical_device *device,
uint32_t queueFamilyIndex,
VkBool32* pSupported)
};
static VkResult
-wsi_wl_surface_get_capabilities(struct anv_wsi_surface *surface,
+wsi_wl_surface_get_capabilities(VkIcdSurfaceBase *surface,
struct anv_physical_device *device,
VkSurfaceCapabilitiesKHR* caps)
{
}
static VkResult
-wsi_wl_surface_get_formats(struct anv_wsi_surface *wsi_surface,
+wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface,
struct anv_physical_device *device,
uint32_t* pSurfaceFormatCount,
VkSurfaceFormatKHR* pSurfaceFormats)
{
- struct wsi_wl_surface *surface = (struct wsi_wl_surface *)wsi_surface;
+ VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
struct wsi_wl_display *display =
wsi_wl_get_display(device->instance, surface->display);
}
static VkResult
-wsi_wl_surface_get_present_modes(struct anv_wsi_surface *surface,
+wsi_wl_surface_get_present_modes(VkIcdSurfaceBase *surface,
struct anv_physical_device *device,
uint32_t* pPresentModeCount,
VkPresentModeKHR* pPresentModes)
return VK_SUCCESS;
}
-static void
-wsi_wl_surface_destroy(struct anv_wsi_surface *surface,
- const VkAllocationCallbacks *pAllocator)
-{
- anv_free2(&surface->instance->alloc, pAllocator, surface);
-}
-
static VkResult
-wsi_wl_surface_create_swapchain(struct anv_wsi_surface *surface,
+wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *surface,
struct anv_device *device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface)
{
+ ANV_FROM_HANDLE(anv_instance, instance, _instance);
+
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR);
- ANV_FROM_HANDLE(anv_instance, instance, _instance);
- struct wsi_wl_surface *surface;
+ VkIcdSurfaceWayland *surface;
surface = anv_alloc2(&instance->alloc, pAllocator, sizeof *surface, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
surface->display = pCreateInfo->display;
surface->surface = pCreateInfo->surface;
- surface->base.instance = instance;
- surface->base.destroy = wsi_wl_surface_destroy;
- surface->base.get_support = wsi_wl_surface_get_support;
- surface->base.get_capabilities = wsi_wl_surface_get_capabilities;
- surface->base.get_formats = wsi_wl_surface_get_formats;
- surface->base.get_present_modes = wsi_wl_surface_get_present_modes;
- surface->base.create_swapchain = wsi_wl_surface_create_swapchain;
-
- *pSurface = anv_wsi_surface_to_handle(&surface->base);
+ *pSurface = _VkIcdSurfaceBase_to_handle(&surface->base);
return VK_SUCCESS;
}
}
static VkResult
-wsi_wl_surface_create_swapchain(struct anv_wsi_surface *wsi_surface,
+wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
struct anv_device *device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
struct anv_swapchain **swapchain_out)
{
- struct wsi_wl_surface *surface = (struct wsi_wl_surface *)wsi_surface;
+ VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
struct wsi_wl_swapchain *chain;
VkResult result;
goto fail_mutex;
}
- instance->wayland_wsi = wsi;
+ wsi->base.get_support = wsi_wl_surface_get_support;
+ wsi->base.get_capabilities = wsi_wl_surface_get_capabilities;
+ wsi->base.get_formats = wsi_wl_surface_get_formats;
+ 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;
return VK_SUCCESS;
fail_alloc:
anv_free(&instance->alloc, wsi);
fail:
- instance->wayland_wsi = NULL;
+ instance->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
return result;
}
void
anv_wl_finish_wsi(struct anv_instance *instance)
{
- struct wsi_wayland *wsi = instance->wayland_wsi;
+ struct wsi_wayland *wsi =
+ (struct wsi_wayland *)instance->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
if (wsi) {
_mesa_hash_table_destroy(wsi->displays, NULL);
#include "anv_wsi.h"
-struct x11_surface {
- struct anv_wsi_surface base;
-
- xcb_connection_t *connection;
- xcb_window_t window;
-};
-
static const VkSurfaceFormatKHR formats[] = {
{ .format = VK_FORMAT_B8G8R8A8_UNORM, },
};
}
static VkResult
-x11_surface_get_capabilities(struct anv_wsi_surface *wsi_surface,
+x11_surface_get_support(VkIcdSurfaceBase *surface,
+ struct anv_physical_device *device,
+ uint32_t queueFamilyIndex,
+ VkBool32* pSupported)
+{
+ anv_finishme("Check that we actually have DRI3");
+ *pSupported = true;
+
+ return VK_SUCCESS;
+}
+
+static VkResult
+x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface,
struct anv_physical_device *device,
VkSurfaceCapabilitiesKHR *caps)
{
- struct x11_surface *surface = (struct x11_surface *)wsi_surface;
+ VkIcdSurfaceXcb *surface = (VkIcdSurfaceXcb *)icd_surface;
xcb_get_geometry_cookie_t cookie = xcb_get_geometry(surface->connection,
surface->window);
}
static VkResult
-x11_surface_get_formats(struct anv_wsi_surface *surface,
+x11_surface_get_formats(VkIcdSurfaceBase *surface,
struct anv_physical_device *device,
uint32_t *pSurfaceFormatCount,
VkSurfaceFormatKHR *pSurfaceFormats)
}
static VkResult
-x11_surface_get_present_modes(struct anv_wsi_surface *surface,
+x11_surface_get_present_modes(VkIcdSurfaceBase *surface,
struct anv_physical_device *device,
uint32_t *pPresentModeCount,
VkPresentModeKHR *pPresentModes)
return VK_SUCCESS;
}
-static void
-x11_surface_destroy(struct anv_wsi_surface *surface,
- const VkAllocationCallbacks *pAllocator)
-{
- anv_free2(&surface->instance->alloc, pAllocator, surface);
-}
-
static VkResult
-x11_surface_create_swapchain(struct anv_wsi_surface *surface,
+x11_surface_create_swapchain(VkIcdSurfaceBase *surface,
struct anv_device *device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
struct anv_swapchain **swapchain);
+static struct anv_wsi_interface x11_interface = {
+ .get_support = x11_surface_get_support,
+ .get_capabilities = x11_surface_get_capabilities,
+ .get_formats = x11_surface_get_formats,
+ .get_present_modes = x11_surface_get_present_modes,
+ .create_swapchain = x11_surface_create_swapchain,
+};
+
VkResult anv_CreateXcbSurfaceKHR(
VkInstance _instance,
const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface)
{
+ ANV_FROM_HANDLE(anv_instance, instance, _instance);
+
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR);
- ANV_FROM_HANDLE(anv_instance, instance, _instance);
- struct x11_surface *surface;
+ VkIcdSurfaceXcb *surface;
surface = anv_alloc2(&instance->alloc, pAllocator, sizeof *surface, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
surface->connection = pCreateInfo->connection;
surface->window = pCreateInfo->window;
- surface->base.instance = instance;
- surface->base.destroy = x11_surface_destroy;
- surface->base.get_capabilities = x11_surface_get_capabilities;
- surface->base.get_formats = x11_surface_get_formats;
- surface->base.get_present_modes = x11_surface_get_present_modes;
- surface->base.create_swapchain = x11_surface_create_swapchain;
-
- *pSurface = anv_wsi_surface_to_handle(&surface->base);
+ *pSurface = _VkIcdSurfaceBase_to_handle(&surface->base);
return VK_SUCCESS;
}
}
static VkResult
-x11_surface_create_swapchain(struct anv_wsi_surface *wsi_surface,
+x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
struct anv_device *device,
const VkSwapchainCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks* pAllocator,
struct anv_swapchain **swapchain_out)
{
- struct x11_surface *surface = (struct x11_surface *)wsi_surface;
+ VkIcdSurfaceXcb *surface = (VkIcdSurfaceXcb *)icd_surface;
struct x11_swapchain *chain;
xcb_void_cookie_t cookie;
VkResult result;
VkResult
anv_x11_init_wsi(struct anv_instance *instance)
{
+ instance->wsi[VK_ICD_WSI_PLATFORM_XCB] = &x11_interface;
+
return VK_SUCCESS;
}