From d666487dc6c46ea6ad7ca71fd0b0b1e099e5da0f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 2 Dec 2015 16:28:36 -0800 Subject: [PATCH] vk: Add new WSI support and bump the API to 0.210.1 --- include/vulkan/vk_ext_khr_device_swapchain.h | 210 -------- include/vulkan/vk_ext_khr_swapchain.h | 153 ------ include/vulkan/vulkan.h | 498 ++++++++++++++++++- src/vulkan/Makefile.am | 4 +- src/vulkan/anv_device.c | 20 +- src/vulkan/anv_private.h | 15 +- src/vulkan/anv_wsi.c | 211 +++----- src/vulkan/anv_wsi.h | 60 ++- src/vulkan/anv_wsi_wayland.c | 247 +++++---- src/vulkan/anv_wsi_x11.c | 196 ++++---- 10 files changed, 900 insertions(+), 714 deletions(-) delete mode 100644 include/vulkan/vk_ext_khr_device_swapchain.h delete mode 100644 include/vulkan/vk_ext_khr_swapchain.h diff --git a/include/vulkan/vk_ext_khr_device_swapchain.h b/include/vulkan/vk_ext_khr_device_swapchain.h deleted file mode 100644 index bb243b32dd2..00000000000 --- a/include/vulkan/vk_ext_khr_device_swapchain.h +++ /dev/null @@ -1,210 +0,0 @@ -// -// File: vk_ext_khr_device_swapchain.h -// -/* -** Copyright (c) 2015 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __VK_EXT_KHR_DEVICE_SWAPCHAIN_H__ -#define __VK_EXT_KHR_DEVICE_SWAPCHAIN_H__ - -#include "vulkan.h" - -#define VK_EXT_KHR_DEVICE_SWAPCHAIN_REVISION 53 -#define VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NUMBER 2 -#define VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME "VK_EXT_KHR_device_swapchain" - -#ifdef __cplusplus -extern "C" -{ -#endif // __cplusplus - -// ------------------------------------------------------------------------------------------------ -// Objects - -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR); - -// ------------------------------------------------------------------------------------------------ -// Enumeration constants - -#define VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(type,id) ((type)((int)0xc0000000 - VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NUMBER * -1024 + (id))) -#define VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM_POSITIVE(type,id) ((type)((int)0x40000000 + (VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NUMBER - 1) * 1024 + (id))) - -// Extend VkStructureType enum with extension specific constants -#define VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(VkStructureType, 0) -#define VK_STRUCTURE_TYPE_PRESENT_INFO_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(VkStructureType, 1) - -// Extend VkImageLayout enum with extension specific constants -#define VK_IMAGE_LAYOUT_PRESENT_SOURCE_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(VkImageLayout, 2) - -// Extend VkResult enum with extension specific constants -// Return codes for successful operation execution -#define VK_SUBOPTIMAL_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM_POSITIVE(VkResult, 3) -// Error codes -#define VK_ERROR_OUT_OF_DATE_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(VkResult, 4) - -// ------------------------------------------------------------------------------------------------ -// Enumerations - -typedef enum { - VK_PRESENT_MODE_IMMEDIATE_KHR = 0, - VK_PRESENT_MODE_MAILBOX_KHR = 1, - VK_PRESENT_MODE_FIFO_KHR = 2, - VK_PRESENT_MODE_BEGIN_RANGE_KHR = VK_PRESENT_MODE_IMMEDIATE_KHR, - VK_PRESENT_MODE_END_RANGE_KHR = VK_PRESENT_MODE_FIFO_KHR, - VK_PRESENT_MODE_NUM = (VK_PRESENT_MODE_FIFO_KHR - VK_PRESENT_MODE_IMMEDIATE_KHR + 1), - VK_PRESENT_MODE_MAX_ENUM_KHR = 0x7FFFFFFF -} VkPresentModeKHR; - -typedef enum { - VK_COLORSPACE_SRGB_NONLINEAR_KHR = 0x00000000, - VK_COLORSPACE_NUM = (VK_COLORSPACE_SRGB_NONLINEAR_KHR - VK_COLORSPACE_SRGB_NONLINEAR_KHR + 1), - VK_COLORSPACE_MAX_ENUM_KHR = 0x7FFFFFFF -} VkColorSpaceKHR; - -// ------------------------------------------------------------------------------------------------ -// Flags - -// ------------------------------------------------------------------------------------------------ -// Structures - -typedef struct { - uint32_t minImageCount; // Supported minimum number of images for the surface - uint32_t maxImageCount; // Supported maximum number of images for the surface, 0 for unlimited - - VkExtent2D currentExtent; // Current image width and height for the surface, (-1, -1) if undefined - VkExtent2D minImageExtent; // Supported minimum image width and height for the surface - VkExtent2D maxImageExtent; // Supported maximum image width and height for the surface - - VkSurfaceTransformFlagsKHR supportedTransforms;// 1 or more bits representing the transforms supported - VkSurfaceTransformKHR currentTransform; // The surface's current transform relative to the device's natural orientation - - uint32_t maxImageArraySize; // Supported maximum number of image layers for the surface - - VkImageUsageFlags supportedUsageFlags;// Supported image usage flags for the surface -} VkSurfacePropertiesKHR; - -typedef struct { - VkFormat format; // Supported pair of rendering format - VkColorSpaceKHR colorSpace; // and colorspace for the surface -} VkSurfaceFormatKHR; - -typedef struct { - VkStructureType sType; // Must be VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR - const void* pNext; // Pointer to next structure - - const VkSurfaceDescriptionKHR* pSurfaceDescription;// describes the swap chain's target surface - - uint32_t minImageCount; // Minimum number of presentation images the application needs - VkFormat imageFormat; // Format of the presentation images - VkColorSpaceKHR imageColorSpace; // Colorspace of the presentation images - VkExtent2D imageExtent; // Dimensions of the presentation images - VkImageUsageFlags imageUsageFlags; // Bits indicating how the presentation images will be used - VkSurfaceTransformKHR preTransform; // The transform, relative to the device's natural orientation, applied to the image content prior to presentation - uint32_t imageArraySize; // Determines the number of views for multiview/stereo presentation - - VkSharingMode sharingMode; // Sharing mode used for the presentation images - uint32_t queueFamilyCount; // Number of queue families having access to the images in case of concurrent sharing mode - const uint32_t* pQueueFamilyIndices; // Array of queue family indices having access to the images in case of concurrent sharing mode - - VkPresentModeKHR presentMode; // Which presentation mode to use for presents on this swap chain - - VkSwapchainKHR oldSwapchain; // Existing swap chain to replace, if any - - VkBool32 clipped; // Specifies whether presentable images may be affected by window clip regions -} VkSwapchainCreateInfoKHR; - -typedef struct { - VkStructureType sType; // Must be VK_STRUCTURE_TYPE_PRESENT_INFO_KHR - const void* pNext; // Pointer to next structure - uint32_t swapchainCount; // Number of swap chains to present in this call - const VkSwapchainKHR* swapchains; // Swap chains to present an image from - const uint32_t* imageIndices; // Indices of which swapchain images to present -} VkPresentInfoKHR; - -// ------------------------------------------------------------------------------------------------ -// Function types - -typedef VkResult (VKAPI_PTR *PFN_vkGetSurfacePropertiesKHR)(VkDevice device, const VkSurfaceDescriptionKHR* pSurfaceDescription, VkSurfacePropertiesKHR* pSurfaceProperties); -typedef VkResult (VKAPI_PTR *PFN_vkGetSurfaceFormatsKHR)(VkDevice device, const VkSurfaceDescriptionKHR* pSurfaceDescription, uint32_t* pCount, VkSurfaceFormatKHR* pSurfaceFormats); -typedef VkResult (VKAPI_PTR *PFN_vkGetSurfacePresentModesKHR)(VkDevice device, const VkSurfaceDescriptionKHR* pSurfaceDescription, uint32_t* pCount, VkPresentModeKHR* pPresentModes); -typedef VkResult (VKAPI_PTR *PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, VkSwapchainKHR* pSwapchain); -typedef VkResult (VKAPI_PTR *PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain); -typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pCount, VkImage* pSwapchainImages); -typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, uint32_t* pImageIndex); -typedef VkResult (VKAPI_PTR *PFN_vkQueuePresentKHR)(VkQueue queue, VkPresentInfoKHR* pPresentInfo); - -// ------------------------------------------------------------------------------------------------ -// Function prototypes - -#ifdef VK_PROTOTYPES - -VKAPI_ATTR VkResult VKAPI_CALL vkGetSurfacePropertiesKHR( - VkDevice device, - const VkSurfaceDescriptionKHR* pSurfaceDescription, - VkSurfacePropertiesKHR* pSurfaceProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetSurfaceFormatsKHR( - VkDevice device, - const VkSurfaceDescriptionKHR* pSurfaceDescription, - uint32_t* pCount, - VkSurfaceFormatKHR* pSurfaceFormats); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetSurfacePresentModesKHR( - VkDevice device, - const VkSurfaceDescriptionKHR* pSurfaceDescription, - uint32_t* pCount, - VkPresentModeKHR* pPresentModes); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( - VkDevice device, - const VkSwapchainCreateInfoKHR* pCreateInfo, - VkSwapchainKHR* pSwapchain); - -VKAPI_ATTR VkResult VKAPI_CALL vkDestroySwapchainKHR( - VkDevice device, - VkSwapchainKHR swapchain); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( - VkDevice device, - VkSwapchainKHR swapchain, - uint32_t* pCount, - VkImage* pSwapchainImages); - -VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( - VkDevice device, - VkSwapchainKHR swapchain, - uint64_t timeout, - VkSemaphore semaphore, - uint32_t* pImageIndex); - -VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR( - VkQueue queue, - VkPresentInfoKHR* pPresentInfo); - -#endif // VK_PROTOTYPES - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#endif // __VK_EXT_KHR_SWAPCHAIN_H__ diff --git a/include/vulkan/vk_ext_khr_swapchain.h b/include/vulkan/vk_ext_khr_swapchain.h deleted file mode 100644 index 4c4f8a58a01..00000000000 --- a/include/vulkan/vk_ext_khr_swapchain.h +++ /dev/null @@ -1,153 +0,0 @@ -// -// File: vk_ext_khr_swapchain.h -// -/* -** Copyright (c) 2015 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __VK_EXT_KHR_SWAPCHAIN_H__ -#define __VK_EXT_KHR_SWAPCHAIN_H__ - -#include "vulkan.h" - -#define VK_EXT_KHR_SWAPCHAIN_REVISION 17 -#define VK_EXT_KHR_SWAPCHAIN_EXTENSION_NUMBER 1 -#define VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME "VK_EXT_KHR_swapchain" - -#ifdef __cplusplus -extern "C" -{ -#endif // __cplusplus - -// ------------------------------------------------------------------------------------------------ -// Objects - -// ------------------------------------------------------------------------------------------------ -// Enumeration constants - -#define VK_EXT_KHR_SWAPCHAIN_ENUM(type,id) ((type)((int)0xc0000000 - VK_EXT_KHR_SWAPCHAIN_EXTENSION_NUMBER * -1024 + (id))) -#define VK_EXT_KHR_SWAPCHAIN_ENUM_POSITIVE(type,id) ((type)((int)0x40000000 + (VK_EXT_KHR_SWAPCHAIN_EXTENSION_NUMBER - 1) * 1024 + (id))) - -// Extend VkStructureType enum with extension specific constants -#define VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR VK_EXT_KHR_SWAPCHAIN_ENUM(VkStructureType, 0) - -// ------------------------------------------------------------------------------------------------ -// Enumerations - -typedef enum { - VK_SURFACE_TRANSFORM_NONE_KHR = 0, - VK_SURFACE_TRANSFORM_ROT90_KHR = 1, - VK_SURFACE_TRANSFORM_ROT180_KHR = 2, - VK_SURFACE_TRANSFORM_ROT270_KHR = 3, - VK_SURFACE_TRANSFORM_HMIRROR_KHR = 4, - VK_SURFACE_TRANSFORM_HMIRROR_ROT90_KHR = 5, - VK_SURFACE_TRANSFORM_HMIRROR_ROT180_KHR = 6, - VK_SURFACE_TRANSFORM_HMIRROR_ROT270_KHR = 7, - VK_SURFACE_TRANSFORM_INHERIT_KHR = 8, -} VkSurfaceTransformKHR; - -typedef enum { - VK_SURFACE_TRANSFORM_NONE_BIT_KHR = 0x00000001, - VK_SURFACE_TRANSFORM_ROT90_BIT_KHR = 0x00000002, - VK_SURFACE_TRANSFORM_ROT180_BIT_KHR = 0x00000004, - VK_SURFACE_TRANSFORM_ROT270_BIT_KHR = 0x00000008, - VK_SURFACE_TRANSFORM_HMIRROR_BIT_KHR = 0x00000010, - VK_SURFACE_TRANSFORM_HMIRROR_ROT90_BIT_KHR = 0x00000020, - VK_SURFACE_TRANSFORM_HMIRROR_ROT180_BIT_KHR = 0x00000040, - VK_SURFACE_TRANSFORM_HMIRROR_ROT270_BIT_KHR = 0x00000080, - VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 0x00000100, -} VkSurfaceTransformFlagBitsKHR; -typedef VkFlags VkSurfaceTransformFlagsKHR; - -typedef enum { - VK_PLATFORM_WIN32_KHR = 0, - VK_PLATFORM_X11_KHR = 1, - VK_PLATFORM_XCB_KHR = 2, - VK_PLATFORM_ANDROID_KHR = 3, - VK_PLATFORM_WAYLAND_KHR = 4, - VK_PLATFORM_MIR_KHR = 5, - VK_PLATFORM_BEGIN_RANGE_KHR = VK_PLATFORM_WIN32_KHR, - VK_PLATFORM_END_RANGE_KHR = VK_PLATFORM_MIR_KHR, - VK_PLATFORM_NUM_KHR = (VK_PLATFORM_MIR_KHR - VK_PLATFORM_WIN32_KHR + 1), - VK_PLATFORM_MAX_ENUM_KHR = 0x7FFFFFFF -} VkPlatformKHR; - -// ------------------------------------------------------------------------------------------------ -// Flags - -// ------------------------------------------------------------------------------------------------ -// Structures - -// Placeholder structure header for the different types of surface description structures -typedef struct { - VkStructureType sType; // Can be any of the VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_XXX_KHR constants - const void* pNext; // Pointer to next structure -} VkSurfaceDescriptionKHR; - -// Surface description structure for a native platform window surface -typedef struct { - VkStructureType sType; // Must be VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR - const void* pNext; // Pointer to next structure - VkPlatformKHR platform; // e.g. VK_PLATFORM_*_KHR - void* pPlatformHandle; - void* pPlatformWindow; -} VkSurfaceDescriptionWindowKHR; - -// pPlatformHandle points to this struct when platform is VK_PLATFORM_X11_KHR -#ifdef _X11_XLIB_H_ -typedef struct { - Display* dpy; // Display connection to an X server - Window root; // To identify the X screen -} VkPlatformHandleX11KHR; -#endif /* _X11_XLIB_H_ */ - -// pPlatformHandle points to this struct when platform is VK_PLATFORM_XCB_KHR -#ifdef __XCB_H__ -typedef struct { - xcb_connection_t* connection; // XCB connection to an X server - xcb_window_t root; // To identify the X screen -} VkPlatformHandleXcbKHR; -#endif /* __XCB_H__ */ - -// ------------------------------------------------------------------------------------------------ -// Function types - -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, const VkSurfaceDescriptionKHR* pSurfaceDescription, VkBool32* pSupported); - -// ------------------------------------------------------------------------------------------------ -// Function prototypes - -#ifdef VK_PROTOTYPES - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - const VkSurfaceDescriptionKHR* pSurfaceDescription, - VkBool32* pSupported); - -#endif // VK_PROTOTYPES - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#endif // __VK_EXT_KHR_SWAPCHAIN_H__ diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index 61ea4fb1f61..fa58c593fb6 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -41,7 +41,7 @@ extern "C" { ((major << 22) | (minor << 12) | patch) // Vulkan API version supported by this file -#define VK_API_VERSION VK_MAKE_VERSION(0, 210, 0) +#define VK_API_VERSION VK_MAKE_VERSION(0, 210, 1) #define VK_NULL_HANDLE 0 @@ -125,6 +125,11 @@ typedef enum VkResult { VK_ERROR_INCOMPATIBLE_DRIVER = -9, VK_ERROR_TOO_MANY_OBJECTS = -10, VK_ERROR_FORMAT_NOT_SUPPORTED = -11, + VK_ERROR_SURFACE_LOST_KHR = -1000000000, + VK_SUBOPTIMAL_KHR = 1000001003, + VK_ERROR_OUT_OF_DATE_KHR = -1000001004, + VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, + VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000008000, VK_RESULT_BEGIN_RANGE = VK_ERROR_FORMAT_NOT_SUPPORTED, VK_RESULT_END_RANGE = VK_INCOMPLETE, VK_RESULT_RANGE_SIZE = (VK_INCOMPLETE - VK_ERROR_FORMAT_NOT_SUPPORTED + 1), @@ -180,6 +185,11 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_MEMORY_BARRIER = 45, VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO = 46, VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO = 47, + VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR = 1000001000, + VK_STRUCTURE_TYPE_PRESENT_INFO_KHR = 1000001001, + VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR = 1000002000, + VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR = 1000002001, + VK_STRUCTURE_TYPE_DISPLAY_PRESENT_INFO_KHR = 1000003000, VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO, VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO, VK_STRUCTURE_TYPE_RANGE_SIZE = (VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1), @@ -458,6 +468,7 @@ typedef enum VkImageLayout { VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL = 6, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL = 7, VK_IMAGE_LAYOUT_PREINITIALIZED = 8, + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002, VK_IMAGE_LAYOUT_BEGIN_RANGE = VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_END_RANGE = VK_IMAGE_LAYOUT_PREINITIALIZED, VK_IMAGE_LAYOUT_RANGE_SIZE = (VK_IMAGE_LAYOUT_PREINITIALIZED - VK_IMAGE_LAYOUT_UNDEFINED + 1), @@ -3081,6 +3092,491 @@ VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands( const VkCommandBuffer* pCommandBuffers); #endif +#define VK_KHR_surface 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) + +#define VK_KHR_SURFACE_REVISION 24 +#define VK_KHR_SURFACE_EXTENSION_NUMBER 1 +#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface" + + +typedef enum VkColorSpaceKHR { + VK_COLORSPACE_SRGB_NONLINEAR_KHR = 0, + VK_COLORSPACE_BEGIN_RANGE = VK_COLORSPACE_SRGB_NONLINEAR_KHR, + VK_COLORSPACE_END_RANGE = VK_COLORSPACE_SRGB_NONLINEAR_KHR, + VK_COLORSPACE_RANGE_SIZE = (VK_COLORSPACE_SRGB_NONLINEAR_KHR - VK_COLORSPACE_SRGB_NONLINEAR_KHR + 1), + VK_COLORSPACE_MAX_ENUM = 0x7FFFFFFF +} VkColorSpaceKHR; + +typedef enum VkPresentModeKHR { + VK_PRESENT_MODE_IMMEDIATE_KHR = 0, + VK_PRESENT_MODE_MAILBOX_KHR = 1, + VK_PRESENT_MODE_FIFO_KHR = 2, + VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3, + VK_PRESENT_MODE_BEGIN_RANGE = VK_PRESENT_MODE_IMMEDIATE_KHR, + VK_PRESENT_MODE_END_RANGE = VK_PRESENT_MODE_FIFO_RELAXED_KHR, + VK_PRESENT_MODE_RANGE_SIZE = (VK_PRESENT_MODE_FIFO_RELAXED_KHR - VK_PRESENT_MODE_IMMEDIATE_KHR + 1), + VK_PRESENT_MODE_MAX_ENUM = 0x7FFFFFFF +} VkPresentModeKHR; + + +typedef enum VkSurfaceTransformFlagBitsKHR { + VK_SURFACE_TRANSFORM_NONE_BIT_KHR = 0x00000001, + VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 0x00000002, + VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR = 0x00000004, + VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR = 0x00000008, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR = 0x00000010, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR = 0x00000020, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR = 0x00000040, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 0x00000080, + VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 0x00000100, +} VkSurfaceTransformFlagBitsKHR; +typedef VkFlags VkSurfaceTransformFlagsKHR; + +typedef enum VkCompositeAlphaFlagBitsKHR { + VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR = 0x00000001, + VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 0x00000002, + VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 0x00000004, + VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 0x00000008, +} VkCompositeAlphaFlagBitsKHR; +typedef VkFlags VkCompositeAlphaFlagsKHR; + +typedef struct VkSurfaceCapabilitiesKHR { + uint32_t minImageCount; + uint32_t maxImageCount; + VkExtent2D currentExtent; + VkExtent2D minImageExtent; + VkExtent2D maxImageExtent; + uint32_t maxImageArrayLayers; + VkSurfaceTransformFlagsKHR supportedTransforms; + VkSurfaceTransformFlagBitsKHR currentTransform; + VkCompositeAlphaFlagsKHR supportedCompositeAlpha; + VkImageUsageFlags supportedUsageFlags; +} VkSurfaceCapabilitiesKHR; + +typedef struct VkSurfaceFormatKHR { + VkFormat format; + VkColorSpaceKHR colorSpace; +} VkSurfaceFormatKHR; + + +typedef void (VKAPI_PTR *PFN_vkDestroySurfaceKHR)(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32* pSupported); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR( + VkInstance instance, + VkSurfaceKHR surface, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + VkSurfaceKHR surface, + VkBool32* pSupported); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + uint32_t* pSurfaceFormatCount, + VkSurfaceFormatKHR* pSurfaceFormats); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + uint32_t* pPresentModeCount, + VkPresentModeKHR* pPresentModes); +#endif + +#define VK_KHR_swapchain 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR) + +#define VK_KHR_SWAPCHAIN_REVISION 67 +#define VK_KHR_SWAPCHAIN_EXTENSION_NUMBER 2 +#define VK_KHR_SWAPCHAIN_EXTENSION_NAME "VK_KHR_swapchain" + +typedef VkFlags VkSwapchainCreateFlagsKHR; + +typedef struct VkSwapchainCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkSwapchainCreateFlagsKHR flags; + VkSurfaceKHR surface; + uint32_t minImageCount; + VkFormat imageFormat; + VkColorSpaceKHR imageColorSpace; + VkExtent2D imageExtent; + uint32_t imageArrayLayers; + VkImageUsageFlags imageUsage; + VkSharingMode imageSharingMode; + uint32_t queueFamilyIndexCount; + const uint32_t* pQueueFamilyIndices; + VkSurfaceTransformFlagBitsKHR preTransform; + VkCompositeAlphaFlagBitsKHR compositeAlpha; + VkPresentModeKHR presentMode; + VkBool32 clipped; + VkSwapchainKHR oldSwapchain; +} VkSwapchainCreateInfoKHR; + +typedef struct VkPresentInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreCount; + const VkSemaphore* pWaitSemaphores; + uint32_t swapchainCount; + const VkSwapchainKHR* pSwapchains; + const uint32_t* pImageIndices; + VkResult* pResults; +} VkPresentInfoKHR; + + +typedef VkResult (VKAPI_PTR *PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain); +typedef void (VKAPI_PTR *PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages); +typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex); +typedef VkResult (VKAPI_PTR *PFN_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR* pPresentInfo); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( + VkDevice device, + const VkSwapchainCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSwapchainKHR* pSwapchain); + +VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR( + VkDevice device, + VkSwapchainKHR swapchain, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( + VkDevice device, + VkSwapchainKHR swapchain, + uint32_t* pSwapchainImageCount, + VkImage* pSwapchainImages); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( + VkDevice device, + VkSwapchainKHR swapchain, + uint64_t timeout, + VkSemaphore semaphore, + VkFence fence, + uint32_t* pImageIndex); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR( + VkQueue queue, + const VkPresentInfoKHR* pPresentInfo); +#endif + +#define VK_KHR_display 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayModeKHR) + +#define VK_KHR_DISPLAY_REVISION 21 +#define VK_KHR_DISPLAY_EXTENSION_NUMBER 3 +#define VK_KHR_DISPLAY_EXTENSION_NAME "VK_KHR_display" + + +typedef enum VkDisplayPlaneAlphaFlagBitsKHR { + VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR = 0x00000001, + VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR = 0x00000002, + VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR = 0x00000004, + VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR = 0x00000008, +} VkDisplayPlaneAlphaFlagBitsKHR; +typedef VkFlags VkDisplayModeCreateFlagsKHR; +typedef VkFlags VkDisplayPlaneAlphaFlagsKHR; +typedef VkFlags VkDisplaySurfaceCreateFlagsKHR; + +typedef struct VkDisplayPropertiesKHR { + VkDisplayKHR display; + const char* displayName; + VkExtent2D physicalDimensions; + VkExtent2D physicalResolution; + VkSurfaceTransformFlagsKHR supportedTransforms; + VkBool32 planeReorderPossible; + VkBool32 persistentContent; +} VkDisplayPropertiesKHR; + +typedef struct VkDisplayModeParametersKHR { + VkExtent2D visibleRegion; + uint32_t refreshRate; +} VkDisplayModeParametersKHR; + +typedef struct VkDisplayModePropertiesKHR { + VkDisplayModeKHR displayMode; + VkDisplayModeParametersKHR parameters; +} VkDisplayModePropertiesKHR; + +typedef struct VkDisplayModeCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDisplayModeCreateFlagsKHR flags; + VkDisplayModeParametersKHR parameters; +} VkDisplayModeCreateInfoKHR; + +typedef struct VkDisplayPlaneCapabilitiesKHR { + VkDisplayPlaneAlphaFlagsKHR supportedAlpha; + VkOffset2D minSrcPosition; + VkOffset2D maxSrcPosition; + VkExtent2D minSrcExtent; + VkExtent2D maxSrcExtent; + VkOffset2D minDstPosition; + VkOffset2D maxDstPosition; + VkExtent2D minDstExtent; + VkExtent2D maxDstExtent; +} VkDisplayPlaneCapabilitiesKHR; + +typedef struct VkDisplayPlanePropertiesKHR { + VkDisplayKHR currentDisplay; + uint32_t currentStackIndex; +} VkDisplayPlanePropertiesKHR; + +typedef struct VkDisplaySurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDisplaySurfaceCreateFlagsKHR flags; + VkDisplayModeKHR displayMode; + uint32_t planeIndex; + uint32_t planeStackIndex; + VkSurfaceTransformFlagBitsKHR transform; + float globalAlpha; + VkDisplayPlaneAlphaFlagBitsKHR alphaMode; + VkExtent2D imageExtent; +} VkDisplaySurfaceCreateInfoKHR; + + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPlanePropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneSupportedDisplaysKHR)(VkPhysicalDevice physicalDevice, uint32_t* pDisplayCount, VkDisplayKHR* pDisplays); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayModePropertiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t* pPropertyCount, VkDisplayModePropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayModeKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR*pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDisplayModeKHR* pMode); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR* pCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayPlaneSurfaceKHR)(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayPropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlanePropertiesKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayPlanePropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pDisplayCount, + VkDisplayKHR* pDisplays); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display, + uint32_t* pPropertyCount, + VkDisplayModePropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display, + const VkDisplayModeCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDisplayModeKHR* pMode); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + VkDisplayModeKHR mode, + uint32_t planeIndex, + VkDisplayPlaneCapabilitiesKHR* pCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR( + VkInstance instance, + const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + +#define VK_KHR_display_swapchain 1 +#define VK_KHR_DISPLAY_SWAPCHAIN_REVISION 9 +#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NUMBER 4 +#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME "VK_KHR_display_swapchain" + +typedef struct VkDisplayPresentInfoKHR { + VkStructureType sType; + const void* pNext; + VkRect2D srcRect; + VkRect2D dstRect; + VkBool32 persistent; +} VkDisplayPresentInfoKHR; + + +typedef VkResult (VKAPI_PTR *PFN_vkCreateSharedSwapchainsKHR)(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchains); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR( + VkDevice device, + uint32_t swapchainCount, + const VkSwapchainCreateInfoKHR* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkSwapchainKHR* pSwapchains); +#endif + +#ifdef VK_USE_PLATFORM_XLIB_KHR +#define VK_KHR_xlib_surface 1 +#include + +#define VK_KHR_XLIB_SURFACE_REVISION 5 +#define VK_KHR_XLIB_SURFACE_EXTENSION_NUMBER 5 +#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface" + +typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, Display* dpy, Window window, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( + VkInstance instance, + Display* dpy, + Window window, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + Display* dpy, + VisualID visualID); +#endif +#endif /* VK_USE_PLATFORM_XLIB_KHR */ + +#ifdef VK_USE_PLATFORM_XCB_KHR +#define VK_KHR_xcb_surface 1 +#include + +#define VK_KHR_XCB_SURFACE_REVISION 5 +#define VK_KHR_XCB_SURFACE_EXTENSION_NUMBER 6 +#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface" + +typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, xcb_connection_t* connection, xcb_window_t window, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( + VkInstance instance, + xcb_connection_t* connection, + xcb_window_t window, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + xcb_connection_t* connection, + xcb_visualid_t visual_id); +#endif +#endif /* VK_USE_PLATFORM_XCB_KHR */ + +#ifdef VK_USE_PLATFORM_WAYLAND_KHR +#define VK_KHR_wayland_surface 1 +#include + +#define VK_KHR_WAYLAND_SURFACE_REVISION 4 +#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NUMBER 7 +#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface" + +typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, struct wl_display* display, struct wl_surface* surface, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( + VkInstance instance, + struct wl_display* display, + struct wl_surface* surface, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + struct wl_display* display); +#endif +#endif /* VK_USE_PLATFORM_WAYLAND_KHR */ + +#ifdef VK_USE_PLATFORM_MIR_KHR +#define VK_KHR_mir_surface 1 +#include + +#define VK_KHR_MIR_SURFACE_REVISION 4 +#define VK_KHR_MIR_SURFACE_EXTENSION_NUMBER 8 +#define VK_KHR_MIR_SURFACE_EXTENSION_NAME "VK_KHR_mir_surface" + +typedef VkResult (VKAPI_PTR *PFN_vkCreateMirSurfaceKHR)(VkInstance instance, MirConnection* connection, MirSurface* mirSurface, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection* connection); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR( + VkInstance instance, + MirConnection* connection, + MirSurface* mirSurface, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + MirConnection* connection); +#endif +#endif /* VK_USE_PLATFORM_MIR_KHR */ + +#ifdef VK_USE_PLATFORM_ANDROID_KHR +#define VK_KHR_android_surface 1 +#include + +#define VK_KHR_ANDROID_SURFACE_REVISION 4 +#define VK_KHR_ANDROID_SURFACE_EXTENSION_NUMBER 9 +#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface" + +typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, ANativeWindow* window, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR( + VkInstance instance, + ANativeWindow* window, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif +#endif /* VK_USE_PLATFORM_ANDROID_KHR */ + +#ifdef VK_USE_PLATFORM_WIN32_KHR +#define VK_KHR_win32_surface 1 +#include + +#define VK_KHR_WIN32_SURFACE_REVISION 4 +#define VK_KHR_WIN32_SURFACE_EXTENSION_NUMBER 10 +#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface" + +typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, HINSTANCE hinstance, HWND hwnd, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex); + +#ifdef VK_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( + VkInstance instance, + HINSTANCE hinstance, + HWND hwnd, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex); +#endif +#endif /* VK_USE_PLATFORM_WIN32_KHR */ + #ifdef __cplusplus } #endif diff --git a/src/vulkan/Makefile.am b/src/vulkan/Makefile.am index 2f249488270..24391eafc0b 100644 --- a/src/vulkan/Makefile.am +++ b/src/vulkan/Makefile.am @@ -26,9 +26,7 @@ vulkan_includedir = $(includedir)/vulkan vulkan_include_HEADERS = \ $(top_srcdir)/include/vulkan/vk_platform.h \ $(top_srcdir)/include/vulkan/vulkan.h \ - $(top_srcdir)/include/vulkan/vulkan_intel.h \ - $(top_srcdir)/include/vulkan/vk_ext_khr_swapchain.h \ - $(top_srcdir)/include/vulkan/vk_ext_khr_device_swapchain.h + $(top_srcdir)/include/vulkan/vulkan_intel.h # Used when generating entrypoints to filter out unwanted extensions VULKAN_ENTRYPOINT_CPPFLAGS = \ diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 37462a4a4a6..32f8dcf976f 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -150,15 +150,25 @@ anv_physical_device_finish(struct anv_physical_device *device) static const VkExtensionProperties global_extensions[] = { { - .extensionName = VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME, - .specVersion = 17, + .extensionName = VK_KHR_SURFACE_EXTENSION_NAME, + .specVersion = 24, }, + { + .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME, + .specVersion = 5, + }, +#ifdef HAVE_WAYLAND_PLATFORM + { + .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, + .specVersion = 4, + }, +#endif }; static const VkExtensionProperties device_extensions[] = { { - .extensionName = VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME, - .specVersion = 53, + .extensionName = VK_KHR_SWAPCHAIN_EXTENSION_NAME, + .specVersion = 67, }, }; @@ -198,7 +208,7 @@ VkResult anv_CreateInstance( assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO); - if (pCreateInfo->pApplicationInfo->apiVersion != VK_MAKE_VERSION(0, 210, 0)) + if (pCreateInfo->pApplicationInfo->apiVersion != VK_MAKE_VERSION(0, 210, 1)) return vk_error(VK_ERROR_INCOMPATIBLE_DRIVER); for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) { diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 9c1e6b2f955..43ebf4c11ae 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #ifdef HAVE_VALGRIND @@ -43,11 +44,19 @@ #include "util/macros.h" #include "util/list.h" +/* Pre-declarations needed for WSI entrypoints */ +struct wl_surface; +struct wl_display; +typedef struct xcb_connection_t xcb_connection_t; +typedef uint32_t xcb_visualid_t; +typedef uint32_t xcb_window_t; + +#define VK_USE_PLATFORM_XCB_KHR +#define VK_USE_PLATFORM_WAYLAND_KHR + #define VK_PROTOTYPES #include #include -#include -#include #include "anv_entrypoints.h" #include "anv_gen_macros.h" @@ -498,7 +507,7 @@ struct anv_instance { int physicalDeviceCount; struct anv_physical_device physicalDevice; - struct anv_wsi_implementation * wsi_impl[VK_PLATFORM_NUM_KHR]; + void * wayland_wsi; }; VkResult anv_init_wsi(struct anv_instance *instance); diff --git a/src/vulkan/anv_wsi.c b/src/vulkan/anv_wsi.c index f5c2d3716a5..c181cd4d729 100644 --- a/src/vulkan/anv_wsi.c +++ b/src/vulkan/anv_wsi.c @@ -28,8 +28,6 @@ anv_init_wsi(struct anv_instance *instance) { VkResult result; - memset(instance->wsi_impl, 0, sizeof(instance->wsi_impl)); - result = anv_x11_init_wsi(instance); if (result != VK_SUCCESS) return result; @@ -54,186 +52,135 @@ anv_finish_wsi(struct anv_instance *instance) anv_x11_finish_wsi(instance); } -VkResult -anv_GetPhysicalDeviceSurfaceSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - const VkSurfaceDescriptionKHR* pSurfaceDescription, - VkBool32* pSupported) +void anv_DestroySurfaceKHR( + VkInstance instance, + VkSurfaceKHR _surface, + const VkAllocationCallbacks* pAllocator) { - ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice); - - assert(pSurfaceDescription->sType == - VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR); - - VkSurfaceDescriptionWindowKHR *window = (void *)pSurfaceDescription; - - struct anv_wsi_implementation *impl = - physical_device->instance->wsi_impl[window->platform]; + ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface); - if (impl) { - return impl->get_window_supported(impl, physical_device, - window, pSupported); - } else { - *pSupported = false; - return VK_SUCCESS; - } + surface->destroy(surface, pAllocator); } -VkResult -anv_GetSurfacePropertiesKHR( - VkDevice _device, - const VkSurfaceDescriptionKHR* pSurfaceDescription, - VkSurfacePropertiesKHR* pSurfaceProperties) +VkResult anv_GetPhysicalDeviceSurfaceSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + VkSurfaceKHR _surface, + VkBool32* pSupported) { - ANV_FROM_HANDLE(anv_device, device, _device); - - assert(pSurfaceDescription->sType == - VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR); - VkSurfaceDescriptionWindowKHR *window = - (VkSurfaceDescriptionWindowKHR *)pSurfaceDescription; - - struct anv_wsi_implementation *impl = - device->instance->wsi_impl[window->platform]; + ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice); + ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface); - assert(impl); - - return impl->get_surface_properties(impl, device, window, - pSurfaceProperties); + return surface->get_support(surface, device, queueFamilyIndex, pSupported); } -VkResult -anv_GetSurfaceFormatsKHR( - VkDevice _device, - const VkSurfaceDescriptionKHR* pSurfaceDescription, - uint32_t* pCount, - VkSurfaceFormatKHR* pSurfaceFormats) +VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR _surface, + VkSurfaceCapabilitiesKHR* pSurfaceCapabilities) { - ANV_FROM_HANDLE(anv_device, device, _device); - - assert(pSurfaceDescription->sType == - VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR); - VkSurfaceDescriptionWindowKHR *window = - (VkSurfaceDescriptionWindowKHR *)pSurfaceDescription; - - struct anv_wsi_implementation *impl = - device->instance->wsi_impl[window->platform]; + ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice); + ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface); - assert(impl); - - return impl->get_surface_formats(impl, device, window, - pCount, pSurfaceFormats); + return surface->get_capabilities(surface, device, pSurfaceCapabilities); } -VkResult -anv_GetSurfacePresentModesKHR( - VkDevice _device, - const VkSurfaceDescriptionKHR* pSurfaceDescription, - uint32_t* pCount, - VkPresentModeKHR* pPresentModes) +VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR _surface, + uint32_t* pSurfaceFormatCount, + VkSurfaceFormatKHR* pSurfaceFormats) { - ANV_FROM_HANDLE(anv_device, device, _device); - - assert(pSurfaceDescription->sType == - VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR); - VkSurfaceDescriptionWindowKHR *window = - (VkSurfaceDescriptionWindowKHR *)pSurfaceDescription; + ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice); + ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface); - struct anv_wsi_implementation *impl = - device->instance->wsi_impl[window->platform]; + return surface->get_formats(surface, device, pSurfaceFormatCount, + pSurfaceFormats); +} - assert(impl); +VkResult anv_GetPhysicalDeviceSurfacePresentModesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR _surface, + uint32_t* pPresentModeCount, + VkPresentModeKHR* pPresentModes) +{ + ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice); + ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface); - return impl->get_surface_present_modes(impl, device, window, - pCount, pPresentModes); + return surface->get_present_modes(surface, device, pPresentModeCount, + pPresentModes); } - -VkResult -anv_CreateSwapchainKHR( - VkDevice _device, - const VkSwapchainCreateInfoKHR* pCreateInfo, - VkSwapchainKHR* pSwapchain) +VkResult anv_CreateSwapchainKHR( + VkDevice _device, + const VkSwapchainCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSwapchainKHR* pSwapchain) { ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_wsi_surface, surface, pCreateInfo->surface); struct anv_swapchain *swapchain; - VkResult result; - assert(pCreateInfo->pSurfaceDescription->sType == - VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR); - VkSurfaceDescriptionWindowKHR *window = - (VkSurfaceDescriptionWindowKHR *)pCreateInfo->pSurfaceDescription; - - struct anv_wsi_implementation *impl = - device->instance->wsi_impl[window->platform]; - - assert(impl); - - result = impl->create_swapchain(impl, device, pCreateInfo, &swapchain); + VkResult result = surface->create_swapchain(surface, device, pCreateInfo, + pAllocator, &swapchain); + if (result != VK_SUCCESS) + return result; - if (result == VK_SUCCESS) - *pSwapchain = anv_swapchain_to_handle(swapchain); + *pSwapchain = anv_swapchain_to_handle(swapchain); - return result; + return VK_SUCCESS; } -VkResult -anv_DestroySwapchainKHR( - VkDevice device, - VkSwapchainKHR swapChain) +void anv_DestroySwapchainKHR( + VkDevice device, + VkSwapchainKHR _swapchain, + const VkAllocationCallbacks* pAllocator) { - ANV_FROM_HANDLE(anv_swapchain, swapchain, swapChain); - - assert(swapchain->device == anv_device_from_handle(device)); + ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain); - return swapchain->destroy(swapchain); + swapchain->destroy(swapchain, pAllocator); } -VkResult -anv_GetSwapchainImagesKHR( - VkDevice device, - VkSwapchainKHR _swapchain, - uint32_t* pCount, - VkImage* pSwapchainImages) +VkResult anv_GetSwapchainImagesKHR( + VkDevice device, + VkSwapchainKHR _swapchain, + uint32_t* pSwapchainImageCount, + VkImage* pSwapchainImages) { ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain); - assert(swapchain->device == anv_device_from_handle(device)); - - return swapchain->get_images(swapchain, pCount, pSwapchainImages); + return swapchain->get_images(swapchain, pSwapchainImageCount, + pSwapchainImages); } -VkResult -anv_AcquireNextImageKHR( - VkDevice device, - VkSwapchainKHR _swapchain, - uint64_t timeout, - VkSemaphore semaphore, - uint32_t* pImageIndex) +VkResult anv_AcquireNextImageKHR( + VkDevice device, + VkSwapchainKHR _swapchain, + uint64_t timeout, + VkSemaphore semaphore, + VkFence fence, + uint32_t* pImageIndex) { ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain); - assert(swapchain->device == anv_device_from_handle(device)); - - return swapchain->acquire_next_image(swapchain, - timeout, semaphore, pImageIndex); + return swapchain->acquire_next_image(swapchain, timeout, semaphore, + pImageIndex); } -VkResult -anv_QueuePresentKHR( +VkResult anv_QueuePresentKHR( VkQueue _queue, - VkPresentInfoKHR* pPresentInfo) + const VkPresentInfoKHR* pPresentInfo) { ANV_FROM_HANDLE(anv_queue, queue, _queue); VkResult result; for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) { - ANV_FROM_HANDLE(anv_swapchain, swapchain, pPresentInfo->swapchains[i]); + ANV_FROM_HANDLE(anv_swapchain, swapchain, pPresentInfo->pSwapchains[i]); assert(swapchain->device == queue->device); result = swapchain->queue_present(swapchain, queue, - pPresentInfo->imageIndices[i]); + pPresentInfo->pImageIndices[i]); /* TODO: What if one of them returns OUT_OF_DATE? */ if (result != VK_SUCCESS) return result; diff --git a/src/vulkan/anv_wsi.h b/src/vulkan/anv_wsi.h index 280049b0e86..15b3f862499 100644 --- a/src/vulkan/anv_wsi.h +++ b/src/vulkan/anv_wsi.h @@ -25,10 +25,40 @@ #include "anv_private.h" +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_physical_device *device, + uint32_t queueFamilyIndex, + VkBool32* pSupported); + VkResult (*get_capabilities)(struct anv_wsi_surface *surface, + struct anv_physical_device *device, + VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); + VkResult (*get_formats)(struct anv_wsi_surface *surface, + struct anv_physical_device *device, + uint32_t* pSurfaceFormatCount, + VkSurfaceFormatKHR* pSurfaceFormats); + VkResult (*get_present_modes)(struct anv_wsi_surface *surface, + struct anv_physical_device *device, + uint32_t* pPresentModeCount, + VkPresentModeKHR* pPresentModes); + VkResult (*create_swapchain)(struct anv_wsi_surface *surface, + struct anv_device *device, + const VkSwapchainCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + struct anv_swapchain **swapchain); +}; + struct anv_swapchain { - struct anv_device * device; + struct anv_device *device; - VkResult (*destroy)(struct anv_swapchain *swapchain); + VkResult (*destroy)(struct anv_swapchain *swapchain, + const VkAllocationCallbacks *pAllocator); VkResult (*get_images)(struct anv_swapchain *swapchain, uint32_t *pCount, VkImage *pSwapchainImages); VkResult (*acquire_next_image)(struct anv_swapchain *swap_chain, @@ -39,33 +69,9 @@ struct anv_swapchain { uint32_t image_index); }; +ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_wsi_surface, VkSurfaceKHR) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_swapchain, VkSwapchainKHR) -struct anv_wsi_implementation { - VkResult (*get_window_supported)(struct anv_wsi_implementation *impl, - struct anv_physical_device *physical_device, - const VkSurfaceDescriptionWindowKHR *window, - VkBool32 *pSupported); - VkResult (*get_surface_properties)(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSurfaceDescriptionWindowKHR *window, - VkSurfacePropertiesKHR *properties); - VkResult (*get_surface_formats)(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSurfaceDescriptionWindowKHR *window, - uint32_t *pCount, - VkSurfaceFormatKHR *pSurfaceFormats); - VkResult (*get_surface_present_modes)(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSurfaceDescriptionWindowKHR *window, - uint32_t *pCount, - VkPresentModeKHR *pPresentModes); - VkResult (*create_swapchain)(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSwapchainCreateInfoKHR *pCreateInfo, - struct anv_swapchain **swapchain); -}; - 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); diff --git a/src/vulkan/anv_wsi_wayland.c b/src/vulkan/anv_wsi_wayland.c index d75919ea19a..1dafcd996fe 100644 --- a/src/vulkan/anv_wsi_wayland.c +++ b/src/vulkan/anv_wsi_wayland.c @@ -30,6 +30,13 @@ #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; @@ -41,13 +48,11 @@ struct wsi_wl_display { }; struct wsi_wayland { - struct anv_wsi_implementation base; - struct anv_instance * instance; - pthread_mutex_t mutex; - /* Hash table of wl_display -> wsi_wl_display mappings */ - struct hash_table * displays; + pthread_mutex_t mutex; + /* Hash table of wl_display -> wsi_wl_display mappings */ + struct hash_table * displays; }; static void @@ -234,7 +239,7 @@ 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, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + VK_SYSTEM_ALLOCATION_SCOPE_CACHE); if (!display) return NULL; @@ -278,8 +283,10 @@ fail: } static struct wsi_wl_display * -wsi_wl_get_display(struct wsi_wayland *wsi, struct wl_display *wl_display) +wsi_wl_get_display(struct anv_instance *instance, struct wl_display *wl_display) { + struct wsi_wayland *wsi = instance->wayland_wsi; + pthread_mutex_lock(&wsi->mutex); struct hash_entry *entry = _mesa_hash_table_search(wsi->displays, @@ -308,15 +315,23 @@ wsi_wl_get_display(struct wsi_wayland *wsi, struct wl_display *wl_display) return entry->data; } -static VkResult -wsi_wl_get_window_supported(struct anv_wsi_implementation *impl, - struct anv_physical_device *physical_device, - const VkSurfaceDescriptionWindowKHR *window, - VkBool32 *pSupported) +VkBool32 anv_GetPhysicalDeviceWaylandPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + struct wl_display* display) { - struct wsi_wayland *wsi = (struct wsi_wayland *)impl; + ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice); + + return wsi_wl_get_display(physical_device->instance, display) != NULL; +} - *pSupported = wsi_wl_get_display(wsi, window->pPlatformHandle) != NULL; +static VkResult +wsi_wl_surface_get_support(struct anv_wsi_surface *surface, + struct anv_physical_device *device, + uint32_t queueFamilyIndex, + VkBool32* pSupported) +{ + *pSupported = true; return VK_SUCCESS; } @@ -327,20 +342,24 @@ static const VkPresentModeKHR present_modes[] = { }; static VkResult -wsi_wl_get_surface_properties(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSurfaceDescriptionWindowKHR *window, - VkSurfacePropertiesKHR *props) +wsi_wl_surface_get_capabilities(struct anv_wsi_surface *surface, + struct anv_physical_device *device, + VkSurfaceCapabilitiesKHR* caps) { - props->minImageCount = MIN_NUM_IMAGES; - props->maxImageCount = 4; - props->currentExtent = (VkExtent2D) { -1, -1 }; - props->minImageExtent = (VkExtent2D) { 1, 1 }; - props->maxImageExtent = (VkExtent2D) { INT16_MAX, INT16_MAX }; - props->supportedTransforms = VK_SURFACE_TRANSFORM_NONE_BIT_KHR; - props->currentTransform = VK_SURFACE_TRANSFORM_NONE_KHR; - props->maxImageArraySize = 1; - props->supportedUsageFlags = + caps->minImageCount = MIN_NUM_IMAGES; + caps->maxImageCount = 4; + caps->currentExtent = (VkExtent2D) { -1, -1 }; + caps->minImageExtent = (VkExtent2D) { 1, 1 }; + caps->maxImageExtent = (VkExtent2D) { INT16_MAX, INT16_MAX }; + caps->supportedTransforms = VK_SURFACE_TRANSFORM_NONE_BIT_KHR; + caps->currentTransform = VK_SURFACE_TRANSFORM_NONE_BIT_KHR; + caps->maxImageArrayLayers = 1; + + caps->supportedCompositeAlpha = + VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR | + VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR; + + caps->supportedUsageFlags = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; @@ -348,25 +367,24 @@ wsi_wl_get_surface_properties(struct anv_wsi_implementation *impl, } static VkResult -wsi_wl_get_surface_formats(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSurfaceDescriptionWindowKHR *window, - uint32_t *pCount, - VkSurfaceFormatKHR *pSurfaceFormats) +wsi_wl_surface_get_formats(struct anv_wsi_surface *wsi_surface, + struct anv_physical_device *device, + uint32_t* pSurfaceFormatCount, + VkSurfaceFormatKHR* pSurfaceFormats) { - struct wsi_wayland *wsi = (struct wsi_wayland *)impl; + struct wsi_wl_surface *surface = (struct wsi_wl_surface *)wsi_surface; struct wsi_wl_display *display = - wsi_wl_get_display(wsi, window->pPlatformHandle); + wsi_wl_get_display(device->instance, surface->display); uint32_t count = anv_vector_length(&display->formats); if (pSurfaceFormats == NULL) { - *pCount = count; + *pSurfaceFormatCount = count; return VK_SUCCESS; } - assert(*pCount >= count); - *pCount = count; + assert(*pSurfaceFormatCount >= count); + *pSurfaceFormatCount = count; VkFormat *f; anv_vector_foreach(f, &display->formats) { @@ -381,20 +399,64 @@ wsi_wl_get_surface_formats(struct anv_wsi_implementation *impl, } static VkResult -wsi_wl_get_surface_present_modes(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSurfaceDescriptionWindowKHR *window, - uint32_t *pCount, - VkPresentModeKHR *pPresentModes) +wsi_wl_surface_get_present_modes(struct anv_wsi_surface *surface, + struct anv_physical_device *device, + uint32_t* pPresentModeCount, + VkPresentModeKHR* pPresentModes) { if (pPresentModes == NULL) { - *pCount = ARRAY_SIZE(present_modes); + *pPresentModeCount = ARRAY_SIZE(present_modes); return VK_SUCCESS; } - assert(*pCount >= ARRAY_SIZE(present_modes)); - typed_memcpy(pPresentModes, present_modes, *pCount); - *pCount = ARRAY_SIZE(present_modes); + assert(*pPresentModeCount >= ARRAY_SIZE(present_modes)); + typed_memcpy(pPresentModes, present_modes, *pPresentModeCount); + *pPresentModeCount = ARRAY_SIZE(present_modes); + + 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, + struct anv_device *device, + const VkSwapchainCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + struct anv_swapchain **swapchain); + +VkResult anv_CreateWaylandSurfaceKHR( + VkInstance _instance, + struct wl_display* wl_display, + struct wl_surface* wl_surface, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface) +{ + ANV_FROM_HANDLE(anv_instance, instance, _instance); + struct wsi_wl_surface *surface; + + surface = anv_alloc2(&instance->alloc, pAllocator, sizeof *surface, 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (surface == NULL) + return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + + surface->display = wl_display; + surface->surface = wl_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); return VK_SUCCESS; } @@ -425,8 +487,8 @@ struct wsi_wl_swapchain { }; static VkResult -wsi_wl_get_images(struct anv_swapchain *anv_chain, - uint32_t *pCount, VkImage *pSwapchainImages) +wsi_wl_swapchain_get_images(struct anv_swapchain *anv_chain, + uint32_t *pCount, VkImage *pSwapchainImages) { struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain; @@ -445,10 +507,10 @@ wsi_wl_get_images(struct anv_swapchain *anv_chain, } static VkResult -wsi_wl_acquire_next_image(struct anv_swapchain *anv_chain, - uint64_t timeout, - VkSemaphore semaphore, - uint32_t *image_index) +wsi_wl_swapchain_acquire_next_image(struct anv_swapchain *anv_chain, + uint64_t timeout, + VkSemaphore semaphore, + uint32_t *image_index) { struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain; @@ -495,9 +557,9 @@ static const struct wl_callback_listener frame_listener = { }; static VkResult -wsi_wl_queue_present(struct anv_swapchain *anv_chain, - struct anv_queue *queue, - uint32_t image_index) +wsi_wl_swapchain_queue_present(struct anv_swapchain *anv_chain, + struct anv_queue *queue, + uint32_t image_index) { struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain; @@ -528,11 +590,14 @@ wsi_wl_queue_present(struct anv_swapchain *anv_chain, } static void -wsi_wl_image_finish(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image) +wsi_wl_image_finish(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image, + const VkAllocationCallbacks* pAllocator) { VkDevice vk_device = anv_device_to_handle(chain->base.device); - anv_FreeMemory(vk_device, anv_device_memory_to_handle(image->memory), NULL); - anv_DestroyImage(vk_device, anv_image_to_handle(image->image), NULL); + anv_FreeMemory(vk_device, anv_device_memory_to_handle(image->memory), + pAllocator); + anv_DestroyImage(vk_device, anv_image_to_handle(image->image), + pAllocator); } static void @@ -550,7 +615,8 @@ static const struct wl_buffer_listener buffer_listener = { }; static VkResult -wsi_wl_image_init(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image) +wsi_wl_image_init(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image, + const VkAllocationCallbacks* pAllocator) { VkDevice vk_device = anv_device_to_handle(chain->base.device); VkResult result; @@ -579,7 +645,7 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image) .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, .flags = 0, }}, - NULL, + pAllocator, &vk_image); if (result != VK_SUCCESS) @@ -597,7 +663,7 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image) .allocationSize = image->image->size, .memoryTypeIndex = 0, }, - NULL, + pAllocator, &vk_memory); if (result != VK_SUCCESS) @@ -644,46 +710,42 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image) return VK_SUCCESS; fail_mem: - anv_FreeMemory(vk_device, vk_memory, NULL); + anv_FreeMemory(vk_device, vk_memory, pAllocator); fail_image: - anv_DestroyImage(vk_device, vk_image, NULL); + anv_DestroyImage(vk_device, vk_image, pAllocator); return result; } static VkResult -wsi_wl_destroy_swapchain(struct anv_swapchain *anv_chain) +wsi_wl_swapchain_destroy(struct anv_swapchain *anv_chain, + const VkAllocationCallbacks *pAllocator) { struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain; for (uint32_t i = 0; i < chain->image_count; i++) { if (chain->images[i].buffer) - wsi_wl_image_finish(chain, &chain->images[i]); + wsi_wl_image_finish(chain, &chain->images[i], pAllocator); } - anv_free(&chain->base.device->alloc, chain); + anv_free2(&chain->base.device->alloc, pAllocator, chain); return VK_SUCCESS; } static VkResult -wsi_wl_create_swapchain(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSwapchainCreateInfoKHR *pCreateInfo, - struct anv_swapchain **swapchain_out) +wsi_wl_surface_create_swapchain(struct anv_wsi_surface *wsi_surface, + struct anv_device *device, + const VkSwapchainCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + struct anv_swapchain **swapchain_out) { - struct wsi_wayland *wsi = (struct wsi_wayland *)impl; + struct wsi_wl_surface *surface = (struct wsi_wl_surface *)wsi_surface; struct wsi_wl_swapchain *chain; VkResult result; assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR); - assert(pCreateInfo->pSurfaceDescription->sType == - VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR); - VkSurfaceDescriptionWindowKHR *vk_window = - (VkSurfaceDescriptionWindowKHR *)pCreateInfo->pSurfaceDescription; - assert(vk_window->platform == VK_PLATFORM_WAYLAND_KHR); - int num_images = pCreateInfo->minImageCount; assert(num_images >= MIN_NUM_IMAGES); @@ -698,18 +760,18 @@ wsi_wl_create_swapchain(struct anv_wsi_implementation *impl, num_images = MAX2(num_images, 4); size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]); - chain = anv_alloc(&device->alloc, size, 8, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + chain = anv_alloc2(&device->alloc, pAllocator, size, 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (chain == NULL) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); chain->base.device = device; - chain->base.destroy = wsi_wl_destroy_swapchain; - chain->base.get_images = wsi_wl_get_images; - chain->base.acquire_next_image = wsi_wl_acquire_next_image; - chain->base.queue_present = wsi_wl_queue_present; + 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; + chain->base.queue_present = wsi_wl_swapchain_queue_present; - chain->surface = vk_window->pPlatformWindow; + chain->surface = surface->surface; chain->extent = pCreateInfo->imageExtent; chain->vk_format = pCreateInfo->imageFormat; chain->drm_format = wl_drm_format_for_vk_format(chain->vk_format, false); @@ -726,7 +788,7 @@ wsi_wl_create_swapchain(struct anv_wsi_implementation *impl, chain->images[i].buffer = NULL; chain->queue = NULL; - chain->display = wsi_wl_get_display(wsi, vk_window->pPlatformHandle); + chain->display = wsi_wl_get_display(device->instance, surface->display); if (!chain->display) goto fail; @@ -735,7 +797,7 @@ wsi_wl_create_swapchain(struct anv_wsi_implementation *impl, goto fail; for (uint32_t i = 0; i < chain->image_count; i++) { - result = wsi_wl_image_init(chain, &chain->images[i]); + result = wsi_wl_image_init(chain, &chain->images[i], pAllocator); if (result != VK_SUCCESS) goto fail; chain->images[i].busy = false; @@ -746,7 +808,7 @@ wsi_wl_create_swapchain(struct anv_wsi_implementation *impl, return VK_SUCCESS; fail: - wsi_wl_destroy_swapchain(&chain->base); + wsi_wl_swapchain_destroy(&chain->base, pAllocator); return result; } @@ -762,12 +824,6 @@ anv_wl_init_wsi(struct anv_instance *instance) if (!wsi) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - wsi->base.get_window_supported = wsi_wl_get_window_supported; - wsi->base.get_surface_properties = wsi_wl_get_surface_properties; - wsi->base.get_surface_formats = wsi_wl_get_surface_formats; - wsi->base.get_surface_present_modes = wsi_wl_get_surface_present_modes; - wsi->base.create_swapchain = wsi_wl_create_swapchain; - wsi->instance = instance; int ret = pthread_mutex_init(&wsi->mutex, NULL); @@ -789,7 +845,7 @@ anv_wl_init_wsi(struct anv_instance *instance) goto fail_mutex; } - instance->wsi_impl[VK_PLATFORM_WAYLAND_KHR] = &wsi->base; + instance->wayland_wsi = wsi; return VK_SUCCESS; @@ -805,8 +861,7 @@ fail_alloc: void anv_wl_finish_wsi(struct anv_instance *instance) { - struct wsi_wayland *wsi = - (struct wsi_wayland *)instance->wsi_impl[VK_PLATFORM_WAYLAND_KHR]; + struct wsi_wayland *wsi = instance->wayland_wsi; _mesa_hash_table_destroy(wsi->displays, NULL); diff --git a/src/vulkan/anv_wsi_x11.c b/src/vulkan/anv_wsi_x11.c index f45442d522a..d327f4316d3 100644 --- a/src/vulkan/anv_wsi_x11.c +++ b/src/vulkan/anv_wsi_x11.c @@ -27,6 +27,13 @@ #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, }, }; @@ -35,53 +42,52 @@ static const VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, }; -static VkResult -x11_get_window_supported(struct anv_wsi_implementation *impl, - struct anv_physical_device *physical_device, - const VkSurfaceDescriptionWindowKHR *window, - VkBool32 *pSupported) +VkBool32 anv_GetPhysicalDeviceXcbPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + xcb_connection_t* connection, + xcb_visualid_t visual_id) { - *pSupported = true; - stub_return(VK_SUCCESS); + anv_finishme("Check that we actually have DRI3"); + stub_return(true); } static VkResult -x11_get_surface_properties(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSurfaceDescriptionWindowKHR *vk_window, - VkSurfacePropertiesKHR *props) +x11_surface_get_capabilities(struct anv_wsi_surface *wsi_surface, + struct anv_physical_device *device, + VkSurfaceCapabilitiesKHR *caps) { - VkPlatformHandleXcbKHR *vk_xcb_handle = vk_window->pPlatformHandle; - xcb_connection_t *conn = vk_xcb_handle->connection; - xcb_window_t win = *(xcb_window_t *)vk_window->pPlatformWindow; + struct x11_surface *surface = (struct x11_surface *)wsi_surface; - xcb_get_geometry_cookie_t cookie = xcb_get_geometry(conn, win); + xcb_get_geometry_cookie_t cookie = xcb_get_geometry(surface->connection, + surface->window); xcb_generic_error_t *err; - xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(conn, cookie, - &err); + xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(surface->connection, + cookie, &err); if (geom) { - free(err); VkExtent2D extent = { geom->width, geom->height }; - props->currentExtent = extent; - props->minImageExtent = extent; - props->maxImageExtent = extent; + caps->currentExtent = extent; + caps->minImageExtent = extent; + caps->maxImageExtent = extent; } else { /* This can happen if the client didn't wait for the configure event * to come back from the compositor. In that case, we don't know the * size of the window so we just return valid "I don't know" stuff. */ - free(geom); - props->currentExtent = (VkExtent2D) { -1, -1 }; - props->minImageExtent = (VkExtent2D) { 1, 1 }; - props->maxImageExtent = (VkExtent2D) { INT16_MAX, INT16_MAX }; + caps->currentExtent = (VkExtent2D) { -1, -1 }; + caps->minImageExtent = (VkExtent2D) { 1, 1 }; + caps->maxImageExtent = (VkExtent2D) { INT16_MAX, INT16_MAX }; } - - props->minImageCount = 2; - props->maxImageCount = 4; - props->supportedTransforms = VK_SURFACE_TRANSFORM_NONE_BIT_KHR; - props->currentTransform = VK_SURFACE_TRANSFORM_NONE_KHR; - props->maxImageArraySize = 1; - props->supportedUsageFlags = + free(err); + free(geom); + + caps->minImageCount = 2; + caps->maxImageCount = 4; + caps->supportedTransforms = VK_SURFACE_TRANSFORM_NONE_BIT_KHR; + caps->currentTransform = VK_SURFACE_TRANSFORM_NONE_BIT_KHR; + caps->maxImageArrayLayers = 1; + caps->supportedCompositeAlpha = VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR; + caps->supportedUsageFlags = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; @@ -89,37 +95,81 @@ x11_get_surface_properties(struct anv_wsi_implementation *impl, } static VkResult -x11_get_surface_formats(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSurfaceDescriptionWindowKHR *vk_window, - uint32_t *pCount, VkSurfaceFormatKHR *pSurfaceFormats) +x11_surface_get_formats(struct anv_wsi_surface *surface, + struct anv_physical_device *device, + uint32_t *pSurfaceFormatCount, + VkSurfaceFormatKHR *pSurfaceFormats) { if (pSurfaceFormats == NULL) { - *pCount = ARRAY_SIZE(formats); + *pSurfaceFormatCount = ARRAY_SIZE(formats); return VK_SUCCESS; } - assert(*pCount >= ARRAY_SIZE(formats)); - typed_memcpy(pSurfaceFormats, formats, *pCount); - *pCount = ARRAY_SIZE(formats); + assert(*pSurfaceFormatCount >= ARRAY_SIZE(formats)); + typed_memcpy(pSurfaceFormats, formats, *pSurfaceFormatCount); + *pSurfaceFormatCount = ARRAY_SIZE(formats); return VK_SUCCESS; } static VkResult -x11_get_surface_present_modes(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSurfaceDescriptionWindowKHR *vk_window, - uint32_t *pCount, VkPresentModeKHR *pPresentModes) +x11_surface_get_present_modes(struct anv_wsi_surface *surface, + struct anv_physical_device *device, + uint32_t *pPresentModeCount, + VkPresentModeKHR *pPresentModes) { if (pPresentModes == NULL) { - *pCount = ARRAY_SIZE(present_modes); + *pPresentModeCount = ARRAY_SIZE(present_modes); return VK_SUCCESS; } - assert(*pCount >= ARRAY_SIZE(present_modes)); - typed_memcpy(pPresentModes, present_modes, *pCount); - *pCount = ARRAY_SIZE(present_modes); + assert(*pPresentModeCount >= ARRAY_SIZE(present_modes)); + typed_memcpy(pPresentModes, present_modes, *pPresentModeCount); + *pPresentModeCount = ARRAY_SIZE(present_modes); + + 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, + struct anv_device *device, + const VkSwapchainCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + struct anv_swapchain **swapchain); + +VkResult anv_CreateXcbSurfaceKHR( + VkInstance _instance, + xcb_connection_t* connection, + xcb_window_t window, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface) +{ + ANV_FROM_HANDLE(anv_instance, instance, _instance); + struct x11_surface *surface; + + surface = anv_alloc2(&instance->alloc, pAllocator, sizeof *surface, 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (surface == NULL) + return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + + surface->connection = connection; + surface->window = 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); return VK_SUCCESS; } @@ -228,7 +278,8 @@ x11_queue_present(struct anv_swapchain *anv_chain, } static VkResult -x11_destroy_swapchain(struct anv_swapchain *anv_chain) +x11_swapchain_destroy(struct anv_swapchain *anv_chain, + const VkAllocationCallbacks *pAllocator) { struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain; xcb_void_cookie_t cookie; @@ -251,41 +302,35 @@ x11_destroy_swapchain(struct anv_swapchain *anv_chain) } static VkResult -x11_create_swapchain(struct anv_wsi_implementation *impl, - struct anv_device *device, - const VkSwapchainCreateInfoKHR *pCreateInfo, - struct anv_swapchain **swapchain_out) +x11_surface_create_swapchain(struct anv_wsi_surface *wsi_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; struct x11_swapchain *chain; xcb_void_cookie_t cookie; VkResult result; - assert(pCreateInfo->pSurfaceDescription->sType == - VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR); - VkSurfaceDescriptionWindowKHR *vk_window = - (VkSurfaceDescriptionWindowKHR *)pCreateInfo->pSurfaceDescription; - assert(vk_window->platform == VK_PLATFORM_XCB_KHR); - int num_images = pCreateInfo->minImageCount; assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR); size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]); - chain = anv_alloc(&device->alloc, size, 8, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + chain = anv_alloc2(&device->alloc, pAllocator, size, 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (chain == NULL) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); chain->base.device = device; - chain->base.destroy = x11_destroy_swapchain; + chain->base.destroy = x11_swapchain_destroy; chain->base.get_images = x11_get_images; chain->base.acquire_next_image = x11_acquire_next_image; chain->base.queue_present = x11_queue_present; - VkPlatformHandleXcbKHR *vk_xcb_handle = vk_window->pPlatformHandle; - - chain->conn = (xcb_connection_t *) vk_xcb_handle->connection; - chain->window = *(xcb_window_t *)vk_window->pPlatformWindow; + chain->conn = surface->connection; + chain->window = surface->window; chain->extent = pCreateInfo->imageExtent; chain->image_count = num_images; chain->next_image = 0; @@ -406,26 +451,9 @@ x11_create_swapchain(struct anv_wsi_implementation *impl, VkResult anv_x11_init_wsi(struct anv_instance *instance) { - struct anv_wsi_implementation *impl; - - impl = anv_alloc(&instance->alloc, sizeof(*impl), 8, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - if (!impl) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - - impl->get_window_supported = x11_get_window_supported; - impl->get_surface_properties = x11_get_surface_properties; - impl->get_surface_formats = x11_get_surface_formats; - impl->get_surface_present_modes = x11_get_surface_present_modes; - impl->create_swapchain = x11_create_swapchain; - - instance->wsi_impl[VK_PLATFORM_XCB_KHR] = impl; - return VK_SUCCESS; } void anv_x11_finish_wsi(struct anv_instance *instance) -{ - anv_free(&instance->alloc, instance->wsi_impl[VK_PLATFORM_XCB_KHR]); -} +{ } -- 2.30.2