turnip: Make Android platform build
authorKristian H. Kristensen <hoegsberg@google.com>
Tue, 7 Apr 2020 16:04:00 +0000 (09:04 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 7 Apr 2020 18:44:21 +0000 (18:44 +0000)
We still don't have a way to keep this from breaking, but I don't
think this ever built.  Let's call it progress.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4478>

src/freedreno/vulkan/meson.build
src/freedreno/vulkan/tu_android.c
src/freedreno/vulkan/tu_extensions.py

index ef4c937090989829d552903d66761cec328d514d..0a86a0313a0938b35094219d124833edd7084de3 100644 (file)
@@ -92,6 +92,12 @@ if with_platform_drm
   libtu_files += files('tu_wsi_display.c')
 endif
 
+if with_platform_android
+  tu_flags += '-DVK_USE_PLATFORM_ANDROID_KHR'
+  libtu_files += files('tu_android.c')
+  tu_deps += [dep_android]
+endif
+
 if with_xlib_lease
   tu_deps += [dep_xcb_xrandr, dep_xlib_xrandr]
   tu_flags += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'
index 75fdb904601cb46c1f6a6b820c5f59ef2401310c..57870a7c67445830161b4a05a1814d9a0b6b2d3e 100644 (file)
@@ -119,7 +119,6 @@ tu_image_from_gralloc(VkDevice device_h,
    TU_FROM_HANDLE(tu_device, device, device_h);
    VkImage image_h = VK_NULL_HANDLE;
    struct tu_image *image = NULL;
-   struct tu_bo *bo = NULL;
    VkResult result;
 
    result = tu_image_create(device_h, base_info, alloc, &image_h,
@@ -151,37 +150,20 @@ tu_image_from_gralloc(VkDevice device_h,
       .image = image_h
    };
 
-   const VkImportMemoryFdInfo import_info = {
-      .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO,
+   const VkImportMemoryFdInfoKHR import_info = {
+      .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
       .pNext = &ded_alloc,
       .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT,
       .fd = dup(dma_buf),
    };
-   /* Find the first VRAM memory type, or GART for PRIME images. */
-   int memory_type_index = -1;
-   for (int i = 0;
-        i < device->physical_device->memory_properties.memoryTypeCount; ++i) {
-      bool is_local =
-         !!(device->physical_device->memory_properties.memoryTypes[i]
-               .propertyFlags &
-            VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
-      if (is_local) {
-         memory_type_index = i;
-         break;
-      }
-   }
-
-   /* fallback */
-   if (memory_type_index == -1)
-      memory_type_index = 0;
 
    result =
       tu_AllocateMemory(device_h,
                         &(VkMemoryAllocateInfo) {
                            .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
                            .pNext = &import_info,
-                           .allocationSize = image->size,
-                           .memoryTypeIndex = memory_type_index,
+                           .allocationSize = image->layout.size,
+                           .memoryTypeIndex = 0,
                         },
                         alloc, &memory_h);
    if (result != VK_SUCCESS)
@@ -196,7 +178,6 @@ tu_image_from_gralloc(VkDevice device_h,
    return VK_SUCCESS;
 
 fail_create_image:
-fail_size:
    tu_DestroyImage(device_h, image_h, alloc);
 
    return result;
@@ -288,6 +269,19 @@ tu_GetSwapchainGrallocUsageANDROID(VkDevice device_h,
    return VK_SUCCESS;
 }
 
+VkResult
+tu_GetSwapchainGrallocUsage2ANDROID(VkDevice device,
+                                    VkFormat format,
+                                    VkImageUsageFlags imageUsage,
+                                    VkSwapchainImageUsageFlagsANDROID swapchainImageUsage,
+                                    uint64_t *grallocConsumerUsage,
+                                    uint64_t *grallocProducerUsage)
+{
+   tu_stub();
+
+   return VK_SUCCESS;
+}
+
 VkResult
 tu_AcquireImageANDROID(VkDevice device,
                        VkImage image_h,
index b06ce88a6730d8661d38b71259865cef62322a56..574e9411c086d5ab89f0ec1ce6a272d89788f320 100644 (file)
@@ -78,6 +78,7 @@ EXTENSIONS = [
     Extension('VK_EXT_external_memory_dma_buf',           1, True),
     Extension('VK_EXT_image_drm_format_modifier',         1, False),
     Extension('VK_EXT_transform_feedback',                1, True),
+    Extension('VK_ANDROID_native_buffer',                 1, True),
     Extension('VK_KHR_external_semaphore_fd',             1, True),
     Extension('VK_KHR_external_fence_fd',                 1, True),
 ]