anv: Use the common WSI wrappers

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
This commit is contained in:
Jason Ekstrand 2021-10-06 11:21:55 -05:00 committed by Marge Bot
parent 75955c6685
commit a64d90026b
6 changed files with 9 additions and 616 deletions

View file

@ -793,6 +793,8 @@ anv_physical_device_try_create(struct anv_instance *instance,
struct vk_physical_device_dispatch_table dispatch_table;
vk_physical_device_dispatch_table_from_entrypoints(
&dispatch_table, &anv_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, /* We set up extensions later */
@ -1099,6 +1101,8 @@ VkResult anv_CreateInstance(
struct vk_instance_dispatch_table dispatch_table;
vk_instance_dispatch_table_from_entrypoints(
&dispatch_table, &anv_instance_entrypoints, true);
vk_instance_dispatch_table_from_entrypoints(
&dispatch_table, &wsi_instance_entrypoints, false);
result = vk_instance_init(&instance->vk, &instance_extensions,
&dispatch_table, pCreateInfo, pAllocator);
@ -2931,6 +2935,8 @@ VkResult anv_CreateDevice(
anv_genX(&physical_device->info, device_entrypoints), true);
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
&anv_device_entrypoints, false);
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);

View file

@ -96,195 +96,19 @@ anv_init_wsi(struct anv_physical_device *physical_device)
physical_device->wsi_device.signal_fence_for_memory =
anv_wsi_signal_fence_for_memory;
physical_device->vk.wsi_device = &physical_device->wsi_device;
return VK_SUCCESS;
}
void
anv_finish_wsi(struct anv_physical_device *physical_device)
{
physical_device->vk.wsi_device = NULL;
wsi_device_finish(&physical_device->wsi_device,
&physical_device->instance->vk.alloc);
}
void anv_DestroySurfaceKHR(
VkInstance _instance,
VkSurfaceKHR _surface,
const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_instance, instance, _instance);
ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
if (!surface)
return;
vk_free2(&instance->vk.alloc, pAllocator, surface);
}
VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
VkSurfaceKHR surface,
VkBool32* pSupported)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_common_get_surface_support(&device->wsi_device,
queueFamilyIndex,
surface,
pSupported);
}
VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_common_get_surface_capabilities(&device->wsi_device,
surface,
pSurfaceCapabilities);
}
VkResult anv_GetPhysicalDeviceSurfaceCapabilities2KHR(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
VkSurfaceCapabilities2KHR* pSurfaceCapabilities)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_common_get_surface_capabilities2(&device->wsi_device,
pSurfaceInfo,
pSurfaceCapabilities);
}
VkResult anv_GetPhysicalDeviceSurfaceCapabilities2EXT(
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
VkSurfaceCapabilities2EXT* pSurfaceCapabilities)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_common_get_surface_capabilities2ext(&device->wsi_device,
surface,
pSurfaceCapabilities);
}
VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR(
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t* pSurfaceFormatCount,
VkSurfaceFormatKHR* pSurfaceFormats)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_common_get_surface_formats(&device->wsi_device, surface,
pSurfaceFormatCount, pSurfaceFormats);
}
VkResult anv_GetPhysicalDeviceSurfaceFormats2KHR(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
uint32_t* pSurfaceFormatCount,
VkSurfaceFormat2KHR* pSurfaceFormats)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_common_get_surface_formats2(&device->wsi_device, pSurfaceInfo,
pSurfaceFormatCount, pSurfaceFormats);
}
VkResult anv_GetPhysicalDeviceSurfacePresentModesKHR(
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t* pPresentModeCount,
VkPresentModeKHR* pPresentModes)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_common_get_surface_present_modes(&device->wsi_device, surface,
pPresentModeCount,
pPresentModes);
}
VkResult anv_CreateSwapchainKHR(
VkDevice _device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSwapchainKHR* pSwapchain)
{
ANV_FROM_HANDLE(anv_device, device, _device);
struct wsi_device *wsi_device = &device->physical->wsi_device;
const VkAllocationCallbacks *alloc;
if (pAllocator)
alloc = pAllocator;
else
alloc = &device->vk.alloc;
return wsi_common_create_swapchain(wsi_device, _device,
pCreateInfo, alloc, pSwapchain);
}
void anv_DestroySwapchainKHR(
VkDevice _device,
VkSwapchainKHR swapchain,
const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
const VkAllocationCallbacks *alloc;
if (pAllocator)
alloc = pAllocator;
else
alloc = &device->vk.alloc;
wsi_common_destroy_swapchain(_device, swapchain, alloc);
}
VkResult anv_GetSwapchainImagesKHR(
VkDevice device,
VkSwapchainKHR swapchain,
uint32_t* pSwapchainImageCount,
VkImage* pSwapchainImages)
{
return wsi_common_get_images(swapchain,
pSwapchainImageCount,
pSwapchainImages);
}
VkResult anv_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 anv_AcquireNextImage2KHR(device, &acquire_info, pImageIndex);
}
VkResult anv_AcquireNextImage2KHR(
VkDevice _device,
const VkAcquireNextImageInfoKHR* pAcquireInfo,
uint32_t* pImageIndex)
{
ANV_FROM_HANDLE(anv_device, device, _device);
anv_measure_acquire(device);
return wsi_common_acquire_next_image2(&device->physical->wsi_device,
_device, pAcquireInfo, pImageIndex);
}
VkResult anv_QueuePresentKHR(
VkQueue _queue,
const VkPresentInfoKHR* pPresentInfo)
@ -364,38 +188,3 @@ VkResult anv_QueuePresentKHR(
return result;
}
VkResult anv_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;
}
VkResult anv_GetDeviceGroupSurfacePresentModesKHR(
VkDevice device,
VkSurfaceKHR surface,
VkDeviceGroupPresentModeFlagsKHR* pModes)
{
*pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
return VK_SUCCESS;
}
VkResult anv_GetPhysicalDevicePresentRectanglesKHR(
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t* pRectCount,
VkRect2D* pRects)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_common_get_present_rectangles(&device->wsi_device,
surface,
pRectCount, pRects);
}

View file

@ -25,225 +25,8 @@
#include "vk_util.h"
#include "wsi_common_display.h"
VkResult
anv_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device,
uint32_t *property_count,
VkDisplayPropertiesKHR *properties)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_display_get_physical_device_display_properties(
physical_device,
&pdevice->wsi_device,
property_count,
properties);
}
VkResult
anv_GetPhysicalDeviceDisplayProperties2KHR(
VkPhysicalDevice physicalDevice,
uint32_t* pPropertyCount,
VkDisplayProperties2KHR* pProperties)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
return wsi_display_get_physical_device_display_properties2(
physicalDevice, &pdevice->wsi_device,
pPropertyCount, pProperties);
}
VkResult
anv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
VkPhysicalDevice physical_device,
uint32_t *property_count,
VkDisplayPlanePropertiesKHR *properties)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_display_get_physical_device_display_plane_properties(
physical_device, &pdevice->wsi_device,
property_count, properties);
}
VkResult
anv_GetPhysicalDeviceDisplayPlaneProperties2KHR(
VkPhysicalDevice physicalDevice,
uint32_t* pPropertyCount,
VkDisplayPlaneProperties2KHR* pProperties)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
return wsi_display_get_physical_device_display_plane_properties2(
physicalDevice, &pdevice->wsi_device,
pPropertyCount, pProperties);
}
VkResult
anv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device,
uint32_t plane_index,
uint32_t *display_count,
VkDisplayKHR *displays)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_display_get_display_plane_supported_displays(physical_device,
&pdevice->wsi_device,
plane_index,
display_count,
displays);
}
VkResult
anv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device,
VkDisplayKHR display,
uint32_t *property_count,
VkDisplayModePropertiesKHR *properties)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_display_get_display_mode_properties(physical_device,
&pdevice->wsi_device,
display,
property_count,
properties);
}
VkResult
anv_GetDisplayModeProperties2KHR(
VkPhysicalDevice physicalDevice,
VkDisplayKHR display,
uint32_t* pPropertyCount,
VkDisplayModeProperties2KHR* pProperties)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
return wsi_display_get_display_mode_properties2(physicalDevice,
&pdevice->wsi_device,
display,
pPropertyCount,
pProperties);
}
VkResult
anv_CreateDisplayModeKHR(VkPhysicalDevice physical_device,
VkDisplayKHR display,
const VkDisplayModeCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator,
VkDisplayModeKHR *mode)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_display_create_display_mode(physical_device,
&pdevice->wsi_device,
display,
create_info,
allocator,
mode);
}
VkResult
anv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device,
VkDisplayModeKHR mode_khr,
uint32_t plane_index,
VkDisplayPlaneCapabilitiesKHR *capabilities)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_get_display_plane_capabilities(physical_device,
&pdevice->wsi_device,
mode_khr,
plane_index,
capabilities);
}
VkResult
anv_GetDisplayPlaneCapabilities2KHR(
VkPhysicalDevice physicalDevice,
const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo,
VkDisplayPlaneCapabilities2KHR* pCapabilities)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
return wsi_get_display_plane_capabilities2(physicalDevice,
&pdevice->wsi_device,
pDisplayPlaneInfo,
pCapabilities);
}
VkResult
anv_CreateDisplayPlaneSurfaceKHR(
VkInstance _instance,
const VkDisplaySurfaceCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator,
VkSurfaceKHR *surface)
{
ANV_FROM_HANDLE(anv_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);
}
VkResult
anv_ReleaseDisplayEXT(VkPhysicalDevice physical_device,
VkDisplayKHR display)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_release_display(physical_device,
&pdevice->wsi_device,
display);
}
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
VkResult
anv_AcquireXlibDisplayEXT(VkPhysicalDevice physical_device,
Display *dpy,
VkDisplayKHR display)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_acquire_xlib_display(physical_device,
&pdevice->wsi_device,
dpy,
display);
}
VkResult
anv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device,
Display *dpy,
RROutput output,
VkDisplayKHR *display)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_get_randr_output_display(physical_device,
&pdevice->wsi_device,
dpy,
output,
display);
}
#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
/* VK_EXT_display_control */
VkResult
anv_DisplayPowerControlEXT(VkDevice _device,
VkDisplayKHR display,
const VkDisplayPowerInfoEXT *display_power_info)
{
ANV_FROM_HANDLE(anv_device, device, _device);
return wsi_display_power_control(
_device, &device->physical->wsi_device,
display, display_power_info);
}
VkResult
anv_RegisterDeviceEventEXT(VkDevice _device,
const VkDeviceEventInfoEXT *device_event_info,
@ -302,37 +85,3 @@ anv_RegisterDisplayEventEXT(VkDevice _device,
vk_free2(&device->vk.alloc, allocator, fence);
return ret;
}
VkResult
anv_GetSwapchainCounterEXT(VkDevice _device,
VkSwapchainKHR swapchain,
VkSurfaceCounterFlagBitsEXT flag_bits,
uint64_t *value)
{
ANV_FROM_HANDLE(anv_device, device, _device);
return wsi_get_swapchain_counter(
_device, &device->physical->wsi_device,
swapchain, flag_bits, value);
}
VkResult
anv_AcquireDrmDisplayEXT(VkPhysicalDevice physical_device,
int32_t drm_fd,
VkDisplayKHR display)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_acquire_drm_display(physical_device, &pdevice->wsi_device, drm_fd, display);
}
VkResult
anv_GetDrmDisplayEXT(VkPhysicalDevice physical_device,
int32_t drm_fd,
uint32_t connector_id,
VkDisplayKHR *display)
{
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
return wsi_get_drm_display(physical_device, &pdevice->wsi_device, drm_fd, connector_id, display);
}

