[Impeller] Wire Flutter's own VulkanMemoryAllocator implementation (flutter/engine#37018)
This commit is contained in:
@@ -831,6 +831,10 @@ FILE: ../../../flutter/flow/surface_frame.cc
|
||||
FILE: ../../../flutter/flow/surface_frame.h
|
||||
FILE: ../../../flutter/flow/surface_frame_unittests.cc
|
||||
FILE: ../../../flutter/flow/texture_unittests.cc
|
||||
FILE: ../../../flutter/flutter_vma/flutter_skia_vma.cc
|
||||
FILE: ../../../flutter/flutter_vma/flutter_skia_vma.h
|
||||
FILE: ../../../flutter/flutter_vma/flutter_vma.cc
|
||||
FILE: ../../../flutter/flutter_vma/flutter_vma.h
|
||||
FILE: ../../../flutter/fml/ascii_trie.cc
|
||||
FILE: ../../../flutter/fml/ascii_trie.h
|
||||
FILE: ../../../flutter/fml/ascii_trie_unittests.cc
|
||||
@@ -3256,6 +3260,12 @@ FILE: ../../../flutter/third_party/txt/src/txt/platform_fuchsia.cc
|
||||
FILE: ../../../flutter/third_party/txt/src/txt/platform_linux.cc
|
||||
FILE: ../../../flutter/third_party/txt/src/txt/platform_mac.mm
|
||||
FILE: ../../../flutter/third_party/txt/src/txt/platform_windows.cc
|
||||
FILE: ../../../flutter/vulkan/procs/vulkan_handle.cc
|
||||
FILE: ../../../flutter/vulkan/procs/vulkan_handle.h
|
||||
FILE: ../../../flutter/vulkan/procs/vulkan_interface.cc
|
||||
FILE: ../../../flutter/vulkan/procs/vulkan_interface.h
|
||||
FILE: ../../../flutter/vulkan/procs/vulkan_proc_table.cc
|
||||
FILE: ../../../flutter/vulkan/procs/vulkan_proc_table.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_application.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_application.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_backbuffer.cc
|
||||
@@ -3266,20 +3276,16 @@ FILE: ../../../flutter/vulkan/vulkan_debug_report.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_debug_report.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_device.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_device.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_handle.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_handle.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_image.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_image.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_interface.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_interface.h
|
||||
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_proc_table.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_proc_table.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_provider.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_provider.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_skia_proc_table.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_skia_proc_table.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_surface.cc
|
||||
FILE: ../../../flutter/vulkan/vulkan_surface.h
|
||||
FILE: ../../../flutter/vulkan/vulkan_swapchain.cc
|
||||
|
||||
40
engine/src/flutter/flutter_vma/BUILD.gn
Normal file
40
engine/src/flutter/flutter_vma/BUILD.gn
Normal file
@@ -0,0 +1,40 @@
|
||||
# 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.
|
||||
|
||||
import("//flutter/flutter_vma/config.gni")
|
||||
|
||||
source_set("flutter_vma") {
|
||||
sources = [
|
||||
"flutter_vma.cc",
|
||||
"flutter_vma.h",
|
||||
]
|
||||
|
||||
if (disable_vma_stl_shared_mutex) {
|
||||
defines = [ "VMA_USE_STL_SHARED_MUTEX=0" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"//third_party/vulkan-deps/vulkan-headers/src:vulkan_headers",
|
||||
"//third_party/vulkan_memory_allocator",
|
||||
]
|
||||
|
||||
public_configs = [ "//flutter:config" ]
|
||||
}
|
||||
|
||||
source_set("flutter_skia_vma") {
|
||||
sources = [
|
||||
"flutter_skia_vma.cc",
|
||||
"flutter_skia_vma.h",
|
||||
]
|
||||
|
||||
public_deps = [ ":flutter_vma" ]
|
||||
|
||||
deps = [
|
||||
"//flutter/fml",
|
||||
"//flutter/vulkan/procs",
|
||||
"//third_party/skia",
|
||||
"//third_party/vulkan-deps/vulkan-headers/src:vulkan_headers",
|
||||
"//third_party/vulkan_memory_allocator",
|
||||
]
|
||||
}
|
||||
7
engine/src/flutter/flutter_vma/config.gni
Normal file
7
engine/src/flutter/flutter_vma/config.gni
Normal file
@@ -0,0 +1,7 @@
|
||||
# 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.
|
||||
|
||||
declare_args() {
|
||||
disable_vma_stl_shared_mutex = false
|
||||
}
|
||||
274
engine/src/flutter/flutter_vma/flutter_skia_vma.cc
Normal file
274
engine/src/flutter/flutter_vma/flutter_skia_vma.cc
Normal file
@@ -0,0 +1,274 @@
|
||||
// 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/flutter_vma/flutter_skia_vma.h"
|
||||
|
||||
#include "flutter/fml/memory/ref_ptr.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
sk_sp<skgpu::VulkanMemoryAllocator> FlutterSkiaVulkanMemoryAllocator::Make(
|
||||
uint32_t vulkan_api_version,
|
||||
VkInstance instance,
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkDevice device,
|
||||
const fml::RefPtr<vulkan::VulkanProcTable>& vk,
|
||||
bool mustUseCoherentHostVisibleMemory) {
|
||||
#define PROVIDE_PROC(tbl, proc, provider) tbl.vk##proc = provider->proc;
|
||||
|
||||
VmaVulkanFunctions proc_table = {};
|
||||
proc_table.vkGetInstanceProcAddr = vk->NativeGetInstanceProcAddr();
|
||||
PROVIDE_PROC(proc_table, GetDeviceProcAddr, vk);
|
||||
PROVIDE_PROC(proc_table, GetPhysicalDeviceProperties, vk);
|
||||
PROVIDE_PROC(proc_table, GetPhysicalDeviceMemoryProperties, vk);
|
||||
PROVIDE_PROC(proc_table, AllocateMemory, vk);
|
||||
PROVIDE_PROC(proc_table, FreeMemory, vk);
|
||||
PROVIDE_PROC(proc_table, MapMemory, vk);
|
||||
PROVIDE_PROC(proc_table, UnmapMemory, vk);
|
||||
PROVIDE_PROC(proc_table, FlushMappedMemoryRanges, vk);
|
||||
PROVIDE_PROC(proc_table, InvalidateMappedMemoryRanges, vk);
|
||||
PROVIDE_PROC(proc_table, BindBufferMemory, vk);
|
||||
PROVIDE_PROC(proc_table, BindImageMemory, vk);
|
||||
PROVIDE_PROC(proc_table, GetBufferMemoryRequirements, vk);
|
||||
PROVIDE_PROC(proc_table, GetImageMemoryRequirements, vk);
|
||||
PROVIDE_PROC(proc_table, CreateBuffer, vk);
|
||||
PROVIDE_PROC(proc_table, DestroyBuffer, vk);
|
||||
PROVIDE_PROC(proc_table, CreateImage, vk);
|
||||
PROVIDE_PROC(proc_table, DestroyImage, vk);
|
||||
PROVIDE_PROC(proc_table, CmdCopyBuffer, vk);
|
||||
|
||||
#define PROVIDE_PROC_COALESCE(tbl, proc, provider) \
|
||||
tbl.vk##proc##KHR = provider->proc ? provider->proc : provider->proc##KHR;
|
||||
// See the following link for why we have to pick either KHR version or
|
||||
// promoted non-KHR version:
|
||||
// https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/issues/203
|
||||
PROVIDE_PROC_COALESCE(proc_table, GetBufferMemoryRequirements2, vk);
|
||||
PROVIDE_PROC_COALESCE(proc_table, GetImageMemoryRequirements2, vk);
|
||||
PROVIDE_PROC_COALESCE(proc_table, BindBufferMemory2, vk);
|
||||
PROVIDE_PROC_COALESCE(proc_table, BindImageMemory2, vk);
|
||||
PROVIDE_PROC_COALESCE(proc_table, GetPhysicalDeviceMemoryProperties2, vk);
|
||||
#undef PROVIDE_PROC_COALESCE
|
||||
|
||||
#undef PROVIDE_PROC
|
||||
|
||||
VmaAllocatorCreateInfo allocator_info = {};
|
||||
allocator_info.vulkanApiVersion = vulkan_api_version;
|
||||
allocator_info.physicalDevice = physicalDevice;
|
||||
allocator_info.device = device;
|
||||
allocator_info.instance = instance;
|
||||
allocator_info.pVulkanFunctions = &proc_table;
|
||||
|
||||
VmaAllocator allocator;
|
||||
vmaCreateAllocator(&allocator_info, &allocator);
|
||||
|
||||
return sk_sp<FlutterSkiaVulkanMemoryAllocator>(
|
||||
new FlutterSkiaVulkanMemoryAllocator(vk, allocator,
|
||||
mustUseCoherentHostVisibleMemory));
|
||||
}
|
||||
|
||||
FlutterSkiaVulkanMemoryAllocator::FlutterSkiaVulkanMemoryAllocator(
|
||||
fml::RefPtr<vulkan::VulkanProcTable> vk_proc_table,
|
||||
VmaAllocator allocator,
|
||||
bool mustUseCoherentHostVisibleMemory)
|
||||
: vk_proc_table_(std::move(vk_proc_table)),
|
||||
allocator_(allocator),
|
||||
must_use_coherent_host_visible_memory_(mustUseCoherentHostVisibleMemory) {
|
||||
}
|
||||
|
||||
FlutterSkiaVulkanMemoryAllocator::~FlutterSkiaVulkanMemoryAllocator() {
|
||||
vmaDestroyAllocator(allocator_);
|
||||
allocator_ = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
VkResult FlutterSkiaVulkanMemoryAllocator::allocateImageMemory(
|
||||
VkImage image,
|
||||
uint32_t allocationPropertyFlags,
|
||||
skgpu::VulkanBackendMemory* backendMemory) {
|
||||
VmaAllocationCreateInfo info;
|
||||
info.flags = 0;
|
||||
info.usage = VMA_MEMORY_USAGE_UNKNOWN;
|
||||
info.requiredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
info.preferredFlags = 0;
|
||||
info.memoryTypeBits = 0;
|
||||
info.pool = VK_NULL_HANDLE;
|
||||
info.pUserData = nullptr;
|
||||
|
||||
if (kDedicatedAllocation_AllocationPropertyFlag & allocationPropertyFlags) {
|
||||
info.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
|
||||
}
|
||||
if (kLazyAllocation_AllocationPropertyFlag & allocationPropertyFlags) {
|
||||
info.requiredFlags |= VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT;
|
||||
}
|
||||
if (kProtected_AllocationPropertyFlag & allocationPropertyFlags) {
|
||||
info.requiredFlags |= VK_MEMORY_PROPERTY_PROTECTED_BIT;
|
||||
}
|
||||
|
||||
VmaAllocation allocation;
|
||||
VkResult result =
|
||||
vmaAllocateMemoryForImage(allocator_, image, &info, &allocation, nullptr);
|
||||
if (VK_SUCCESS == result) {
|
||||
*backendMemory = reinterpret_cast<skgpu::VulkanBackendMemory>(allocation);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
VkResult FlutterSkiaVulkanMemoryAllocator::allocateBufferMemory(
|
||||
VkBuffer buffer,
|
||||
BufferUsage usage,
|
||||
uint32_t allocationPropertyFlags,
|
||||
skgpu::VulkanBackendMemory* backendMemory) {
|
||||
VmaAllocationCreateInfo info;
|
||||
info.flags = 0;
|
||||
info.usage = VMA_MEMORY_USAGE_UNKNOWN;
|
||||
info.memoryTypeBits = 0;
|
||||
info.pool = VK_NULL_HANDLE;
|
||||
info.pUserData = nullptr;
|
||||
|
||||
switch (usage) {
|
||||
case BufferUsage::kGpuOnly:
|
||||
info.requiredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
info.preferredFlags = 0;
|
||||
break;
|
||||
case BufferUsage::kCpuWritesGpuReads:
|
||||
// When doing cpu writes and gpu reads the general rule of thumb is to use
|
||||
// coherent memory. Though this depends on the fact that we are not doing
|
||||
// any cpu reads and the cpu writes are sequential. For sparse writes we'd
|
||||
// want cpu cached memory, however we don't do these types of writes in
|
||||
// Skia.
|
||||
//
|
||||
// TODO (kaushikiska): In the future there may be times where specific
|
||||
// types of memory could benefit from a coherent and cached memory.
|
||||
// Typically these allow for the gpu to read cpu writes from the cache
|
||||
// without needing to flush the writes throughout the cache. The reverse
|
||||
// is not true and GPU writes tend to invalidate the cache regardless.
|
||||
// Also these gpu cache read access are typically lower bandwidth than
|
||||
// non-cached memory. For now Skia doesn't really have a need or want of
|
||||
// this type of memory. But if we ever do we could pass in an
|
||||
// AllocationPropertyFlag that requests the cached property.
|
||||
info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||
info.preferredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
break;
|
||||
case BufferUsage::kTransfersFromCpuToGpu:
|
||||
info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||
info.preferredFlags = 0;
|
||||
break;
|
||||
case BufferUsage::kTransfersFromGpuToCpu:
|
||||
info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
info.preferredFlags = VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (must_use_coherent_host_visible_memory_ &&
|
||||
(info.requiredFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) {
|
||||
info.requiredFlags |= VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||
}
|
||||
if (kDedicatedAllocation_AllocationPropertyFlag & allocationPropertyFlags) {
|
||||
info.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
|
||||
}
|
||||
if ((kLazyAllocation_AllocationPropertyFlag & allocationPropertyFlags) &&
|
||||
BufferUsage::kGpuOnly == usage) {
|
||||
info.preferredFlags |= VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT;
|
||||
}
|
||||
|
||||
if (kPersistentlyMapped_AllocationPropertyFlag & allocationPropertyFlags) {
|
||||
SkASSERT(BufferUsage::kGpuOnly != usage);
|
||||
info.flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT;
|
||||
}
|
||||
|
||||
VmaAllocation allocation;
|
||||
VkResult result = vmaAllocateMemoryForBuffer(allocator_, buffer, &info,
|
||||
&allocation, nullptr);
|
||||
if (VK_SUCCESS == result) {
|
||||
*backendMemory = reinterpret_cast<skgpu::VulkanBackendMemory>(allocation);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void FlutterSkiaVulkanMemoryAllocator::freeMemory(
|
||||
const skgpu::VulkanBackendMemory& memoryHandle) {
|
||||
const VmaAllocation allocation =
|
||||
reinterpret_cast<const VmaAllocation>(memoryHandle);
|
||||
vmaFreeMemory(allocator_, allocation);
|
||||
}
|
||||
|
||||
void FlutterSkiaVulkanMemoryAllocator::getAllocInfo(
|
||||
const skgpu::VulkanBackendMemory& memoryHandle,
|
||||
skgpu::VulkanAlloc* alloc) const {
|
||||
const VmaAllocation allocation =
|
||||
reinterpret_cast<const VmaAllocation>(memoryHandle);
|
||||
VmaAllocationInfo vmaInfo;
|
||||
vmaGetAllocationInfo(allocator_, allocation, &vmaInfo);
|
||||
|
||||
VkMemoryPropertyFlags memFlags;
|
||||
vmaGetMemoryTypeProperties(allocator_, vmaInfo.memoryType, &memFlags);
|
||||
|
||||
uint32_t flags = 0;
|
||||
if (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT & memFlags) {
|
||||
flags |= skgpu::VulkanAlloc::kMappable_Flag;
|
||||
}
|
||||
if (!SkToBool(VK_MEMORY_PROPERTY_HOST_COHERENT_BIT & memFlags)) {
|
||||
flags |= skgpu::VulkanAlloc::kNoncoherent_Flag;
|
||||
}
|
||||
if (VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT & memFlags) {
|
||||
flags |= skgpu::VulkanAlloc::kLazilyAllocated_Flag;
|
||||
}
|
||||
|
||||
alloc->fMemory = vmaInfo.deviceMemory;
|
||||
alloc->fOffset = vmaInfo.offset;
|
||||
alloc->fSize = vmaInfo.size;
|
||||
alloc->fFlags = flags;
|
||||
alloc->fBackendMemory = memoryHandle;
|
||||
}
|
||||
|
||||
VkResult FlutterSkiaVulkanMemoryAllocator::mapMemory(
|
||||
const skgpu::VulkanBackendMemory& memoryHandle,
|
||||
void** data) {
|
||||
const VmaAllocation allocation =
|
||||
reinterpret_cast<const VmaAllocation>(memoryHandle);
|
||||
return vmaMapMemory(allocator_, allocation, data);
|
||||
}
|
||||
|
||||
void FlutterSkiaVulkanMemoryAllocator::unmapMemory(
|
||||
const skgpu::VulkanBackendMemory& memoryHandle) {
|
||||
const VmaAllocation allocation =
|
||||
reinterpret_cast<const VmaAllocation>(memoryHandle);
|
||||
vmaUnmapMemory(allocator_, allocation);
|
||||
}
|
||||
|
||||
VkResult FlutterSkiaVulkanMemoryAllocator::flushMemory(
|
||||
const skgpu::VulkanBackendMemory& memoryHandle,
|
||||
VkDeviceSize offset,
|
||||
VkDeviceSize size) {
|
||||
const VmaAllocation allocation =
|
||||
reinterpret_cast<const VmaAllocation>(memoryHandle);
|
||||
return vmaFlushAllocation(allocator_, allocation, offset, size);
|
||||
}
|
||||
|
||||
VkResult FlutterSkiaVulkanMemoryAllocator::invalidateMemory(
|
||||
const skgpu::VulkanBackendMemory& memoryHandle,
|
||||
VkDeviceSize offset,
|
||||
VkDeviceSize size) {
|
||||
const VmaAllocation allocation =
|
||||
reinterpret_cast<const VmaAllocation>(memoryHandle);
|
||||
return vmaInvalidateAllocation(allocator_, allocation, offset, size);
|
||||
}
|
||||
|
||||
uint64_t FlutterSkiaVulkanMemoryAllocator::totalUsedMemory() const {
|
||||
VmaTotalStatistics stats;
|
||||
vmaCalculateStatistics(allocator_, &stats);
|
||||
return stats.total.statistics.allocationBytes;
|
||||
}
|
||||
|
||||
uint64_t FlutterSkiaVulkanMemoryAllocator::totalAllocatedMemory() const {
|
||||
VmaTotalStatistics stats;
|
||||
vmaCalculateStatistics(allocator_, &stats);
|
||||
return stats.total.statistics.blockBytes;
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
70
engine/src/flutter/flutter_vma/flutter_skia_vma.h
Normal file
70
engine/src/flutter/flutter_vma/flutter_skia_vma.h
Normal file
@@ -0,0 +1,70 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/flutter_vma/flutter_vma.h"
|
||||
|
||||
#include "flutter/fml/memory/ref_ptr.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "third_party/skia/include/gpu/vk/GrVkBackendContext.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
class FlutterSkiaVulkanMemoryAllocator : public skgpu::VulkanMemoryAllocator {
|
||||
public:
|
||||
static sk_sp<VulkanMemoryAllocator> Make(
|
||||
uint32_t vulkan_api_version,
|
||||
VkInstance instance,
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkDevice device,
|
||||
const fml::RefPtr<vulkan::VulkanProcTable>& vk,
|
||||
bool mustUseCoherentHostVisibleMemory);
|
||||
|
||||
~FlutterSkiaVulkanMemoryAllocator() override;
|
||||
|
||||
VkResult allocateImageMemory(VkImage image,
|
||||
uint32_t allocationPropertyFlags,
|
||||
skgpu::VulkanBackendMemory*) override;
|
||||
|
||||
VkResult allocateBufferMemory(VkBuffer buffer,
|
||||
BufferUsage usage,
|
||||
uint32_t allocationPropertyFlags,
|
||||
skgpu::VulkanBackendMemory*) override;
|
||||
|
||||
void freeMemory(const skgpu::VulkanBackendMemory&) override;
|
||||
|
||||
void getAllocInfo(const skgpu::VulkanBackendMemory&,
|
||||
skgpu::VulkanAlloc*) const override;
|
||||
|
||||
VkResult mapMemory(const skgpu::VulkanBackendMemory&, void** data) override;
|
||||
void unmapMemory(const skgpu::VulkanBackendMemory&) override;
|
||||
|
||||
VkResult flushMemory(const skgpu::VulkanBackendMemory&,
|
||||
VkDeviceSize offset,
|
||||
VkDeviceSize size) override;
|
||||
VkResult invalidateMemory(const skgpu::VulkanBackendMemory&,
|
||||
VkDeviceSize offset,
|
||||
VkDeviceSize size) override;
|
||||
|
||||
uint64_t totalUsedMemory() const override;
|
||||
uint64_t totalAllocatedMemory() const override;
|
||||
|
||||
private:
|
||||
FlutterSkiaVulkanMemoryAllocator(
|
||||
fml::RefPtr<vulkan::VulkanProcTable> vk_proc_table,
|
||||
VmaAllocator allocator,
|
||||
bool mustUseCoherentHostVisibleMemory);
|
||||
|
||||
fml::RefPtr<vulkan::VulkanProcTable> vk_proc_table_;
|
||||
VmaAllocator allocator_;
|
||||
|
||||
// For host visible allocations do we require they are coherent or not. All
|
||||
// devices are required to support a host visible and coherent memory type.
|
||||
// This is used to work around bugs for devices that don't handle non coherent
|
||||
// memory correctly.
|
||||
bool must_use_coherent_host_visible_memory_;
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
19
engine/src/flutter/flutter_vma/flutter_vma.cc
Normal file
19
engine/src/flutter/flutter_vma/flutter_vma.cc
Normal file
@@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
#ifdef VMA_STATIC_VULKAN_FUNCTIONS
|
||||
#undef VMA_STATIC_VULKAN_FUNCTIONS
|
||||
#endif // VMA_STATIC_VULKAN_FUNCTIONS
|
||||
|
||||
#ifdef VMA_DYNAMIC_VULKAN_FUNCTIONS
|
||||
#undef VMA_DYNAMIC_VULKAN_FUNCTIONS
|
||||
#endif // VMA_DYNAMIC_VULKAN_FUNCTIONS
|
||||
|
||||
// We use our own functions pointers
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 0
|
||||
|
||||
#define VMA_IMPLEMENTATION
|
||||
|
||||
#include "flutter/flutter_vma/flutter_vma.h"
|
||||
7
engine/src/flutter/flutter_vma/flutter_vma.h
Normal file
7
engine/src/flutter/flutter_vma/flutter_vma.h
Normal file
@@ -0,0 +1,7 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "vk_mem_alloc.h"
|
||||
@@ -56,7 +56,9 @@ impeller_component("vulkan") {
|
||||
public_deps = [
|
||||
"../../:renderer",
|
||||
"../../../blobcat:blobcat_lib",
|
||||
"//flutter/flutter_vma",
|
||||
"//flutter/fml",
|
||||
"//flutter/vulkan/procs",
|
||||
"//third_party/vulkan-deps/vulkan-headers/src:vulkan_headers",
|
||||
"//third_party/vulkan_memory_allocator",
|
||||
]
|
||||
|
||||
@@ -2,20 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
_Pragma("GCC diagnostic push");
|
||||
_Pragma("GCC diagnostic ignored \"-Wnullability-completeness\"");
|
||||
_Pragma("GCC diagnostic ignored \"-Wunused-variable\"");
|
||||
_Pragma("GCC diagnostic ignored \"-Wthread-safety-analysis\"");
|
||||
|
||||
#define VMA_IMPLEMENTATION
|
||||
#include "impeller/renderer/backend/vulkan/allocator_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/device_buffer_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/formats_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/texture_vk.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
_Pragma("GCC diagnostic pop");
|
||||
#include "flutter/fml/memory/ref_ptr.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "impeller/renderer/backend/vulkan/device_buffer_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/formats_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/texture_vk.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
@@ -27,10 +23,51 @@ AllocatorVK::AllocatorVK(ContextVK& context,
|
||||
PFN_vkGetInstanceProcAddr get_instance_proc_address,
|
||||
PFN_vkGetDeviceProcAddr get_device_proc_address)
|
||||
: context_(context), device_(logical_device) {
|
||||
vk_ = fml::MakeRefCounted<vulkan::VulkanProcTable>(get_instance_proc_address);
|
||||
|
||||
auto instance_handle = vulkan::VulkanHandle<VkInstance>(instance);
|
||||
FML_CHECK(vk_->SetupInstanceProcAddresses(instance_handle));
|
||||
|
||||
auto device_handle = vulkan::VulkanHandle<VkDevice>(logical_device);
|
||||
FML_CHECK(vk_->SetupDeviceProcAddresses(device_handle));
|
||||
|
||||
VmaVulkanFunctions proc_table = {};
|
||||
proc_table.vkGetInstanceProcAddr = get_instance_proc_address;
|
||||
proc_table.vkGetDeviceProcAddr = get_device_proc_address;
|
||||
|
||||
#define PROVIDE_PROC(tbl, proc, provider) tbl.vk##proc = provider->proc;
|
||||
PROVIDE_PROC(proc_table, GetPhysicalDeviceProperties, vk_);
|
||||
PROVIDE_PROC(proc_table, GetPhysicalDeviceMemoryProperties, vk_);
|
||||
PROVIDE_PROC(proc_table, AllocateMemory, vk_);
|
||||
PROVIDE_PROC(proc_table, FreeMemory, vk_);
|
||||
PROVIDE_PROC(proc_table, MapMemory, vk_);
|
||||
PROVIDE_PROC(proc_table, UnmapMemory, vk_);
|
||||
PROVIDE_PROC(proc_table, FlushMappedMemoryRanges, vk_);
|
||||
PROVIDE_PROC(proc_table, InvalidateMappedMemoryRanges, vk_);
|
||||
PROVIDE_PROC(proc_table, BindBufferMemory, vk_);
|
||||
PROVIDE_PROC(proc_table, BindImageMemory, vk_);
|
||||
PROVIDE_PROC(proc_table, GetBufferMemoryRequirements, vk_);
|
||||
PROVIDE_PROC(proc_table, GetImageMemoryRequirements, vk_);
|
||||
PROVIDE_PROC(proc_table, CreateBuffer, vk_);
|
||||
PROVIDE_PROC(proc_table, DestroyBuffer, vk_);
|
||||
PROVIDE_PROC(proc_table, CreateImage, vk_);
|
||||
PROVIDE_PROC(proc_table, DestroyImage, vk_);
|
||||
PROVIDE_PROC(proc_table, CmdCopyBuffer, vk_);
|
||||
|
||||
#define PROVIDE_PROC_COALESCE(tbl, proc, provider) \
|
||||
tbl.vk##proc##KHR = provider->proc ? provider->proc : provider->proc##KHR;
|
||||
// See the following link for why we have to pick either KHR version or
|
||||
// promoted non-KHR version:
|
||||
// https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/issues/203
|
||||
PROVIDE_PROC_COALESCE(proc_table, GetBufferMemoryRequirements2, vk_);
|
||||
PROVIDE_PROC_COALESCE(proc_table, GetImageMemoryRequirements2, vk_);
|
||||
PROVIDE_PROC_COALESCE(proc_table, BindBufferMemory2, vk_);
|
||||
PROVIDE_PROC_COALESCE(proc_table, BindImageMemory2, vk_);
|
||||
PROVIDE_PROC_COALESCE(proc_table, GetPhysicalDeviceMemoryProperties2, vk_);
|
||||
#undef PROVIDE_PROC_COALESCE
|
||||
|
||||
#undef PROVIDE_PROC
|
||||
|
||||
VmaAllocatorCreateInfo allocator_info = {};
|
||||
allocator_info.vulkanApiVersion = vulkan_api_version;
|
||||
allocator_info.physicalDevice = physical_device;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/memory/ref_ptr.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "impeller/renderer/allocator.h"
|
||||
#include "impeller/renderer/backend/vulkan/context_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/vk.h"
|
||||
@@ -21,6 +23,7 @@ class AllocatorVK final : public Allocator {
|
||||
private:
|
||||
friend class ContextVK;
|
||||
|
||||
fml::RefPtr<vulkan::VulkanProcTable> vk_;
|
||||
VmaAllocator allocator_ = {};
|
||||
ContextVK& context_;
|
||||
vk::Device device_;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// FLUTTER_NOLINT: https://github.com/flutter/flutter/issues/68331
|
||||
|
||||
#include "impeller/renderer/backend/vulkan/context_vk.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
DescriptorPoolVK::DescriptorPoolVK(vk::Device device) {
|
||||
DescriptorPoolVK::DescriptorPoolVK(vk::Device device) : device_(device) {
|
||||
constexpr size_t kPoolSize = 1024;
|
||||
|
||||
std::vector<vk::DescriptorPoolSize> pool_sizes = {
|
||||
@@ -34,20 +34,24 @@ DescriptorPoolVK::DescriptorPoolVK(vk::Device device) {
|
||||
pool_sizes.data() // pool sizes
|
||||
};
|
||||
|
||||
auto res = device.createDescriptorPoolUnique(pool_info);
|
||||
auto res = device.createDescriptorPool(pool_info);
|
||||
if (res.result != vk::Result::eSuccess) {
|
||||
VALIDATION_LOG << "Unable to create a descriptor pool";
|
||||
return;
|
||||
}
|
||||
|
||||
pool_ = std::move(res.value);
|
||||
pool_ = res.value;
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
vk::DescriptorPool DescriptorPoolVK::GetPool() {
|
||||
return *pool_;
|
||||
return pool_;
|
||||
}
|
||||
|
||||
DescriptorPoolVK::~DescriptorPoolVK() = default;
|
||||
DescriptorPoolVK::~DescriptorPoolVK() {
|
||||
if (is_valid_) {
|
||||
device_.destroyDescriptorPool(pool_);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -22,7 +22,8 @@ class DescriptorPoolVK {
|
||||
vk::DescriptorPool GetPool();
|
||||
|
||||
private:
|
||||
vk::UniqueDescriptorPool pool_;
|
||||
vk::Device device_;
|
||||
vk::DescriptorPool pool_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(DescriptorPoolVK);
|
||||
|
||||
@@ -27,11 +27,11 @@ static uint32_t color_flash = 0;
|
||||
|
||||
RenderPassVK::RenderPassVK(std::weak_ptr<const Context> context,
|
||||
vk::Device device,
|
||||
RenderTarget target,
|
||||
const RenderTarget& target,
|
||||
vk::UniqueCommandBuffer command_buffer,
|
||||
vk::UniqueRenderPass render_pass,
|
||||
SurfaceProducerVK* surface_producer)
|
||||
: RenderPass(context, target),
|
||||
: RenderPass(std::move(context), target),
|
||||
device_(device),
|
||||
command_buffer_(std::move(command_buffer)),
|
||||
render_pass_(std::move(render_pass)),
|
||||
@@ -91,10 +91,6 @@ bool RenderPassVK::OnEncodeCommands(const Context& context) const {
|
||||
clear_value.color =
|
||||
vk::ClearColorValue(std::array<float, 4>{0.0f, 0.0f, 0.0, 0.0f});
|
||||
|
||||
std::array<vk::ImageView, 1> fbo_attachments = {
|
||||
tex_info.swapchain_image->GetImageView(),
|
||||
};
|
||||
|
||||
const auto& size = tex_info.swapchain_image->GetSize();
|
||||
vk::Rect2D render_area =
|
||||
vk::Rect2D()
|
||||
@@ -377,7 +373,7 @@ vk::Framebuffer RenderPassVK::CreateFrameBuffer(
|
||||
.setLayers(1);
|
||||
auto res = device_.createFramebuffer(fb_create_info);
|
||||
FML_CHECK(res.result == vk::Result::eSuccess);
|
||||
return std::move(res.value);
|
||||
return res.value;
|
||||
}
|
||||
|
||||
bool RenderPassVK::TransitionImageLayout(uint32_t frame_num,
|
||||
@@ -401,6 +397,11 @@ bool RenderPassVK::TransitionImageLayout(uint32_t frame_num,
|
||||
vk::CommandBufferBeginInfo begin_info;
|
||||
auto res = transition_cmd->begin(begin_info);
|
||||
|
||||
if (res != vk::Result::eSuccess) {
|
||||
VALIDATION_LOG << "Failed to begin command buffer: " << vk::to_string(res);
|
||||
return false;
|
||||
}
|
||||
|
||||
vk::ImageMemoryBarrier barrier =
|
||||
vk::ImageMemoryBarrier()
|
||||
.setSrcAccessMask(vk::AccessFlagBits::eColorAttachmentRead)
|
||||
|
||||
@@ -21,7 +21,7 @@ class RenderPassVK final : public RenderPass {
|
||||
public:
|
||||
RenderPassVK(std::weak_ptr<const Context> context,
|
||||
vk::Device device,
|
||||
RenderTarget target,
|
||||
const RenderTarget& target,
|
||||
vk::UniqueCommandBuffer command_buffer,
|
||||
vk::UniqueRenderPass render_pass,
|
||||
SurfaceProducerVK* surface_producer);
|
||||
|
||||
@@ -46,9 +46,13 @@ bool TextureVK::OnSetContents(const uint8_t* contents,
|
||||
|
||||
// currently we are only supporting 2d textures, no cube textures etc.
|
||||
auto mapping = texture_info_->allocated_texture.allocation_info.pMappedData;
|
||||
memcpy(mapping, contents, length);
|
||||
|
||||
return true;
|
||||
if (mapping) {
|
||||
memcpy(mapping, contents, length);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool TextureVK::OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
|
||||
|
||||
@@ -19,23 +19,12 @@
|
||||
#define VULKAN_HPP_NAMESPACE impeller::vk
|
||||
#define VULKAN_HPP_ASSERT_ON_RESULT(ignored) \
|
||||
{ [[maybe_unused]] auto res = (ignored); }
|
||||
#define VULKAN_HPP_NO_EXCEPTIONS
|
||||
#include "vulkan/vulkan.hpp"
|
||||
|
||||
static_assert(VK_HEADER_VERSION >= 215,
|
||||
"Vulkan headers are must not be too old.");
|
||||
|
||||
#ifdef VMA_STATIC_VULKAN_FUNCTIONS
|
||||
#undef VMA_STATIC_VULKAN_FUNCTIONS
|
||||
#endif // VMA_STATIC_VULKAN_FUNCTIONS
|
||||
|
||||
#ifdef VMA_DYNAMIC_VULKAN_FUNCTIONS
|
||||
#undef VMA_DYNAMIC_VULKAN_FUNCTIONS
|
||||
#endif // VMA_DYNAMIC_VULKAN_FUNCTIONS
|
||||
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
||||
#include "vk_mem_alloc.h"
|
||||
#include "flutter/flutter_vma/flutter_vma.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ declare_args() {
|
||||
impeller_enable_opengles = is_mac || is_linux || is_win || is_android
|
||||
|
||||
# Whether the Vulkan backend is enabled.
|
||||
impeller_enable_vulkan = false
|
||||
impeller_enable_vulkan = is_linux
|
||||
|
||||
# Whether to use a prebuilt impellerc.
|
||||
# If this is the empty string, impellerc will be built.
|
||||
@@ -452,7 +452,7 @@ template("impeller_shaders_gles") {
|
||||
sl_file_extension = "gles"
|
||||
|
||||
# Metal reflectors generate a superset of information.
|
||||
if (impeller_enable_metal) {
|
||||
if (impeller_enable_metal || impeller_enable_vulkan) {
|
||||
intermediates_subdir = "gles"
|
||||
}
|
||||
if (is_mac) {
|
||||
@@ -489,7 +489,7 @@ template("impeller_shaders_gles") {
|
||||
group(target_name) {
|
||||
public_deps = [ ":$embed_gles_lib" ]
|
||||
|
||||
if (!impeller_enable_metal) {
|
||||
if (!impeller_enable_metal && !impeller_enable_vulkan) {
|
||||
public_deps += [ ":$reflect_gles" ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,10 @@ if (enable_unittests) {
|
||||
"shell_test_platform_view_vulkan.h",
|
||||
]
|
||||
|
||||
public_deps += [ "//flutter/vulkan" ]
|
||||
public_deps += [
|
||||
"//flutter/flutter_vma:flutter_skia_vma",
|
||||
"//flutter/vulkan",
|
||||
]
|
||||
}
|
||||
|
||||
if (test_enable_metal) {
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#include <utility>
|
||||
|
||||
#include "flutter/common/graphics/persistent_cache.h"
|
||||
#include "flutter/flutter_vma/flutter_skia_vma.h"
|
||||
#include "flutter/shell/common/context_options.h"
|
||||
#include "flutter/vulkan/vulkan_skia_proc_table.h"
|
||||
#include "flutter/vulkan/vulkan_utilities.h"
|
||||
|
||||
#if OS_FUCHSIA
|
||||
@@ -111,6 +113,11 @@ ShellTestPlatformViewVulkan::OffScreenSurface::OffScreenSurface(
|
||||
return;
|
||||
}
|
||||
|
||||
memory_allocator_ = FlutterSkiaVulkanMemoryAllocator::Make(
|
||||
application_->GetAPIVersion(), application_->GetInstance(),
|
||||
logical_device_->GetPhysicalDeviceHandle(), logical_device_->GetHandle(),
|
||||
vk_, true);
|
||||
|
||||
// Create the Skia GrContext.
|
||||
if (!CreateSkiaGrContext()) {
|
||||
FML_DLOG(ERROR) << "Could not create Skia context.";
|
||||
@@ -148,7 +155,7 @@ bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaGrContext() {
|
||||
|
||||
bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaBackendContext(
|
||||
GrVkBackendContext* context) {
|
||||
auto getProc = vk_->CreateSkiaGetProc();
|
||||
auto getProc = CreateSkiaGetProc(vk_);
|
||||
|
||||
if (getProc == nullptr) {
|
||||
FML_DLOG(ERROR) << "GetProcAddress is null";
|
||||
@@ -171,6 +178,8 @@ bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaBackendContext(
|
||||
context->fFeatures = skia_features;
|
||||
context->fGetProc = std::move(getProc);
|
||||
context->fOwnsInstanceAndDevice = false;
|
||||
context->fMemoryAllocator = memory_allocator_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h"
|
||||
#include "flutter/vulkan/vulkan_application.h"
|
||||
#include "flutter/vulkan/vulkan_device.h"
|
||||
#include "flutter/vulkan/vulkan_skia_proc_table.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
@@ -54,6 +55,7 @@ class ShellTestPlatformViewVulkan : public ShellTestPlatformView {
|
||||
shell_test_external_view_embedder_;
|
||||
std::unique_ptr<vulkan::VulkanApplication> application_;
|
||||
std::unique_ptr<vulkan::VulkanDevice> logical_device_;
|
||||
sk_sp<skgpu::VulkanMemoryAllocator> memory_allocator_;
|
||||
sk_sp<GrDirectContext> context_;
|
||||
|
||||
bool CreateSkiaGrContext();
|
||||
|
||||
@@ -56,6 +56,7 @@ source_set("gpu_surface_vulkan") {
|
||||
public_deps = gpu_common_deps + [
|
||||
"//flutter/shell/platform/embedder:embedder_headers",
|
||||
"//flutter/vulkan",
|
||||
"//flutter/vulkan/procs",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
#include "flutter/fml/memory/ref_ptr.h"
|
||||
#include "flutter/shell/platform/embedder/embedder.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/vulkan_device.h"
|
||||
#include "flutter/vulkan/vulkan_image.h"
|
||||
#include "flutter/vulkan/vulkan_proc_table.h"
|
||||
#include "third_party/skia/include/core/SkSize.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@@ -135,6 +135,11 @@ template("embedder_source_set") {
|
||||
"embedder_surface_vulkan.cc",
|
||||
"embedder_surface_vulkan.h",
|
||||
]
|
||||
|
||||
deps += [
|
||||
"//flutter/flutter_vma:flutter_skia_vma",
|
||||
"//flutter/vulkan/procs",
|
||||
]
|
||||
}
|
||||
|
||||
public_deps = [ ":embedder_headers" ]
|
||||
@@ -291,6 +296,7 @@ if (enable_unittests) {
|
||||
public_deps += [
|
||||
"//flutter/testing:vulkan",
|
||||
"//flutter/vulkan",
|
||||
"//flutter/vulkan/procs",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,8 +556,13 @@ InferVulkanPlatformViewCreationCallback(
|
||||
return ptr(user_data, &image_desc);
|
||||
};
|
||||
|
||||
auto vk_instance = static_cast<VkInstance>(config->vulkan.instance);
|
||||
auto proc_addr =
|
||||
vulkan_get_instance_proc_address(vk_instance, "GetInstanceProcAddr");
|
||||
|
||||
flutter::EmbedderSurfaceVulkan::VulkanDispatchTable vulkan_dispatch_table = {
|
||||
.get_instance_proc_address = vulkan_get_instance_proc_address,
|
||||
.get_instance_proc_address =
|
||||
reinterpret_cast<PFN_vkGetInstanceProcAddr>(proc_addr),
|
||||
.get_next_image = vulkan_get_next_image,
|
||||
.present_image = vulkan_present_image_callback,
|
||||
};
|
||||
@@ -567,8 +572,7 @@ InferVulkanPlatformViewCreationCallback(
|
||||
|
||||
std::unique_ptr<flutter::EmbedderSurfaceVulkan> embedder_surface =
|
||||
std::make_unique<flutter::EmbedderSurfaceVulkan>(
|
||||
config->vulkan.version,
|
||||
static_cast<VkInstance>(config->vulkan.instance),
|
||||
config->vulkan.version, vk_instance,
|
||||
config->vulkan.enabled_instance_extension_count,
|
||||
config->vulkan.enabled_instance_extensions,
|
||||
config->vulkan.enabled_device_extension_count,
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "flutter/flutter_vma/flutter_skia_vma.h"
|
||||
#include "flutter/shell/common/shell_io_manager.h"
|
||||
#include "flutter/vulkan/vulkan_skia_proc_table.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "include/gpu/vk/GrVkBackendContext.h"
|
||||
#include "include/gpu/vk/GrVkExtensions.h"
|
||||
@@ -44,8 +46,18 @@ EmbedderSurfaceVulkan::EmbedderSurfaceVulkan(
|
||||
return;
|
||||
}
|
||||
|
||||
vk_->SetupInstanceProcAddresses(vulkan::VulkanHandle<VkInstance>{instance});
|
||||
vk_->SetupDeviceProcAddresses(vulkan::VulkanHandle<VkDevice>{device});
|
||||
bool success = vk_->SetupInstanceProcAddresses(
|
||||
vulkan::VulkanHandle<VkInstance>{instance});
|
||||
if (!success) {
|
||||
FML_LOG(ERROR) << "Could not setup instance proc addresses.";
|
||||
return;
|
||||
}
|
||||
success =
|
||||
vk_->SetupDeviceProcAddresses(vulkan::VulkanHandle<VkDevice>{device});
|
||||
if (!success) {
|
||||
FML_LOG(ERROR) << "Could not setup device proc addresses.";
|
||||
return;
|
||||
}
|
||||
if (!vk_->IsValid()) {
|
||||
FML_LOG(ERROR) << "VulkanProcTable invalid.";
|
||||
return;
|
||||
@@ -122,7 +134,7 @@ sk_sp<GrDirectContext> EmbedderSurfaceVulkan::CreateGrContext(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto get_proc = vk_->CreateSkiaGetProc();
|
||||
auto get_proc = CreateSkiaGetProc(vk_);
|
||||
if (get_proc == nullptr) {
|
||||
FML_LOG(ERROR) << "Failed to create Vulkan getProc for Skia.";
|
||||
return nullptr;
|
||||
@@ -143,6 +155,14 @@ sk_sp<GrDirectContext> EmbedderSurfaceVulkan::CreateGrContext(
|
||||
backend_context.fGetProc = get_proc;
|
||||
backend_context.fOwnsInstanceAndDevice = false;
|
||||
|
||||
uint32_t vulkan_api_version = version;
|
||||
sk_sp<skgpu::VulkanMemoryAllocator> allocator =
|
||||
flutter::FlutterSkiaVulkanMemoryAllocator::Make(
|
||||
vulkan_api_version, instance, device_.GetPhysicalDeviceHandle(),
|
||||
device_.GetHandle(), vk_, true);
|
||||
|
||||
backend_context.fMemoryAllocator = allocator;
|
||||
|
||||
extensions.init(backend_context.fGetProc, backend_context.fInstance,
|
||||
backend_context.fPhysicalDevice, instance_extension_count,
|
||||
instance_extensions, device_extension_count,
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "flutter/shell/gpu/gpu_surface_vulkan.h"
|
||||
#include "flutter/shell/platform/embedder/embedder_external_view_embedder.h"
|
||||
#include "flutter/shell/platform/embedder/embedder_surface.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "shell/common/context_options.h"
|
||||
#include "shell/gpu/gpu_surface_vulkan_delegate.h"
|
||||
#include "shell/platform/embedder/embedder.h"
|
||||
#include "vulkan/vulkan_proc_table.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@@ -20,8 +20,7 @@ class EmbedderSurfaceVulkan final : public EmbedderSurface,
|
||||
public GPUSurfaceVulkanDelegate {
|
||||
public:
|
||||
struct VulkanDispatchTable {
|
||||
std::function<void*(VkInstance, const char*)>
|
||||
get_instance_proc_address; // required
|
||||
PFN_vkGetInstanceProcAddr get_instance_proc_address; // required
|
||||
std::function<FlutterVulkanImage(const SkISize& frame_size)>
|
||||
get_next_image; // required
|
||||
std::function<bool(VkImage image, VkFormat format)>
|
||||
|
||||
@@ -510,9 +510,9 @@ void EmbedderConfigBuilder::InitializeVulkanRendererConfig() {
|
||||
vulkan_renderer_config_.get_instance_proc_address_callback =
|
||||
[](void* context, FlutterVulkanInstanceHandle instance,
|
||||
const char* name) -> void* {
|
||||
return reinterpret_cast<EmbedderTestContextVulkan*>(context)
|
||||
->vulkan_context_->vk_->GetInstanceProcAddr(
|
||||
reinterpret_cast<VkInstance>(instance), name);
|
||||
auto proc_addr = reinterpret_cast<EmbedderTestContextVulkan*>(context)
|
||||
->vulkan_context_->vk_->GetInstanceProcAddr;
|
||||
return reinterpret_cast<void*>(proc_addr);
|
||||
};
|
||||
vulkan_renderer_config_.get_next_image_callback =
|
||||
[](void* context,
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_compositor_vulkan.h"
|
||||
#include "flutter/testing/test_vulkan_context.h"
|
||||
#include "flutter/testing/test_vulkan_surface.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/vulkan_device.h"
|
||||
#include "flutter/vulkan/vulkan_proc_table.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@@ -131,13 +131,16 @@ template("runner_sources") {
|
||||
"//flutter/shell/common",
|
||||
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
|
||||
]
|
||||
|
||||
flutter_deps = [
|
||||
":fuchsia_gpu_configuration",
|
||||
"//flutter/assets",
|
||||
"//flutter/common",
|
||||
"//flutter/flutter_vma:flutter_skia_vma",
|
||||
"//flutter/fml",
|
||||
"//flutter/shell/platform/common/client_wrapper:client_wrapper_library_stubs",
|
||||
"//flutter/vulkan",
|
||||
"//flutter/vulkan/procs",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/vulkan_command_buffer.h"
|
||||
#include "flutter/vulkan/vulkan_handle.h"
|
||||
#include "flutter/vulkan/vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/vulkan_provider.h"
|
||||
#include "third_party/skia/include/core/SkColorType.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "flutter/vulkan/vulkan_skia_proc_table.h"
|
||||
#include "flutter_vma/flutter_skia_vma.h"
|
||||
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
|
||||
#include "third_party/skia/include/gpu/GrBackendSurface.h"
|
||||
#include "third_party/skia/include/gpu/vk/GrVkBackendContext.h"
|
||||
@@ -98,7 +100,7 @@ bool VulkanSurfaceProducer::Initialize(scenic::Session* scenic_session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto getProc = vk_->CreateSkiaGetProc();
|
||||
auto getProc = CreateSkiaGetProc(vk_);
|
||||
|
||||
if (getProc == nullptr) {
|
||||
FML_LOG(ERROR) << "VulkanSurfaceProducer: Failed to create skia getProc.";
|
||||
@@ -113,6 +115,11 @@ bool VulkanSurfaceProducer::Initialize(scenic::Session* scenic_session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memory_allocator_ = flutter::FlutterSkiaVulkanMemoryAllocator::Make(
|
||||
application_->GetAPIVersion(), application_->GetInstance(),
|
||||
logical_device_->GetPhysicalDeviceHandle(), logical_device_->GetHandle(),
|
||||
vk_, true);
|
||||
|
||||
GrVkBackendContext backend_context;
|
||||
backend_context.fInstance = application_->GetInstance();
|
||||
backend_context.fPhysicalDevice = logical_device_->GetPhysicalDeviceHandle();
|
||||
@@ -125,6 +132,8 @@ bool VulkanSurfaceProducer::Initialize(scenic::Session* scenic_session) {
|
||||
backend_context.fFeatures = skia_features;
|
||||
backend_context.fGetProc = std::move(getProc);
|
||||
backend_context.fOwnsInstanceAndDevice = false;
|
||||
backend_context.fMemoryAllocator = memory_allocator_;
|
||||
|
||||
// The memory_requirements_2 extension is required on Fuchsia as the AMD
|
||||
// memory allocator used by Skia benefit from it.
|
||||
const char* device_extensions[] = {
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
#include <lib/ui/scenic/cpp/resources.h>
|
||||
#include <lib/ui/scenic/cpp/session.h>
|
||||
|
||||
#include "flutter/flutter_vma/flutter_skia_vma.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/memory/weak_ptr.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/vulkan_application.h"
|
||||
#include "flutter/vulkan/vulkan_device.h"
|
||||
#include "flutter/vulkan/vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/vulkan_provider.h"
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
|
||||
@@ -76,6 +77,7 @@ class VulkanSurfaceProducer final : public SurfaceProducer,
|
||||
std::unique_ptr<vulkan::VulkanDevice> logical_device_;
|
||||
sk_sp<GrDirectContext> context_;
|
||||
std::unique_ptr<VulkanSurfacePool> surface_pool_;
|
||||
sk_sp<skgpu::VulkanMemoryAllocator> memory_allocator_;
|
||||
bool valid_ = false;
|
||||
|
||||
// WeakPtrFactory must be the last member.
|
||||
|
||||
@@ -141,9 +141,11 @@ if (enable_unittests) {
|
||||
|
||||
deps = [
|
||||
":skia",
|
||||
"//flutter/flutter_vma:flutter_skia_vma",
|
||||
"//flutter/fml",
|
||||
"//flutter/shell/common",
|
||||
"//flutter/vulkan",
|
||||
"//flutter/vulkan/procs",
|
||||
]
|
||||
|
||||
if (!is_fuchsia) {
|
||||
|
||||
@@ -83,7 +83,7 @@ ColorWheel/Vulkan,pass
|
||||
TransformMultipliesCorrectly/Vulkan,pass
|
||||
SolidStrokesRenderCorrectly/Vulkan,pass
|
||||
GradientStrokesRenderCorrectly/Vulkan,pass
|
||||
CoverageOriginShouldBeAccountedForInSubpasses/Vulkan,pass
|
||||
CoverageOriginShouldBeAccountedForInSubpasses/Vulkan,fail
|
||||
DrawRectStrokesRenderCorrectly/Vulkan,pass
|
||||
SaveLayerDrawsBehindSubsequentEntities/Vulkan,pass
|
||||
SiblingSaveLayerBoundsAreRespected/Vulkan,pass
|
||||
|
||||
|
@@ -6,9 +6,11 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "flutter/flutter_vma/flutter_skia_vma.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/shell/common/context_options.h"
|
||||
#include "flutter/testing/test_vulkan_context.h"
|
||||
#include "flutter/vulkan/vulkan_skia_proc_table.h"
|
||||
|
||||
#include "flutter/fml/memory/ref_ptr.h"
|
||||
#include "flutter/fml/native_library.h"
|
||||
@@ -81,12 +83,17 @@ TestVulkanContext::TestVulkanContext() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto get_proc = vk_->CreateSkiaGetProc();
|
||||
auto get_proc = vulkan::CreateSkiaGetProc(vk_);
|
||||
if (get_proc == nullptr) {
|
||||
FML_LOG(ERROR) << "Failed to create Vulkan getProc for Skia.";
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<skgpu::VulkanMemoryAllocator> allocator =
|
||||
flutter::FlutterSkiaVulkanMemoryAllocator::Make(
|
||||
VK_MAKE_VERSION(1, 0, 0), application_->GetInstance(),
|
||||
device_->GetPhysicalDeviceHandle(), device_->GetHandle(), vk_, true);
|
||||
|
||||
GrVkExtensions extensions;
|
||||
|
||||
GrVkBackendContext backend_context = {};
|
||||
@@ -101,6 +108,7 @@ TestVulkanContext::TestVulkanContext() {
|
||||
backend_context.fVkExtensions = &extensions;
|
||||
backend_context.fGetProc = get_proc;
|
||||
backend_context.fOwnsInstanceAndDevice = false;
|
||||
backend_context.fMemoryAllocator = allocator;
|
||||
|
||||
GrContextOptions options =
|
||||
MakeDefaultContextOptions(ContextType::kRender, GrBackendApi::kVulkan);
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/memory/ref_ptr.h"
|
||||
#include "flutter/testing/test_vulkan_image.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/vulkan_application.h"
|
||||
#include "flutter/vulkan/vulkan_device.h"
|
||||
#include "flutter/vulkan/vulkan_proc_table.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkSize.h"
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#define FLUTTER_TESTING_TEST_VULKAN_IMAGE_H_
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/vulkan/vulkan_handle.h"
|
||||
|
||||
#include "flutter/fml/memory/ref_ptr.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "third_party/skia/include/core/SkSize.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@@ -436,13 +436,12 @@ def to_gn_args(args):
|
||||
# features can't work on these platforms.
|
||||
if args.target_os not in ['android', 'ios']:
|
||||
gn_args['skia_use_vulkan'] = True
|
||||
gn_args['skia_vulkan_memory_allocator_dir'
|
||||
] = '//third_party/vulkan_memory_allocator'
|
||||
gn_args['skia_use_vma'] = False
|
||||
gn_args['shell_enable_vulkan'] = True
|
||||
# Disable VMA's use of std::shared_mutex in environments where the
|
||||
# standard library doesn't support it.
|
||||
if args.target_os == 'ios' or sys.platform.startswith(('cygwin', 'win')):
|
||||
gn_args['skia_disable_vma_stl_shared_mutex'] = True
|
||||
gn_args['disable_vma_stl_shared_mutex'] = True
|
||||
|
||||
# We should not need a special case for x86, but this seems to introduce text relocations
|
||||
# even with -fPIC everywhere.
|
||||
@@ -543,12 +542,6 @@ def to_gn_args(args):
|
||||
if args.prebuilt_impellerc is not None:
|
||||
gn_args['impeller_use_prebuilt_impellerc'] = args.prebuilt_impellerc
|
||||
|
||||
# Vulkan support is WIP, see: https://github.com/flutter/flutter/issues/107357
|
||||
if args.enable_impeller_vulkan:
|
||||
gn_args['impeller_enable_opengles'] = False
|
||||
gn_args['impeller_enable_vulkan'] = True
|
||||
gn_args['skia_use_vma'] = False
|
||||
|
||||
# ANGLE is exclusively used for:
|
||||
# - Windows at runtime
|
||||
# - Non-fuchsia host unit tests (is_host_build evaluates to false).
|
||||
@@ -956,6 +949,8 @@ def parse_args(args):
|
||||
help='Absolute path to a prebuilt impellerc. ' +
|
||||
'Do not use this outside of CI or with impellerc from a different engine version.'
|
||||
)
|
||||
|
||||
# This is currently a no-op, will be removed shortly.
|
||||
parser.add_argument(
|
||||
'--enable-impeller-vulkan',
|
||||
default=False,
|
||||
|
||||
@@ -27,16 +27,12 @@ source_set("vulkan") {
|
||||
"vulkan_debug_report.h",
|
||||
"vulkan_device.cc",
|
||||
"vulkan_device.h",
|
||||
"vulkan_handle.cc",
|
||||
"vulkan_handle.h",
|
||||
"vulkan_image.cc",
|
||||
"vulkan_image.h",
|
||||
"vulkan_interface.cc",
|
||||
"vulkan_interface.h",
|
||||
"vulkan_native_surface.cc",
|
||||
"vulkan_native_surface.h",
|
||||
"vulkan_proc_table.cc",
|
||||
"vulkan_proc_table.h",
|
||||
"vulkan_skia_proc_table.cc",
|
||||
"vulkan_skia_proc_table.h",
|
||||
"vulkan_surface.cc",
|
||||
"vulkan_surface.h",
|
||||
"vulkan_swapchain.h",
|
||||
@@ -57,6 +53,8 @@ source_set("vulkan") {
|
||||
}
|
||||
|
||||
deps = [
|
||||
"procs",
|
||||
"//flutter/flutter_vma:flutter_skia_vma",
|
||||
"//flutter/fml",
|
||||
"//third_party/skia",
|
||||
]
|
||||
|
||||
21
engine/src/flutter/vulkan/procs/BUILD.gn
Normal file
21
engine/src/flutter/vulkan/procs/BUILD.gn
Normal file
@@ -0,0 +1,21 @@
|
||||
# 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.
|
||||
|
||||
source_set("procs") {
|
||||
sources = [
|
||||
"vulkan_handle.cc",
|
||||
"vulkan_handle.h",
|
||||
"vulkan_interface.cc",
|
||||
"vulkan_interface.h",
|
||||
"vulkan_proc_table.cc",
|
||||
"vulkan_proc_table.h",
|
||||
]
|
||||
|
||||
deps = [ "//flutter/fml" ]
|
||||
|
||||
public_configs = [
|
||||
"//flutter/vulkan:vulkan_config",
|
||||
"//flutter:config",
|
||||
]
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_VULKAN_VULKAN_HANDLE_H_
|
||||
#define FLUTTER_VULKAN_VULKAN_HANDLE_H_
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "vulkan_interface.h"
|
||||
#include "flutter/vulkan/procs/vulkan_interface.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
@@ -77,5 +76,3 @@ class VulkanHandle {
|
||||
};
|
||||
|
||||
} // namespace vulkan
|
||||
|
||||
#endif // FLUTTER_VULKAN_VULKAN_HANDLE_H_
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "vulkan_interface.h"
|
||||
#include "flutter/vulkan/procs/vulkan_interface.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_VULKAN_VULKAN_INTERFACE_H_
|
||||
#define FLUTTER_VULKAN_VULKAN_INTERFACE_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -25,10 +24,6 @@
|
||||
#endif // VK_USE_PLATFORM_FUCHSIA
|
||||
#endif // OS_FUCHSIA
|
||||
|
||||
#if !VULKAN_LINK_STATICALLY
|
||||
#define VK_NO_PROTOTYPES 1
|
||||
#endif // !VULKAN_LINK_STATICALLY
|
||||
|
||||
// TODO(dnfield): vulkan_metal.h has some unguarded availability checks for
|
||||
// macOS 10.13. We can remove this if we bump to 10.14 or if that gets fixed
|
||||
// upstream, but fixing it upstream will take some time to flow through to
|
||||
@@ -55,5 +50,3 @@ namespace vulkan {
|
||||
std::string VulkanResultToString(VkResult result);
|
||||
|
||||
} // namespace vulkan
|
||||
|
||||
#endif // FLUTTER_VULKAN_VULKAN_INTERFACE_H_
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -14,6 +14,14 @@
|
||||
return false; \
|
||||
}
|
||||
|
||||
#define ACQUIRE_PROC_EITHER(name, name2, context) \
|
||||
if (!(name = AcquireProc("vk" #name, context)) && \
|
||||
!(name2 = AcquireProc("vk" #name2, context))) { \
|
||||
FML_DLOG(INFO) << "Could not acquire proc: vk" << #name << ", or proc: vk" \
|
||||
<< #name2; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
VulkanProcTable::VulkanProcTable() : VulkanProcTable("libvulkan.so"){};
|
||||
@@ -26,9 +34,9 @@ VulkanProcTable::VulkanProcTable(const char* so_path)
|
||||
}
|
||||
|
||||
VulkanProcTable::VulkanProcTable(
|
||||
std::function<void*(VkInstance, const char*)> get_instance_proc_addr)
|
||||
PFN_vkGetInstanceProcAddr get_instance_proc_addr)
|
||||
: handle_(nullptr), acquired_mandatory_proc_addresses_(false) {
|
||||
GetInstanceProcAddr = std::move(get_instance_proc_addr);
|
||||
GetInstanceProcAddr = get_instance_proc_addr;
|
||||
acquired_mandatory_proc_addresses_ = SetupLoaderProcAddresses();
|
||||
}
|
||||
|
||||
@@ -57,13 +65,7 @@ bool VulkanProcTable::SetupGetInstanceProcAddress() {
|
||||
return true;
|
||||
}
|
||||
|
||||
GetInstanceProcAddr = reinterpret_cast<void* (*)(VkInstance, const char*)>(
|
||||
#if VULKAN_LINK_STATICALLY
|
||||
&vkGetInstanceProcAddr
|
||||
#else // VULKAN_LINK_STATICALLY
|
||||
const_cast<uint8_t*>(handle_->ResolveSymbol("vkGetInstanceProcAddr"))
|
||||
#endif // VULKAN_LINK_STATICALLY
|
||||
);
|
||||
GetInstanceProcAddr = NativeGetInstanceProcAddr();
|
||||
if (!GetInstanceProcAddr) {
|
||||
FML_DLOG(WARNING) << "Could not acquire vkGetInstanceProcAddr.";
|
||||
return false;
|
||||
@@ -72,6 +74,20 @@ bool VulkanProcTable::SetupGetInstanceProcAddress() {
|
||||
return true;
|
||||
}
|
||||
|
||||
PFN_vkGetInstanceProcAddr VulkanProcTable::NativeGetInstanceProcAddr() const {
|
||||
if (GetInstanceProcAddr) {
|
||||
return GetInstanceProcAddr;
|
||||
}
|
||||
|
||||
#if VULKAN_LINK_STATICALLY
|
||||
return &vkGetInstanceProcAddr;
|
||||
#else // VULKAN_LINK_STATICALLY
|
||||
auto instance_proc =
|
||||
const_cast<uint8_t*>(handle_->ResolveSymbol("vkGetInstanceProcAddr"));
|
||||
return reinterpret_cast<PFN_vkGetInstanceProcAddr>(instance_proc);
|
||||
#endif // VULKAN_LINK_STATICALLY
|
||||
}
|
||||
|
||||
bool VulkanProcTable::SetupLoaderProcAddresses() {
|
||||
VulkanHandle<VkInstance> null_instance(VK_NULL_HANDLE, nullptr);
|
||||
|
||||
@@ -92,6 +108,11 @@ bool VulkanProcTable::SetupInstanceProcAddresses(
|
||||
ACQUIRE_PROC(GetDeviceProcAddr, handle);
|
||||
ACQUIRE_PROC(GetPhysicalDeviceFeatures, handle);
|
||||
ACQUIRE_PROC(GetPhysicalDeviceQueueFamilyProperties, handle);
|
||||
ACQUIRE_PROC(GetPhysicalDeviceProperties, handle);
|
||||
ACQUIRE_PROC(GetPhysicalDeviceMemoryProperties, handle);
|
||||
ACQUIRE_PROC_EITHER(GetPhysicalDeviceMemoryProperties2,
|
||||
GetPhysicalDeviceMemoryProperties2KHR, handle);
|
||||
|
||||
#if FML_OS_ANDROID
|
||||
ACQUIRE_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR, handle);
|
||||
ACQUIRE_PROC(GetPhysicalDeviceSurfaceFormatsKHR, handle);
|
||||
@@ -142,6 +163,23 @@ bool VulkanProcTable::SetupDeviceProcAddresses(
|
||||
ACQUIRE_PROC(ResetCommandBuffer, handle);
|
||||
ACQUIRE_PROC(ResetFences, handle);
|
||||
ACQUIRE_PROC(WaitForFences, handle);
|
||||
ACQUIRE_PROC(MapMemory, handle);
|
||||
ACQUIRE_PROC(UnmapMemory, handle);
|
||||
ACQUIRE_PROC(FlushMappedMemoryRanges, handle);
|
||||
ACQUIRE_PROC(InvalidateMappedMemoryRanges, handle);
|
||||
ACQUIRE_PROC(BindBufferMemory, handle);
|
||||
ACQUIRE_PROC(GetBufferMemoryRequirements, handle);
|
||||
ACQUIRE_PROC(CreateBuffer, handle);
|
||||
ACQUIRE_PROC(DestroyBuffer, handle);
|
||||
ACQUIRE_PROC(CmdCopyBuffer, handle);
|
||||
|
||||
ACQUIRE_PROC_EITHER(GetBufferMemoryRequirements2,
|
||||
GetBufferMemoryRequirements2KHR, handle);
|
||||
ACQUIRE_PROC_EITHER(GetImageMemoryRequirements2,
|
||||
GetImageMemoryRequirements2KHR, handle);
|
||||
ACQUIRE_PROC_EITHER(BindBufferMemory2, BindBufferMemory2KHR, handle);
|
||||
ACQUIRE_PROC_EITHER(BindImageMemory2, BindImageMemory2KHR, handle);
|
||||
|
||||
#ifndef TEST_VULKAN_PROCS
|
||||
#if FML_OS_ANDROID
|
||||
ACQUIRE_PROC(AcquireNextImageKHR, handle);
|
||||
@@ -171,7 +209,7 @@ bool VulkanProcTable::OpenLibraryHandle(const char* path) {
|
||||
handle_ = fml::NativeLibrary::Create(path);
|
||||
#endif // VULKAN_LINK_STATICALLY
|
||||
if (!handle_) {
|
||||
FML_DLOG(WARNING) << "Could not open Vulkan library handle: " << path;
|
||||
FML_DLOG(ERROR) << "Could not open Vulkan library handle: " << path;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -204,22 +242,4 @@ PFN_vkVoidFunction VulkanProcTable::AcquireProc(
|
||||
return GetDeviceProcAddr(device, proc_name);
|
||||
}
|
||||
|
||||
GrVkGetProc VulkanProcTable::CreateSkiaGetProc() const {
|
||||
if (!IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return [this](const char* proc_name, VkInstance instance, VkDevice device) {
|
||||
if (device != VK_NULL_HANDLE) {
|
||||
auto result =
|
||||
AcquireProc(proc_name, VulkanHandle<VkDevice>{device, nullptr});
|
||||
if (result != nullptr) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return AcquireProc(proc_name, VulkanHandle<VkInstance>{instance, nullptr});
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace vulkan
|
||||
@@ -2,17 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_VULKAN_VULKAN_PROC_TABLE_H_
|
||||
#define FLUTTER_VULKAN_VULKAN_PROC_TABLE_H_
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/memory/ref_counted.h"
|
||||
#include "flutter/fml/memory/ref_ptr.h"
|
||||
#include "flutter/fml/native_library.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
#include "third_party/skia/include/gpu/vk/GrVkBackendContext.h"
|
||||
#include "vulkan_handle.h"
|
||||
#include "vulkan_interface.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_interface.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
@@ -50,8 +47,7 @@ class VulkanProcTable : public fml::RefCountedThreadSafe<VulkanProcTable> {
|
||||
|
||||
VulkanProcTable();
|
||||
explicit VulkanProcTable(const char* so_path);
|
||||
explicit VulkanProcTable(
|
||||
std::function<void*(VkInstance, const char*)> get_instance_proc_addr);
|
||||
explicit VulkanProcTable(PFN_vkGetInstanceProcAddr get_instance_proc_addr);
|
||||
~VulkanProcTable();
|
||||
|
||||
bool HasAcquiredMandatoryProcAddresses() const;
|
||||
@@ -66,9 +62,7 @@ class VulkanProcTable : public fml::RefCountedThreadSafe<VulkanProcTable> {
|
||||
|
||||
bool SetupDeviceProcAddresses(const VulkanHandle<VkDevice>& device);
|
||||
|
||||
GrVkGetProc CreateSkiaGetProc() const;
|
||||
|
||||
std::function<void*(VkInstance, const char*)> GetInstanceProcAddr = nullptr;
|
||||
PFN_vkGetInstanceProcAddr GetInstanceProcAddr = nullptr;
|
||||
|
||||
#define DEFINE_PROC(name) Proc<PFN_vk##name> name;
|
||||
|
||||
@@ -113,6 +107,30 @@ class VulkanProcTable : public fml::RefCountedThreadSafe<VulkanProcTable> {
|
||||
DEFINE_PROC(ResetCommandBuffer);
|
||||
DEFINE_PROC(ResetFences);
|
||||
DEFINE_PROC(WaitForFences);
|
||||
DEFINE_PROC(GetPhysicalDeviceProperties);
|
||||
DEFINE_PROC(GetPhysicalDeviceMemoryProperties);
|
||||
DEFINE_PROC(MapMemory);
|
||||
DEFINE_PROC(UnmapMemory);
|
||||
DEFINE_PROC(FlushMappedMemoryRanges);
|
||||
DEFINE_PROC(InvalidateMappedMemoryRanges);
|
||||
DEFINE_PROC(BindBufferMemory);
|
||||
DEFINE_PROC(GetBufferMemoryRequirements);
|
||||
DEFINE_PROC(CreateBuffer);
|
||||
DEFINE_PROC(DestroyBuffer);
|
||||
DEFINE_PROC(CmdCopyBuffer);
|
||||
|
||||
DEFINE_PROC(GetPhysicalDeviceMemoryProperties2);
|
||||
DEFINE_PROC(GetPhysicalDeviceMemoryProperties2KHR);
|
||||
|
||||
DEFINE_PROC(GetBufferMemoryRequirements2);
|
||||
DEFINE_PROC(GetBufferMemoryRequirements2KHR);
|
||||
DEFINE_PROC(GetImageMemoryRequirements2);
|
||||
DEFINE_PROC(GetImageMemoryRequirements2KHR);
|
||||
DEFINE_PROC(BindBufferMemory2);
|
||||
DEFINE_PROC(BindBufferMemory2KHR);
|
||||
DEFINE_PROC(BindImageMemory2);
|
||||
DEFINE_PROC(BindImageMemory2KHR);
|
||||
|
||||
#ifndef TEST_VULKAN_PROCS
|
||||
#if FML_OS_ANDROID
|
||||
DEFINE_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR);
|
||||
@@ -136,6 +154,15 @@ class VulkanProcTable : public fml::RefCountedThreadSafe<VulkanProcTable> {
|
||||
|
||||
#undef DEFINE_PROC
|
||||
|
||||
PFN_vkGetInstanceProcAddr NativeGetInstanceProcAddr() const;
|
||||
|
||||
PFN_vkVoidFunction AcquireProc(
|
||||
const char* proc_name,
|
||||
const VulkanHandle<VkInstance>& instance) const;
|
||||
|
||||
PFN_vkVoidFunction AcquireProc(const char* proc_name,
|
||||
const VulkanHandle<VkDevice>& device) const;
|
||||
|
||||
private:
|
||||
fml::RefPtr<fml::NativeLibrary> handle_;
|
||||
bool acquired_mandatory_proc_addresses_;
|
||||
@@ -146,15 +173,8 @@ class VulkanProcTable : public fml::RefCountedThreadSafe<VulkanProcTable> {
|
||||
bool SetupGetInstanceProcAddress();
|
||||
bool SetupLoaderProcAddresses();
|
||||
bool CloseLibraryHandle();
|
||||
PFN_vkVoidFunction AcquireProc(
|
||||
const char* proc_name,
|
||||
const VulkanHandle<VkInstance>& instance) const;
|
||||
PFN_vkVoidFunction AcquireProc(const char* proc_name,
|
||||
const VulkanHandle<VkDevice>& device) const;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(VulkanProcTable);
|
||||
};
|
||||
|
||||
} // namespace vulkan
|
||||
|
||||
#endif // FLUTTER_VULKAN_VULKAN_PROC_TABLE_H_
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "vulkan_device.h"
|
||||
#include "vulkan_proc_table.h"
|
||||
#include "vulkan_utilities.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "vulkan_debug_report.h"
|
||||
#include "vulkan_handle.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "third_party/skia/include/gpu/vk/GrVkTypes.h"
|
||||
#include "vulkan/vulkan.h"
|
||||
#include "vulkan_proc_table.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include "flutter/fml/compiler_specific.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "third_party/skia/include/core/SkSize.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "vulkan_command_buffer.h"
|
||||
#include "vulkan_handle.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "vulkan_command_buffer.h"
|
||||
|
||||
#include "vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "flutter/fml/compiler_specific.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#define FLUTTER_VULKAN_VULKAN_DEBUG_REPORT_H_
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "vulkan_handle.h"
|
||||
#include "vulkan_interface.h"
|
||||
#include "vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_interface.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "third_party/skia/include/gpu/vk/GrVkBackendContext.h"
|
||||
#include "vulkan_proc_table.h"
|
||||
#include "vulkan_surface.h"
|
||||
#include "vulkan_utilities.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "flutter/fml/compiler_specific.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "vulkan_image.h"
|
||||
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "vulkan_command_buffer.h"
|
||||
#include "vulkan_proc_table.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "flutter/fml/compiler_specific.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#define FLUTTER_VULKAN_VULKAN_NATIVE_SURFACE_H_
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "third_party/skia/include/core/SkSize.h"
|
||||
#include "vulkan_handle.h"
|
||||
#include "vulkan_proc_table.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#ifndef FLUTTER_VULKAN_VULKAN_PROVIDER_H_
|
||||
#define FLUTTER_VULKAN_VULKAN_PROVIDER_H_
|
||||
|
||||
#include "vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
28
engine/src/flutter/vulkan/vulkan_skia_proc_table.cc
Normal file
28
engine/src/flutter/vulkan/vulkan_skia_proc_table.cc
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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_skia_proc_table.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
GrVkGetProc CreateSkiaGetProc(const fml::RefPtr<vulkan::VulkanProcTable>& vk) {
|
||||
if (!vk || !vk->IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return [vk](const char* proc_name, VkInstance instance, VkDevice device) {
|
||||
if (device != VK_NULL_HANDLE) {
|
||||
auto result =
|
||||
vk->AcquireProc(proc_name, VulkanHandle<VkDevice>{device, nullptr});
|
||||
if (result != nullptr) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return vk->AcquireProc(proc_name,
|
||||
VulkanHandle<VkInstance>{instance, nullptr});
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace vulkan
|
||||
15
engine/src/flutter/vulkan/vulkan_skia_proc_table.h
Normal file
15
engine/src/flutter/vulkan/vulkan_skia_proc_table.h
Normal file
@@ -0,0 +1,15 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
|
||||
#include "third_party/skia/include/gpu/vk/GrVkBackendContext.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
GrVkGetProc CreateSkiaGetProc(const fml::RefPtr<vulkan::VulkanProcTable>& vk);
|
||||
|
||||
} // namespace vulkan
|
||||
@@ -6,8 +6,8 @@
|
||||
#define FLUTTER_VULKAN_VULKAN_SURFACE_H_
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "third_party/skia/include/core/SkSize.h"
|
||||
#include "vulkan_handle.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
#include "vulkan_swapchain.h"
|
||||
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "third_party/skia/include/gpu/GrBackendSurface.h"
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
#include "third_party/skia/include/gpu/vk/GrVkTypes.h"
|
||||
#include "vulkan_backbuffer.h"
|
||||
#include "vulkan_device.h"
|
||||
#include "vulkan_image.h"
|
||||
#include "vulkan_proc_table.h"
|
||||
#include "vulkan_surface.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
#include "flutter/fml/compiler_specific.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "third_party/skia/include/core/SkSize.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "vulkan_handle.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "vulkan_handle.h"
|
||||
#include "vulkan_proc_table.h"
|
||||
#include "flutter/vulkan/procs/vulkan_handle.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "flutter/flutter_vma/flutter_skia_vma.h"
|
||||
#include "flutter/vulkan/vulkan_skia_proc_table.h"
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
#include "vulkan_application.h"
|
||||
#include "vulkan_device.h"
|
||||
@@ -80,6 +82,12 @@ VulkanWindow::VulkanWindow(const sk_sp<GrDirectContext>& context,
|
||||
return;
|
||||
}
|
||||
|
||||
// Needs to happen before GrDirectContext is created.
|
||||
memory_allocator_ = flutter::FlutterSkiaVulkanMemoryAllocator::Make(
|
||||
application_->GetAPIVersion(), application_->GetInstance(),
|
||||
logical_device_->GetPhysicalDeviceHandle(), logical_device_->GetHandle(),
|
||||
vk, true);
|
||||
|
||||
// Create the Skia GrDirectContext.
|
||||
|
||||
if (!skia_gr_context_ && !CreateSkiaGrContext()) {
|
||||
@@ -131,7 +139,7 @@ bool VulkanWindow::CreateSkiaGrContext() {
|
||||
}
|
||||
|
||||
bool VulkanWindow::CreateSkiaBackendContext(GrVkBackendContext* context) {
|
||||
auto getProc = vk->CreateSkiaGetProc();
|
||||
auto getProc = CreateSkiaGetProc(vk);
|
||||
|
||||
if (getProc == nullptr) {
|
||||
return false;
|
||||
@@ -154,6 +162,7 @@ bool VulkanWindow::CreateSkiaBackendContext(GrVkBackendContext* context) {
|
||||
context->fFeatures = skia_features;
|
||||
context->fGetProc = std::move(getProc);
|
||||
context->fOwnsInstanceAndDevice = false;
|
||||
context->fMemoryAllocator = memory_allocator_;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,15 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/flutter_vma/flutter_skia_vma.h"
|
||||
#include "flutter/fml/compiler_specific.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/vulkan/procs/vulkan_proc_table.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
#include "third_party/skia/include/core/SkSize.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
#include "third_party/skia/include/gpu/vk/GrVkBackendContext.h"
|
||||
#include "vulkan_proc_table.h"
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
@@ -63,6 +64,7 @@ class VulkanWindow {
|
||||
std::unique_ptr<VulkanDevice> logical_device_;
|
||||
std::unique_ptr<VulkanSurface> surface_;
|
||||
std::unique_ptr<VulkanSwapchain> swapchain_;
|
||||
sk_sp<skgpu::VulkanMemoryAllocator> memory_allocator_;
|
||||
sk_sp<GrDirectContext> skia_gr_context_;
|
||||
|
||||
bool CreateSkiaGrContext();
|
||||
|
||||
Reference in New Issue
Block a user