Path: blob/21.2-virgl/src/broadcom/vulkan/v3dv_wsi_x11.c
4560 views
/*1* Copyright © 2020 Raspberry Pi2*3* based mostly on anv driver which is:4* Copyright © 2015 Intel Corporation5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the "Software"),8* to deal in the Software without restriction, including without limitation9* the rights to use, copy, modify, merge, publish, distribute, sublicense,10* and/or sell copies of the Software, and to permit persons to whom the11* Software is furnished to do so, subject to the following conditions:12*13* The above copyright notice and this permission notice (including the next14* paragraph) shall be included in all copies or substantial portions of the15* Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL20* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER21* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING22* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS23* IN THE SOFTWARE.24*/2526#include <X11/Xlib-xcb.h>27#include <X11/xshmfence.h>28#include <xcb/xcb.h>29#include <xcb/dri3.h>30#include <xcb/present.h>3132#include "wsi_common_x11.h"33#include "v3dv_private.h"3435VKAPI_ATTR VkBool32 VKAPI_CALL36v3dv_GetPhysicalDeviceXcbPresentationSupportKHR(37VkPhysicalDevice physicalDevice,38uint32_t queueFamilyIndex,39xcb_connection_t* connection,40xcb_visualid_t visual_id)41{42V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice);4344return wsi_get_physical_device_xcb_presentation_support(45&device->wsi_device,46queueFamilyIndex,47connection, visual_id);48}4950VKAPI_ATTR VkBool32 VKAPI_CALL51v3dv_GetPhysicalDeviceXlibPresentationSupportKHR(52VkPhysicalDevice physicalDevice,53uint32_t queueFamilyIndex,54Display* dpy,55VisualID visualID)56{57V3DV_FROM_HANDLE(v3dv_physical_device, device, physicalDevice);5859return wsi_get_physical_device_xcb_presentation_support(60&device->wsi_device,61queueFamilyIndex,62XGetXCBConnection(dpy), visualID);63}6465VKAPI_ATTR VkResult VKAPI_CALL66v3dv_CreateXcbSurfaceKHR(67VkInstance _instance,68const VkXcbSurfaceCreateInfoKHR* pCreateInfo,69const VkAllocationCallbacks* pAllocator,70VkSurfaceKHR* pSurface)71{72V3DV_FROM_HANDLE(v3dv_instance, instance, _instance);73const VkAllocationCallbacks *alloc;74assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR);7576if (pAllocator)77alloc = pAllocator;78else79alloc = &instance->vk.alloc;8081return wsi_create_xcb_surface(alloc, pCreateInfo, pSurface);82}8384VKAPI_ATTR VkResult VKAPI_CALL85v3dv_CreateXlibSurfaceKHR(86VkInstance _instance,87const VkXlibSurfaceCreateInfoKHR* pCreateInfo,88const VkAllocationCallbacks* pAllocator,89VkSurfaceKHR* pSurface)90{91V3DV_FROM_HANDLE(v3dv_instance, instance, _instance);92const VkAllocationCallbacks *alloc;9394assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR);9596if (pAllocator)97alloc = pAllocator;98else99alloc = &instance->vk.alloc;100101return wsi_create_xlib_surface(alloc, pCreateInfo, pSurface);102}103104105