2 * Copyright 2020 Red Hat, Inc.
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:
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
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.
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
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
31 * So instead let's just keep this as a Mesa-internal detail.
34 #ifndef KOPPER_INTERFACE_H
35 #define KOPPER_INTERFACE_H
37 #include <GL/internal/dri_interface.h>
38 #include <vulkan/vulkan.h>
39 #ifdef VK_USE_PLATFORM_XCB_KHR
41 #include <vulkan/vulkan_xcb.h>
43 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
44 #include <vulkan/vulkan_wayland.h>
46 #ifdef VK_USE_PLATFORM_WIN32_KHR
47 #include <vulkan/vulkan_win32.h>
50 typedef struct __DRIkopperExtensionRec __DRIkopperExtension;
51 typedef struct __DRIkopperLoaderExtensionRec __DRIkopperLoaderExtension;
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.
58 #define __DRI_KOPPER "DRI_Kopper"
59 #define __DRI_KOPPER_VERSION 1
61 struct kopper_surface;
63 struct __DRIkopperExtensionRec {
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.
72 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
73 const __DRIconfig *config,
76 int64_t (*swapBuffers)(__DRIdrawable *draw);
77 void (*setSwapInterval)(__DRIdrawable *drawable, int interval);
78 int (*queryBufferAge)(__DRIdrawable *drawable);
82 * Kopper loader extension.
85 struct kopper_loader_info {
87 VkBaseOutStructure bos;
88 #ifdef VK_USE_PLATFORM_XCB_KHR
89 VkXcbSurfaceCreateInfoKHR xcb;
91 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
92 VkWaylandSurfaceCreateInfoKHR wl;
94 #ifdef VK_USE_PLATFORM_WIN32_KHR
95 VkWin32SurfaceCreateInfoKHR win32;
99 int initial_swap_interval;
102 #define __DRI_KOPPER_LOADER "DRI_KopperLoader"
103 #define __DRI_KOPPER_LOADER_VERSION 0
104 struct __DRIkopperLoaderExtensionRec {
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,
113 #endif /* KOPPER_INTERFACE_H */