Path: blob/21.2-virgl/src/virtio/vulkan/vn_android.h
4560 views
/*1* Copyright 2021 Google LLC2* SPDX-License-Identifier: MIT3*4* based in part on anv and radv which are:5* Copyright © 2015 Intel Corporation6* Copyright © 2016 Red Hat7* Copyright © 2016 Bas Nieuwenhuizen8*/910#ifndef VN_ANDROID_H11#define VN_ANDROID_H1213#include "vn_common.h"1415#include <vulkan/vk_android_native_buffer.h>16#include <vulkan/vulkan.h>17#include <vulkan/vulkan_android.h>1819/* venus implements VK_ANDROID_native_buffer up to spec version 7 */20#define VN_ANDROID_NATIVE_BUFFER_SPEC_VERSION 72122#ifdef ANDROID2324static inline const VkNativeBufferANDROID *25vn_android_find_native_buffer(const VkImageCreateInfo *create_info)26{27return vk_find_struct_const(create_info->pNext, NATIVE_BUFFER_ANDROID);28}2930VkResult31vn_android_image_from_anb(struct vn_device *dev,32const VkImageCreateInfo *image_info,33const VkNativeBufferANDROID *anb_info,34const VkAllocationCallbacks *alloc,35struct vn_image **out_img);3637bool38vn_android_get_drm_format_modifier_info(39const VkPhysicalDeviceImageFormatInfo2 *format_info,40VkPhysicalDeviceImageDrmFormatModifierInfoEXT *out_info);4142uint64_t43vn_android_get_ahb_usage(const VkImageUsageFlags usage,44const VkImageCreateFlags flags);4546VkResult47vn_android_image_from_ahb(struct vn_device *dev,48const VkImageCreateInfo *create_info,49const VkAllocationCallbacks *alloc,50struct vn_image **out_img);5152VkResult53vn_android_device_import_ahb(struct vn_device *dev,54struct vn_device_memory *mem,55const VkMemoryAllocateInfo *alloc_info,56const VkAllocationCallbacks *alloc,57struct AHardwareBuffer *ahb);5859VkResult60vn_android_device_allocate_ahb(struct vn_device *dev,61struct vn_device_memory *mem,62const VkMemoryAllocateInfo *alloc_info,63const VkAllocationCallbacks *alloc);6465void66vn_android_release_ahb(struct AHardwareBuffer *ahb);6768VkFormat69vn_android_drm_format_to_vk_format(uint32_t format);7071VkResult72vn_android_buffer_from_ahb(struct vn_device *dev,73const VkBufferCreateInfo *create_info,74const VkAllocationCallbacks *alloc,75struct vn_buffer **out_buf);7677VkResult78vn_android_init_ahb_buffer_memory_type_bits(struct vn_device *dev);7980#else8182static inline const VkNativeBufferANDROID *83vn_android_find_native_buffer(UNUSED const VkImageCreateInfo *create_info)84{85return NULL;86}8788static inline VkResult89vn_android_image_from_anb(UNUSED struct vn_device *dev,90UNUSED const VkImageCreateInfo *image_info,91UNUSED const VkNativeBufferANDROID *anb_info,92UNUSED const VkAllocationCallbacks *alloc,93UNUSED struct vn_image **out_img)94{95return VK_ERROR_OUT_OF_HOST_MEMORY;96}9798static inline bool99vn_android_get_drm_format_modifier_info(100UNUSED const VkPhysicalDeviceImageFormatInfo2 *format_info,101UNUSED VkPhysicalDeviceImageDrmFormatModifierInfoEXT *out_info)102{103return false;104}105106static inline uint64_t107vn_android_get_ahb_usage(UNUSED const VkImageUsageFlags usage,108UNUSED const VkImageCreateFlags flags)109{110return 0;111}112113static inline VkResult114vn_android_image_from_ahb(UNUSED struct vn_device *dev,115UNUSED const VkImageCreateInfo *create_info,116UNUSED const VkAllocationCallbacks *alloc,117UNUSED struct vn_image **out_img)118{119return VK_ERROR_OUT_OF_HOST_MEMORY;120}121122static inline VkResult123vn_android_device_import_ahb(UNUSED struct vn_device *dev,124UNUSED struct vn_device_memory *mem,125UNUSED const VkMemoryAllocateInfo *alloc_info,126UNUSED const VkAllocationCallbacks *alloc,127UNUSED struct AHardwareBuffer *ahb)128{129return VK_ERROR_OUT_OF_HOST_MEMORY;130}131132static inline VkResult133vn_android_device_allocate_ahb(UNUSED struct vn_device *dev,134UNUSED struct vn_device_memory *mem,135UNUSED const VkMemoryAllocateInfo *alloc_info,136UNUSED const VkAllocationCallbacks *alloc)137{138return VK_ERROR_OUT_OF_HOST_MEMORY;139}140141static inline void142vn_android_release_ahb(UNUSED struct AHardwareBuffer *ahb)143{144return;145}146147static inline VkFormat148vn_android_drm_format_to_vk_format(UNUSED uint32_t format)149{150return VK_FORMAT_UNDEFINED;151}152153static inline VkResult154vn_android_buffer_from_ahb(UNUSED struct vn_device *dev,155UNUSED const VkBufferCreateInfo *create_info,156UNUSED const VkAllocationCallbacks *alloc,157UNUSED struct vn_buffer **out_buf)158{159return VK_ERROR_OUT_OF_HOST_MEMORY;160}161162static inline VkResult163vn_android_init_ahb_buffer_memory_type_bits(UNUSED struct vn_device *dev)164{165return VK_ERROR_FEATURE_NOT_PRESENT;166}167168#endif /* ANDROID */169170#endif /* VN_ANDROID_H */171172173