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_core.h> 39 40 typedef struct __DRIkopperExtensionRec __DRIkopperExtension; 41 typedef struct __DRIkopperLoaderExtensionRec __DRIkopperLoaderExtension; 42 typedef struct __DRIkopperDrawableInfoRec __DRIkopperDrawableInfo; 43 44 /** 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. 48 */ 49 #define __DRI_KOPPER "DRI_Kopper" 50 #define __DRI_KOPPER_VERSION 1 51 52 struct __DRIkopperDrawableInfoRec { 53 bool multiplanes_available; 54 int is_pixmap; 55 }; 56 57 struct __DRIkopperExtensionRec { 58 __DRIextension base; 59 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. 65 */ 66 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen, 67 const __DRIconfig *config, 68 void *loaderPrivate, 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); 74 }; 75 76 /** 77 * Kopper loader extension. 78 */ 79 80 /** 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. 84 * For example: 85 * VkWin32SurfaceCreateInfoKHR contains flags, hinstance and hwnd besides bos header 86 */ 87 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; 92 intptr_t padding[3]; 93 }; 94 95 struct kopper_loader_info { 96 struct kopper_vk_surface_create_storage bos; 97 int has_alpha; 98 int initial_swap_interval; 99 }; 100 101 #define __DRI_KOPPER_LOADER "DRI_KopperLoader" 102 #define __DRI_KOPPER_LOADER_VERSION 0 103 struct __DRIkopperLoaderExtensionRec { 104 __DRIextension base; 105 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, 110 void *closure); 111 }; 112 #endif /* KOPPER_INTERFACE_H */ 113