vulkan/wsi: Use VK_EXT_pci_bus_info for DRM fd matching
This lets us avoid passing the DRM fd around all over the place and gets us closer to layer utopia. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
This commit is contained in:
@@ -72,7 +72,6 @@ VkResult radv_GetPhysicalDeviceSurfaceSupportKHR(
|
|||||||
RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
|
RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
|
||||||
|
|
||||||
return wsi_common_get_surface_support(&device->wsi_device,
|
return wsi_common_get_surface_support(&device->wsi_device,
|
||||||
device->local_fd,
|
|
||||||
queueFamilyIndex,
|
queueFamilyIndex,
|
||||||
surface,
|
surface,
|
||||||
pSupported);
|
pSupported);
|
||||||
@@ -171,7 +170,6 @@ VkResult radv_CreateSwapchainKHR(
|
|||||||
|
|
||||||
return wsi_common_create_swapchain(&device->physical_device->wsi_device,
|
return wsi_common_create_swapchain(&device->physical_device->wsi_device,
|
||||||
radv_device_to_handle(device),
|
radv_device_to_handle(device),
|
||||||
device->physical_device->local_fd,
|
|
||||||
pCreateInfo,
|
pCreateInfo,
|
||||||
alloc,
|
alloc,
|
||||||
pSwapchain);
|
pSwapchain);
|
||||||
@@ -294,7 +292,6 @@ VkResult radv_GetPhysicalDevicePresentRectanglesKHR(
|
|||||||
RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
|
RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
|
||||||
|
|
||||||
return wsi_common_get_present_rectangles(&device->wsi_device,
|
return wsi_common_get_present_rectangles(&device->wsi_device,
|
||||||
device->local_fd,
|
|
||||||
surface,
|
surface,
|
||||||
pRectCount, pRects);
|
pRectCount, pRects);
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ VkBool32 radv_GetPhysicalDeviceXcbPresentationSupportKHR(
|
|||||||
return wsi_get_physical_device_xcb_presentation_support(
|
return wsi_get_physical_device_xcb_presentation_support(
|
||||||
&device->wsi_device,
|
&device->wsi_device,
|
||||||
queueFamilyIndex,
|
queueFamilyIndex,
|
||||||
device->local_fd, true,
|
true,
|
||||||
connection, visual_id);
|
connection, visual_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ VkBool32 radv_GetPhysicalDeviceXlibPresentationSupportKHR(
|
|||||||
return wsi_get_physical_device_xcb_presentation_support(
|
return wsi_get_physical_device_xcb_presentation_support(
|
||||||
&device->wsi_device,
|
&device->wsi_device,
|
||||||
queueFamilyIndex,
|
queueFamilyIndex,
|
||||||
device->local_fd, true,
|
true,
|
||||||
XGetXCBConnection(dpy), visualID);
|
XGetXCBConnection(dpy), visualID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,7 +89,6 @@ VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
|
|||||||
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
||||||
|
|
||||||
return wsi_common_get_surface_support(&device->wsi_device,
|
return wsi_common_get_surface_support(&device->wsi_device,
|
||||||
device->local_fd,
|
|
||||||
queueFamilyIndex,
|
queueFamilyIndex,
|
||||||
surface,
|
surface,
|
||||||
pSupported);
|
pSupported);
|
||||||
@@ -183,7 +182,7 @@ VkResult anv_CreateSwapchainKHR(
|
|||||||
else
|
else
|
||||||
alloc = &device->alloc;
|
alloc = &device->alloc;
|
||||||
|
|
||||||
return wsi_common_create_swapchain(wsi_device, _device, device->fd,
|
return wsi_common_create_swapchain(wsi_device, _device,
|
||||||
pCreateInfo, alloc, pSwapchain);
|
pCreateInfo, alloc, pSwapchain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +302,6 @@ VkResult anv_GetPhysicalDevicePresentRectanglesKHR(
|
|||||||
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
|
||||||
|
|
||||||
return wsi_common_get_present_rectangles(&device->wsi_device,
|
return wsi_common_get_present_rectangles(&device->wsi_device,
|
||||||
device->local_fd,
|
|
||||||
surface,
|
surface,
|
||||||
pRectCount, pRects);
|
pRectCount, pRects);
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ VkBool32 anv_GetPhysicalDeviceXcbPresentationSupportKHR(
|
|||||||
return wsi_get_physical_device_xcb_presentation_support(
|
return wsi_get_physical_device_xcb_presentation_support(
|
||||||
&device->wsi_device,
|
&device->wsi_device,
|
||||||
queueFamilyIndex,
|
queueFamilyIndex,
|
||||||
device->local_fd, false,
|
false,
|
||||||
connection, visual_id);
|
connection, visual_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ VkBool32 anv_GetPhysicalDeviceXlibPresentationSupportKHR(
|
|||||||
return wsi_get_physical_device_xcb_presentation_support(
|
return wsi_get_physical_device_xcb_presentation_support(
|
||||||
&device->wsi_device,
|
&device->wsi_device,
|
||||||
queueFamilyIndex,
|
queueFamilyIndex,
|
||||||
device->local_fd, false,
|
false,
|
||||||
XGetXCBConnection(dpy), visualID);
|
XGetXCBConnection(dpy), visualID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "vk_util.h"
|
#include "vk_util.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <xf86drm.h>
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_device_init(struct wsi_device *wsi,
|
wsi_device_init(struct wsi_device *wsi,
|
||||||
@@ -44,10 +45,19 @@ wsi_device_init(struct wsi_device *wsi,
|
|||||||
|
|
||||||
#define WSI_GET_CB(func) \
|
#define WSI_GET_CB(func) \
|
||||||
PFN_vk##func func = (PFN_vk##func)proc_addr(pdevice, "vk" #func)
|
PFN_vk##func func = (PFN_vk##func)proc_addr(pdevice, "vk" #func)
|
||||||
|
WSI_GET_CB(GetPhysicalDeviceProperties2);
|
||||||
WSI_GET_CB(GetPhysicalDeviceMemoryProperties);
|
WSI_GET_CB(GetPhysicalDeviceMemoryProperties);
|
||||||
WSI_GET_CB(GetPhysicalDeviceQueueFamilyProperties);
|
WSI_GET_CB(GetPhysicalDeviceQueueFamilyProperties);
|
||||||
#undef WSI_GET_CB
|
#undef WSI_GET_CB
|
||||||
|
|
||||||
|
wsi->pci_bus_info.sType =
|
||||||
|
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT;
|
||||||
|
VkPhysicalDeviceProperties2 pdp2 = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
|
||||||
|
.pNext = &wsi->pci_bus_info,
|
||||||
|
};
|
||||||
|
GetPhysicalDeviceProperties2(pdevice, &pdp2);
|
||||||
|
|
||||||
GetPhysicalDeviceMemoryProperties(pdevice, &wsi->memory_props);
|
GetPhysicalDeviceMemoryProperties(pdevice, &wsi->memory_props);
|
||||||
GetPhysicalDeviceQueueFamilyProperties(pdevice, &wsi->queue_family_count, NULL);
|
GetPhysicalDeviceQueueFamilyProperties(pdevice, &wsi->queue_family_count, NULL);
|
||||||
|
|
||||||
@@ -121,6 +131,32 @@ wsi_device_finish(struct wsi_device *wsi,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd)
|
||||||
|
{
|
||||||
|
drmDevicePtr fd_device;
|
||||||
|
int ret = drmGetDevice(drm_fd, &fd_device);
|
||||||
|
if (ret)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool match = false;
|
||||||
|
switch (fd_device->bustype) {
|
||||||
|
case DRM_BUS_PCI:
|
||||||
|
match = wsi->pci_bus_info.pciDomain == fd_device->businfo.pci->domain &&
|
||||||
|
wsi->pci_bus_info.pciBus == fd_device->businfo.pci->bus &&
|
||||||
|
wsi->pci_bus_info.pciDevice == fd_device->businfo.pci->dev &&
|
||||||
|
wsi->pci_bus_info.pciFunction == fd_device->businfo.pci->func;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
drmFreeDevice(&fd_device);
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_swapchain_init(const struct wsi_device *wsi,
|
wsi_swapchain_init(const struct wsi_device *wsi,
|
||||||
struct wsi_swapchain *chain,
|
struct wsi_swapchain *chain,
|
||||||
@@ -675,7 +711,6 @@ wsi_destroy_image(const struct wsi_swapchain *chain,
|
|||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_common_get_surface_support(struct wsi_device *wsi_device,
|
wsi_common_get_surface_support(struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
VkSurfaceKHR _surface,
|
VkSurfaceKHR _surface,
|
||||||
VkBool32* pSupported)
|
VkBool32* pSupported)
|
||||||
@@ -684,7 +719,7 @@ wsi_common_get_surface_support(struct wsi_device *wsi_device,
|
|||||||
struct wsi_interface *iface = wsi_device->wsi[surface->platform];
|
struct wsi_interface *iface = wsi_device->wsi[surface->platform];
|
||||||
|
|
||||||
return iface->get_support(surface, wsi_device,
|
return iface->get_support(surface, wsi_device,
|
||||||
queueFamilyIndex, local_fd, pSupported);
|
queueFamilyIndex, pSupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
@@ -805,7 +840,6 @@ wsi_common_get_surface_present_modes(struct wsi_device *wsi_device,
|
|||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_common_get_present_rectangles(struct wsi_device *wsi_device,
|
wsi_common_get_present_rectangles(struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
VkSurfaceKHR _surface,
|
VkSurfaceKHR _surface,
|
||||||
uint32_t* pRectCount,
|
uint32_t* pRectCount,
|
||||||
VkRect2D* pRects)
|
VkRect2D* pRects)
|
||||||
@@ -813,14 +847,13 @@ wsi_common_get_present_rectangles(struct wsi_device *wsi_device,
|
|||||||
ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
|
ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
|
||||||
struct wsi_interface *iface = wsi_device->wsi[surface->platform];
|
struct wsi_interface *iface = wsi_device->wsi[surface->platform];
|
||||||
|
|
||||||
return iface->get_present_rectangles(surface, wsi_device, local_fd,
|
return iface->get_present_rectangles(surface, wsi_device,
|
||||||
pRectCount, pRects);
|
pRectCount, pRects);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_common_create_swapchain(struct wsi_device *wsi,
|
wsi_common_create_swapchain(struct wsi_device *wsi,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
int fd,
|
|
||||||
const VkSwapchainCreateInfoKHR *pCreateInfo,
|
const VkSwapchainCreateInfoKHR *pCreateInfo,
|
||||||
const VkAllocationCallbacks *pAllocator,
|
const VkAllocationCallbacks *pAllocator,
|
||||||
VkSwapchainKHR *pSwapchain)
|
VkSwapchainKHR *pSwapchain)
|
||||||
@@ -829,7 +862,7 @@ wsi_common_create_swapchain(struct wsi_device *wsi,
|
|||||||
struct wsi_interface *iface = wsi->wsi[surface->platform];
|
struct wsi_interface *iface = wsi->wsi[surface->platform];
|
||||||
struct wsi_swapchain *swapchain;
|
struct wsi_swapchain *swapchain;
|
||||||
|
|
||||||
VkResult result = iface->create_swapchain(surface, device, wsi, fd,
|
VkResult result = iface->create_swapchain(surface, device, wsi,
|
||||||
pCreateInfo, pAllocator,
|
pCreateInfo, pAllocator,
|
||||||
&swapchain);
|
&swapchain);
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
|
@@ -97,6 +97,8 @@ struct wsi_device {
|
|||||||
VkPhysicalDeviceMemoryProperties memory_props;
|
VkPhysicalDeviceMemoryProperties memory_props;
|
||||||
uint32_t queue_family_count;
|
uint32_t queue_family_count;
|
||||||
|
|
||||||
|
VkPhysicalDevicePCIBusInfoPropertiesEXT pci_bus_info;
|
||||||
|
|
||||||
bool supports_modifiers;
|
bool supports_modifiers;
|
||||||
uint64_t (*image_get_modifier)(VkImage image);
|
uint64_t (*image_get_modifier)(VkImage image);
|
||||||
|
|
||||||
@@ -166,7 +168,6 @@ ICD_DEFINE_NONDISP_HANDLE_CASTS(VkIcdSurfaceBase, VkSurfaceKHR)
|
|||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_common_get_surface_support(struct wsi_device *wsi_device,
|
wsi_common_get_surface_support(struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
VkSurfaceKHR surface,
|
VkSurfaceKHR surface,
|
||||||
VkBool32* pSupported);
|
VkBool32* pSupported);
|
||||||
@@ -201,7 +202,6 @@ wsi_common_get_surface_present_modes(struct wsi_device *wsi_device,
|
|||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_common_get_present_rectangles(struct wsi_device *wsi,
|
wsi_common_get_present_rectangles(struct wsi_device *wsi,
|
||||||
int local_fd,
|
|
||||||
VkSurfaceKHR surface,
|
VkSurfaceKHR surface,
|
||||||
uint32_t* pRectCount,
|
uint32_t* pRectCount,
|
||||||
VkRect2D* pRects);
|
VkRect2D* pRects);
|
||||||
@@ -226,7 +226,6 @@ wsi_common_acquire_next_image2(const struct wsi_device *wsi,
|
|||||||
VkResult
|
VkResult
|
||||||
wsi_common_create_swapchain(struct wsi_device *wsi,
|
wsi_common_create_swapchain(struct wsi_device *wsi,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
int fd,
|
|
||||||
const VkSwapchainCreateInfoKHR *pCreateInfo,
|
const VkSwapchainCreateInfoKHR *pCreateInfo,
|
||||||
const VkAllocationCallbacks *pAllocator,
|
const VkAllocationCallbacks *pAllocator,
|
||||||
VkSwapchainKHR *pSwapchain);
|
VkSwapchainKHR *pSwapchain);
|
||||||
|
@@ -803,7 +803,6 @@ static VkResult
|
|||||||
wsi_display_surface_get_support(VkIcdSurfaceBase *surface,
|
wsi_display_surface_get_support(VkIcdSurfaceBase *surface,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
int local_fd,
|
|
||||||
VkBool32* pSupported)
|
VkBool32* pSupported)
|
||||||
{
|
{
|
||||||
*pSupported = VK_TRUE;
|
*pSupported = VK_TRUE;
|
||||||
@@ -934,27 +933,9 @@ wsi_display_surface_get_present_modes(VkIcdSurfaceBase *surface,
|
|||||||
return vk_outarray_status(&conn);
|
return vk_outarray_status(&conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
fds_are_same_gpu(int fd1, int fd2)
|
|
||||||
{
|
|
||||||
if (fd1 == -1 || fd2 == -1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char *fd1_dev = drmGetRenderDeviceNameFromFd(fd1);
|
|
||||||
char *fd2_dev = drmGetRenderDeviceNameFromFd(fd2);
|
|
||||||
|
|
||||||
int ret = strcmp(fd1_dev, fd2_dev);
|
|
||||||
|
|
||||||
free(fd1_dev);
|
|
||||||
free(fd2_dev);
|
|
||||||
|
|
||||||
return ret == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VkResult
|
static VkResult
|
||||||
wsi_display_surface_get_present_rectangles(VkIcdSurfaceBase *surface_base,
|
wsi_display_surface_get_present_rectangles(VkIcdSurfaceBase *surface_base,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
uint32_t* pRectCount,
|
uint32_t* pRectCount,
|
||||||
VkRect2D* pRects)
|
VkRect2D* pRects)
|
||||||
{
|
{
|
||||||
@@ -962,7 +943,7 @@ wsi_display_surface_get_present_rectangles(VkIcdSurfaceBase *surface_base,
|
|||||||
wsi_display_mode *mode = wsi_display_mode_from_handle(surface->displayMode);
|
wsi_display_mode *mode = wsi_display_mode_from_handle(surface->displayMode);
|
||||||
VK_OUTARRAY_MAKE(out, pRects, pRectCount);
|
VK_OUTARRAY_MAKE(out, pRects, pRectCount);
|
||||||
|
|
||||||
if (fds_are_same_gpu(local_fd, mode->connector->wsi->fd)) {
|
if (wsi_device_matches_drm_fd(wsi_device, mode->connector->wsi->fd)) {
|
||||||
vk_outarray_append(&out, rect) {
|
vk_outarray_append(&out, rect) {
|
||||||
*rect = (VkRect2D) {
|
*rect = (VkRect2D) {
|
||||||
.offset = { 0, 0 },
|
.offset = { 0, 0 },
|
||||||
@@ -1730,7 +1711,6 @@ wsi_display_surface_create_swapchain(
|
|||||||
VkIcdSurfaceBase *icd_surface,
|
VkIcdSurfaceBase *icd_surface,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
const VkSwapchainCreateInfoKHR *create_info,
|
const VkSwapchainCreateInfoKHR *create_info,
|
||||||
const VkAllocationCallbacks *allocator,
|
const VkAllocationCallbacks *allocator,
|
||||||
struct wsi_swapchain **swapchain_out)
|
struct wsi_swapchain **swapchain_out)
|
||||||
|
@@ -69,6 +69,9 @@ struct wsi_swapchain {
|
|||||||
const VkPresentRegionKHR *damage);
|
const VkPresentRegionKHR *damage);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool
|
||||||
|
wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd);
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_swapchain_init(const struct wsi_device *wsi,
|
wsi_swapchain_init(const struct wsi_device *wsi,
|
||||||
struct wsi_swapchain *chain,
|
struct wsi_swapchain *chain,
|
||||||
@@ -101,7 +104,6 @@ struct wsi_interface {
|
|||||||
VkResult (*get_support)(VkIcdSurfaceBase *surface,
|
VkResult (*get_support)(VkIcdSurfaceBase *surface,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
int local_fd,
|
|
||||||
VkBool32* pSupported);
|
VkBool32* pSupported);
|
||||||
VkResult (*get_capabilities2)(VkIcdSurfaceBase *surface,
|
VkResult (*get_capabilities2)(VkIcdSurfaceBase *surface,
|
||||||
const void *info_next,
|
const void *info_next,
|
||||||
@@ -120,13 +122,11 @@ struct wsi_interface {
|
|||||||
VkPresentModeKHR* pPresentModes);
|
VkPresentModeKHR* pPresentModes);
|
||||||
VkResult (*get_present_rectangles)(VkIcdSurfaceBase *surface,
|
VkResult (*get_present_rectangles)(VkIcdSurfaceBase *surface,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
uint32_t* pRectCount,
|
uint32_t* pRectCount,
|
||||||
VkRect2D* pRects);
|
VkRect2D* pRects);
|
||||||
VkResult (*create_swapchain)(VkIcdSurfaceBase *surface,
|
VkResult (*create_swapchain)(VkIcdSurfaceBase *surface,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
const VkSwapchainCreateInfoKHR* pCreateInfo,
|
const VkSwapchainCreateInfoKHR* pCreateInfo,
|
||||||
const VkAllocationCallbacks* pAllocator,
|
const VkAllocationCallbacks* pAllocator,
|
||||||
struct wsi_swapchain **swapchain);
|
struct wsi_swapchain **swapchain);
|
||||||
|
@@ -465,7 +465,6 @@ static VkResult
|
|||||||
wsi_wl_surface_get_support(VkIcdSurfaceBase *surface,
|
wsi_wl_surface_get_support(VkIcdSurfaceBase *surface,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
int local_fd,
|
|
||||||
VkBool32* pSupported)
|
VkBool32* pSupported)
|
||||||
{
|
{
|
||||||
*pSupported = true;
|
*pSupported = true;
|
||||||
@@ -604,7 +603,6 @@ wsi_wl_surface_get_present_modes(VkIcdSurfaceBase *surface,
|
|||||||
static VkResult
|
static VkResult
|
||||||
wsi_wl_surface_get_present_rectangles(VkIcdSurfaceBase *surface,
|
wsi_wl_surface_get_present_rectangles(VkIcdSurfaceBase *surface,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
uint32_t* pRectCount,
|
uint32_t* pRectCount,
|
||||||
VkRect2D* pRects)
|
VkRect2D* pRects)
|
||||||
{
|
{
|
||||||
@@ -908,7 +906,6 @@ static VkResult
|
|||||||
wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
|
wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
const VkSwapchainCreateInfoKHR* pCreateInfo,
|
const VkSwapchainCreateInfoKHR* pCreateInfo,
|
||||||
const VkAllocationCallbacks* pAllocator,
|
const VkAllocationCallbacks* pAllocator,
|
||||||
struct wsi_swapchain **swapchain_out)
|
struct wsi_swapchain **swapchain_out)
|
||||||
|
@@ -99,29 +99,22 @@ wsi_dri3_open(xcb_connection_t *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
wsi_x11_check_dri3_compatible(xcb_connection_t *conn, int local_fd)
|
wsi_x11_check_dri3_compatible(const struct wsi_device *wsi_dev,
|
||||||
|
xcb_connection_t *conn)
|
||||||
{
|
{
|
||||||
xcb_screen_iterator_t screen_iter =
|
xcb_screen_iterator_t screen_iter =
|
||||||
xcb_setup_roots_iterator(xcb_get_setup(conn));
|
xcb_setup_roots_iterator(xcb_get_setup(conn));
|
||||||
xcb_screen_t *screen = screen_iter.data;
|
xcb_screen_t *screen = screen_iter.data;
|
||||||
|
|
||||||
int dri3_fd = wsi_dri3_open(conn, screen->root, None);
|
int dri3_fd = wsi_dri3_open(conn, screen->root, None);
|
||||||
if (dri3_fd != -1) {
|
if (dri3_fd == -1)
|
||||||
char *local_dev = drmGetRenderDeviceNameFromFd(local_fd);
|
return true;
|
||||||
char *dri3_dev = drmGetRenderDeviceNameFromFd(dri3_fd);
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
close(dri3_fd);
|
bool match = wsi_device_matches_drm_fd(wsi_dev, dri3_fd);
|
||||||
|
|
||||||
ret = strcmp(local_dev, dri3_dev);
|
close(dri3_fd);
|
||||||
|
|
||||||
free(local_dev);
|
return match;
|
||||||
free(dri3_dev);
|
|
||||||
|
|
||||||
if (ret != 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wsi_x11_connection *
|
static struct wsi_x11_connection *
|
||||||
@@ -382,7 +375,6 @@ visual_has_alpha(xcb_visualtype_t *visual, unsigned depth)
|
|||||||
VkBool32 wsi_get_physical_device_xcb_presentation_support(
|
VkBool32 wsi_get_physical_device_xcb_presentation_support(
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
int fd,
|
|
||||||
bool can_handle_different_gpu,
|
bool can_handle_different_gpu,
|
||||||
xcb_connection_t* connection,
|
xcb_connection_t* connection,
|
||||||
xcb_visualid_t visual_id)
|
xcb_visualid_t visual_id)
|
||||||
@@ -397,7 +389,7 @@ VkBool32 wsi_get_physical_device_xcb_presentation_support(
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!can_handle_different_gpu)
|
if (!can_handle_different_gpu)
|
||||||
if (!wsi_x11_check_dri3_compatible(connection, fd))
|
if (!wsi_x11_check_dri3_compatible(wsi_device, connection))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
unsigned visual_depth;
|
unsigned visual_depth;
|
||||||
@@ -432,7 +424,6 @@ static VkResult
|
|||||||
x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
|
x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
int local_fd,
|
|
||||||
VkBool32* pSupported)
|
VkBool32* pSupported)
|
||||||
{
|
{
|
||||||
xcb_connection_t *conn = x11_surface_get_connection(icd_surface);
|
xcb_connection_t *conn = x11_surface_get_connection(icd_surface);
|
||||||
@@ -601,7 +592,6 @@ x11_surface_get_present_modes(VkIcdSurfaceBase *surface,
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
x11_surface_is_local_to_gpu(struct wsi_device *wsi_dev,
|
x11_surface_is_local_to_gpu(struct wsi_device *wsi_dev,
|
||||||
int local_fd,
|
|
||||||
xcb_connection_t *conn)
|
xcb_connection_t *conn)
|
||||||
{
|
{
|
||||||
struct wsi_x11_connection *wsi_conn =
|
struct wsi_x11_connection *wsi_conn =
|
||||||
@@ -613,7 +603,7 @@ x11_surface_is_local_to_gpu(struct wsi_device *wsi_dev,
|
|||||||
if (!wsi_x11_check_for_dri3(wsi_conn))
|
if (!wsi_x11_check_for_dri3(wsi_conn))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!wsi_x11_check_dri3_compatible(conn, local_fd))
|
if (!wsi_x11_check_dri3_compatible(wsi_dev, conn))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -622,7 +612,6 @@ x11_surface_is_local_to_gpu(struct wsi_device *wsi_dev,
|
|||||||
static VkResult
|
static VkResult
|
||||||
x11_surface_get_present_rectangles(VkIcdSurfaceBase *icd_surface,
|
x11_surface_get_present_rectangles(VkIcdSurfaceBase *icd_surface,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
uint32_t* pRectCount,
|
uint32_t* pRectCount,
|
||||||
VkRect2D* pRects)
|
VkRect2D* pRects)
|
||||||
{
|
{
|
||||||
@@ -630,7 +619,7 @@ x11_surface_get_present_rectangles(VkIcdSurfaceBase *icd_surface,
|
|||||||
xcb_window_t window = x11_surface_get_window(icd_surface);
|
xcb_window_t window = x11_surface_get_window(icd_surface);
|
||||||
VK_OUTARRAY_MAKE(out, pRects, pRectCount);
|
VK_OUTARRAY_MAKE(out, pRects, pRectCount);
|
||||||
|
|
||||||
if (x11_surface_is_local_to_gpu(wsi_device, local_fd, conn)) {
|
if (x11_surface_is_local_to_gpu(wsi_device, conn)) {
|
||||||
vk_outarray_append(&out, rect) {
|
vk_outarray_append(&out, rect) {
|
||||||
xcb_generic_error_t *err = NULL;
|
xcb_generic_error_t *err = NULL;
|
||||||
xcb_get_geometry_cookie_t geom_cookie = xcb_get_geometry(conn, window);
|
xcb_get_geometry_cookie_t geom_cookie = xcb_get_geometry(conn, window);
|
||||||
@@ -1321,7 +1310,6 @@ static VkResult
|
|||||||
x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
|
x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
int local_fd,
|
|
||||||
const VkSwapchainCreateInfoKHR *pCreateInfo,
|
const VkSwapchainCreateInfoKHR *pCreateInfo,
|
||||||
const VkAllocationCallbacks* pAllocator,
|
const VkAllocationCallbacks* pAllocator,
|
||||||
struct wsi_swapchain **swapchain_out)
|
struct wsi_swapchain **swapchain_out)
|
||||||
@@ -1388,7 +1376,7 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
|
|||||||
else
|
else
|
||||||
chain->last_present_mode = XCB_PRESENT_COMPLETE_MODE_COPY;
|
chain->last_present_mode = XCB_PRESENT_COMPLETE_MODE_COPY;
|
||||||
|
|
||||||
if (!wsi_x11_check_dri3_compatible(conn, local_fd))
|
if (!wsi_x11_check_dri3_compatible(wsi_device, conn))
|
||||||
chain->base.use_prime_blit = true;
|
chain->base.use_prime_blit = true;
|
||||||
|
|
||||||
chain->event_id = xcb_generate_id(chain->conn);
|
chain->event_id = xcb_generate_id(chain->conn);
|
||||||
|
@@ -28,7 +28,6 @@
|
|||||||
VkBool32 wsi_get_physical_device_xcb_presentation_support(
|
VkBool32 wsi_get_physical_device_xcb_presentation_support(
|
||||||
struct wsi_device *wsi_device,
|
struct wsi_device *wsi_device,
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
int local_fd,
|
|
||||||
bool can_handle_different_gpu,
|
bool can_handle_different_gpu,
|
||||||
xcb_connection_t* connection,
|
xcb_connection_t* connection,
|
||||||
xcb_visualid_t visual_id);
|
xcb_visualid_t visual_id);
|
||||||
|
Reference in New Issue
Block a user