Path: blob/21.2-virgl/src/freedreno/vulkan/tu_wsi_x11.c
4565 views
/*1* Copyright © 2016 Red Hat.2* Copyright © 2016 Bas Nieuwenhuizen3*4* based mostly on anv driver which is:5* Copyright © 2015 Intel Corporation6*7* Permission is hereby granted, free of charge, to any person obtaining a8* copy of this software and associated documentation files (the "Software"),9* to deal in the Software without restriction, including without limitation10* the rights to use, copy, modify, merge, publish, distribute, sublicense,11* and/or sell copies of the Software, and to permit persons to whom the12* Software is furnished to do so, subject to the following conditions:13*14* The above copyright notice and this permission notice (including the next15* paragraph) shall be included in all copies or substantial portions of the16* Software.17*18* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR19* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,20* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL21* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER22* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING23* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS24* IN THE SOFTWARE.25*/2627#include <X11/Xlib-xcb.h>28#include <X11/xshmfence.h>29#include <xcb/xcb.h>30#include <xcb/dri3.h>31#include <xcb/present.h>3233#include "wsi_common_x11.h"34#include "tu_private.h"3536VKAPI_ATTR VkBool32 VKAPI_CALL37tu_GetPhysicalDeviceXcbPresentationSupportKHR(38VkPhysicalDevice physicalDevice,39uint32_t queueFamilyIndex,40xcb_connection_t* connection,41xcb_visualid_t visual_id)42{43TU_FROM_HANDLE(tu_physical_device, device, physicalDevice);4445return wsi_get_physical_device_xcb_presentation_support(46&device->wsi_device,47queueFamilyIndex,48connection, visual_id);49}5051VKAPI_ATTR VkBool32 VKAPI_CALL52tu_GetPhysicalDeviceXlibPresentationSupportKHR(53VkPhysicalDevice physicalDevice,54uint32_t queueFamilyIndex,55Display* dpy,56VisualID visualID)57{58TU_FROM_HANDLE(tu_physical_device, device, physicalDevice);5960return wsi_get_physical_device_xcb_presentation_support(61&device->wsi_device,62queueFamilyIndex,63XGetXCBConnection(dpy), visualID);64}6566VKAPI_ATTR VkResult VKAPI_CALL67tu_CreateXcbSurfaceKHR(68VkInstance _instance,69const VkXcbSurfaceCreateInfoKHR* pCreateInfo,70const VkAllocationCallbacks* pAllocator,71VkSurfaceKHR* pSurface)72{73TU_FROM_HANDLE(tu_instance, instance, _instance);74const VkAllocationCallbacks *alloc;75assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR);7677if (pAllocator)78alloc = pAllocator;79else80alloc = &instance->vk.alloc;8182return wsi_create_xcb_surface(alloc, pCreateInfo, pSurface);83}8485VKAPI_ATTR VkResult VKAPI_CALL86tu_CreateXlibSurfaceKHR(87VkInstance _instance,88const VkXlibSurfaceCreateInfoKHR* pCreateInfo,89const VkAllocationCallbacks* pAllocator,90VkSurfaceKHR* pSurface)91{92TU_FROM_HANDLE(tu_instance, instance, _instance);93const VkAllocationCallbacks *alloc;9495assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR);9697if (pAllocator)98alloc = pAllocator;99else100alloc = &instance->vk.alloc;101102return wsi_create_xlib_surface(alloc, pCreateInfo, pSurface);103}104105106