7 #include "flutter/fml/logging.h"
8 #include "flutter/fml/trace_event.h"
13 std::weak_ptr<Context> context,
15 VmaAllocationInfo info)
17 context_(
std::move(context)),
18 resource_(
ContextVK::Cast(*context_.lock().get()).GetResourceManager(),
26 uint8_t* DeviceBufferVK::OnGetContents()
const {
27 return static_cast<uint8_t*
>(resource_->info.pMappedData);
30 bool DeviceBufferVK::OnCopyHostBuffer(
const uint8_t* source,
33 TRACE_EVENT0(
"impeller",
"CopyToDeviceBuffer");
34 uint8_t* dest = OnGetContents();
41 ::memmove(dest + offset, source + source_range.offset, source_range.length);
43 ::vmaFlushAllocation(resource_->buffer.get().allocator,
44 resource_->buffer.get().allocation, offset,
50 bool DeviceBufferVK::SetLabel(
const std::string& label) {
51 auto context = context_.lock();
52 if (!context || !resource_->buffer.is_valid()) {
57 ::vmaSetAllocationName(resource_->buffer.get().allocator,
58 resource_->buffer.get().allocation,
66 bool DeviceBufferVK::SetLabel(
const std::string& label, Range range) {
68 return SetLabel(label);
72 return resource_->buffer.get().buffer;