panvk: Use the common WSI wrappers

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
This commit is contained in:
Jason Ekstrand
2021-10-06 11:54:13 -05:00
committed by Marge Bot
parent dfed852ddf
commit 1f06554df7
5 changed files with 12 additions and 409 deletions

View File

@@ -50,7 +50,6 @@ libpanvk_files = files(
'panvk_sync.c',
'panvk_util.c',
'panvk_wsi.c',
'panvk_wsi_display.c',
)
panvk_deps = []
@@ -94,13 +93,8 @@ foreach arch : ['5', '6', '7']
)
endforeach
if system_has_kms_drm
libpanvk_files += files('panvk_wsi_display.c')
endif
if with_platform_wayland
panvk_deps += [dep_wayland_client, dep_wl_protocols]
libpanvk_files += files('panvk_wsi_wayland.c')
libpanvk_files += [wayland_drm_client_protocol_h, wayland_drm_protocol_c]
endif

View File

@@ -175,6 +175,9 @@ panvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
vk_instance_dispatch_table_from_entrypoints(&dispatch_table,
&panvk_instance_entrypoints,
true);
vk_instance_dispatch_table_from_entrypoints(&dispatch_table,
&wsi_instance_entrypoints,
false);
result = vk_instance_init(&instance->vk,
&panvk_instance_extensions,
&dispatch_table,
@@ -279,6 +282,9 @@ panvk_physical_device_init(struct panvk_physical_device *device,
vk_physical_device_dispatch_table_from_entrypoints(&dispatch_table,
&panvk_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,
&supported_extensions,
@@ -976,6 +982,9 @@ panvk_CreateDevice(VkPhysicalDevice physicalDevice,
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
&panvk_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);
if (result != VK_SUCCESS) {

View File

@@ -53,178 +53,19 @@ panvk_wsi_init(struct panvk_physical_device *physical_device)
physical_device->wsi_device.supports_modifiers = false;
physical_device->vk.wsi_device = &physical_device->wsi_device;
return VK_SUCCESS;
}
void
panvk_wsi_finish(struct panvk_physical_device *physical_device)
{
physical_device->vk.wsi_device = NULL;
wsi_device_finish(&physical_device->wsi_device,
&physical_device->instance->vk.alloc);
}
void
panvk_DestroySurfaceKHR(VkInstance _instance,
VkSurfaceKHR _surface,
const VkAllocationCallbacks *pAllocator)
{
VK_FROM_HANDLE(panvk_instance, instance, _instance);
ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
vk_free2(&instance->vk.alloc, pAllocator, surface);
}
VkResult
panvk_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
VkSurfaceKHR surface,
VkBool32 *pSupported)
{
VK_FROM_HANDLE(panvk_physical_device, device, physicalDevice);
return wsi_common_get_surface_support(
&device->wsi_device, queueFamilyIndex, surface, pSupported);
}
VkResult
panvk_GetPhysicalDeviceSurfaceCapabilitiesKHR(
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
VkSurfaceCapabilitiesKHR *pSurfaceCapabilities)
{
VK_FROM_HANDLE(panvk_physical_device, device, physicalDevice);
return wsi_common_get_surface_capabilities(&device->wsi_device, surface,
pSurfaceCapabilities);
}
VkResult
panvk_GetPhysicalDeviceSurfaceCapabilities2KHR(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
VkSurfaceCapabilities2KHR *pSurfaceCapabilities)
{
VK_FROM_HANDLE(panvk_physical_device, device, physicalDevice);
return wsi_common_get_surface_capabilities2(
&device->wsi_device, pSurfaceInfo, pSurfaceCapabilities);
}
VkResult
panvk_GetPhysicalDeviceSurfaceCapabilities2EXT(
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
VkSurfaceCapabilities2EXT *pSurfaceCapabilities)
{
VK_FROM_HANDLE(panvk_physical_device, device, physicalDevice);
return wsi_common_get_surface_capabilities2ext(
&device->wsi_device, surface, pSurfaceCapabilities);
}
VkResult
panvk_GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t *pSurfaceFormatCount,
VkSurfaceFormatKHR *pSurfaceFormats)
{
VK_FROM_HANDLE(panvk_physical_device, device, physicalDevice);
return wsi_common_get_surface_formats(
&device->wsi_device, surface, pSurfaceFormatCount, pSurfaceFormats);
}
VkResult
panvk_GetPhysicalDeviceSurfaceFormats2KHR(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
uint32_t *pSurfaceFormatCount,
VkSurfaceFormat2KHR *pSurfaceFormats)
{
VK_FROM_HANDLE(panvk_physical_device, device, physicalDevice);
return wsi_common_get_surface_formats2(&device->wsi_device, pSurfaceInfo,
pSurfaceFormatCount,
pSurfaceFormats);
}
VkResult
panvk_GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t *pPresentModeCount,
VkPresentModeKHR *pPresentModes)
{
VK_FROM_HANDLE(panvk_physical_device, device, physicalDevice);
return wsi_common_get_surface_present_modes(
&device->wsi_device, surface, pPresentModeCount, pPresentModes);
}
VkResult
panvk_CreateSwapchainKHR(VkDevice _device,
const VkSwapchainCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSwapchainKHR *pSwapchain)
{
VK_FROM_HANDLE(panvk_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,
panvk_device_to_handle(device),
pCreateInfo, alloc, pSwapchain);
}
void
panvk_DestroySwapchainKHR(VkDevice _device,
VkSwapchainKHR swapchain,
const VkAllocationCallbacks *pAllocator)
{
VK_FROM_HANDLE(panvk_device, device, _device);
const VkAllocationCallbacks *alloc;
if (pAllocator)
alloc = pAllocator;
else
alloc = &device->vk.alloc;
wsi_common_destroy_swapchain(_device, swapchain, alloc);
}
VkResult
panvk_GetSwapchainImagesKHR(VkDevice device,
VkSwapchainKHR swapchain,
uint32_t *pSwapchainImageCount,
VkImage *pSwapchainImages)
{
return wsi_common_get_images(swapchain, pSwapchainImageCount,
pSwapchainImages);
}
VkResult
panvk_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 panvk_AcquireNextImage2KHR(device, &acquire_info, pImageIndex);
}
VkResult
panvk_AcquireNextImage2KHR(VkDevice _device,
const VkAcquireNextImageInfoKHR *pAcquireInfo,
@@ -247,47 +88,3 @@ panvk_AcquireNextImage2KHR(VkDevice _device,
return result;
}
VkResult
panvk_QueuePresentKHR(VkQueue _queue, const VkPresentInfoKHR *pPresentInfo)
{
VK_FROM_HANDLE(panvk_queue, queue, _queue);
return wsi_common_queue_present(
&queue->device->physical_device->wsi_device,
panvk_device_to_handle(queue->device), _queue,
queue->vk.queue_family_index, pPresentInfo);
}
VkResult
panvk_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
panvk_GetDeviceGroupSurfacePresentModesKHR(
VkDevice device,
VkSurfaceKHR surface,
VkDeviceGroupPresentModeFlagsKHR *pModes)
{
*pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
return VK_SUCCESS;
}
VkResult
panvk_GetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t *pRectCount,
VkRect2D *pRects)
{
VK_FROM_HANDLE(panvk_physical_device, device, physicalDevice);
return wsi_common_get_present_rectangles(&device->wsi_device, surface,
pRectCount, pRects);
}

