Mesa (main): venus: properly support GPU_DATA_BUFFER for AHB

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 28 21:25:54 UTC 2021


Module: Mesa
Branch: main
Commit: 8391fb98cd8c068be4487106c1e7be50d625ff9f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8391fb98cd8c068be4487106c1e7be50d625ff9f

Author: Yiwei Zhang <zzyiwei at chromium.org>
Date:   Sun Jun 20 17:05:41 2021 +0000

venus: properly support GPU_DATA_BUFFER for AHB

CrOS gralloc was missing support for GPU_DATA_BUFFER, which was only
fixed until recently. Now we can allcate properly.

This patch also removes a redundant TODO regarding image format list
support for AHB. vkGetPhysicalDeviceImageFormatProperties2 has already
checked the support for such though it only checks whether the optimal
tiling and the associated drm format modifier for the AHB image format
itself applies to the entire format list or not. Given the use case for
such combination is quite limited, we choose not to add new gralloc
support to force linear modifier as a fallback for wider coverage.

Signed-off-by: Yiwei Zhang <zzyiwei at chromium.org>
Reviewed-by: Chia-I Wu <olvaffe at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11501>

---

 src/virtio/vulkan/vn_android.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/virtio/vulkan/vn_android.c b/src/virtio/vulkan/vn_android.c
index 1a1ab1d8833..542c26e8ba0 100644
--- a/src/virtio/vulkan/vn_android.c
+++ b/src/virtio/vulkan/vn_android.c
@@ -1037,19 +1037,21 @@ vn_android_device_allocate_ahb(struct vn_device *dev,
       height = image_info->extent.height;
       layers = image_info->arrayLayers;
       format = vn_android_ahb_format_from_vk_format(image_info->format);
-      /* TODO Need to further resolve the gralloc usage bits for image format
-       * list info, which might involve disabling compression if there exists
-       * no universally applied compression strategy across the formats.
-       */
       usage = vn_android_get_ahb_usage(image_info->usage, image_info->flags);
    } else {
+      const VkPhysicalDeviceMemoryProperties *mem_props =
+         &dev->physical_device->memory_properties.memoryProperties;
+
+      assert(alloc_info->memoryTypeIndex < mem_props->memoryTypeCount);
+
       width = alloc_info->allocationSize;
       format = AHARDWAREBUFFER_FORMAT_BLOB;
-      /* TODO AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER is not supported by cros
-       * gralloc. So here we work around with CPU usage bits for VkBuffer.
-       */
-      usage = AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN |
-              AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN;
+      usage = AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER;
+      if (mem_props->memoryTypes[alloc_info->memoryTypeIndex].propertyFlags &
+          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
+         usage |= AHARDWAREBUFFER_USAGE_CPU_READ_RARELY |
+                  AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY;
+      }
    }
 
    ahb = vn_android_ahb_allocate(width, height, layers, format, usage);



More information about the mesa-commit mailing list