From: Jason Ekstrand Date: Wed, 6 Oct 2021 16:58:48 +0000 (-0500) Subject: lavapipe: Use the common WSI wrappers X-Git-Tag: upstream/22.3.5~16721 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c4d78c764c14cdd20bd81f3513428f4c6709f3e;p=platform%2Fupstream%2Fmesa.git lavapipe: Use the common WSI wrappers Reviewed-by: Emma Anholt Reviewed-By: Mike Blumenkrantz Part-of: --- diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index d661048..e36f71e 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -167,6 +167,8 @@ lvp_physical_device_init(struct lvp_physical_device *device, struct vk_physical_device_dispatch_table dispatch_table; vk_physical_device_dispatch_table_from_entrypoints( &dispatch_table, &lvp_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); if (result != VK_SUCCESS) { @@ -222,6 +224,8 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateInstance( struct vk_instance_dispatch_table dispatch_table; vk_instance_dispatch_table_from_entrypoints( &dispatch_table, &lvp_instance_entrypoints, true); + vk_instance_dispatch_table_from_entrypoints( + &dispatch_table, &wsi_instance_entrypoints, false); result = vk_instance_init(&instance->vk, &lvp_instance_extensions_supported, @@ -1419,6 +1423,8 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice( struct vk_device_dispatch_table dispatch_table; vk_device_dispatch_table_from_entrypoints(&dispatch_table, &lvp_device_entrypoints, true); + vk_device_dispatch_table_from_entrypoints(&dispatch_table, + &wsi_device_entrypoints, false); VkResult result = vk_device_init(&device->vk, &physical_device->vk, &dispatch_table, pCreateInfo, diff --git a/src/gallium/frontends/lavapipe/lvp_wsi.c b/src/gallium/frontends/lavapipe/lvp_wsi.c index 272d4c8..2a4562a 100644 --- a/src/gallium/frontends/lavapipe/lvp_wsi.c +++ b/src/gallium/frontends/lavapipe/lvp_wsi.c @@ -43,187 +43,29 @@ lvp_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName) VkResult lvp_init_wsi(struct lvp_physical_device *physical_device) { - return wsi_device_init(&physical_device->wsi_device, - lvp_physical_device_to_handle(physical_device), - lvp_wsi_proc_addr, - &physical_device->vk.instance->alloc, - -1, NULL, true); + VkResult result; + + result = wsi_device_init(&physical_device->wsi_device, + lvp_physical_device_to_handle(physical_device), + lvp_wsi_proc_addr, + &physical_device->vk.instance->alloc, + -1, NULL, true); + if (result != VK_SUCCESS) + return result; + + physical_device->vk.wsi_device = &physical_device->wsi_device; + + return VK_SUCCESS; } void lvp_finish_wsi(struct lvp_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 lvp_DestroySurfaceKHR( - VkInstance _instance, - VkSurfaceKHR _surface, - const VkAllocationCallbacks* pAllocator) -{ - LVP_FROM_HANDLE(lvp_instance, instance, _instance); - ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface); - - vk_free2(&instance->vk.alloc, pAllocator, surface); -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPhysicalDeviceSurfaceSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - VkSurfaceKHR surface, - VkBool32* pSupported) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - - return wsi_common_get_surface_support(&device->wsi_device, - queueFamilyIndex, - surface, - pSupported); -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPhysicalDeviceSurfaceCapabilitiesKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - VkSurfaceCapabilitiesKHR* pSurfaceCapabilities) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - - return wsi_common_get_surface_capabilities(&device->wsi_device, - surface, - pSurfaceCapabilities); -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPhysicalDeviceSurfaceCapabilities2KHR( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, - VkSurfaceCapabilities2KHR* pSurfaceCapabilities) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - - return wsi_common_get_surface_capabilities2(&device->wsi_device, - pSurfaceInfo, - pSurfaceCapabilities); -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPhysicalDeviceSurfaceCapabilities2EXT( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - VkSurfaceCapabilities2EXT* pSurfaceCapabilities) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - - return wsi_common_get_surface_capabilities2ext(&device->wsi_device, - surface, - pSurfaceCapabilities); -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPhysicalDeviceSurfaceFormatsKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pSurfaceFormatCount, - VkSurfaceFormatKHR* pSurfaceFormats) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - return wsi_common_get_surface_formats(&device->wsi_device, - surface, - pSurfaceFormatCount, - pSurfaceFormats); -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPhysicalDeviceSurfaceFormats2KHR( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, - uint32_t* pSurfaceFormatCount, - VkSurfaceFormat2KHR* pSurfaceFormats) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - - return wsi_common_get_surface_formats2(&device->wsi_device, pSurfaceInfo, - pSurfaceFormatCount, pSurfaceFormats); -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPhysicalDeviceSurfacePresentModesKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pPresentModeCount, - VkPresentModeKHR* pPresentModes) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - - return wsi_common_get_surface_present_modes(&device->wsi_device, - surface, - pPresentModeCount, - pPresentModes); -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateSwapchainKHR( - VkDevice _device, - const VkSwapchainCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSwapchainKHR* pSwapchain) -{ - LVP_FROM_HANDLE(lvp_device, device, _device); - const VkAllocationCallbacks *alloc; - if (pAllocator) - alloc = pAllocator; - else - alloc = &device->vk.alloc; - - return wsi_common_create_swapchain(&device->physical_device->wsi_device, - lvp_device_to_handle(device), - pCreateInfo, - alloc, - pSwapchain); -} - -VKAPI_ATTR void VKAPI_CALL lvp_DestroySwapchainKHR( - VkDevice _device, - VkSwapchainKHR swapchain, - const VkAllocationCallbacks* pAllocator) -{ - LVP_FROM_HANDLE(lvp_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 lvp_GetSwapchainImagesKHR( - VkDevice device, - VkSwapchainKHR swapchain, - uint32_t* pSwapchainImageCount, - VkImage* pSwapchainImages) -{ - return wsi_common_get_images(swapchain, - pSwapchainImageCount, - pSwapchainImages); -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_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 lvp_AcquireNextImage2KHR(device, &acquire_info, pImageIndex); -} - VKAPI_ATTR VkResult VKAPI_CALL lvp_AcquireNextImage2KHR( VkDevice _device, const VkAcquireNextImageInfoKHR* pAcquireInfo, @@ -245,50 +87,3 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_AcquireNextImage2KHR( } return result; } - -VKAPI_ATTR VkResult VKAPI_CALL lvp_QueuePresentKHR( - VkQueue _queue, - const VkPresentInfoKHR* pPresentInfo) -{ - LVP_FROM_HANDLE(lvp_queue, queue, _queue); - return wsi_common_queue_present(&queue->device->physical_device->wsi_device, - lvp_device_to_handle(queue->device), - _queue, 0, - pPresentInfo); -} - - -VKAPI_ATTR VkResult VKAPI_CALL lvp_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 lvp_GetDeviceGroupSurfacePresentModesKHR( - VkDevice device, - VkSurfaceKHR surface, - VkDeviceGroupPresentModeFlagsKHR* pModes) -{ - *pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR; - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPhysicalDevicePresentRectanglesKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pRectCount, - VkRect2D* pRects) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - - return wsi_common_get_present_rectangles(&device->wsi_device, - surface, - pRectCount, pRects); -} diff --git a/src/gallium/frontends/lavapipe/lvp_wsi_wayland.c b/src/gallium/frontends/lavapipe/lvp_wsi_wayland.c deleted file mode 100644 index 3521b96..0000000 --- a/src/gallium/frontends/lavapipe/lvp_wsi_wayland.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2016 Red Hat - * 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 "lvp_private.h" - -VkBool32 lvp_GetPhysicalDeviceWaylandPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - struct wl_display* display) -{ - LVP_FROM_HANDLE(lvp_physical_device, physical_device, physicalDevice); - - return wsi_wl_get_presentation_support(&physical_device->wsi_device, display); -} - -VkResult lvp_CreateWaylandSurfaceKHR( - VkInstance _instance, - const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) -{ - LVP_FROM_HANDLE(lvp_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/gallium/frontends/lavapipe/lvp_wsi_win32.c b/src/gallium/frontends/lavapipe/lvp_wsi_win32.c deleted file mode 100644 index 09f2847..0000000 --- a/src/gallium/frontends/lavapipe/lvp_wsi_win32.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright © 2016 Red Hat - * 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_win32.h" -#include "lvp_private.h" - -VkBool32 VKAPI_CALL lvp_GetPhysicalDeviceWin32PresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex) -{ - LVP_FROM_HANDLE(lvp_physical_device, physical_device, physicalDevice); - - return wsi_win32_get_presentation_support(&physical_device->wsi_device); -} - -VkResult VKAPI_CALL lvp_CreateWin32SurfaceKHR( - VkInstance _instance, - const VkWin32SurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) -{ - LVP_FROM_HANDLE(lvp_instance, instance, _instance); - const VkAllocationCallbacks *alloc; - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR); - - if (pAllocator) - alloc = pAllocator; - else - alloc = &instance->vk.alloc; - - return wsi_create_win32_surface(_instance, alloc, pCreateInfo, pSurface); -} diff --git a/src/gallium/frontends/lavapipe/lvp_wsi_x11.c b/src/gallium/frontends/lavapipe/lvp_wsi_x11.c deleted file mode 100644 index f18aa25..0000000 --- a/src/gallium/frontends/lavapipe/lvp_wsi_x11.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 "wsi_common_x11.h" -#include "lvp_private.h" - -VkBool32 lvp_GetPhysicalDeviceXcbPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - xcb_connection_t* connection, - xcb_visualid_t visual_id) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - - return wsi_get_physical_device_xcb_presentation_support( - &device->wsi_device, - queueFamilyIndex, - connection, visual_id); -} - -VkBool32 lvp_GetPhysicalDeviceXlibPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - Display* dpy, - VisualID visualID) -{ - LVP_FROM_HANDLE(lvp_physical_device, device, physicalDevice); - - return wsi_get_physical_device_xcb_presentation_support( - &device->wsi_device, - queueFamilyIndex, - XGetXCBConnection(dpy), visualID); -} - -VkResult lvp_CreateXcbSurfaceKHR( - VkInstance _instance, - const VkXcbSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) -{ - LVP_FROM_HANDLE(lvp_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); -} - -VkResult lvp_CreateXlibSurfaceKHR( - VkInstance _instance, - const VkXlibSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) -{ - LVP_FROM_HANDLE(lvp_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); -} diff --git a/src/gallium/frontends/lavapipe/meson.build b/src/gallium/frontends/lavapipe/meson.build index 4fc38ff..5a6ffee 100644 --- a/src/gallium/frontends/lavapipe/meson.build +++ b/src/gallium/frontends/lavapipe/meson.build @@ -43,16 +43,10 @@ lvp_flags = [] if with_platform_x11 lvp_deps += dep_xcb_dri3 - liblvp_files += files('lvp_wsi_x11.c') endif if with_platform_wayland lvp_deps += dep_wayland_client - liblvp_files += files('lvp_wsi_wayland.c') -endif - -if with_platform_windows - liblvp_files += files('lvp_wsi_win32.c') endif liblavapipe_st = static_library(