2 * Copyright 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __VK_ANDROID_NATIVE_BUFFER_H__
18 #define __VK_ANDROID_NATIVE_BUFFER_H__
20 /* MESA: A hack to avoid #ifdefs in driver code. */
22 #include <system/window.h>
23 #include <vulkan/vulkan.h>
25 typedef void *buffer_handle_t
;
32 #define VK_ANDROID_native_buffer 1
34 #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER 11
35 #define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 5
36 #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer"
38 #define VK_ANDROID_NATIVE_BUFFER_ENUM(type,id) ((type)(1000000000 + (1000 * (VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER - 1)) + (id)))
39 #define VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 0)
42 VkStructureType sType
; // must be VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID
45 // Buffer handle and stride returned from gralloc alloc()
46 buffer_handle_t handle
;
49 // Gralloc format and usage requested when the buffer was allocated.
52 } VkNativeBufferANDROID
;
54 typedef VkResult (VKAPI_PTR
*PFN_vkGetSwapchainGrallocUsageANDROID
)(VkDevice device
, VkFormat format
, VkImageUsageFlags imageUsage
, int* grallocUsage
);
55 typedef VkResult (VKAPI_PTR
*PFN_vkAcquireImageANDROID
)(VkDevice device
, VkImage image
, int nativeFenceFd
, VkSemaphore semaphore
, VkFence fence
);
56 typedef VkResult (VKAPI_PTR
*PFN_vkQueueSignalReleaseImageANDROID
)(VkQueue queue
, uint32_t waitSemaphoreCount
, const VkSemaphore
* pWaitSemaphores
, VkImage image
, int* pNativeFenceFd
);
58 #ifndef VK_NO_PROTOTYPES
59 VKAPI_ATTR VkResult VKAPI_CALL
vkGetSwapchainGrallocUsageANDROID(
62 VkImageUsageFlags imageUsage
,
65 VKAPI_ATTR VkResult VKAPI_CALL
vkAcquireImageANDROID(
69 VkSemaphore semaphore
,
72 VKAPI_ATTR VkResult VKAPI_CALL
vkQueueSignalReleaseImageANDROID(
74 uint32_t waitSemaphoreCount
,
75 const VkSemaphore
* pWaitSemaphores
,
80 VKAPI_ATTR VkResult VKAPI_CALL
vkImportNativeFenceANDROID(
82 VkSemaphore semaphore
,
85 VKAPI_ATTR VkResult VKAPI_CALL
vkQueueSignalNativeFenceANDROID(
96 #endif // __VK_ANDROID_NATIVE_BUFFER_H__