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.
29
Bytes
GetAllocationSize
();
30
31
private
:
32
std::atomic<size_t> size_ = 0;
33
};
34
35
ISize
DeviceMaxTextureSizeSupported
(id<MTLDevice> device);
36
37
class
AllocatorMTL
final :
public
Allocator
{
38
public
:
39
AllocatorMTL
();
40
41
// |Allocator|
42
~AllocatorMTL
()
override
;
43
44
// |Allocator|
45
Bytes
DebugGetHeapUsage
()
const override
;
46
47
private
:
48
friend
class
ContextMTL
;
49
50
id<MTLDevice> device_;
51
std::string allocator_label_;
52
bool
supports_memoryless_targets_ =
false
;
53
bool
supports_uma_ =
false
;
54
bool
is_valid_ =
false
;
55
56
#ifdef IMPELLER_DEBUG
57
std::shared_ptr<DebugAllocatorStats> debug_allocater_ =
58
std::make_shared<DebugAllocatorStats>();
59
#endif // IMPELLER_DEBUG
60
61
ISize
max_texture_supported_;
62
63
AllocatorMTL
(id<MTLDevice> device, std::string label);
64
65
// |Allocator|
66
bool
IsValid()
const
;
67
68
// |Allocator|
69
std::shared_ptr<DeviceBuffer> OnCreateBuffer(
70
const
DeviceBufferDescriptor
& desc)
override
;
71
72
// |Allocator|
73
std::shared_ptr<Texture> OnCreateTexture(
74
const
TextureDescriptor
& desc)
override
;
75
76
// |Allocator|
77
uint16_t MinimumBytesPerRow(
PixelFormat
format)
const override
;
78
79
// |Allocator|
80
ISize
GetMaxTextureSizeSupported()
const override
;
81
82
// |Allocator|
83
void
DebugTraceMemoryStatistics()
const override
;
84
85
AllocatorMTL
(
const
AllocatorMTL
&) =
delete
;
86
87
AllocatorMTL
& operator=(
const
AllocatorMTL
&) =
delete
;
88
};
89
90
}
// namespace impeller
91
92
#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_ALLOCATOR_MTL_H_
impeller::ISize
ISize64 ISize
Definition:
size.h:140
impeller::AllocatorMTL
Definition:
allocator_mtl.h:37
impeller::DeviceBufferDescriptor
Definition:
device_buffer_descriptor.h:14
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:98
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:23
impeller::AllocationSize
Represents the size of an allocation in different units.
Definition:
allocation_size.h:29
impeller::AllocatorMTL::DebugGetHeapUsage
Bytes DebugGetHeapUsage() const override
Definition:
allocator_mtl.mm:258
impeller::AllocatorMTL::~AllocatorMTL
~AllocatorMTL() override
impeller::DeviceMaxTextureSizeSupported
ISize DeviceMaxTextureSizeSupported(id< MTLDevice > device)
Definition:
allocator_mtl.mm:55
allocator.h
impeller::DebugAllocatorStats::Increment
void Increment(size_t size)
Increment the tracked allocation size in bytes.
Definition:
allocator_mtl.mm:94
impeller::DebugAllocatorStats::GetAllocationSize
Bytes GetAllocationSize()
Get the current tracked allocation size.
Definition:
allocator_mtl.mm:102
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:65
thread.h
impeller
Definition:
allocation.cc:12
impeller
renderer
backend
metal
allocator_mtl.h
Generated by
1.8.17