148e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand/*
248e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * Copyright © 2015 Intel Corporation
348e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand *
448e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * Permission is hereby granted, free of charge, to any person obtaining a
548e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * copy of this software and associated documentation files (the "Software"),
648e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * to deal in the Software without restriction, including without limitation
748e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * the rights to use, copy, modify, merge, publish, distribute, sublicense,
848e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * and/or sell copies of the Software, and to permit persons to whom the
948e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * Software is furnished to do so, subject to the following conditions:
1048e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand *
1148e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * The above copyright notice and this permission notice (including the next
1248e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * paragraph) shall be included in all copies or substantial portions of the
1348e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * Software.
1448e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand *
1548e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1648e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1748e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1848e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1948e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2048e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2148e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand * IN THE SOFTWARE.
2248e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand */
2348e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand
2448e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand#include <wayland-client.h>
2548e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand#include <wayland-drm-client-protocol.h>
2648e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand
27be94a23b4402e1562eebc6aa6c485be2a2506a79Jason Ekstrand#include "vk_format_info.h"
2848e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand#include <util/hash_table.h>
2948e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand
30971523410fd2235e13c617b6a1569f70486258d7Dave Airlie#include "wsi_common_wayland.h"
31ec0bc14a700c2503d834ac0763f4cfbe312998faDave Airlie#include "anv_private.h"
3248e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand
33d666487dc6c46ea6ad7ca71fd0b0b1e099e5da0fJason EkstrandVkBool32 anv_GetPhysicalDeviceWaylandPresentationSupportKHR(
34d666487dc6c46ea6ad7ca71fd0b0b1e099e5da0fJason Ekstrand    VkPhysicalDevice                            physicalDevice,
35d666487dc6c46ea6ad7ca71fd0b0b1e099e5da0fJason Ekstrand    uint32_t                                    queueFamilyIndex,
36d666487dc6c46ea6ad7ca71fd0b0b1e099e5da0fJason Ekstrand    struct wl_display*                          display)
3748e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand{
38d666487dc6c46ea6ad7ca71fd0b0b1e099e5da0fJason Ekstrand   ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
39d666487dc6c46ea6ad7ca71fd0b0b1e099e5da0fJason Ekstrand
40971523410fd2235e13c617b6a1569f70486258d7Dave Airlie   return wsi_wl_get_presentation_support(&physical_device->wsi_device, display);
4148e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand}
4248e87c01630b8559e4e5ee669b77b8b1d10fd623Jason Ekstrand
43507722b882df63f6c275d110060b3d4ad09665d1Dave AirlieVkResult anv_CreateWaylandSurfaceKHR(
44507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie    VkInstance                                  _instance,
45507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie    const VkWaylandSurfaceCreateInfoKHR*        pCreateInfo,
46507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie    const VkAllocationCallbacks*                pAllocator,
47507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie    VkSurfaceKHR*                               pSurface)
48507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie{
49507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie   ANV_FROM_HANDLE(anv_instance, instance, _instance);
50507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie   const VkAllocationCallbacks *alloc;
51507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie   assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR);
52507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie
53507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie   if (pAllocator)
54507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie      alloc = pAllocator;
55507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie   else
56507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie      alloc = &instance->alloc;
57507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie
58ec0bc14a700c2503d834ac0763f4cfbe312998faDave Airlie   return wsi_create_wl_surface(alloc, pCreateInfo, pSurface);
59507722b882df63f6c275d110060b3d4ad09665d1Dave Airlie}
60