Name device buffers.
This commit is contained in:
@@ -27,6 +27,10 @@ class DeviceBuffer final : public Buffer,
|
||||
|
||||
id<MTLBuffer> GetMTLBuffer() const;
|
||||
|
||||
bool SetLabel(const std::string& label);
|
||||
|
||||
bool SetLabel(const std::string& label, Range range);
|
||||
|
||||
private:
|
||||
friend class Allocator;
|
||||
|
||||
|
||||
@@ -45,4 +45,21 @@ std::shared_ptr<const DeviceBuffer> 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
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
@@ -22,6 +23,8 @@ class HostBuffer final : public std::enable_shared_from_this<HostBuffer>,
|
||||
|
||||
static std::shared_ptr<HostBuffer> 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<HostBuffer>,
|
||||
size_t length_ = 0;
|
||||
size_t reserved_ = 0;
|
||||
size_t generation_ = 1u;
|
||||
std::string label_;
|
||||
|
||||
// |Buffer|
|
||||
std::shared_ptr<const DeviceBuffer> GetDeviceBuffer(
|
||||
|
||||
@@ -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<const DeviceBuffer> HostBuffer::GetDeviceBuffer(
|
||||
if (!new_buffer) {
|
||||
return nullptr;
|
||||
}
|
||||
new_buffer->SetLabel(label_);
|
||||
device_buffer_generation_ = generation_;
|
||||
device_buffer_ = std::move(new_buffer);
|
||||
return device_buffer_;
|
||||
|
||||
Reference in New Issue
Block a user