Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
skgpu::VulkanMemoryAllocator Class Referenceabstract

#include <VulkanMemoryAllocator.h>

Inheritance diagram for skgpu::VulkanMemoryAllocator:
SkRefCnt SkRefCntBase flutter::FlutterSkiaVulkanMemoryAllocator sk_gpu_test::VkTestMemoryAllocator skgpu::VulkanAMDMemoryAllocator

Public Types

enum  AllocationPropertyFlags {
  kNone_AllocationPropertyFlag = 0b0000 , kDedicatedAllocation_AllocationPropertyFlag = 0b0001 , kLazyAllocation_AllocationPropertyFlag = 0b0010 , kPersistentlyMapped_AllocationPropertyFlag = 0b0100 ,
  kProtected_AllocationPropertyFlag = 0b1000
}
 
enum class  BufferUsage { kGpuOnly , kCpuWritesGpuReads , kTransfersFromCpuToGpu , kTransfersFromGpuToCpu }
 

Public Member Functions

virtual VkResult allocateImageMemory (VkImage image, uint32_t allocationPropertyFlags, skgpu::VulkanBackendMemory *memory)=0
 
virtual VkResult allocateBufferMemory (VkBuffer buffer, BufferUsage usage, uint32_t allocationPropertyFlags, skgpu::VulkanBackendMemory *memory)=0
 
virtual void getAllocInfo (const skgpu::VulkanBackendMemory &, skgpu::VulkanAlloc *) const =0
 
virtual void * mapMemory (const skgpu::VulkanBackendMemory &)
 
virtual VkResult mapMemory (const skgpu::VulkanBackendMemory &memory, void **data)
 
virtual void unmapMemory (const skgpu::VulkanBackendMemory &)=0
 
virtual void flushMappedMemory (const skgpu::VulkanBackendMemory &, VkDeviceSize, VkDeviceSize)
 
virtual VkResult flushMemory (const skgpu::VulkanBackendMemory &memory, VkDeviceSize offset, VkDeviceSize size)
 
virtual void invalidateMappedMemory (const skgpu::VulkanBackendMemory &, VkDeviceSize, VkDeviceSize)
 
virtual VkResult invalidateMemory (const skgpu::VulkanBackendMemory &memory, VkDeviceSize offset, VkDeviceSize size)
 
virtual void freeMemory (const skgpu::VulkanBackendMemory &)=0
 
virtual std::pair< uint64_t, uint64_t > totalAllocatedAndUsedMemory () const =0
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Detailed Description

Definition at line 20 of file VulkanMemoryAllocator.h.

Member Enumeration Documentation

◆ AllocationPropertyFlags

Enumerator
kNone_AllocationPropertyFlag 
kDedicatedAllocation_AllocationPropertyFlag 
kLazyAllocation_AllocationPropertyFlag 
kPersistentlyMapped_AllocationPropertyFlag 
kProtected_AllocationPropertyFlag 

Definition at line 22 of file VulkanMemoryAllocator.h.

22 {
24 // Allocation will be placed in its own VkDeviceMemory and not suballocated from some larger
25 // block.
27 // Says that the backing memory can only be accessed by the device. Additionally the device
28 // may lazily allocate the memory. This cannot be used with buffers that will be host
29 // visible. Setting this flag does not guarantee that we will allocate memory that respects
30 // it, but we will try to prefer memory that can respect it.
32 // The allocation will be mapped immediately and stay mapped until it is destroyed. This
33 // flag is only valid for buffers which are host visible (i.e. must have a usage other than
34 // BufferUsage::kGpuOnly).
36 // Allocation can only be accessed by the device using a protected context.
38 };

◆ BufferUsage

Enumerator
kGpuOnly 
kCpuWritesGpuReads 
kTransfersFromCpuToGpu 
kTransfersFromGpuToCpu 

Definition at line 40 of file VulkanMemoryAllocator.h.

40 {
41 // Buffers that will only be accessed from the device (large const buffers) will always be
42 // in device local memory.
44 // Buffers that typically will be updated multiple times by the host and read on the gpu
45 // (e.g. uniform or vertex buffers). CPU writes will generally be sequential in the buffer
46 // and will try to take advantage of the write-combined nature of the gpu buffers. Thus this
47 // will always be mappable and coherent memory, and it will prefer to be in device local
48 // memory.
49 kCpuWritesGpuReads,
50 // Buffers that will be accessed on the host and copied to another GPU resource (transfer
51 // buffers). Will always be mappable and coherent memory.
52 kTransfersFromCpuToGpu,
53 // Buffers which are typically writted to by the GPU and then read on the host. Will always
54 // be mappable memory, and will prefer cached memory.
55 kTransfersFromGpuToCpu,
56 };

