Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::AllocatorVK Class Referencefinal

#include <allocator_vk.h>

Inheritance diagram for impeller::AllocatorVK:
impeller::Allocator

Public Member Functions

 ~AllocatorVK () override
 
Bytes DebugGetHeapUsage () const 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, bool threadsafe=false)
 Creates a new texture.
 
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)
 

Static Public Member Functions

static int32_t FindMemoryTypeIndex (uint32_t memory_type_bits_requirement, vk::PhysicalDeviceMemoryProperties &memory_properties)
 Select a matching memory type for the given [memory_type_bits_requirement], or -1 if none is found.
 
static vk::ImageUsageFlags ToVKImageUsageFlags (PixelFormat format, TextureUsageMask usage, StorageMode mode, bool supports_memoryless_textures)
 

Friends

class ContextVK
 

Additional Inherited Members

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

Detailed Description

Definition at line 19 of file allocator_vk.h.

Constructor & Destructor Documentation

◆ ~AllocatorVK()

impeller::AllocatorVK::~AllocatorVK ( )
overridedefault

Member Function Documentation

◆ DebugGetHeapUsage()

Bytes impeller::AllocatorVK::DebugGetHeapUsage ( ) const
overridevirtual

Reimplemented from impeller::Allocator.

Definition at line 612 of file allocator_vk.cc.

612 {
613 auto count = memory_properties_.memoryHeapCount;
614 std::vector<VmaBudget> budgets(count);
615 vmaGetHeapBudgets(allocator_.get(), budgets.data());
616 size_t total_usage = 0;
617 for (auto i = 0u; i < count; i++) {
618 const VmaBudget& budget = budgets[i];
619 total_usage += budget.usage;
620 }
621 return Bytes{static_cast<double>(total_usage)};
622}
const T & get() const
AllocationSize< 1u > Bytes

References i.

◆ FindMemoryTypeIndex()

int32_t impeller::AllocatorVK::FindMemoryTypeIndex ( uint32_t  memory_type_bits_requirement,
vk::PhysicalDeviceMemoryProperties &  memory_properties 
)
static

Select a matching memory type for the given [memory_type_bits_requirement], or -1 if none is found.

This only returns memory types with deviceLocal allocations.

Definition at line 182 of file allocator_vk.cc.

184 {
185 int32_t type_index = -1;
186 vk::MemoryPropertyFlagBits required_properties =
187 vk::MemoryPropertyFlagBits::eDeviceLocal;
188
189 const uint32_t memory_count = memory_properties.memoryTypeCount;
190 for (uint32_t memory_index = 0; memory_index < memory_count; ++memory_index) {
191 const uint32_t memory_type_bits = (1 << memory_index);
192 const bool is_required_memory_type =
193 memory_type_bits_requirement & memory_type_bits;
194
195 const auto properties =
196 memory_properties.memoryTypes[memory_index].propertyFlags;
197 const bool has_required_properties =
198 (properties & required_properties) == required_properties;
199
200 if (is_required_memory_type && has_required_properties) {
201 return static_cast<int32_t>(memory_index);
202 }
203 }
204
205 return type_index;
206}

Referenced by impeller::testing::TEST(), and impeller::testing::TEST().

◆ ToVKImageUsageFlags()

vk::ImageUsageFlags impeller::AllocatorVK::ToVKImageUsageFlags ( PixelFormat  format,
TextureUsageMask  usage,
StorageMode  mode,
bool  supports_memoryless_textures 
)
static

Definition at line 208 of file allocator_vk.cc.

212 {
213 vk::ImageUsageFlags vk_usage;
214
215 switch (mode) {
218 break;
220 if (supports_memoryless_textures) {
221 vk_usage |= vk::ImageUsageFlagBits::eTransientAttachment;
222 }
223 break;
224 }
225
226 if (usage & TextureUsage::kRenderTarget) {
227 if (PixelFormatIsDepthStencil(format)) {
228 vk_usage |= vk::ImageUsageFlagBits::eDepthStencilAttachment;
229 } else {
230 vk_usage |= vk::ImageUsageFlagBits::eColorAttachment;
231 vk_usage |= vk::ImageUsageFlagBits::eInputAttachment;
232 }
233 }
234
235 if (usage & TextureUsage::kShaderRead) {
236 vk_usage |= vk::ImageUsageFlagBits::eSampled;
237 }
238
239 if (usage & TextureUsage::kShaderWrite) {
240 vk_usage |= vk::ImageUsageFlagBits::eStorage;
241 }
242
243 if (mode != StorageMode::kDeviceTransient) {
244 // Add transfer usage flags to support blit passes only if image isn't
245 // device transient.
246 vk_usage |= vk::ImageUsageFlagBits::eTransferSrc |
247 vk::ImageUsageFlagBits::eTransferDst;
248 }
249
250 return vk_usage;
251}
constexpr bool PixelFormatIsDepthStencil(PixelFormat format)
Definition formats_vk.h:450

References format, and impeller::PixelFormatIsDepthStencil().

Referenced by impeller::testing::TEST().

Friends And Related Symbol Documentation

◆ ContextVK

friend class ContextVK
friend

Definition at line 43 of file allocator_vk.h.


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