vulkan/wsi: create a common function to compare drm devices
Effectively moves most of v3dv_wsi_can_present_on_device to the common code to be used in other drivers. Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com> Reviewed-by: Emma Anholt <emma@anholt.net> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11091>
This commit is contained in:
parent
e86ce98c6a
commit
fa75b2a027
|
@ -28,6 +28,7 @@
|
|||
#include "wsi_common_entrypoints.h"
|
||||
#include "vk_util.h"
|
||||
#include "wsi_common.h"
|
||||
#include "wsi_common_drm.h"
|
||||
|
||||
static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
|
||||
v3dv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
|
||||
|
@ -41,24 +42,7 @@ v3dv_wsi_can_present_on_device(VkPhysicalDevice _pdevice, int fd)
|
|||
{
|
||||
V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, _pdevice);
|
||||
|
||||
drmDevicePtr fd_devinfo, display_devinfo;
|
||||
int ret;
|
||||
|
||||
ret = drmGetDevice2(fd, 0, &fd_devinfo);
|
||||
if (ret)
|
||||
return false;
|
||||
|
||||
ret = drmGetDevice2(pdevice->display_fd, 0, &display_devinfo);
|
||||
if (ret) {
|
||||
drmFreeDevice(&fd_devinfo);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = drmDevicesEqual(fd_devinfo, display_devinfo);
|
||||
|
||||
drmFreeDevice(&fd_devinfo);
|
||||
drmFreeDevice(&display_devinfo);
|
||||
return result;
|
||||
return wsi_common_drm_devices_equal(fd, pdevice->display_fd);
|
||||
}
|
||||
|
||||
VkResult
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "wsi_common_private.h"
|
||||
#include "wsi_common_drm.h"
|
||||
#include "util/macros.h"
|
||||
#include "util/os_file.h"
|
||||
#include "util/xmlconfig.h"
|
||||
|
@ -34,6 +35,30 @@
|
|||
#include <stdio.h>
|
||||
#include <xf86drm.h>
|
||||
|
||||
bool
|
||||
wsi_common_drm_devices_equal(int fd_a, int fd_b)
|
||||
{
|
||||
drmDevicePtr device_a, device_b;
|
||||
int ret;
|
||||
|
||||
ret = drmGetDevice2(fd_a, 0, &device_a);
|
||||
if (ret)
|
||||
return false;
|
||||
|
||||
ret = drmGetDevice2(fd_b, 0, &device_b);
|
||||
if (ret) {
|
||||
drmFreeDevice(&device_a);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = drmDevicesEqual(device_a, device_b);
|
||||
|
||||
drmFreeDevice(&device_a);
|
||||
drmFreeDevice(&device_b);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright © 2021 Igalia S.L.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef WSI_COMMON_DRM_H
|
||||
#define WSI_COMMON_DRM_H
|
||||
|
||||
bool
|
||||
wsi_common_drm_devices_equal(int fd_a, int fd_b);
|
||||
|
||||
#endif /* WSI_COMMON_DRM_H */
|
Loading…
Reference in New Issue