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

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
static const uint8_t buffer[]
size_t length

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

Reimplemented in impeller::AllocatorVK.

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.

Reimplemented in impeller::AllocatorMTL, and impeller::TestImpellerAllocator.

Definition at line 69 of file allocator.cc.

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

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