diff --git a/engine/src/flutter/impeller/compositor/device_buffer.h b/engine/src/flutter/impeller/compositor/device_buffer.h index a484db7776..b49684a58c 100644 --- a/engine/src/flutter/impeller/compositor/device_buffer.h +++ b/engine/src/flutter/impeller/compositor/device_buffer.h @@ -27,6 +27,10 @@ class DeviceBuffer final : public Buffer, id GetMTLBuffer() const; + bool SetLabel(const std::string& label); + + bool SetLabel(const std::string& label, Range range); + private: friend class Allocator; diff --git a/engine/src/flutter/impeller/compositor/device_buffer.mm b/engine/src/flutter/impeller/compositor/device_buffer.mm index 7ecf61ea76..0475e5e9fc 100644 --- a/engine/src/flutter/impeller/compositor/device_buffer.mm +++ b/engine/src/flutter/impeller/compositor/device_buffer.mm @@ -45,4 +45,21 @@ std::shared_ptr DeviceBuffer::GetDeviceBuffer( return shared_from_this(); } +bool DeviceBuffer::SetLabel(const std::string& label) { + if (label.empty()) { + return false; + } + [buffer_ setLabel:@(label.c_str())]; + return true; +} + +bool DeviceBuffer::SetLabel(const std::string& label, Range range) { + if (label.empty()) { + return false; + } + [buffer_ addDebugMarker:@(label.c_str()) + range:NSMakeRange(range.offset, range.length)]; + return true; +} + } // namespace impeller diff --git a/engine/src/flutter/impeller/compositor/host_buffer.h b/engine/src/flutter/impeller/compositor/host_buffer.h index 4c73d7dbbe..75cd731ec2 100644 --- a/engine/src/flutter/impeller/compositor/host_buffer.h +++ b/engine/src/flutter/impeller/compositor/host_buffer.h @@ -6,6 +6,7 @@ #include #include +#include #include #include "flutter/fml/macros.h" @@ -22,6 +23,8 @@ class HostBuffer final : public std::enable_shared_from_this, static std::shared_ptr Create(); + void SetLabel(std::string label); + size_t GetLength() const; size_t GetReservedLength() const; @@ -44,6 +47,7 @@ class HostBuffer final : public std::enable_shared_from_this, size_t length_ = 0; size_t reserved_ = 0; size_t generation_ = 1u; + std::string label_; // |Buffer| std::shared_ptr GetDeviceBuffer( diff --git a/engine/src/flutter/impeller/compositor/host_buffer.mm b/engine/src/flutter/impeller/compositor/host_buffer.mm index 5cae5bfb65..da32b1b1b4 100644 --- a/engine/src/flutter/impeller/compositor/host_buffer.mm +++ b/engine/src/flutter/impeller/compositor/host_buffer.mm @@ -10,6 +10,7 @@ #include "impeller/compositor/allocator.h" #include "impeller/compositor/buffer_view.h" +#include "impeller/compositor/device_buffer.h" namespace impeller { @@ -23,6 +24,10 @@ HostBuffer::~HostBuffer() { ::free(buffer_); } +void HostBuffer::SetLabel(std::string label) { + label_ = std::move(label); +} + size_t HostBuffer::GetLength() const { return length_; } @@ -121,6 +126,7 @@ std::shared_ptr HostBuffer::GetDeviceBuffer( if (!new_buffer) { return nullptr; } + new_buffer->SetLabel(label_); device_buffer_generation_ = generation_; device_buffer_ = std::move(new_buffer); return device_buffer_;