Member Function Documentation

◆ allocateBufferMemory()

virtual VkResult skgpu::VulkanMemoryAllocator::allocateBufferMemory ( VkBuffer  buffer,
BufferUsage  usage,
uint32_t  allocationPropertyFlags,
skgpu::VulkanBackendMemory memory 
)
pure virtual

◆ allocateImageMemory()

virtual VkResult skgpu::VulkanMemoryAllocator::allocateImageMemory ( VkImage  image,
uint32_t  allocationPropertyFlags,
skgpu::VulkanBackendMemory memory 
)
pure virtual

◆ flushMappedMemory()

virtual void skgpu::VulkanMemoryAllocator::flushMappedMemory ( const skgpu::VulkanBackendMemory ,
VkDeviceSize  ,
VkDeviceSize   
)
inlinevirtual

Definition at line 90 of file VulkanMemoryAllocator.h.

90{}

◆ flushMemory()

virtual VkResult skgpu::VulkanMemoryAllocator::flushMemory ( const skgpu::VulkanBackendMemory memory,
VkDeviceSize  offset,
VkDeviceSize  size 
)
inlinevirtual

Reimplemented in flutter::FlutterSkiaVulkanMemoryAllocator, sk_gpu_test::VkTestMemoryAllocator, and skgpu::VulkanAMDMemoryAllocator.

Definition at line 91 of file VulkanMemoryAllocator.h.

93 {
94 this->flushMappedMemory(memory, offset, size);
95 return VK_SUCCESS;
96 }
virtual void flushMappedMemory(const skgpu::VulkanBackendMemory &, VkDeviceSize, VkDeviceSize)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SeparatedVector2 offset
@ VK_SUCCESS
Definition: vulkan_core.h:141

◆ freeMemory()

virtual void skgpu::VulkanMemoryAllocator::freeMemory ( const skgpu::VulkanBackendMemory )
pure virtual

◆ getAllocInfo()

virtual void skgpu::VulkanMemoryAllocator::getAllocInfo ( const skgpu::VulkanBackendMemory ,
skgpu::VulkanAlloc  
) const
pure virtual

◆ invalidateMappedMemory()

virtual void skgpu::VulkanMemoryAllocator::invalidateMappedMemory ( const skgpu::VulkanBackendMemory ,
VkDeviceSize  ,
VkDeviceSize   
)
inlinevirtual

Definition at line 97 of file VulkanMemoryAllocator.h.

99 {}

◆ invalidateMemory()

virtual VkResult skgpu::VulkanMemoryAllocator::invalidateMemory ( const skgpu::VulkanBackendMemory memory,
VkDeviceSize  offset,
VkDeviceSize  size 
)
inlinevirtual

Reimplemented in flutter::FlutterSkiaVulkanMemoryAllocator, sk_gpu_test::VkTestMemoryAllocator, and skgpu::VulkanAMDMemoryAllocator.

Definition at line 100 of file VulkanMemoryAllocator.h.

102 {
103 this->invalidateMappedMemory(memory, offset, size);
104 return VK_SUCCESS;
105 }
virtual void invalidateMappedMemory(const skgpu::VulkanBackendMemory &, VkDeviceSize, VkDeviceSize)

◆ mapMemory() [1/2]

virtual void * skgpu::VulkanMemoryAllocator::mapMemory ( const skgpu::VulkanBackendMemory )
inlinevirtual

Definition at line 74 of file VulkanMemoryAllocator.h.

74{ return nullptr; }

◆ mapMemory() [2/2]

virtual VkResult skgpu::VulkanMemoryAllocator::mapMemory ( const skgpu::VulkanBackendMemory memory,
void **  data 
)
inlinevirtual

Reimplemented in flutter::FlutterSkiaVulkanMemoryAllocator, sk_gpu_test::VkTestMemoryAllocator, and skgpu::VulkanAMDMemoryAllocator.

Definition at line 75 of file VulkanMemoryAllocator.h.

75 {
76 *data = this->mapMemory(memory);
77 // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is
78 // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to
79 // mean something specific happened like device lost or oom. This will be removed once we
80 // update clients to implement this virtual.
82 }
virtual void * mapMemory(const skgpu::VulkanBackendMemory &)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
@ VK_ERROR_INITIALIZATION_FAILED
Definition: vulkan_core.h:149

◆ totalAllocatedAndUsedMemory()

virtual std::pair< uint64_t, uint64_t > skgpu::VulkanMemoryAllocator::totalAllocatedAndUsedMemory ( ) const
pure virtual

◆ unmapMemory()

virtual void skgpu::VulkanMemoryAllocator::unmapMemory ( const skgpu::VulkanBackendMemory )
pure virtual

The documentation for this class was generated from the following file: