Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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

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 17 of file VulkanMemoryAllocator.h.

Member Enumeration Documentation

◆ AllocationPropertyFlags

Enumerator
kNone_AllocationPropertyFlag 
kDedicatedAllocation_AllocationPropertyFlag 
kLazyAllocation_AllocationPropertyFlag 
kPersistentlyMapped_AllocationPropertyFlag 
kProtected_AllocationPropertyFlag 

Definition at line 19 of file VulkanMemoryAllocator.h.

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

◆ BufferUsage

Enumerator
kGpuOnly 
kCpuWritesGpuReads 
kTransfersFromCpuToGpu 
kTransfersFromGpuToCpu 

Definition at line 37 of file VulkanMemoryAllocator.h.

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

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 87 of file VulkanMemoryAllocator.h.

87{}

◆ flushMemory()

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

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

Definition at line 88 of file VulkanMemoryAllocator.h.

90 {
91 this->flushMappedMemory(memory, offset, size);
92 return VK_SUCCESS;
93 }
virtual void flushMappedMemory(const skgpu::VulkanBackendMemory &, VkDeviceSize, VkDeviceSize)
Point offset
@ VK_SUCCESS

◆ 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 94 of file VulkanMemoryAllocator.h.

96 {}

◆ invalidateMemory()

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

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

Definition at line 97 of file VulkanMemoryAllocator.h.

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

◆ mapMemory() [1/2]

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

Definition at line 71 of file VulkanMemoryAllocator.h.

71{ return nullptr; }

◆ mapMemory() [2/2]

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

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

Definition at line 72 of file VulkanMemoryAllocator.h.

72 {
73 *data = this->mapMemory(memory);
74 // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is
75 // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to
76 // mean something specific happened like device lost or oom. This will be removed once we
77 // update clients to implement this virtual.
79 }
virtual void * mapMemory(const skgpu::VulkanBackendMemory &)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
@ VK_ERROR_INITIALIZATION_FAILED

◆ 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: