1/* 2 * Copyright 2020 Red Hat, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24/* 25 * In principle this could all go in dri_interface.h, but: 26 * - I want type safety in here, but I don't want to require vulkan.h from 27 * dri_interface.h 28 * - I don't especially want this to be an interface outside of Mesa itself 29 * - Ideally dri_interface.h wouldn't even be a thing anymore 30 * 31 * So instead let's just keep this as a Mesa-internal detail. 32 */ 33 34#ifndef KOPPER_INTERFACE_H 35#define KOPPER_INTERFACE_H 36 37#include <GL/internal/dri_interface.h> 38#include <vulkan/vulkan.h> 39#ifdef VK_USE_PLATFORM_XCB_KHR 40#include <xcb/xcb.h> 41#include <vulkan/vulkan_xcb.h> 42#endif 43#ifdef VK_USE_PLATFORM_WAYLAND_KHR 44#include <vulkan/vulkan_wayland.h> 45#endif 46#ifdef VK_USE_PLATFORM_WIN32_KHR 47#include <vulkan/vulkan_win32.h> 48#endif 49 50typedef struct __DRIkopperExtensionRec __DRIkopperExtension; 51typedef struct __DRIkopperLoaderExtensionRec __DRIkopperLoaderExtension; 52 53/** 54 * This extension defines the core GL-atop-VK functionality. This is used by the 55 * zink driver to implement GL (or other APIs) natively atop Vulkan, without 56 * relying on a particular window system or DRI protocol. 57 */ 58#define __DRI_KOPPER "DRI_Kopper" 59#define __DRI_KOPPER_VERSION 1 60 61struct kopper_surface; 62 63struct __DRIkopperExtensionRec { 64 __DRIextension base; 65 66 /* This is called by a kopper-aware loader in preference to the one 67 * in __DRI_DRISW. The additional fourth argument sets whether the winsys 68 * drawable is a pixmap. This matters because swapchains correspond to 69 * on-screen surfaces (eg X11 window) and trying to create a swapchain for 70 * a pixmap is undefined. 71 */ 72 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen, 73 const __DRIconfig *config, 74 void *loaderPrivate, 75 int pixmap); 76 int64_t (*swapBuffers)(__DRIdrawable *draw); 77 void (*setSwapInterval)(__DRIdrawable *drawable, int interval); 78 int (*queryBufferAge)(__DRIdrawable *drawable); 79}; 80 81/** 82 * Kopper loader extension. 83 */ 84 85struct kopper_loader_info { 86 union { 87 VkBaseOutStructure bos; 88#ifdef VK_USE_PLATFORM_XCB_KHR 89 VkXcbSurfaceCreateInfoKHR xcb; 90#endif 91#ifdef VK_USE_PLATFORM_WAYLAND_KHR 92 VkWaylandSurfaceCreateInfoKHR wl; 93#endif 94#ifdef VK_USE_PLATFORM_WIN32_KHR 95 VkWin32SurfaceCreateInfoKHR win32; 96#endif 97 }; 98 int has_alpha; 99 int initial_swap_interval; 100}; 101 102#define __DRI_KOPPER_LOADER "DRI_KopperLoader" 103#define __DRI_KOPPER_LOADER_VERSION 0 104struct __DRIkopperLoaderExtensionRec { 105 __DRIextension base; 106 107 /* Asks the loader to fill in VkWhateverSurfaceCreateInfo etc. */ 108 void (*SetSurfaceCreateInfo)(void *draw, struct kopper_loader_info *out); 109 /* Asks the loader to fill in the drawable's width and height */ 110 void (*GetDrawableInfo)(__DRIdrawable *draw, int *w, int *h, 111 void *closure); 112}; 113#endif /* KOPPER_INTERFACE_H */ 114