[Mesa-dev] [PATCH 09/15] anv/android: add ahardwarebuffer external memory properties

Lionel Landwerlin lionel.g.landwerlin at intel.com
Tue Dec 11 11:37:04 UTC 2018


On 27/11/2018 10:53, Tapani Pälli wrote:
> v2: have separate memory properties for android, set usage
>      flags for buffers correctly
>
> v3: code cleanup (Jason)
>      + limit maxArrayLayers to 1 for AHardwareBuffer based images
>
> v4: rebase to b43f955037c changes
>
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>


Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>


> ---
>   src/intel/vulkan/anv_formats.c | 41 ++++++++++++++++++++++++++++++++++
>   1 file changed, 41 insertions(+)
>
> diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
> index aa2093f7f15..972a6f98620 100644
> --- a/src/intel/vulkan/anv_formats.c
> +++ b/src/intel/vulkan/anv_formats.c
> @@ -973,6 +973,26 @@ static const VkExternalMemoryProperties prime_fd_props = {
>         VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
>   };
>   
> +static const VkExternalMemoryProperties android_buffer_props = {
> +   .externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
> +                             VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT,
> +   .exportFromImportedHandleTypes =
> +      VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
> +   .compatibleHandleTypes =
> +      VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
> +};
> +
> +
> +static const VkExternalMemoryProperties android_image_props = {
> +   .externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
> +                             VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT |
> +                             VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT,
> +   .exportFromImportedHandleTypes =
> +      VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
> +   .compatibleHandleTypes =
> +      VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
> +};
> +
>   VkResult anv_GetPhysicalDeviceImageFormatProperties2(
>       VkPhysicalDevice                            physicalDevice,
>       const VkPhysicalDeviceImageFormatInfo2*     base_info,
> @@ -982,6 +1002,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2(
>      const VkPhysicalDeviceExternalImageFormatInfo *external_info = NULL;
>      VkExternalImageFormatPropertiesKHR *external_props = NULL;
>      VkSamplerYcbcrConversionImageFormatProperties *ycbcr_props = NULL;
> +   struct VkAndroidHardwareBufferUsageANDROID *android_usage = NULL;
>      VkResult result;
>   
>      /* Extract input structs */
> @@ -1005,6 +1026,9 @@ VkResult anv_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:
>            anv_debug_ignored_stype(s->sType);
>            break;
> @@ -1016,6 +1040,15 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2(
>      if (result != VK_SUCCESS)
>         goto fail;
>   
> +   if (android_usage) {
> +      android_usage->androidHardwareBufferUsage =
> +         anv_ahw_usage_from_vk_usage(base_info->flags,
> +                                     base_info->usage);
> +
> +      /* Limit maxArrayLayers to 1 for AHardwareBuffer based images for now. */
> +      base_props->imageFormatProperties.maxArrayLayers = 1;
> +   }
> +
>      /* From the Vulkan 1.0.42 spec:
>       *
>       *    If handleType is 0, vkGetPhysicalDeviceImageFormatProperties2 will
> @@ -1029,6 +1062,10 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2(
>            if (external_props)
>               external_props->externalMemoryProperties = prime_fd_props;
>            break;
> +      case VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID:
> +         if (external_props)
> +            external_props->externalMemoryProperties = android_image_props;
> +         break;
>         default:
>            /* From the Vulkan 1.0.42 spec:
>             *
> @@ -1111,6 +1148,10 @@ void anv_GetPhysicalDeviceExternalBufferProperties(
>      case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT:
>         pExternalBufferProperties->externalMemoryProperties = prime_fd_props;
>         return;
> +   case VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID:
> +      pExternalBufferProperties->externalMemoryProperties =
> +         android_buffer_props;
> +      return;
>      default:
>         goto unsupported;
>      }




More information about the mesa-dev mailing list