1 /* 2 * Copyright © 2016 Red Hat. 3 * Copyright © 2016 Bas Nieuwenhuizen 4 * 5 * based in part on anv driver which is: 6 * Copyright © 2015 Intel Corporation 7 * 8 * SPDX-License-Identifier: MIT 9 */ 10 11 #ifndef RADV_ANDROID_H 12 #define RADV_ANDROID_H 13 14 #include <stdbool.h> 15 16 #include <vulkan/vulkan.h> 17 18 #include <vulkan/vk_android_native_buffer.h> 19 #include <vulkan/vulkan_android.h> 20 21 #include "vk_android.h" 22 23 /* Helper to determine if we should compile 24 * any of the Android AHB support. 25 * 26 * To actually enable the ext we also need 27 * the necessary kernel support. 28 */ 29 #if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26 30 #define RADV_SUPPORT_ANDROID_HARDWARE_BUFFER 1 31 #include <vndk/hardware_buffer.h> 32 #else 33 #define RADV_SUPPORT_ANDROID_HARDWARE_BUFFER 0 34 #endif 35 36 struct radv_device; 37 struct radv_device_memory; 38 39 VkResult radv_image_from_gralloc(VkDevice device_h, const VkImageCreateInfo *base_info, 40 const VkNativeBufferANDROID *gralloc_info, const VkAllocationCallbacks *alloc, 41 VkImage *out_image_h); 42 43 unsigned radv_ahb_format_for_vk_format(VkFormat vk_format); 44 45 VkFormat radv_select_android_external_format(const void *next, VkFormat default_format); 46 47 VkResult radv_import_ahb_memory(struct radv_device *device, struct radv_device_memory *mem, unsigned priority, 48 const VkImportAndroidHardwareBufferInfoANDROID *info); 49 50 VkResult radv_create_ahb_memory(struct radv_device *device, struct radv_device_memory *mem, unsigned priority, 51 const VkMemoryAllocateInfo *pAllocateInfo); 52 53 bool radv_android_gralloc_supports_format(VkFormat format, VkImageUsageFlagBits usage); 54 55 #endif /* RADV_ANDROID_H */ 56