radv/android: Add android hardware buffer field to device memory.
authorBas Nieuwenhuizen <basni@chromium.org>
Wed, 10 Jul 2019 12:27:37 +0000 (14:27 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 10 Oct 2019 17:02:34 +0000 (17:02 +0000)
You cannot go from BO to Android hardware buffer, so for export we
have to remember it.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_private.h

index a5b3839394dd087e98768a368ab75f987bcf867f..b953f63e21674706858206f62b1dfead26978c64 100644 (file)
@@ -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 ||
index 2f5062d99a1880ff106f0a035b18cc260a569023..8674d1bd931bf5ea77f9c3826e5fbccb1df7b7ae 100644 (file)
@@ -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
 };