From d024ae400949b9b0e51f42bf98325d03a8aa55f5 Mon Sep 17 00:00:00 2001 From: David Reveman Date: Mon, 13 Jul 2020 17:37:20 -0400 Subject: [PATCH] [fuchsia] Use memory_requirements_2 extension. (#19678) This is required by some Vulkan 1.0 drivers. For example, MoltenVK through goldfish ICD when running in the emulator. Co-authored-by: David Reveman --- .../fuchsia/flutter/vulkan_surface_producer.cc | 11 +++++++++++ vulkan/vulkan_device.cc | 1 + 2 files changed, 12 insertions(+) diff --git a/shell/platform/fuchsia/flutter/vulkan_surface_producer.cc b/shell/platform/fuchsia/flutter/vulkan_surface_producer.cc index f0a240e16a3bd..27b215181bd26 100644 --- a/shell/platform/fuchsia/flutter/vulkan_surface_producer.cc +++ b/shell/platform/fuchsia/flutter/vulkan_surface_producer.cc @@ -16,6 +16,7 @@ #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrContext.h" #include "third_party/skia/include/gpu/vk/GrVkBackendContext.h" +#include "third_party/skia/include/gpu/vk/GrVkExtensions.h" #include "third_party/skia/include/gpu/vk/GrVkTypes.h" namespace flutter_runner { @@ -126,6 +127,16 @@ bool VulkanSurfaceProducer::Initialize(scenic::Session* scenic_session) { backend_context.fFeatures = skia_features; backend_context.fGetProc = std::move(getProc); backend_context.fOwnsInstanceAndDevice = false; + // The memory_requirements_2 extension is required on Fuchsia as the AMD + // memory allocator used by Skia benefit from it. + const char* device_extensions[] = { + VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, + }; + GrVkExtensions vk_extensions; + vk_extensions.init(backend_context.fGetProc, backend_context.fInstance, + backend_context.fPhysicalDevice, 0, nullptr, + countof(device_extensions), device_extensions); + backend_context.fVkExtensions = &vk_extensions; context_ = GrContext::MakeVulkan(backend_context); diff --git a/vulkan/vulkan_device.cc b/vulkan/vulkan_device.cc index b221ebb81b136..b4e0071b7e64a 100644 --- a/vulkan/vulkan_device.cc +++ b/vulkan/vulkan_device.cc @@ -68,6 +68,7 @@ VulkanDevice::VulkanDevice(VulkanProcTable& p_vk, VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME, VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME, + VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, #endif };