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