vk_android_native_buffer.h revision 061938022b3f5f37f7aaebf7ccc8ac20bf4dbf97
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 17#ifndef __VK_ANDROID_NATIVE_BUFFER_H__ 18#define __VK_ANDROID_NATIVE_BUFFER_H__ 19 20#include <system/window.h> 21#include <vulkan/vulkan.h> 22 23#ifdef __cplusplus 24extern "C" { 25#endif 26 27#define VK_ANDROID_native_buffer 1 28 29#define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER 11 30#define VK_ANDROID_NATIVE_BUFFER_REVISION 4 31#define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer" 32 33#define VK_ANDROID_NATIVE_BUFFER_ENUM(type,id) ((type)(1000000000 + (1000 * (VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER - 1)) + (id))) 34#define VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 0) 35 36typedef struct { 37 VkStructureType sType; // must be VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID 38 const void* pNext; 39 40 // Buffer handle and stride returned from gralloc alloc() 41 buffer_handle_t handle; 42 int stride; 43 44 // Gralloc format and usage requested when the buffer was allocated. 45 int format; 46 int usage; 47} VkNativeBufferANDROID; 48 49typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage); 50typedef VkResult (VKAPI_PTR *PFN_vkAcquireImageANDROID)(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence); 51typedef VkResult (VKAPI_PTR *PFN_vkQueueSignalReleaseImageANDROID)(VkQueue queue, VkImage image, int* pNativeFenceFd); 52// -- DEPRECATED -- 53typedef VkResult (VKAPI_PTR *PFN_vkImportNativeFenceANDROID)(VkDevice device, VkSemaphore semaphore, int nativeFenceFd); 54typedef VkResult (VKAPI_PTR *PFN_vkQueueSignalNativeFenceANDROID)(VkQueue queue, int* pNativeFenceFd); 55// ---------------- 56 57#ifdef VK_PROTOTYPES 58VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageANDROID( 59 VkDevice device, 60 VkFormat format, 61 VkImageUsageFlags imageUsage, 62 int* grallocUsage 63); 64VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID( 65 VkDevice device, 66 VkImage image, 67 int nativeFenceFd, 68 VkSemaphore semaphore, 69 VkFence fence 70); 71VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalReleaseImageANDROID( 72 VkQueue queue, 73 VkImage image, 74 int* pNativeFenceFd 75); 76// -- DEPRECATED -- 77VKAPI_ATTR VkResult VKAPI_CALL vkImportNativeFenceANDROID( 78 VkDevice device, 79 VkSemaphore semaphore, 80 int nativeFenceFd 81); 82VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalNativeFenceANDROID( 83 VkQueue queue, 84 int* pNativeFenceFd 85); 86// ---------------- 87#endif 88 89#ifdef __cplusplus 90} 91#endif 92 93#endif // __VK_ANDROID_NATIVE_BUFFER_H__ 94