diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 63b2ac899e260..5442f3c564cad 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -594,8 +594,6 @@ FILE: ../../../flutter/vulkan/vulkan_native_surface.cc FILE: ../../../flutter/vulkan/vulkan_native_surface.h FILE: ../../../flutter/vulkan/vulkan_native_surface_android.cc FILE: ../../../flutter/vulkan/vulkan_native_surface_android.h -FILE: ../../../flutter/vulkan/vulkan_native_surface_magma.cc -FILE: ../../../flutter/vulkan/vulkan_native_surface_magma.h FILE: ../../../flutter/vulkan/vulkan_proc_table.cc FILE: ../../../flutter/vulkan/vulkan_proc_table.h FILE: ../../../flutter/vulkan/vulkan_provider.cc diff --git a/vulkan/BUILD.gn b/vulkan/BUILD.gn index e5412a6431a21..d6e3767af9518 100644 --- a/vulkan/BUILD.gn +++ b/vulkan/BUILD.gn @@ -35,8 +35,6 @@ source_set("vulkan") { "vulkan_proc_table.h", "vulkan_surface.cc", "vulkan_surface.h", - "vulkan_swapchain.cc", - "vulkan_swapchain.h", "vulkan_utilities.cc", "vulkan_utilities.h", "vulkan_window.cc", @@ -47,13 +45,8 @@ source_set("vulkan") { sources += [ "vulkan_native_surface_android.cc", "vulkan_native_surface_android.h", - ] - } - - if (is_fuchsia) { - sources += [ - "vulkan_native_surface_magma.cc", - "vulkan_native_surface_magma.h", + "vulkan_swapchain.cc", + "vulkan_swapchain.h", ] } diff --git a/vulkan/vulkan_device.cc b/vulkan/vulkan_device.cc index 50688c1bac16a..772b1909225af 100644 --- a/vulkan/vulkan_device.cc +++ b/vulkan/vulkan_device.cc @@ -58,7 +58,9 @@ VulkanDevice::VulkanDevice(VulkanProcTable& p_vk, }; const char* extensions[] = { +#if OS_ANDROID VK_KHR_SWAPCHAIN_EXTENSION_NAME, +#endif #if OS_FUCHSIA VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_FUCHSIA_EXTENSION_NAME, @@ -177,6 +179,7 @@ uint32_t VulkanDevice::GetGraphicsQueueIndex() const { bool VulkanDevice::GetSurfaceCapabilities( const VulkanSurface& surface, VkSurfaceCapabilitiesKHR* capabilities) const { +#if OS_ANDROID if (!surface.IsValid() || capabilities == nullptr) { return false; } @@ -206,6 +209,9 @@ bool VulkanDevice::GetSurfaceCapabilities( capabilities->currentExtent.width = size.width(); capabilities->currentExtent.height = size.height(); return true; +#else + return false; +#endif } bool VulkanDevice::GetPhysicalDeviceFeatures( @@ -262,6 +268,7 @@ std::vector VulkanDevice::GetQueueFamilyProperties() int VulkanDevice::ChooseSurfaceFormat(const VulkanSurface& surface, std::vector desired_formats, VkSurfaceFormatKHR* format) const { +#if OS_ANDROID if (!surface.IsValid() || format == nullptr) { return -1; } @@ -297,7 +304,7 @@ int VulkanDevice::ChooseSurfaceFormat(const VulkanSurface& surface, return static_cast(i); } } - +#endif return -1; } diff --git a/vulkan/vulkan_native_surface_magma.cc b/vulkan/vulkan_native_surface_magma.cc deleted file mode 100644 index 61c12d8d2d0ac..0000000000000 --- a/vulkan/vulkan_native_surface_magma.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/vulkan/vulkan_native_surface_magma.h" - -namespace vulkan { - -VulkanNativeSurfaceMagma::VulkanNativeSurfaceMagma() = default; - -VulkanNativeSurfaceMagma::VulkanNativeSurfaceMagma(int32_t width, - int32_t height) { - size_ = SkISize::Make(width, height); -} - -VulkanNativeSurfaceMagma::~VulkanNativeSurfaceMagma() = default; - -const char* VulkanNativeSurfaceMagma::GetExtensionName() const { - return VK_KHR_MAGMA_SURFACE_EXTENSION_NAME; -} - -uint32_t VulkanNativeSurfaceMagma::GetSkiaExtensionName() const { - // There is no counterpart in Skia that recognizes the Magma extension name. - // However, Flutter handles all setup anyway, so this is unnecessary. - return 0; -} - -VkSurfaceKHR VulkanNativeSurfaceMagma::CreateSurfaceHandle( - vulkan::VulkanProcTable& vk, - const vulkan::VulkanHandle& instance) const { - if (!vk.IsValid() || !instance) { - return VK_NULL_HANDLE; - } - - const VkMagmaSurfaceCreateInfoKHR create_info = { - .sType = VK_STRUCTURE_TYPE_MAGMA_SURFACE_CREATE_INFO_KHR, - .pNext = nullptr, - }; - - VkSurfaceKHR surface = VK_NULL_HANDLE; - - if (VK_CALL_LOG_ERROR(vk.CreateMagmaSurfaceKHR( - instance, &create_info, nullptr /* allocator */, &surface)) != - VK_SUCCESS) { - return VK_NULL_HANDLE; - } - - return surface; -} - -bool VulkanNativeSurfaceMagma::IsValid() const { - // vkCreateMagmaSurfaceKHR doesn't actually take a native handle. So there is - // nothing to check the validity of. - return true; -} - -SkISize VulkanNativeSurfaceMagma::GetSize() const { - if (size_.width() != 0 && size_.height() != 0) { - return size_; - } else { - // TODO: Don't hardcode this after we get a proper Fuchsia Display API. - return SkISize::Make(2160, 1440); - } -} - -} // namespace vulkan diff --git a/vulkan/vulkan_native_surface_magma.h b/vulkan/vulkan_native_surface_magma.h deleted file mode 100644 index 1f3bbfe2f09f2..0000000000000 --- a/vulkan/vulkan_native_surface_magma.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_VULKAN_VULKAN_NATIVE_SURFACE_MAGMA_H_ -#define FLUTTER_VULKAN_VULKAN_NATIVE_SURFACE_MAGMA_H_ - -#include "flutter/fml/macros.h" -#include "flutter/vulkan/vulkan_native_surface.h" - -namespace vulkan { - -class VulkanNativeSurfaceMagma : public vulkan::VulkanNativeSurface { - public: - VulkanNativeSurfaceMagma(); - - // Alternate constructor which allows the caller to specify the surface's - // width and height. - // TODO: Remove this once we have a Fuchsia Display API. - VulkanNativeSurfaceMagma(int32_t surface_width, int32_t surface_height); - - ~VulkanNativeSurfaceMagma(); - - const char* GetExtensionName() const override; - - uint32_t GetSkiaExtensionName() const override; - - VkSurfaceKHR CreateSurfaceHandle( - vulkan::VulkanProcTable& vk, - const vulkan::VulkanHandle& instance) const override; - - bool IsValid() const override; - - SkISize GetSize() const override; - - private: - SkISize size_; - FML_DISALLOW_COPY_AND_ASSIGN(VulkanNativeSurfaceMagma); -}; - -} // namespace vulkan - -#endif // FLUTTER_VULKAN_VULKAN_NATIVE_SURFACE_MAGMA_H_ diff --git a/vulkan/vulkan_proc_table.cc b/vulkan/vulkan_proc_table.cc index 50d25b44263ef..b94e1ab4b23db 100644 --- a/vulkan/vulkan_proc_table.cc +++ b/vulkan/vulkan_proc_table.cc @@ -74,29 +74,20 @@ bool VulkanProcTable::SetupInstanceProcAddresses( ACQUIRE_PROC(CreateDevice, handle); ACQUIRE_PROC(DestroyDevice, handle); ACQUIRE_PROC(DestroyInstance, handle); - ACQUIRE_PROC(DestroySurfaceKHR, handle); ACQUIRE_PROC(EnumerateDeviceLayerProperties, handle); ACQUIRE_PROC(EnumeratePhysicalDevices, handle); ACQUIRE_PROC(GetDeviceProcAddr, handle); ACQUIRE_PROC(GetPhysicalDeviceFeatures, handle); ACQUIRE_PROC(GetPhysicalDeviceQueueFamilyProperties, handle); +#if OS_ANDROID ACQUIRE_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR, handle); ACQUIRE_PROC(GetPhysicalDeviceSurfaceFormatsKHR, handle); ACQUIRE_PROC(GetPhysicalDeviceSurfacePresentModesKHR, handle); ACQUIRE_PROC(GetPhysicalDeviceSurfaceSupportKHR, handle); - -#if OS_ANDROID + ACQUIRE_PROC(DestroySurfaceKHR, handle); ACQUIRE_PROC(CreateAndroidSurfaceKHR, handle); #endif // OS_ANDROID -#if OS_FUCHSIA - [this, &handle]() -> bool { - ACQUIRE_PROC(CreateMagmaSurfaceKHR, handle); - ACQUIRE_PROC(GetPhysicalDeviceMagmaPresentationSupportKHR, handle); - return true; - }(); -#endif // OS_FUCHSIA - // The debug report functions are optional. We don't want proc acquisition to // fail here because the optional methods were not present (since ACQUIRE_PROC // returns false on failure). Wrap the optional proc acquisitions in an @@ -114,7 +105,6 @@ bool VulkanProcTable::SetupInstanceProcAddresses( bool VulkanProcTable::SetupDeviceProcAddresses( const VulkanHandle& handle) { - ACQUIRE_PROC(AcquireNextImageKHR, handle); ACQUIRE_PROC(AllocateCommandBuffers, handle); ACQUIRE_PROC(AllocateMemory, handle); ACQUIRE_PROC(BeginCommandBuffer, handle); @@ -124,25 +114,28 @@ bool VulkanProcTable::SetupDeviceProcAddresses( ACQUIRE_PROC(CreateFence, handle); ACQUIRE_PROC(CreateImage, handle); ACQUIRE_PROC(CreateSemaphore, handle); - ACQUIRE_PROC(CreateSwapchainKHR, handle); ACQUIRE_PROC(DestroyCommandPool, handle); ACQUIRE_PROC(DestroyFence, handle); ACQUIRE_PROC(DestroyImage, handle); ACQUIRE_PROC(DestroySemaphore, handle); - ACQUIRE_PROC(DestroySwapchainKHR, handle); ACQUIRE_PROC(DeviceWaitIdle, handle); ACQUIRE_PROC(EndCommandBuffer, handle); ACQUIRE_PROC(FreeCommandBuffers, handle); ACQUIRE_PROC(FreeMemory, handle); ACQUIRE_PROC(GetDeviceQueue, handle); ACQUIRE_PROC(GetImageMemoryRequirements, handle); - ACQUIRE_PROC(GetSwapchainImagesKHR, handle); - ACQUIRE_PROC(QueuePresentKHR, handle); ACQUIRE_PROC(QueueSubmit, handle); ACQUIRE_PROC(QueueWaitIdle, handle); ACQUIRE_PROC(ResetCommandBuffer, handle); ACQUIRE_PROC(ResetFences, handle); ACQUIRE_PROC(WaitForFences, handle); +#if OS_ANDROID + ACQUIRE_PROC(AcquireNextImageKHR, handle); + ACQUIRE_PROC(CreateSwapchainKHR, handle); + ACQUIRE_PROC(DestroySwapchainKHR, handle); + ACQUIRE_PROC(GetSwapchainImagesKHR, handle); + ACQUIRE_PROC(QueuePresentKHR, handle); +#endif // OS_ANDROID #if OS_FUCHSIA ACQUIRE_PROC(GetMemoryFuchsiaHandleKHR, handle); ACQUIRE_PROC(ImportSemaphoreFuchsiaHandleKHR, handle); diff --git a/vulkan/vulkan_proc_table.h b/vulkan/vulkan_proc_table.h index 12d4b5beb9b03..d145150bcf84c 100644 --- a/vulkan/vulkan_proc_table.h +++ b/vulkan/vulkan_proc_table.h @@ -100,24 +100,22 @@ class VulkanProcTable : public fml::RefCountedThreadSafe { DEFINE_PROC(GetInstanceProcAddr); DEFINE_PROC(GetPhysicalDeviceFeatures); DEFINE_PROC(GetPhysicalDeviceQueueFamilyProperties); - DEFINE_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR); - DEFINE_PROC(GetPhysicalDeviceSurfaceFormatsKHR); - DEFINE_PROC(GetPhysicalDeviceSurfacePresentModesKHR); - DEFINE_PROC(GetPhysicalDeviceSurfaceSupportKHR); - DEFINE_PROC(GetSwapchainImagesKHR); - DEFINE_PROC(QueuePresentKHR); DEFINE_PROC(QueueSubmit); DEFINE_PROC(QueueWaitIdle); DEFINE_PROC(ResetCommandBuffer); DEFINE_PROC(ResetFences); DEFINE_PROC(WaitForFences); #if OS_ANDROID + DEFINE_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR); + DEFINE_PROC(GetPhysicalDeviceSurfaceFormatsKHR); + DEFINE_PROC(GetPhysicalDeviceSurfacePresentModesKHR); + DEFINE_PROC(GetPhysicalDeviceSurfaceSupportKHR); + DEFINE_PROC(GetSwapchainImagesKHR); + DEFINE_PROC(QueuePresentKHR); DEFINE_PROC(CreateAndroidSurfaceKHR); #endif // OS_ANDROID #if OS_FUCHSIA - DEFINE_PROC(CreateMagmaSurfaceKHR); DEFINE_PROC(GetMemoryFuchsiaHandleKHR); - DEFINE_PROC(GetPhysicalDeviceMagmaPresentationSupportKHR); DEFINE_PROC(ImportSemaphoreFuchsiaHandleKHR); #endif // OS_FUCHSIA