From dfed852ddf225e7cfa527924ff9427d3fcdfe24d Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 6 Oct 2021 11:45:06 -0500 Subject: [PATCH] v3dv: Use the common WSI wrappers Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/vulkan/meson.build | 6 - src/broadcom/vulkan/v3dv_device.c | 6 + src/broadcom/vulkan/v3dv_wsi.c | 203 ++----------------------- src/broadcom/vulkan/v3dv_wsi_display.c | 195 ------------------------ src/broadcom/vulkan/v3dv_wsi_wayland.c | 57 ------- src/broadcom/vulkan/v3dv_wsi_x11.c | 103 ------------- 6 files changed, 17 insertions(+), 553 deletions(-) delete mode 100644 src/broadcom/vulkan/v3dv_wsi_display.c delete mode 100644 src/broadcom/vulkan/v3dv_wsi_wayland.c delete mode 100644 src/broadcom/vulkan/v3dv_wsi_x11.c diff --git a/src/broadcom/vulkan/meson.build b/src/broadcom/vulkan/meson.build index 11995a7ccbd..a1cc5863764 100644 --- a/src/broadcom/vulkan/meson.build +++ b/src/broadcom/vulkan/meson.build @@ -90,19 +90,13 @@ v3dv_deps = [ if with_platform_x11 v3dv_deps += dep_xcb_dri3 - libv3dv_files += files('v3dv_wsi_x11.c') endif if with_platform_wayland v3dv_deps += [dep_wayland_client, dep_wl_protocols] - libv3dv_files += files('v3dv_wsi_wayland.c') libv3dv_files += [wayland_drm_client_protocol_h, wayland_drm_protocol_c] endif -if system_has_kms_drm and not with_platform_android - libv3dv_files += files('v3dv_wsi_display.c') -endif - per_version_libs = [] foreach ver : v3d_versions per_version_libs += static_library( diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 586c22338f6..7435499c930 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -187,6 +187,8 @@ v3dv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, struct vk_instance_dispatch_table dispatch_table; vk_instance_dispatch_table_from_entrypoints( &dispatch_table, &v3dv_instance_entrypoints, true); + vk_instance_dispatch_table_from_entrypoints( + &dispatch_table, &wsi_instance_entrypoints, false); result = vk_instance_init(&instance->vk, &instance_extensions, @@ -692,6 +694,8 @@ physical_device_init(struct v3dv_physical_device *device, struct vk_physical_device_dispatch_table dispatch_table; vk_physical_device_dispatch_table_from_entrypoints (&dispatch_table, &v3dv_physical_device_entrypoints, true); + vk_physical_device_dispatch_table_from_entrypoints( + &dispatch_table, &wsi_physical_device_entrypoints, false); result = vk_physical_device_init(&device->vk, &instance->vk, NULL, &dispatch_table); @@ -1748,6 +1752,8 @@ v3dv_CreateDevice(VkPhysicalDevice physicalDevice, struct vk_device_dispatch_table dispatch_table; vk_device_dispatch_table_from_entrypoints(&dispatch_table, &v3dv_device_entrypoints, true); + vk_device_dispatch_table_from_entrypoints(&dispatch_table, + &wsi_device_entrypoints, false); result = vk_device_init(&device->vk, &physical_device->vk, &dispatch_table, pCreateInfo, pAllocator); if (result != VK_SUCCESS) { diff --git a/src/broadcom/vulkan/v3dv_wsi.c b/src/broadcom/vulkan/v3dv_wsi.c index 23c542cbc05..154adf3a7da 100644 --- a/src/broadcom/vulkan/v3dv_wsi.c +++ b/src/broadcom/vulkan/v3dv_wsi.c @@ -25,6 +25,7 @@ #include "v3dv_private.h" #include "drm-uapi/drm_fourcc.h" +#include "wsi_common_entrypoints.h" #include "vk_format_info.h" #include "vk_util.h" #include "wsi_common.h" @@ -89,46 +90,19 @@ v3dv_wsi_init(struct v3dv_physical_device *physical_device) physical_device->wsi_device.can_present_on_device = v3dv_wsi_can_present_on_device; + physical_device->vk.wsi_device = &physical_device->wsi_device; + return VK_SUCCESS; } void v3dv_wsi_finish(struct v3dv_physical_device *physical_device) { + physical_device->vk.wsi_device = NULL; wsi_device_finish(&physical_device->wsi_device, &physical_device->vk.instance->alloc); } -VKAPI_ATTR void VKAPI_CALL -v3dv_DestroySurfaceKHR( - VkInstance _instance, - VkSurfaceKHR _surface, - const VkAllocationCallbacks* pAllocator) -{ - V3DV_FROM_HANDLE(v3dv_instance, instance, _instance); - ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface); - - if (!surface) - return; - - vk_free2(&instance->vk.alloc, pAllocator, surface); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetPhysicalDeviceSurfaceSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - VkSurfaceKHR surface, - VkBool32* pSupported) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice); - - return wsi_common_get_surface_support(&device->wsi_device, - queueFamilyIndex, - surface, - pSupported); -} - static void constraint_surface_capabilities(VkSurfaceCapabilitiesKHR *caps) { @@ -149,12 +123,10 @@ v3dv_GetPhysicalDeviceSurfaceCapabilitiesKHR( VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities) { - V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice); - VkResult result; - result = wsi_common_get_surface_capabilities(&device->wsi_device, - surface, - pSurfaceCapabilities); + result = wsi_GetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, + surface, + pSurfaceCapabilities); constraint_surface_capabilities(pSurfaceCapabilities); return result; } @@ -165,56 +137,14 @@ v3dv_GetPhysicalDeviceSurfaceCapabilities2KHR( const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkSurfaceCapabilities2KHR* pSurfaceCapabilities) { - V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice); - VkResult result; - result = wsi_common_get_surface_capabilities2(&device->wsi_device, - pSurfaceInfo, - pSurfaceCapabilities); + result = wsi_GetPhysicalDeviceSurfaceCapabilities2KHR(physicalDevice, + pSurfaceInfo, + pSurfaceCapabilities); constraint_surface_capabilities(&pSurfaceCapabilities->surfaceCapabilities); return result; } -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetPhysicalDeviceSurfaceFormatsKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pSurfaceFormatCount, - VkSurfaceFormatKHR* pSurfaceFormats) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice); - - return wsi_common_get_surface_formats(&device->wsi_device, surface, - pSurfaceFormatCount, pSurfaceFormats); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetPhysicalDeviceSurfaceFormats2KHR( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, - uint32_t* pSurfaceFormatCount, - VkSurfaceFormat2KHR* pSurfaceFormats) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice); - - return wsi_common_get_surface_formats2(&device->wsi_device, pSurfaceInfo, - pSurfaceFormatCount, pSurfaceFormats); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetPhysicalDeviceSurfacePresentModesKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pPresentModeCount, - VkPresentModeKHR* pPresentModes) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice); - - return wsi_common_get_surface_present_modes(&device->wsi_device, surface, - pPresentModeCount, - pPresentModes); -} - VKAPI_ATTR VkResult VKAPI_CALL v3dv_CreateSwapchainKHR( VkDevice _device, @@ -225,7 +155,6 @@ v3dv_CreateSwapchainKHR( V3DV_FROM_HANDLE(v3dv_device, device, _device); struct v3dv_instance *instance = device->instance; struct v3dv_physical_device *pdevice = &instance->physicalDevice; - struct wsi_device *wsi_device = &pdevice->wsi_device; ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pCreateInfo->surface); VkResult result = @@ -233,43 +162,7 @@ v3dv_CreateSwapchainKHR( if (result != VK_SUCCESS) return result; - const VkAllocationCallbacks *alloc; - if (pAllocator) - alloc = pAllocator; - else - alloc = &device->vk.alloc; - - return wsi_common_create_swapchain(wsi_device, _device, - pCreateInfo, alloc, pSwapchain); -} - -VKAPI_ATTR void VKAPI_CALL -v3dv_DestroySwapchainKHR( - VkDevice _device, - VkSwapchainKHR swapchain, - const VkAllocationCallbacks* pAllocator) -{ - V3DV_FROM_HANDLE(v3dv_device, device, _device); - const VkAllocationCallbacks *alloc; - - if (pAllocator) - alloc = pAllocator; - else - alloc = &device->vk.alloc; - - wsi_common_destroy_swapchain(_device, swapchain, alloc); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetSwapchainImagesKHR( - VkDevice device, - VkSwapchainKHR swapchain, - uint32_t* pSwapchainImageCount, - VkImage* pSwapchainImages) -{ - return wsi_common_get_images(swapchain, - pSwapchainImageCount, - pSwapchainImages); + return wsi_CreateSwapchainKHR(_device, pCreateInfo, pAllocator, pSwapchain); } struct v3dv_image * @@ -290,27 +183,6 @@ v3dv_wsi_get_image_from_swapchain(VkSwapchainKHR swapchain, uint32_t index) return image; } -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_AcquireNextImageKHR( - VkDevice device, - VkSwapchainKHR swapchain, - uint64_t timeout, - VkSemaphore semaphore, - VkFence fence, - uint32_t* pImageIndex) -{ - VkAcquireNextImageInfoKHR acquire_info = { - .sType = VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR, - .swapchain = swapchain, - .timeout = timeout, - .semaphore = semaphore, - .fence = fence, - .deviceMask = 0, - }; - - return v3dv_AcquireNextImage2KHR(device, &acquire_info, pImageIndex); -} - VKAPI_ATTR VkResult VKAPI_CALL v3dv_AcquireNextImage2KHR( VkDevice _device, @@ -336,56 +208,3 @@ v3dv_AcquireNextImage2KHR( return result; } - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_QueuePresentKHR( - VkQueue _queue, - const VkPresentInfoKHR* pPresentInfo) -{ - V3DV_FROM_HANDLE(v3dv_queue, queue, _queue); - struct v3dv_physical_device *pdevice = - &queue->device->instance->physicalDevice; - - return wsi_common_queue_present(&pdevice->wsi_device, - v3dv_device_to_handle(queue->device), - _queue, 0, - pPresentInfo); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetDeviceGroupPresentCapabilitiesKHR( - VkDevice device, - VkDeviceGroupPresentCapabilitiesKHR* pCapabilities) -{ - memset(pCapabilities->presentMask, 0, - sizeof(pCapabilities->presentMask)); - pCapabilities->presentMask[0] = 0x1; - pCapabilities->modes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR; - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetDeviceGroupSurfacePresentModesKHR( - VkDevice device, - VkSurfaceKHR surface, - VkDeviceGroupPresentModeFlagsKHR* pModes) -{ - *pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR; - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetPhysicalDevicePresentRectanglesKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pRectCount, - VkRect2D* pRects) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice); - - return wsi_common_get_present_rectangles(&device->wsi_device, - surface, - pRectCount, pRects); -} diff --git a/src/broadcom/vulkan/v3dv_wsi_display.c b/src/broadcom/vulkan/v3dv_wsi_display.c deleted file mode 100644 index 3d1cf91ecbe..00000000000 --- a/src/broadcom/vulkan/v3dv_wsi_display.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright © 2020 Raspberry Pi - * based on KHR_display extension code: - * Copyright © 2017 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ -#include "v3dv_private.h" -#include "wsi_common_display.h" - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device, - uint32_t *property_count, - VkDisplayPropertiesKHR *properties) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_display_get_physical_device_display_properties( - physical_device, - &pdevice->wsi_device, - property_count, - properties); -} - -VkResult -v3dv_GetPhysicalDeviceDisplayProperties2KHR( - VkPhysicalDevice physical_device, - uint32_t *pPropertyCount, - VkDisplayProperties2KHR *pProperties) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_display_get_physical_device_display_properties2( - physical_device, - &pdevice->wsi_device, - pPropertyCount, - pProperties); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetPhysicalDeviceDisplayPlanePropertiesKHR( - VkPhysicalDevice physical_device, - uint32_t *property_count, - VkDisplayPlanePropertiesKHR *properties) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_display_get_physical_device_display_plane_properties( - physical_device, - &pdevice->wsi_device, - property_count, - properties); -} - -VkResult -v3dv_GetPhysicalDeviceDisplayPlaneProperties2KHR( - VkPhysicalDevice physical_device, - uint32_t *pPropertyCount, - VkDisplayPlaneProperties2KHR *pProperties) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_display_get_physical_device_display_plane_properties2( - physical_device, - &pdevice->wsi_device, - pPropertyCount, - pProperties); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device, - uint32_t plane_index, - uint32_t *display_count, - VkDisplayKHR *displays) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_display_get_display_plane_supported_displays( - physical_device, - &pdevice->wsi_device, - plane_index, - display_count, - displays); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device, - VkDisplayKHR display, - uint32_t *property_count, - VkDisplayModePropertiesKHR *properties) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_display_get_display_mode_properties(physical_device, - &pdevice->wsi_device, - display, - property_count, - properties); -} - -VkResult -v3dv_GetDisplayModeProperties2KHR(VkPhysicalDevice physical_device, - VkDisplayKHR display, - uint32_t *pPropertyCount, - VkDisplayModeProperties2KHR *pProperties) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_display_get_display_mode_properties2(physical_device, - &pdevice->wsi_device, - display, - pPropertyCount, - pProperties); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_CreateDisplayModeKHR(VkPhysicalDevice physical_device, - VkDisplayKHR display, - const VkDisplayModeCreateInfoKHR *create_info, - const VkAllocationCallbacks *allocator, - VkDisplayModeKHR *mode) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_display_create_display_mode(physical_device, - &pdevice->wsi_device, - display, - create_info, - allocator, - mode); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device, - VkDisplayModeKHR mode_khr, - uint32_t plane_index, - VkDisplayPlaneCapabilitiesKHR *capabilities) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_get_display_plane_capabilities(physical_device, - &pdevice->wsi_device, - mode_khr, - plane_index, - capabilities); -} - -VkResult -v3dv_GetDisplayPlaneCapabilities2KHR( - VkPhysicalDevice physical_device, - const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo, - VkDisplayPlaneCapabilities2KHR *pCapabilities) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physical_device); - - return wsi_get_display_plane_capabilities2(physical_device, - &pdevice->wsi_device, - pDisplayPlaneInfo, - pCapabilities); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_CreateDisplayPlaneSurfaceKHR( - VkInstance _instance, - const VkDisplaySurfaceCreateInfoKHR *create_info, - const VkAllocationCallbacks *allocator, - VkSurfaceKHR *surface) -{ - V3DV_FROM_HANDLE(v3dv_instance, instance, _instance); - const VkAllocationCallbacks *alloc; - - if (allocator) - alloc = allocator; - else - alloc = &instance->vk.alloc; - - return wsi_create_display_surface(_instance, alloc, - create_info, surface); -} diff --git a/src/broadcom/vulkan/v3dv_wsi_wayland.c b/src/broadcom/vulkan/v3dv_wsi_wayland.c deleted file mode 100644 index e61abf3c724..00000000000 --- a/src/broadcom/vulkan/v3dv_wsi_wayland.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2020 Ella Stanforth - * based on intel anv code: - * Copyright © 2015 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS 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 SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "wsi_common_wayland.h" -#include "v3dv_private.h" - -VKAPI_ATTR VkBool32 VKAPI_CALL -v3dv_GetPhysicalDeviceWaylandPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - struct wl_display* display) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, physical_device, physicalDevice); - - return wsi_wl_get_presentation_support(&physical_device->wsi_device, display); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_CreateWaylandSurfaceKHR( - VkInstance _instance, - const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) -{ - V3DV_FROM_HANDLE(v3dv_instance, instance, _instance); - const VkAllocationCallbacks *alloc; - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR); - - if (pAllocator) - alloc = pAllocator; - else - alloc = &instance->vk.alloc; - - return wsi_create_wl_surface(alloc, pCreateInfo, pSurface); -} diff --git a/src/broadcom/vulkan/v3dv_wsi_x11.c b/src/broadcom/vulkan/v3dv_wsi_x11.c deleted file mode 100644 index 4fa99ccd5ab..00000000000 --- a/src/broadcom/vulkan/v3dv_wsi_x11.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright © 2020 Raspberry Pi - * - * based mostly on anv driver which is: - * Copyright © 2015 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS 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 SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#include "wsi_common_x11.h" -#include "v3dv_private.h" - -VKAPI_ATTR VkBool32 VKAPI_CALL -v3dv_GetPhysicalDeviceXcbPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - xcb_connection_t* connection, - xcb_visualid_t visual_id) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice); - - return wsi_get_physical_device_xcb_presentation_support( - &device->wsi_device, - queueFamilyIndex, - connection, visual_id); -} - -VKAPI_ATTR VkBool32 VKAPI_CALL -v3dv_GetPhysicalDeviceXlibPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - Display* dpy, - VisualID visualID) -{ - V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice); - - return wsi_get_physical_device_xcb_presentation_support( - &device->wsi_device, - queueFamilyIndex, - XGetXCBConnection(dpy), visualID); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_CreateXcbSurfaceKHR( - VkInstance _instance, - const VkXcbSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) -{ - V3DV_FROM_HANDLE(v3dv_instance, instance, _instance); - const VkAllocationCallbacks *alloc; - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR); - - if (pAllocator) - alloc = pAllocator; - else - alloc = &instance->vk.alloc; - - return wsi_create_xcb_surface(alloc, pCreateInfo, pSurface); -} - -VKAPI_ATTR VkResult VKAPI_CALL -v3dv_CreateXlibSurfaceKHR( - VkInstance _instance, - const VkXlibSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) -{ - V3DV_FROM_HANDLE(v3dv_instance, instance, _instance); - const VkAllocationCallbacks *alloc; - - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR); - - if (pAllocator) - alloc = pAllocator; - else - alloc = &instance->vk.alloc; - - return wsi_create_xlib_surface(alloc, pCreateInfo, pSurface); -}