diff options
-rw-r--r-- | src/amd/vulkan/radv_android.c | 26 | ||||
-rw-r--r-- | src/amd/vulkan/radv_formats.c | 13 | ||||
-rw-r--r-- | src/amd/vulkan/radv_private.h | 4 |
3 files changed, 43 insertions, 0 deletions
diff --git a/src/amd/vulkan/radv_android.c b/src/amd/vulkan/radv_android.c index df4812257e6..f3cbe2d4bd2 100644 --- a/src/amd/vulkan/radv_android.c +++ b/src/amd/vulkan/radv_android.c @@ -410,6 +410,32 @@ vk_format_from_android(unsigned android_format, unsigned android_usage) } } +uint64_t +radv_ahb_usage_from_vk_usage(const VkImageCreateFlags vk_create, + const VkImageUsageFlags vk_usage) +{ + uint64_t ahb_usage = 0; + if (vk_usage & VK_IMAGE_USAGE_SAMPLED_BIT) + ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE; + + if (vk_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) + ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE; + + if (vk_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) + ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT; + + if (vk_create & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) + ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP; + + if (vk_create & VK_IMAGE_CREATE_PROTECTED_BIT) + ahb_usage |= AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT; + + /* No usage bits set - set at least one GPU usage. */ + if (ahb_usage == 0) + ahb_usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE; + return ahb_usage; +} + static VkResult get_ahb_buffer_format_properties( VkDevice device_h, diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c index e68f7c9040f..c6e01d66fa6 100644 --- a/src/amd/vulkan/radv_formats.c +++ b/src/amd/vulkan/radv_formats.c @@ -1345,6 +1345,7 @@ VkResult radv_GetPhysicalDeviceImageFormatProperties2( RADV_FROM_HANDLE(radv_physical_device, physical_device, physicalDevice); const VkPhysicalDeviceExternalImageFormatInfo *external_info = NULL; VkExternalImageFormatProperties *external_props = NULL; + struct VkAndroidHardwareBufferUsageANDROID *android_usage = NULL; VkSamplerYcbcrConversionImageFormatProperties *ycbcr_props = NULL; VkResult result; @@ -1373,11 +1374,23 @@ VkResult radv_GetPhysicalDeviceImageFormatProperties2( case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES: ycbcr_props = (void *) s; break; + case VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID: + android_usage = (void *) s; + break; default: break; } } + bool ahb_supported = physical_device->supported_extensions.ANDROID_external_memory_android_hardware_buffer; + if (android_usage && ahb_supported) { +#if RADV_SUPPORT_ANDROID_HARDWARE_BUFFER + android_usage->androidHardwareBufferUsage = + radv_ahb_usage_from_vk_usage(base_info->flags, + base_info->usage); +#endif + } + /* From the Vulkan 1.0.97 spec: * * If handleType is 0, vkGetPhysicalDeviceImageFormatProperties2 will diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 8674d1bd931..6ad055aacdc 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -1924,6 +1924,10 @@ radv_image_from_gralloc(VkDevice device_h, const VkNativeBufferANDROID *gralloc_info, const VkAllocationCallbacks *alloc, VkImage *out_image_h); +uint64_t +radv_ahb_usage_from_vk_usage(const VkImageCreateFlags vk_create, + const VkImageUsageFlags vk_usage); + struct radv_image_view_extra_create_info { bool disable_compression; |