radeonsi: split si_all_descriptors_begin_new_cs and rename functions
[mesa.git] / include / vulkan / vk_android_native_buffer.h
1 /*
2 * Copyright 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #ifndef __VK_ANDROID_NATIVE_BUFFER_H__
17 #define __VK_ANDROID_NATIVE_BUFFER_H__
18
19 /* MESA: A hack to avoid #ifdefs in driver code. */
20 #ifdef ANDROID
21 #include <system/window.h>
22 #include <cutils/native_handle.h>
23 #include <vulkan/vulkan.h>
24 #else
25 typedef void *buffer_handle_t;
26 #endif
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #define VK_ANDROID_native_buffer 1
33 #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER 11
34
35 /* NOTE ON VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 6
36 *
37 * This version of the extension transitions from gralloc0 to gralloc1 usage
38 * flags (int -> 2x uint64_t). The WSI implementation will temporarily continue
39 * to fill out deprecated fields in VkNativeBufferANDROID, and will call the
40 * deprecated vkGetSwapchainGrallocUsageANDROID if the new
41 * vkGetSwapchainGrallocUsage2ANDROID is not supported. This transitionary
42 * backwards-compatibility support is temporary, and will likely be removed in
43 * (along with all gralloc0 support) in a future release.
44 */
45 #define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 7
46 #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer"
47
48 #define VK_ANDROID_NATIVE_BUFFER_ENUM(type,id) ((type)(1000000000 + (1000 * (VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER - 1)) + (id)))
49 #define VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 0)
50 #define VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 1)
51 #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 2)
52
53 typedef enum VkSwapchainImageUsageFlagBitsANDROID {
54 VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_ANDROID = 0x00000001,
55 VK_SWAPCHAIN_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
56 } VkSwapchainImageUsageFlagBitsANDROID;
57 typedef VkFlags VkSwapchainImageUsageFlagsANDROID;
58 typedef struct {
59 VkStructureType sType; // must be VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID
60 const void* pNext;
61
62 // Buffer handle and stride returned from gralloc alloc()
63 buffer_handle_t handle;
64 int stride;
65
66 // Gralloc format and usage requested when the buffer was allocated.
67 int format;
68 int usage; // DEPRECATED in SPEC_VERSION 6
69
70 // -- Added in SPEC_VERSION 6 --
71 struct {
72 uint64_t consumer;
73 uint64_t producer;
74 } usage2;
75 } VkNativeBufferANDROID;
76
77 typedef struct {
78 VkStructureType sType; // must be VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID
79 const void* pNext;
80
81 VkSwapchainImageUsageFlagsANDROID usage;
82 } VkSwapchainImageCreateInfoANDROID;
83
84 typedef struct {
85 VkStructureType sType; // must be VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID
86 const void* pNext;
87
88 VkBool32 sharedImage;
89 } VkPhysicalDevicePresentationPropertiesANDROID;
90
91 // -- DEPRECATED in SPEC_VERSION 6 --
92 typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage);
93 // -- ADDED in SPEC_VERSION 6 --
94 typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage2ANDROID)(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainImageUsage, uint64_t* grallocConsumerUsage, uint64_t* grallocProducerUsage);
95 typedef VkResult (VKAPI_PTR *PFN_vkAcquireImageANDROID)(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence);
96 typedef VkResult (VKAPI_PTR *PFN_vkQueueSignalReleaseImageANDROID)(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd);
97
98 #ifndef VK_NO_PROTOTYPES
99 // -- DEPRECATED in SPEC_VERSION 6 --
100 VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageANDROID(
101 VkDevice device,
102 VkFormat format,
103 VkImageUsageFlags imageUsage,
104 int* grallocUsage
105 );
106 // -- ADDED in SPEC_VERSION 6 --
107 VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID(
108 VkDevice device,
109 VkFormat format,
110 VkImageUsageFlags imageUsage,
111 VkSwapchainImageUsageFlagsANDROID swapchainImageUsage,
112 uint64_t* grallocConsumerUsage,
113 uint64_t* grallocProducerUsage
114 );
115 VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID(
116 VkDevice device,
117 VkImage image,
118 int nativeFenceFd,
119 VkSemaphore semaphore,
120 VkFence fence
121 );
122 VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalReleaseImageANDROID(
123 VkQueue queue,
124 uint32_t waitSemaphoreCount,
125 const VkSemaphore* pWaitSemaphores,
126 VkImage image,
127 int* pNativeFenceFd
128 );
129 #endif
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif // __VK_ANDROID_NATIVE_BUFFER_H__