From: Kristian H. Kristensen Date: Tue, 7 Apr 2020 16:04:00 +0000 (-0700) Subject: turnip: Make Android platform build X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5789505ab3b62e40fb30663cc973a97f3a7175ba;p=mesa.git turnip: Make Android platform build 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: --- diff --git a/src/freedreno/vulkan/meson.build b/src/freedreno/vulkan/meson.build index ef4c9370909..0a86a0313a0 100644 --- a/src/freedreno/vulkan/meson.build +++ b/src/freedreno/vulkan/meson.build @@ -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' diff --git a/src/freedreno/vulkan/tu_android.c b/src/freedreno/vulkan/tu_android.c index 75fdb904601..57870a7c674 100644 --- a/src/freedreno/vulkan/tu_android.c +++ b/src/freedreno/vulkan/tu_android.c @@ -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, diff --git a/src/freedreno/vulkan/tu_extensions.py b/src/freedreno/vulkan/tu_extensions.py index b06ce88a673..574e9411c08 100644 --- a/src/freedreno/vulkan/tu_extensions.py +++ b/src/freedreno/vulkan/tu_extensions.py @@ -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), ]