Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Friends | List of all members
impeller::AllocatorMTL Class Referencefinal

#include <allocator_mtl.h>

Inheritance diagram for impeller::AllocatorMTL:
impeller::Allocator

Public Member Functions

 AllocatorMTL ()
 
 ~AllocatorMTL () override
 
- Public Member Functions inherited from impeller::Allocator
virtual ~Allocator ()
 
bool IsValid () const
 
std::shared_ptr< DeviceBufferCreateBuffer (const DeviceBufferDescriptor &desc)
 
std::shared_ptr< TextureCreateTexture (const TextureDescriptor &desc)
 
std::shared_ptr< DeviceBufferCreateBufferWithCopy (const uint8_t *buffer, size_t length)
 
std::shared_ptr< DeviceBufferCreateBufferWithCopy (const fml::Mapping &mapping)
 
virtual void DebugTraceMemoryStatistics () const
 Write debug memory usage information to the dart timeline in debug and profile modes.
 

Private Member Functions

std::shared_ptr< DeviceBufferOnCreateBuffer (const DeviceBufferDescriptor &desc) override
 
std::shared_ptr< TextureOnCreateTexture (const TextureDescriptor &desc) override
 
uint16_t MinimumBytesPerRow (PixelFormat format) const override
 Minimum value for row_bytes on a Texture. The row bytes parameter of that method must be aligned to this value.
 
ISize GetMaxTextureSizeSupported () const override
 

Friends

class ContextMTL
 

Additional Inherited Members

- Protected Member Functions inherited from impeller::Allocator
 Allocator ()
 

Detailed Description

Definition at line 15 of file allocator_mtl.h.

Constructor & Destructor Documentation

◆ AllocatorMTL()

impeller::AllocatorMTL::AllocatorMTL ( )

◆ ~AllocatorMTL()

impeller::AllocatorMTL::~AllocatorMTL ( )
overridedefault

Member Function Documentation

◆ GetMaxTextureSizeSupported()

ISize impeller::AllocatorMTL::GetMaxTextureSizeSupported ( ) const
overrideprivatevirtual

Implements impeller::Allocator.

Definition at line 227 of file allocator_mtl.mm.

227 {
228 return max_texture_supported_;
229}

◆ MinimumBytesPerRow()

uint16_t impeller::AllocatorMTL::MinimumBytesPerRow ( PixelFormat  format) const
overrideprivatevirtual

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

Reimplemented from impeller::Allocator.

Definition at line 222 of file allocator_mtl.mm.

222 {
223 return static_cast<uint16_t>([device_
224 minimumLinearTextureAlignmentForPixelFormat:ToMTLPixelFormat(format)]);
225}
uint32_t uint32_t * format
constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format)
Definition formats_mtl.h:77

◆ OnCreateBuffer()

std::shared_ptr< DeviceBuffer > impeller::AllocatorMTL::OnCreateBuffer ( const DeviceBufferDescriptor desc)
overrideprivatevirtual

Implements impeller::Allocator.

Definition at line 174 of file allocator_mtl.mm.

175 {
176 const auto resource_options = ToMTLResourceOptions(
177 desc.storage_mode, supports_memoryless_targets_, supports_uma_);
178 const auto storage_mode = ToMTLStorageMode(
179 desc.storage_mode, supports_memoryless_targets_, supports_uma_);
180
181 auto buffer = [device_ newBufferWithLength:desc.size
182 options:resource_options];
183 if (!buffer) {
184 return nullptr;
185 }
186 return std::shared_ptr<DeviceBufferMTL>(new DeviceBufferMTL(desc, //
187 buffer, //
188 storage_mode //
189 ));
190}
const char * options
static const uint8_t buffer[]
static MTLStorageMode ToMTLStorageMode(StorageMode mode, bool supports_memoryless_targets, bool supports_uma)
static MTLResourceOptions ToMTLResourceOptions(StorageMode type, bool supports_memoryless_targets, bool supports_uma)

◆ OnCreateTexture()

std::shared_ptr< Texture > impeller::AllocatorMTL::OnCreateTexture ( const TextureDescriptor desc)
overrideprivatevirtual

Implements impeller::Allocator.

Definition at line 192 of file allocator_mtl.mm.

193 {
194 if (!IsValid()) {
195 return nullptr;
196 }
197
198 auto mtl_texture_desc = ToMTLTextureDescriptor(desc);
199
200 if (!mtl_texture_desc) {
201 VALIDATION_LOG << "Texture descriptor was invalid.";
202 return nullptr;
203 }
204
205 mtl_texture_desc.storageMode = ToMTLStorageMode(
206 desc.storage_mode, supports_memoryless_targets_, supports_uma_);
207
208 if (@available(macOS 12.5, ios 15.0, *)) {
209 if (desc.compression_type == CompressionType::kLossy &&
211 mtl_texture_desc.compressionType = MTLTextureCompressionTypeLossy;
212 }
213 }
214
215 auto texture = [device_ newTextureWithDescriptor:mtl_texture_desc];
216 if (!texture) {
217 return nullptr;
218 }
219 return TextureMTL::Create(desc, texture);
220}
static std::shared_ptr< TextureMTL > Create(TextureDescriptor desc, id< MTLTexture > texture)
FlTexture * texture
static bool SupportsLossyTextureCompression(id< MTLDevice > device)
MTLTextureDescriptor * ToMTLTextureDescriptor(const TextureDescriptor &desc)
#define VALIDATION_LOG
Definition validation.h:73

Friends And Related Symbol Documentation

◆ ContextMTL

friend class ContextMTL
friend

Definition at line 23 of file allocator_mtl.h.


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