Path: blob/21.2-virgl/include/vulkan/vk_android_native_buffer.h
4550 views
/*1* Copyright 2015 The Android Open Source Project2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/15#ifndef __VK_ANDROID_NATIVE_BUFFER_H__16#define __VK_ANDROID_NATIVE_BUFFER_H__1718/* MESA: A hack to avoid #ifdefs in driver code. */19#ifdef ANDROID20#include <cutils/native_handle.h>21#include <vulkan/vulkan.h>2223#if ANDROID_API_LEVEL < 2824/* buffer_handle_t was defined in the deprecated system/window.h */25typedef const native_handle_t *buffer_handle_t;26#endif2728#else29typedef void *buffer_handle_t;30#endif3132#ifdef __cplusplus33extern "C" {34#endif3536#define VK_ANDROID_native_buffer 137#define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER 113839/* NOTE ON VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 640*41* This version of the extension transitions from gralloc0 to gralloc1 usage42* flags (int -> 2x uint64_t). The WSI implementation will temporarily continue43* to fill out deprecated fields in VkNativeBufferANDROID, and will call the44* deprecated vkGetSwapchainGrallocUsageANDROID if the new45* vkGetSwapchainGrallocUsage2ANDROID is not supported. This transitionary46* backwards-compatibility support is temporary, and will likely be removed in47* (along with all gralloc0 support) in a future release.48*/49#define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 750#define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer"5152#define VK_ANDROID_NATIVE_BUFFER_ENUM(type,id) ((type)(1000000000 + (1000 * (VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER - 1)) + (id)))53#define VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 0)54#define VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 1)55#define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 2)5657typedef enum VkSwapchainImageUsageFlagBitsANDROID {58VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_ANDROID = 0x00000001,59VK_SWAPCHAIN_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF60} VkSwapchainImageUsageFlagBitsANDROID;61typedef VkFlags VkSwapchainImageUsageFlagsANDROID;62typedef struct {63VkStructureType sType; // must be VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID64const void* pNext;6566// Buffer handle and stride returned from gralloc alloc()67buffer_handle_t handle;68int stride;6970// Gralloc format and usage requested when the buffer was allocated.71int format;72int usage; // DEPRECATED in SPEC_VERSION 67374// -- Added in SPEC_VERSION 6 --75struct {76uint64_t consumer;77uint64_t producer;78} usage2;79} VkNativeBufferANDROID;8081typedef struct {82VkStructureType sType; // must be VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID83const void* pNext;8485VkSwapchainImageUsageFlagsANDROID usage;86} VkSwapchainImageCreateInfoANDROID;8788typedef struct {89VkStructureType sType; // must be VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID90const void* pNext;9192VkBool32 sharedImage;93} VkPhysicalDevicePresentationPropertiesANDROID;9495// -- DEPRECATED in SPEC_VERSION 6 --96typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage);97// -- ADDED in SPEC_VERSION 6 --98typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage2ANDROID)(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainImageUsage, uint64_t* grallocConsumerUsage, uint64_t* grallocProducerUsage);99typedef VkResult (VKAPI_PTR *PFN_vkAcquireImageANDROID)(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence);100typedef VkResult (VKAPI_PTR *PFN_vkQueueSignalReleaseImageANDROID)(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd);101102#ifndef VK_NO_PROTOTYPES103// -- DEPRECATED in SPEC_VERSION 6 --104VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageANDROID(105VkDevice device,106VkFormat format,107VkImageUsageFlags imageUsage,108int* grallocUsage109);110// -- ADDED in SPEC_VERSION 6 --111VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID(112VkDevice device,113VkFormat format,114VkImageUsageFlags imageUsage,115VkSwapchainImageUsageFlagsANDROID swapchainImageUsage,116uint64_t* grallocConsumerUsage,117uint64_t* grallocProducerUsage118);119VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID(120VkDevice device,121VkImage image,122int nativeFenceFd,123VkSemaphore semaphore,124VkFence fence125);126VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalReleaseImageANDROID(127VkQueue queue,128uint32_t waitSemaphoreCount,129const VkSemaphore* pWaitSemaphores,130VkImage image,131int* pNativeFenceFd132);133#endif134135#ifdef __cplusplus136}137#endif138139#endif // __VK_ANDROID_NATIVE_BUFFER_H__140141142