On Wed, Aug 22, 2018 at 12:54 AM Tapani Pälli <tapani.pa...@intel.com>
wrote:

>
>
> On 21.08.2018 11:27, Tapani Pälli wrote:
> > v2: have separate memory properties for android, set usage
> >      flags for buffers correctly
> >
> > Signed-off-by: Tapani Pälli <tapani.pa...@intel.com>
> > ---
> >   src/intel/vulkan/anv_formats.c | 71
> +++++++++++++++++++++++++++++++++++++++++-
> >   1 file changed, 70 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/intel/vulkan/anv_formats.c
> b/src/intel/vulkan/anv_formats.c
> > index dc398306a70..56425a8b614 100644
> > --- a/src/intel/vulkan/anv_formats.c
> > +++ b/src/intel/vulkan/anv_formats.c
> > @@ -929,9 +929,31 @@ static const VkExternalMemoryProperties
> prime_fd_props = {
> >      .exportFromImportedHandleTypes =
> >         VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
> >         VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
> > +
> VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
> >      .compatibleHandleTypes =
> >         VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
> > -      VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
> > +      VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT |
> > +
> VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
> > +};
>
> Oops changes above are leftovers from prototyping stage and I've removed
> these changes locally. I only want to introduce android_buffer_props,
> android_image_props and use those like done below.
>

Thanks!  I was wondering about that...


> > +
> > +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(
> > @@ -943,8 +965,12 @@ VkResult
> anv_GetPhysicalDeviceImageFormatProperties2(
> >      const VkPhysicalDeviceExternalImageFormatInfo *external_info = NULL;
> >      VkExternalImageFormatPropertiesKHR *external_props = NULL;
> >      VkSamplerYcbcrConversionImageFormatProperties *ycbcr_props = NULL;
> > +   struct VkAndroidHardwareBufferUsageANDROID *android_usage = NULL;
> >      VkResult result;
> >
> > +   /* Only used on Android environment. */
> > +   (void) android_usage;
> > +
> >      /* Extract input structs */
> >      vk_foreach_struct_const(s, base_info->pNext) {
> >         switch (s->sType) {
> > @@ -966,6 +992,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;
> > @@ -977,6 +1006,38 @@ VkResult
> anv_GetPhysicalDeviceImageFormatProperties2(
> >      if (result != VK_SUCCESS)
> >         goto fail;
> >
> > +#ifdef ANDROID
> > +   if (android_usage) {
> > +      android_usage->androidHardwareBufferUsage = 0;
> > +
> > +      if (base_info->usage & VK_IMAGE_USAGE_SAMPLED_BIT)
> > +         android_usage->androidHardwareBufferUsage |=
> > +            AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
> > +
> > +      if (base_info->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)
> > +         android_usage->androidHardwareBufferUsage |=
> > +            AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
> > +
> > +      if (base_info->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
> > +         android_usage->androidHardwareBufferUsage |=
> > +            AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
> > +
> > +      if (base_info->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)
> > +         android_usage->androidHardwareBufferUsage |=
> > +            AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP;
> > +
> > +      if (base_info->flags & VK_IMAGE_CREATE_PROTECTED_BIT)
> > +         android_usage->androidHardwareBufferUsage |=
> > +            AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT;
> > +
> > +      /* No usage bits set - set at least one GPU usage. */
> > +      if (android_usage->androidHardwareBufferUsage == 0)
> > +         android_usage->androidHardwareBufferUsage =
> > +            AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
>

Give that you have this exact same code in an earlier patch, it's probably
worth having a vk_to_ahb_usage helper in anv_android.c so we aren't
duplicating it.


> > +   }
> > +#endif
> > +
> >      /* From the Vulkan 1.0.42 spec:
> >       *
> >       *    If handleType is 0, vkGetPhysicalDeviceImageFormatProperties2
> will
> > @@ -990,6 +1051,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:
> >             *
> > @@ -1072,6 +1137,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;
> >      }
> >
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to