Flutter Impeller
allocator_mtl.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_ALLOCATOR_MTL_H_
6
#define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_ALLOCATOR_MTL_H_
7
8
#include <Metal/Metal.h>
9
#include <atomic>
10
11
#include "
impeller/base/thread.h
"
12
#include "
impeller/core/allocator.h
"
13
14
namespace
impeller
{
15
16
class
DebugAllocatorStats
{
17
public
:
18
DebugAllocatorStats
() {}
19
20
~DebugAllocatorStats
() {}
21
22
/// Increment the tracked allocation size in bytes.
23
void
Increment
(
size_t
size);
24
25
/// Decrement the tracked allocation size in bytes.
26
void
Decrement
(
size_t
size);
27
28
/// Get the current tracked allocation size in MB.
29
size_t
GetAllocationSizeMB
();
30
31
private
:
32
std::atomic<size_t> size_ = 0;
33
};
34
35
class
AllocatorMTL
final :
public
Allocator
{
36
public
:
37
AllocatorMTL
();
38
39
// |Allocator|
40
~AllocatorMTL
()
override
;
41
42
// |Allocator|
43
size_t
DebugGetHeapUsage
()
const override
;
44
45
private
:
46
friend
class
ContextMTL
;
47
48
id<MTLDevice> device_;
49
std::string allocator_label_;
50
bool
supports_memoryless_targets_ =
false
;
51
bool
supports_uma_ =
false
;
52
bool
is_valid_ =
false
;
53
54
#ifdef IMPELLER_DEBUG
55
std::shared_ptr<DebugAllocatorStats> debug_allocater_ =
56
std::make_shared<DebugAllocatorStats>();
57
#endif // IMPELLER_DEBUG
58
59
ISize
max_texture_supported_;
60
61
AllocatorMTL
(id<MTLDevice> device, std::string label);
62
63
// |Allocator|
64
bool
IsValid()
const
;
65
66
// |Allocator|
67
std::shared_ptr<DeviceBuffer> OnCreateBuffer(
68
const
DeviceBufferDescriptor
& desc)
override
;
69
70
// |Allocator|
71
std::shared_ptr<Texture> OnCreateTexture(
72
const
TextureDescriptor
& desc)
override
;
73
74
// |Allocator|
75
uint16_t MinimumBytesPerRow(
PixelFormat
format)
const override
;
76
77
// |Allocator|
78
ISize
GetMaxTextureSizeSupported()
const override
;
79
80
// |Allocator|
81
void
DebugTraceMemoryStatistics()
const override
;
82
83
AllocatorMTL
(
const
AllocatorMTL
&) =
delete
;
84
85
AllocatorMTL
& operator=(
const
AllocatorMTL
&) =
delete
;
86
};
87
88
}
// namespace impeller
89
90
#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_ALLOCATOR_MTL_H_
impeller::AllocatorMTL
Definition:
allocator_mtl.h:35
impeller::DeviceBufferDescriptor
Definition:
device_buffer_descriptor.h:14
impeller::AllocatorMTL::DebugGetHeapUsage
size_t DebugGetHeapUsage() const override
Definition:
allocator_mtl.mm:259
impeller::DebugAllocatorStats::GetAllocationSizeMB
size_t GetAllocationSizeMB()
Get the current tracked allocation size in MB.
Definition:
allocator_mtl.mm:101
impeller::AllocatorMTL::AllocatorMTL
AllocatorMTL()
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition:
formats.h:99
impeller::DebugAllocatorStats::Decrement
void Decrement(size_t size)
Decrement the tracked allocation size in bytes.
Definition:
allocator_mtl.mm:97
impeller::DebugAllocatorStats
Definition:
allocator_mtl.h:16
impeller::TSize
Definition:
size.h:19
impeller::DebugAllocatorStats::~DebugAllocatorStats
~DebugAllocatorStats()
Definition:
allocator_mtl.h:20
impeller::DebugAllocatorStats::DebugAllocatorStats
DebugAllocatorStats()
Definition:
allocator_mtl.h:18
impeller::Allocator
An object that allocates device memory.
Definition:
allocator.h:22
impeller::AllocatorMTL::~AllocatorMTL
~AllocatorMTL() override
allocator.h
impeller::DebugAllocatorStats::Increment
void Increment(size_t size)
Increment the tracked allocation size in bytes.
Definition:
allocator_mtl.mm:93
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition:
texture_descriptor.h:38
impeller::ContextMTL
Definition:
context_mtl.h:34
thread.h
impeller
Definition:
aiks_blend_unittests.cc:18
impeller
renderer
backend
metal
allocator_mtl.h
Generated by
1.8.17