[Mesa-dev] [PATCH] Vulkan: Add VK_ANDROID_native_buffer to device extension list

Jason Ekstrand jason at jlekstrand.net
Wed Mar 1 05:25:52 UTC 2017


On Tue, Feb 28, 2017 at 9:21 PM, Xu, Randy <randy.xu at intel.com> wrote:

> Hi, Tapani
>
>
>
> According to https://source.android.com/devices/graphics/implement-
> vulkan.html
> "Window System Integration (WSI) extensions are exported by the loader and
> primarily implemented in it rather than the driver.". Also, Google provides
> the stubhal.c in frameworks/native/vulkan/libvulkan, the
> VK_ANDROID_native_buffer functions are implemented there as a sample.
>
> The reason I guess is that VK_ANDROID_native_buffer implementation needs
> to access Gralloc HAL data structure, but mesa driver should have no
> dependency to Android HAL, which is required by HAL Binderization.
>

I don't know enough of the details of how gralloc works on IA.  I would
have assumed that the fd is just a prime buffer which should be easy enough
for us to handle.  That said, if it's more complicated and requires bits
that don't have a stable API somewhere, maybe it's best left out-of-tree.
I have no real opinion there.


> This patch doesn’t expose VK_ANDROID_native_buffer extension in driver (as
> the function is not implemented here), but avoid screening it when create
> device.
>

Actually, it does.  It will cause the driver to advertise the extension
even if it isn't loaded through the HAL.


> Thanks,
>
> Randy
>
>
>
> *From:* Palli, Tapani
> *Sent:* Wednesday, March 1, 2017 1:03 PM
> *To:* Jason Ekstrand <jason at jlekstrand.net>; Xu, Randy <randy.xu at intel.com
> >
> *Cc:* mesa-dev at lists.freedesktop.org
> *Subject:* Re: [Mesa-dev] [PATCH] Vulkan: Add VK_ANDROID_native_buffer to
> device extension list
>
>
>
> On 03/01/2017 06:17 AM, Jason Ekstrand wrote:
>
> On Tue, Feb 28, 2017 at 7:52 PM, Randy Xu <randy.xu at intel.com> wrote:
>
> The VK_ANDROID_native_buffer is implemented in Android Vulkan HAL,
> not driver, but must be claimed in device extension list. Otherwise,
> this extension will be screened off in framework and driver.
>
>
>
> This seems rather odd.  Can't the Vulkan HAL just hook into
> vkEnumerateDeviceExtensionProperties and add it to the list there?  It
> seems a bit odd to advertise an extension but not actually provide any of
> the functionality.
>
>
> This was my question as well. I proposed Randy to include functionality,
> at the moment it would be along these lines:
>
> https://github.com/android-ia/external-mesa/commit/
> 8b6b2fc4de933c03feba33e5b57c20262e7983cc
>
> I don't have a strong preference where functionality exists but it seems
> like ideally the whole thing would exist in one single component. If the
> extension list cannot be modified in HAL then this becomes harder to
> achieve in HAL.
>

I don't see anything non-trivial in that commit.  Am I missing the part
where we actually import the ANativeImage?

In any case, if the interactions with gralloc aren't too bad, I'm
reasonably happy to have support in the upstream mesa repo.  Someone other
than me will have to be responsible for keeping it building but that's no
different from the current state of things.

> Test: Pass Vulkan dEQP-VK.wsi.android.swapchain.* on Android platform
>
> Signed-off-by: Randy Xu <randy.xu at intel.com>
> ---
>  Android.common.mk             | 3 +++
>  src/intel/vulkan/anv_device.c | 9 +++++++++
>  2 files changed, 12 insertions(+)
>
> diff --git a/Android.common.mk b/Android.common.mk
> index 611162a..f49189b 100644
> --- a/Android.common.mk
> +++ b/Android.common.mk
> @@ -116,6 +116,9 @@ else
>    LOCAL_CFLAGS += -DDEFAULT_DRIVER_DIR=\"/system/lib/$(MESA_DRI_MODULE_
> REL_PATH)\"
>  endif
>
> +# Enable VK_ANDROID_native_buffer
> +LOCAL_CFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR
> +
>  # uncomment to keep the debug symbols
>  #LOCAL_STRIP_MODULE := false
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 0db96f2..478d753 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -258,6 +258,15 @@ static const VkExtensionProperties
> device_extensions[] = {
>        .extensionName = VK_KHR_MAINTENANCE1_EXTENSION_NAME,
>        .specVersion = 1,
>     },
> +#ifdef VK_USE_PLATFORM_ANDROID_KHR
> +   {
> +      // Refer https://source.android.com/devices/graphics/implement-
> vulkan.html
> +      // "Window System Integration (WSI) extensions are exported by the
> loader
> +      //  and primarily implemented in it rather than the driver."
> +      .extensionName = "VK_ANDROID_native_buffer",
>
>
>
> In the other places, we use the EXTENSION_NAME #define
>
>
>
> +      .specVersion = 1,
> +   },
> +#endif
>     {
>        .extensionName = VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME,
>        .specVersion = 1,
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
>
>
>
>
> _______________________________________________
>
> mesa-dev mailing list
>
> mesa-dev at lists.freedesktop.org
>
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170228/fe703032/attachment-0001.html>


More information about the mesa-dev mailing list