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

#include <device_buffer_vk.h>

Inheritance diagram for impeller::DeviceBufferVK:
impeller::DeviceBuffer impeller::BackendCast< DeviceBufferVK, DeviceBuffer >

Public Member Functions

 DeviceBufferVK (DeviceBufferDescriptor desc, std::weak_ptr< Context > context, UniqueBufferVMA buffer, VmaAllocationInfo info)
 
 ~DeviceBufferVK () override
 
vk::Buffer GetBuffer () const
 
- Public Member Functions inherited from impeller::DeviceBuffer
virtual ~DeviceBuffer ()
 
bool CopyHostBuffer (const uint8_t *source, Range source_range, size_t offset=0u)
 
virtual std::shared_ptr< TextureAsTexture (Allocator &allocator, const TextureDescriptor &descriptor, uint16_t row_bytes) const
 
const DeviceBufferDescriptorGetDeviceBufferDescriptor () const
 

Private Member Functions

uint8_t * OnGetContents () const override
 
bool OnCopyHostBuffer (const uint8_t *source, Range source_range, size_t offset) override
 
bool SetLabel (const std::string &label) override
 
bool SetLabel (const std::string &label, Range range) override
 
void Flush (std::optional< Range > range) const override
 
void Invalidate (std::optional< Range > range) const override
 

Friends

class AllocatorVK
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::DeviceBuffer
static BufferView AsBufferView (std::shared_ptr< DeviceBuffer > buffer)
 Create a buffer view of this entire buffer.
 
- Static Public Member Functions inherited from impeller::BackendCast< DeviceBufferVK, DeviceBuffer >
static DeviceBufferVKCast (DeviceBuffer &base)
 
static const DeviceBufferVKCast (const DeviceBuffer &base)
 
static DeviceBufferVKCast (DeviceBuffer *base)
 
static const DeviceBufferVKCast (const DeviceBuffer *base)
 
- Protected Member Functions inherited from impeller::DeviceBuffer
 DeviceBuffer (DeviceBufferDescriptor desc)
 
- Protected Attributes inherited from impeller::DeviceBuffer
const DeviceBufferDescriptor desc_
 

Detailed Description

Definition at line 17 of file device_buffer_vk.h.

Constructor & Destructor Documentation

◆ DeviceBufferVK()

impeller::DeviceBufferVK::DeviceBufferVK ( DeviceBufferDescriptor  desc,
std::weak_ptr< Context context,
UniqueBufferVMA  buffer,
VmaAllocationInfo  info 
)

Definition at line 14 of file device_buffer_vk.cc.

18 : DeviceBuffer(desc),
19 context_(std::move(context)),
20 resource_(ContextVK::Cast(*context_.lock().get()).GetResourceManager(),
21 BufferResource{
22 std::move(buffer), //
23 info //
24 }) {}
static ContextVK & Cast(Context &base)
std::shared_ptr< ResourceManagerVK > GetResourceManager() const
DeviceBuffer(DeviceBufferDescriptor desc)

◆ ~DeviceBufferVK()

impeller::DeviceBufferVK::~DeviceBufferVK ( )
overridedefault

Member Function Documentation

◆ Flush()

void impeller::DeviceBufferVK::Flush ( std::optional< Range range) const
overrideprivatevirtual

Make any pending writes visible to the GPU.

This method must be called if the device pointer provided by [OnGetContents] is written to without using [CopyHostBuffer]. On Devices with coherent host memory, this method will not perform extra work.

If the range is not provided, the entire buffer is flushed.

Reimplemented from impeller::DeviceBuffer.

Definition at line 67 of file device_buffer_vk.cc.

67 {
68 auto flush_range = range.value_or(Range{0, GetDeviceBufferDescriptor().size});
69 ::vmaFlushAllocation(resource_->buffer.get().allocator,
70 resource_->buffer.get().allocation, flush_range.offset,
71 flush_range.length);
72}
const DeviceBufferDescriptor & GetDeviceBufferDescriptor() const

◆ GetBuffer()

vk::Buffer impeller::DeviceBufferVK::GetBuffer ( ) const

Definition at line 86 of file device_buffer_vk.cc.

86 {
87 return resource_->buffer.get().buffer;
88}

◆ Invalidate()

void impeller::DeviceBufferVK::Invalidate ( std::optional< Range range) const
overrideprivatevirtual

Reimplemented from impeller::DeviceBuffer.

Definition at line 74 of file device_buffer_vk.cc.

74 {
75 auto flush_range = range.value_or(Range{0, GetDeviceBufferDescriptor().size});
76 ::vmaInvalidateAllocation(resource_->buffer.get().allocator,
77 resource_->buffer.get().allocation,
78 flush_range.offset, flush_range.length);
79}

◆ OnCopyHostBuffer()

bool impeller::DeviceBufferVK::OnCopyHostBuffer ( const uint8_t *  source,
Range  source_range,
size_t  offset 
)
overrideprivatevirtual

Implements impeller::DeviceBuffer.

Definition at line 32 of file device_buffer_vk.cc.

34 {
35 uint8_t* dest = OnGetContents();
36
37 if (!dest) {
38 return false;
39 }
40
41 if (source) {
42 ::memmove(dest + offset, source + source_range.offset, source_range.length);
43 }
44 ::vmaFlushAllocation(resource_->buffer.get().allocator,
45 resource_->buffer.get().allocation, offset,
46 source_range.length);
47
48 return true;
49}
uint8_t * OnGetContents() const override
SkBitmap source
Definition examples.cpp:28
dest
Definition zip.py:79
Point offset

◆ OnGetContents()

uint8_t * impeller::DeviceBufferVK::OnGetContents ( ) const
overrideprivatevirtual

Implements impeller::DeviceBuffer.

Definition at line 28 of file device_buffer_vk.cc.

28 {
29 return static_cast<uint8_t*>(resource_->info.pMappedData);
30}

◆ SetLabel() [1/2]

bool impeller::DeviceBufferVK::SetLabel ( const std::string &  label)
overrideprivatevirtual

Implements impeller::DeviceBuffer.

Definition at line 51 of file device_buffer_vk.cc.

51 {
52 auto context = context_.lock();
53 if (!context || !resource_->buffer.is_valid()) {
54 // The context could have died at this point.
55 return false;
56 }
57
58 ::vmaSetAllocationName(resource_->buffer.get().allocator, //
59 resource_->buffer.get().allocation, //
60 label.c_str() //
61 );
62
63 return ContextVK::Cast(*context).SetDebugName(resource_->buffer.get().buffer,
64 label);
65}
bool SetDebugName(T handle, std::string_view label) const
Definition context_vk.h:108

◆ SetLabel() [2/2]

bool impeller::DeviceBufferVK::SetLabel ( const std::string &  label,
Range  range 
)
overrideprivatevirtual

Implements impeller::DeviceBuffer.

Definition at line 81 of file device_buffer_vk.cc.

81 {
82 // We do not have the ability to name ranges. Just name the whole thing.
83 return SetLabel(label);
84}
bool SetLabel(const std::string &label) override

Friends And Related Symbol Documentation

◆ AllocatorVK

friend class AllocatorVK
friend

Definition at line 31 of file device_buffer_vk.h.


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