| 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 "mesa_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 2 |
| 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 |
struct dri_drawable *(*createNewDrawable)(struct dri_screen *screen, |
| 67 |
const struct dri_config *config, |
| 68 |
void *loaderPrivate, |
| 69 |
__DRIkopperDrawableInfo *info); |
| 70 |
/* flags is a set of __DRI2_FLUSH_* flags */ |
| 71 |
int64_t (*swapBuffers)(struct dri_drawable *draw, uint32_t flush_flags); |
| 72 |
void (*setSwapInterval)(struct dri_drawable *drawable, int interval); |
| 73 |
int (*queryBufferAge)(struct dri_drawable *drawable); |
| 74 |
int64_t (*swapBuffersWithDamage)(struct dri_drawable *draw, uint32_t flush_flags, int nrects, const int *rects); |
| 75 |
}; |
| 76 |
|
| 77 |
/** |
| 78 |
* Kopper loader extension. |
| 79 |
*/ |
| 80 |
|
| 81 |
/** |
| 82 |
* struct for storage the union of all platform depdendent |
| 83 |
* Vk*SurfaceCreateInfo* type, all platform Vk*SurfaceCreateInfo* contains |
| 84 |
* uint32_t flags and at most two extra pointer besides bos header. |
| 85 |
* For example: |
| 86 |
* VkWin32SurfaceCreateInfoKHR contains flags, hinstance and hwnd besides bos header |
| 87 |
*/ |
| 88 |
|
| 89 |
struct kopper_vk_surface_create_storage { |
| 90 |
/* First two fields are copied from VkBaseOutStructure for easily access shared properties */ |
| 91 |
VkStructureType sType; |
| 92 |
struct VkBaseOutStructure *pNext; |
| 93 |
intptr_t padding[3]; |
| 94 |
}; |
| 95 |
|
| 96 |
struct kopper_loader_info { |
| 97 |
struct kopper_vk_surface_create_storage bos; |
| 98 |
int has_alpha; |
| 99 |
int initial_swap_interval; |
| 100 |
bool present_opaque; |
| 101 |
uint32_t compression; |
| 102 |
}; |
| 103 |
|
| 104 |
#define __DRI_KOPPER_LOADER "DRI_KopperLoader" |
| 105 |
#define __DRI_KOPPER_LOADER_VERSION 0 |
| 106 |
struct __DRIkopperLoaderExtensionRec { |
| 107 |
__DRIextension base; |
| 108 |
|
| 109 |
/* Asks the loader to fill in VkWhateverSurfaceCreateInfo etc. */ |
| 110 |
void (*SetSurfaceCreateInfo)(void *draw, struct kopper_loader_info *out); |
| 111 |
/* Asks the loader to fill in the drawable's width and height */ |
| 112 |
void (*GetDrawableInfo)(struct dri_drawable *draw, int *w, int *h, |
| 113 |
void *closure); |
| 114 |
}; |
| 115 |
#endif /* KOPPER_INTERFACE_H */ |