Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
impeller::Allocator Class Referenceabstract

An object that allocates device memory. More...

#include <allocator.h>

Inheritance diagram for impeller::Allocator:
impeller::AllocatorGLES impeller::AllocatorMTL impeller::AllocatorVK impeller::TestImpellerAllocator impeller::testing::MockAllocator impeller::testing::TestAllocator

Public Member Functions

virtual ~Allocator ()
 
bool IsValid () const
 
std::shared_ptr< DeviceBufferCreateBuffer (const DeviceBufferDescriptor &desc)
 
std::shared_ptr< TextureCreateTexture (const TextureDescriptor &desc)
 
virtual uint16_t MinimumBytesPerRow (PixelFormat format) const
 Minimum value for row_bytes on a Texture. The row bytes parameter of that method must be aligned to this value. More...
 
std::shared_ptr< DeviceBufferCreateBufferWithCopy (const uint8_t *buffer, size_t length)
 
std::shared_ptr< DeviceBufferCreateBufferWithCopy (const fml::Mapping &mapping)
 
virtual ISize GetMaxTextureSizeSupported () const =0
 
virtual void DebugTraceMemoryStatistics () const
 Write debug memory usage information to the dart timeline in debug and profile modes. More...
 

Protected Member Functions

 Allocator ()
 
virtual std::shared_ptr< DeviceBufferOnCreateBuffer (const DeviceBufferDescriptor &desc)=0
 
virtual std::shared_ptr< TextureOnCreateTexture (const TextureDescriptor &desc)=0
 

Detailed Description

An object that allocates device memory.

Definition at line 22 of file allocator.h.

Constructor & Destructor Documentation

◆ ~Allocator()

impeller::Allocator::~Allocator ( )
virtualdefault

◆ Allocator()

impeller::Allocator::Allocator ( )
protecteddefault

Member Function Documentation

◆ CreateBuffer()

std::shared_ptr< DeviceBuffer > impeller::Allocator::CreateBuffer ( const DeviceBufferDescriptor desc)

Definition at line 44 of file allocator.cc.

45 {
46 return OnCreateBuffer(desc);
47}
virtual std::shared_ptr< DeviceBuffer > OnCreateBuffer(const DeviceBufferDescriptor &desc)=0

◆ CreateBufferWithCopy() [1/2]

std::shared_ptr< DeviceBuffer > impeller::Allocator::CreateBufferWithCopy ( const fml::Mapping mapping)

Definition at line 39 of file allocator.cc.

40 {
41 return CreateBufferWithCopy(mapping.GetMapping(), mapping.GetSize());
42}
virtual const uint8_t * GetMapping() const =0
virtual size_t GetSize() const =0
std::shared_ptr< DeviceBuffer > CreateBufferWithCopy(const uint8_t *buffer, size_t length)
Definition: allocator.cc:18

◆ CreateBufferWithCopy() [2/2]

std::shared_ptr< DeviceBuffer > impeller::Allocator::CreateBufferWithCopy ( const uint8_t *  buffer,
size_t  length 
)

Definition at line 18 of file allocator.cc.

20 {
21 DeviceBufferDescriptor desc;
22 desc.size = length;
23 desc.storage_mode = StorageMode::kHostVisible;
24 auto new_buffer = CreateBuffer(desc);
25
26 if (!new_buffer) {
27 return nullptr;
28 }
29
30 auto entire_range = Range{0, length};
31
32 if (!new_buffer->CopyHostBuffer(buffer, entire_range)) {
33 return nullptr;
34 }
35
36 return new_buffer;
37}
std::shared_ptr< DeviceBuffer > CreateBuffer(const DeviceBufferDescriptor &desc)
Definition: allocator.cc:44
size_t length
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ CreateTexture()

std::shared_ptr< Texture > impeller::Allocator::CreateTexture ( const TextureDescriptor desc)

Definition at line 49 of file allocator.cc.

50 {
51 const auto max_size = GetMaxTextureSizeSupported();
52 if (desc.size.width > max_size.width || desc.size.height > max_size.height) {
53 VALIDATION_LOG << "Requested texture size " << desc.size
54 << " exceeds maximum supported size of " << max_size;
55 return nullptr;
56 }
57
58 if (desc.mip_count > desc.size.MipCount()) {
59 VALIDATION_LOG << "Requested mip_count " << desc.mip_count
60 << " exceeds maximum supported for size " << desc.size;
61 TextureDescriptor corrected_desc = desc;
62 corrected_desc.mip_count = desc.size.MipCount();
63 return OnCreateTexture(corrected_desc);
64 }
65
66 return OnCreateTexture(desc);
67}
virtual ISize GetMaxTextureSizeSupported() const =0
virtual std::shared_ptr< Texture > OnCreateTexture(const TextureDescriptor &desc)=0
#define VALIDATION_LOG
Definition: validation.h:73

◆ DebugTraceMemoryStatistics()

virtual void impeller::Allocator::DebugTraceMemoryStatistics ( ) const
inlinevirtual

Write debug memory usage information to the dart timeline in debug and profile modes.

This is only supported on the Vulkan backend.

Definition at line 51 of file allocator.h.

51{};

◆ GetMaxTextureSizeSupported()

virtual ISize impeller::Allocator::GetMaxTextureSizeSupported ( ) const
pure virtual

◆ IsValid()

bool impeller::Allocator::IsValid ( ) const

◆ MinimumBytesPerRow()

uint16_t impeller::Allocator::MinimumBytesPerRow ( PixelFormat  format) const
virtual

Minimum value for row_bytes on a Texture. The row bytes parameter of that method must be aligned to this value.

Definition at line 69 of file allocator.cc.

69 {
71}
uint32_t uint32_t * format
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition: formats.h:460

◆ OnCreateBuffer()

virtual std::shared_ptr< DeviceBuffer > impeller::Allocator::OnCreateBuffer ( const DeviceBufferDescriptor desc)
protectedpure virtual

◆ OnCreateTexture()

virtual std::shared_ptr< Texture > impeller::Allocator::OnCreateTexture ( const TextureDescriptor desc)
protectedpure virtual

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