View File

@@ -1,136 +0,0 @@
/*
* Copyright © 2021 Collabora Ltd.
*
* Derived from v3dv driver:
* Copyright © 2020 Raspberry Pi
* 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 "panvk_private.h"
#include "wsi_common_display.h"
VkResult
panvk_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device,
uint32_t *property_count,
VkDisplayPropertiesKHR *properties)
{
VK_FROM_HANDLE(panvk_physical_device, pdevice, physical_device);
return wsi_display_get_physical_device_display_properties(
physical_device,
&pdevice->wsi_device,
property_count,
properties);
}
VkResult
panvk_GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physical_device,
uint32_t *property_count,
VkDisplayPlanePropertiesKHR *properties)
{
VK_FROM_HANDLE(panvk_physical_device, pdevice, physical_device);
return wsi_display_get_physical_device_display_plane_properties(
physical_device,
&pdevice->wsi_device,
property_count,
properties);
}
VkResult
panvk_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device,
uint32_t plane_index,
uint32_t *display_count,
VkDisplayKHR *displays)
{
VK_FROM_HANDLE(panvk_physical_device, pdevice, physical_device);
return wsi_display_get_display_plane_supported_displays(
physical_device,
&pdevice->wsi_device,
plane_index,
display_count,
displays);
}
VkResult
panvk_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device,
VkDisplayKHR display,
uint32_t *property_count,
VkDisplayModePropertiesKHR *properties)
{
VK_FROM_HANDLE(panvk_physical_device, pdevice, physical_device);
return wsi_display_get_display_mode_properties(physical_device,
&pdevice->wsi_device,
display,
property_count,
properties);
}
VkResult
panvk_CreateDisplayModeKHR(VkPhysicalDevice physical_device,
VkDisplayKHR display,
const VkDisplayModeCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator,
VkDisplayModeKHR *mode)
{
VK_FROM_HANDLE(panvk_physical_device, pdevice, physical_device);
return wsi_display_create_display_mode(physical_device,
&pdevice->wsi_device,
display,
create_info,
allocator,
mode);
}
VkResult
panvk_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device,
VkDisplayModeKHR mode_khr,
uint32_t plane_index,
VkDisplayPlaneCapabilitiesKHR *capabilities)
{
VK_FROM_HANDLE(panvk_physical_device, pdevice, physical_device);
return wsi_get_display_plane_capabilities(physical_device,
&pdevice->wsi_device,
mode_khr,
plane_index,
capabilities);
}
VkResult
panvk_CreateDisplayPlaneSurfaceKHR(VkInstance _instance,
const VkDisplaySurfaceCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator,
VkSurfaceKHR *surface)
{
VK_FROM_HANDLE(panvk_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);
}

View File

@@ -1,61 +0,0 @@
/*
* Copyright © 2021 Collabora Ltd.
*
* Derived from turnip driver:
* Copyright © 2016 Red Hat
* 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 "panvk_private.h"
#include "wsi_common_wayland.h"
VkBool32
panvk_GetPhysicalDeviceWaylandPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
struct wl_display *display)
{
VK_FROM_HANDLE(panvk_physical_device, physical_device, physicalDevice);
return wsi_wl_get_presentation_support(&physical_device->wsi_device,
display);
}
VkResult
panvk_CreateWaylandSurfaceKHR(VkInstance _instance,
const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSurfaceKHR *pSurface)
{
VK_FROM_HANDLE(panvk_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);
}