Mesa (master): radv/android: Add android hardware buffer field to device memory.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Oct 10 17:03:30 UTC 2019


Module: Mesa
Branch: master
Commit: a34e4dd0d2aa40dd85bf41ab1e1e65e31924df73
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a34e4dd0d2aa40dd85bf41ab1e1e65e31924df73

Author: Bas Nieuwenhuizen <basni at chromium.org>
Date:   Wed Jul 10 14:27:37 2019 +0200

radv/android: Add android hardware buffer field to device memory.

You cannot go from BO to Android hardware buffer, so for export we
have to remember it.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

---

 src/amd/vulkan/radv_device.c  | 9 +++++++++
 src/amd/vulkan/radv_private.h | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index a5b3839394d..b953f63e216 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -3427,6 +3427,11 @@ static void radv_free_memory(struct radv_device *device,
 	if (mem == NULL)
 		return;
 
+#if RADV_SUPPORT_ANDROID_HARDWARE_BUFFER
+	if (mem->android_hardware_buffer)
+		AHardwareBuffer_release(mem->android_hardware_buffer);
+#endif
+
 	if (mem->bo) {
 		radv_bo_list_remove(device, mem->bo);
 		device->ws->buffer_destroy(mem->bo);
@@ -3496,6 +3501,10 @@ static VkResult radv_alloc_memory(struct radv_device *device,
 	mem->user_ptr = NULL;
 	mem->bo = NULL;
 
+#if RADV_SUPPORT_ANDROID_HARDWARE_BUFFER
+	mem->android_hardware_buffer = NULL;
+#endif
+
 	if (import_info) {
 		assert(import_info->handleType ==
 		       VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT ||
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 2f5062d99a1..8674d1bd931 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -787,6 +787,10 @@ struct radv_device_memory {
 	VkDeviceSize                                 map_size;
 	void *                                       map;
 	void *                                       user_ptr;
+
+#if RADV_SUPPORT_ANDROID_HARDWARE_BUFFER
+	struct AHardwareBuffer *                    android_hardware_buffer;
+#endif
 };
 
 




More information about the mesa-commit mailing list