View file

@ -1,53 +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 "wsi_common_wayland.h"
#include "anv_private.h"
VkBool32 anv_GetPhysicalDeviceWaylandPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
struct wl_display* display)
{
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
return wsi_wl_get_presentation_support(&physical_device->wsi_device, display);
}
VkResult anv_CreateWaylandSurfaceKHR(
VkInstance _instance,
const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface)
{
ANV_FROM_HANDLE(anv_instance, instance, _instance);
const VkAllocationCallbacks *alloc;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR);
if (pAllocator)
alloc = pAllocator;
else
alloc = &instance->vk.alloc;
return wsi_create_wl_surface(alloc, pCreateInfo, pSurface);
}

View file

@ -1,96 +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 <X11/Xlib-xcb.h>
#include <X11/xshmfence.h>
#include <xcb/xcb.h>
#include <xcb/dri3.h>
#include <xcb/present.h>
#include "wsi_common_x11.h"
#include "anv_private.h"
VkBool32 anv_GetPhysicalDeviceXcbPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
xcb_connection_t* connection,
xcb_visualid_t visual_id)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_get_physical_device_xcb_presentation_support(
&device->wsi_device,
queueFamilyIndex,
connection, visual_id);
}
VkBool32 anv_GetPhysicalDeviceXlibPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
Display* dpy,
VisualID visualID)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
return wsi_get_physical_device_xcb_presentation_support(
&device->wsi_device,
queueFamilyIndex,
XGetXCBConnection(dpy), visualID);
}
VkResult anv_CreateXcbSurfaceKHR(
VkInstance _instance,
const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface)
{
ANV_FROM_HANDLE(anv_instance, instance, _instance);
const VkAllocationCallbacks *alloc;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR);
if (pAllocator)
alloc = pAllocator;
else
alloc = &instance->vk.alloc;
return wsi_create_xcb_surface(alloc, pCreateInfo, pSurface);
}
VkResult anv_CreateXlibSurfaceKHR(
VkInstance _instance,
const VkXlibSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface)
{
ANV_FROM_HANDLE(anv_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);
}

View file

@ -127,12 +127,10 @@ anv_flags = [
if with_platform_x11
anv_deps += dep_xcb_dri3
libanv_files += files('anv_wsi_x11.c')
endif
if with_platform_wayland
anv_deps += dep_wayland_client
libanv_files += files('anv_wsi_wayland.c')
endif
if system_has_kms_drm and not with_platform_android