Skip to content

Commit

Permalink
[fuchsia] Use memory_requirements_2 extension. (flutter#19678)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dreveman and David Reveman authored Jul 13, 2020
1 parent 5b966eb commit d024ae4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions shell/platform/fuchsia/flutter/vulkan_surface_producer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions vulkan/vulkan_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down

0 comments on commit d024ae4

Please sign in to comment.