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_core.h>
40 typedef struct __DRIkopperExtensionRec __DRIkopperExtension;
41 typedef struct __DRIkopperLoaderExtensionRec __DRIkopperLoaderExtension;
42 typedef struct __DRIkopperDrawableInfoRec __DRIkopperDrawableInfo;
45 * This extension defines the core GL-atop-VK functionality. This is used by the
46 * zink driver to implement GL (or other APIs) natively atop Vulkan, without
47 * relying on a particular window system or DRI protocol.
49 #define __DRI_KOPPER "DRI_Kopper"
50 #define __DRI_KOPPER_VERSION 1
52 struct __DRIkopperDrawableInfoRec {
53 bool multiplanes_available;
57 struct __DRIkopperExtensionRec {
60 /* This is called by a kopper-aware loader in preference to the one
61 * in __DRI_DRISW. The additional fourth argument sets whether the winsys
62 * drawable is a pixmap. This matters because swapchains correspond to
63 * on-screen surfaces (eg X11 window) and trying to create a swapchain for
64 * a pixmap is undefined.
66 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
67 const __DRIconfig *config,
69 __DRIkopperDrawableInfo *info);
70 /* flags is a set of __DRI2_FLUSH_* flags */
71 int64_t (*swapBuffers)(__DRIdrawable *draw, uint32_t flush_flags);
72 void (*setSwapInterval)(__DRIdrawable *drawable, int interval);
73 int (*queryBufferAge)(__DRIdrawable *drawable);
77 * Kopper loader extension.
81 * struct for storage the union of all platform depdendent
82 * Vk*SurfaceCreateInfo* type, all platform Vk*SurfaceCreateInfo* contains
83 * uint32_t flags and at most two extra pointer besides bos header.
85 * VkWin32SurfaceCreateInfoKHR contains flags, hinstance and hwnd besides bos header
88 struct kopper_vk_surface_create_storage {
89 /* First two fields are copied from VkBaseOutStructure for easily access shared properties */
90 VkStructureType sType;
91 struct VkBaseOutStructure *pNext;
95 struct kopper_loader_info {
96 struct kopper_vk_surface_create_storage bos;
98 int initial_swap_interval;
101 #define __DRI_KOPPER_LOADER "DRI_KopperLoader"
102 #define __DRI_KOPPER_LOADER_VERSION 0
103 struct __DRIkopperLoaderExtensionRec {
106 /* Asks the loader to fill in VkWhateverSurfaceCreateInfo etc. */
107 void (*SetSurfaceCreateInfo)(void *draw, struct kopper_loader_info *out);
108 /* Asks the loader to fill in the drawable's width and height */
109 void (*GetDrawableInfo)(__DRIdrawable *draw, int *w, int *h,
112 #endif /* KOPPER_INTERFACE_H */