[Impeller] make labeling APIs exclusively use std::string_view. (flutter/engine#55918)
Many of our labeling APIs accepted a std::string. When provided with a string literal (const char*), this would force the allocation of a new std::string object and a copy of the original char*. std::string_view is a view of either a std::string, or a const char* (or other), which allows an API that doesn not need to store the string to accept both without a copy. Of course, we can't store a std::string_view, as that doesn't provide memory ownership - so many of the GLES implementations will still copy the string_view into a string locally. Also updates several of the debug labelling functions to no-op in release mode and removes some expensive interpolations that aren't super necessary.
This commit is contained in:
@@ -23,9 +23,9 @@ class DeviceBuffer {
|
||||
Range source_range,
|
||||
size_t offset = 0u);
|
||||
|
||||
virtual bool SetLabel(const std::string& label) = 0;
|
||||
virtual bool SetLabel(std::string_view label) = 0;
|
||||
|
||||
virtual bool SetLabel(const std::string& label, Range range) = 0;
|
||||
virtual bool SetLabel(std::string_view label, Range range) = 0;
|
||||
|
||||
/// @brief Create a buffer view of this entire buffer.
|
||||
static BufferView AsBufferView(std::shared_ptr<DeviceBuffer> buffer);
|
||||
|
||||
@@ -37,10 +37,6 @@ HostBuffer::HostBuffer(const std::shared_ptr<Allocator>& allocator)
|
||||
|
||||
HostBuffer::~HostBuffer() = default;
|
||||
|
||||
void HostBuffer::SetLabel(std::string label) {
|
||||
label_ = std::move(label);
|
||||
}
|
||||
|
||||
BufferView HostBuffer::Emplace(const void* buffer,
|
||||
size_t length,
|
||||
size_t align) {
|
||||
|
||||
@@ -30,10 +30,7 @@ class HostBuffer {
|
||||
static std::shared_ptr<HostBuffer> Create(
|
||||
const std::shared_ptr<Allocator>& allocator);
|
||||
|
||||
// |Buffer|
|
||||
virtual ~HostBuffer();
|
||||
|
||||
void SetLabel(std::string label);
|
||||
~HostBuffer();
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Emplace uniform data onto the host buffer. Ensure that backend
|
||||
@@ -169,7 +166,6 @@ class HostBuffer {
|
||||
size_t current_buffer_ = 0u;
|
||||
size_t offset_ = 0u;
|
||||
size_t frame_index_ = 0u;
|
||||
std::string label_;
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -94,7 +94,7 @@ TEST_P(AiksTest, CanRenderColorFilterWithInvertColorsDrawPaint) {
|
||||
namespace {
|
||||
bool GenerateMipmap(const std::shared_ptr<Context>& context,
|
||||
std::shared_ptr<Texture> texture,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
auto buffer = context->CreateCommandBuffer();
|
||||
if (!buffer) {
|
||||
return false;
|
||||
@@ -103,7 +103,7 @@ bool GenerateMipmap(const std::shared_ptr<Context>& context,
|
||||
if (!pass) {
|
||||
return false;
|
||||
}
|
||||
pass->GenerateMipmap(std::move(texture), std::move(label));
|
||||
pass->GenerateMipmap(std::move(texture), label);
|
||||
|
||||
pass->EncodeCommands(context->GetResourceAllocator());
|
||||
return context->GetCommandQueue()->Submit({buffer}).ok();
|
||||
|
||||
@@ -94,8 +94,7 @@ bool AtlasContents::Render(const ContentContext& renderer,
|
||||
using FS = PorterDuffBlendPipeline::FragmentShader;
|
||||
|
||||
#ifdef IMPELLER_DEBUG
|
||||
pass.SetCommandLabel(
|
||||
SPrintF("DrawAtlas Blend (%s)", BlendModeToString(blend_mode)));
|
||||
pass.SetCommandLabel("DrawAtlas Blend");
|
||||
#endif // IMPELLER_DEBUG
|
||||
pass.SetVertexBuffer(geometry_->CreateBlendVertexBuffer(host_buffer));
|
||||
pass.SetPipeline(
|
||||
@@ -138,8 +137,7 @@ bool AtlasContents::Render(const ContentContext& renderer,
|
||||
using FS = VerticesUberShader::FragmentShader;
|
||||
|
||||
#ifdef IMPELLER_DEBUG
|
||||
pass.SetCommandLabel(
|
||||
SPrintF("DrawAtlas Advanced Blend (%s)", BlendModeToString(blend_mode)));
|
||||
pass.SetCommandLabel("DrawAtlas Advanced Blend");
|
||||
#endif // IMPELLER_DEBUG
|
||||
pass.SetVertexBuffer(geometry_->CreateBlendVertexBuffer(host_buffer));
|
||||
|
||||
|
||||
@@ -493,12 +493,12 @@ fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
|
||||
if (context->GetCapabilities()->SupportsOffscreenMSAA() && msaa_enabled) {
|
||||
subpass_target = GetRenderTargetCache()->CreateOffscreenMSAA(
|
||||
*context, texture_size,
|
||||
/*mip_count=*/mip_count, SPrintF("%s Offscreen", label.data()),
|
||||
/*mip_count=*/mip_count, label,
|
||||
RenderTarget::kDefaultColorAttachmentConfigMSAA, depth_stencil_config);
|
||||
} else {
|
||||
subpass_target = GetRenderTargetCache()->CreateOffscreen(
|
||||
*context, texture_size,
|
||||
/*mip_count=*/mip_count, SPrintF("%s Offscreen", label.data()),
|
||||
/*mip_count=*/mip_count, label,
|
||||
RenderTarget::kDefaultColorAttachmentConfig, depth_stencil_config);
|
||||
}
|
||||
return MakeSubpass(label, subpass_target, command_buffer, subpass_callback);
|
||||
@@ -520,7 +520,7 @@ fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
|
||||
if (!sub_renderpass) {
|
||||
return fml::Status(fml::StatusCode::kUnknown, "");
|
||||
}
|
||||
sub_renderpass->SetLabel(SPrintF("%s RenderPass", label.data()));
|
||||
sub_renderpass->SetLabel(label);
|
||||
|
||||
if (!subpass_callback(*this, *sub_renderpass)) {
|
||||
return fml::Status(fml::StatusCode::kUnknown, "");
|
||||
|
||||
@@ -992,7 +992,7 @@ class ContentContext {
|
||||
PipelineDescriptor& desc) {
|
||||
opts.ApplyToPipelineDescriptor(desc);
|
||||
desc.SetLabel(
|
||||
SPrintF("%s V#%zu", desc.GetLabel().c_str(), variants_count));
|
||||
SPrintF("%s V#%zu", desc.GetLabel().data(), variants_count));
|
||||
});
|
||||
std::unique_ptr<RenderPipelineHandleT> variant =
|
||||
std::make_unique<RenderPipelineHandleT>(std::move(variant_future));
|
||||
|
||||
@@ -92,7 +92,7 @@ fml::Status RecordingRenderPass::Draw() {
|
||||
}
|
||||
|
||||
// |RenderPass|
|
||||
void RecordingRenderPass::OnSetLabel(std::string label) {
|
||||
void RecordingRenderPass::OnSetLabel(std::string_view label) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class RecordingRenderPass : public RenderPass {
|
||||
const std::unique_ptr<const Sampler>& sampler) override;
|
||||
|
||||
// |RenderPass|
|
||||
void OnSetLabel(std::string label) override;
|
||||
void OnSetLabel(std::string_view label) override;
|
||||
|
||||
// |RenderPass|
|
||||
bool OnEncodeCommands(const Context& context) const override;
|
||||
|
||||
@@ -31,8 +31,8 @@ std::shared_ptr<TextureContents> TextureContents::MakeRect(Rect destination) {
|
||||
return contents;
|
||||
}
|
||||
|
||||
void TextureContents::SetLabel(std::string label) {
|
||||
label_ = std::move(label);
|
||||
void TextureContents::SetLabel(std::string_view label) {
|
||||
label_ = label;
|
||||
}
|
||||
|
||||
void TextureContents::SetDestinationRect(Rect rect) {
|
||||
|
||||
@@ -25,7 +25,7 @@ class TextureContents final : public Contents {
|
||||
/// when image filters are applied.
|
||||
static std::shared_ptr<TextureContents> MakeRect(Rect destination);
|
||||
|
||||
void SetLabel(std::string label);
|
||||
void SetLabel(std::string_view label);
|
||||
|
||||
void SetDestinationRect(Rect rect);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ RenderTarget RenderTargetCache::CreateOffscreen(
|
||||
const Context& context,
|
||||
ISize size,
|
||||
int mip_count,
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
RenderTarget::AttachmentConfig color_attachment_config,
|
||||
std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config,
|
||||
const std::shared_ptr<Texture>& existing_color_texture,
|
||||
@@ -79,7 +79,7 @@ RenderTarget RenderTargetCache::CreateOffscreenMSAA(
|
||||
const Context& context,
|
||||
ISize size,
|
||||
int mip_count,
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
RenderTarget::AttachmentConfigMSAA color_attachment_config,
|
||||
std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config,
|
||||
const std::shared_ptr<Texture>& existing_color_msaa_texture,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef FLUTTER_IMPELLER_ENTITY_RENDER_TARGET_CACHE_H_
|
||||
#define FLUTTER_IMPELLER_ENTITY_RENDER_TARGET_CACHE_H_
|
||||
|
||||
#include <string_view>
|
||||
#include "impeller/renderer/render_target.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -29,7 +30,7 @@ class RenderTargetCache : public RenderTargetAllocator {
|
||||
const Context& context,
|
||||
ISize size,
|
||||
int mip_count,
|
||||
const std::string& label = "Offscreen",
|
||||
std::string_view label = "Offscreen",
|
||||
RenderTarget::AttachmentConfig color_attachment_config =
|
||||
RenderTarget::kDefaultColorAttachmentConfig,
|
||||
std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config =
|
||||
@@ -42,7 +43,7 @@ class RenderTargetCache : public RenderTargetAllocator {
|
||||
const Context& context,
|
||||
ISize size,
|
||||
int mip_count,
|
||||
const std::string& label = "Offscreen MSAA",
|
||||
std::string_view label = "Offscreen MSAA",
|
||||
RenderTarget::AttachmentConfigMSAA color_attachment_config =
|
||||
RenderTarget::kDefaultColorAttachmentConfigMSAA,
|
||||
std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config =
|
||||
|
||||
@@ -27,8 +27,8 @@ bool BlitPassGLES::IsValid() const {
|
||||
}
|
||||
|
||||
// |BlitPass|
|
||||
void BlitPassGLES::OnSetLabel(std::string label) {
|
||||
label_ = std::move(label);
|
||||
void BlitPassGLES::OnSetLabel(std::string_view label) {
|
||||
label_ = std::string(label);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool EncodeCommandsInReactor(
|
||||
@@ -96,7 +96,7 @@ bool BlitPassGLES::OnCopyTextureToTextureCommand(
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect source_region,
|
||||
IPoint destination_origin,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
auto command = std::make_unique<BlitCopyTextureToTextureCommandGLES>();
|
||||
command->label = label;
|
||||
command->source = std::move(source);
|
||||
@@ -114,7 +114,7 @@ bool BlitPassGLES::OnCopyTextureToBufferCommand(
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
IRect source_region,
|
||||
size_t destination_offset,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
auto command = std::make_unique<BlitCopyTextureToBufferCommandGLES>();
|
||||
command->label = label;
|
||||
command->source = std::move(source);
|
||||
@@ -131,7 +131,7 @@ bool BlitPassGLES::OnCopyBufferToTextureCommand(
|
||||
BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect destination_region,
|
||||
std::string label,
|
||||
std::string_view label,
|
||||
uint32_t mip_level,
|
||||
uint32_t slice,
|
||||
bool convert_to_read) {
|
||||
@@ -150,7 +150,7 @@ bool BlitPassGLES::OnCopyBufferToTextureCommand(
|
||||
|
||||
// |BlitPass|
|
||||
bool BlitPassGLES::OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
auto command = std::make_unique<BlitGenerateMipmapCommandGLES>();
|
||||
command->label = label;
|
||||
command->texture = std::move(texture);
|
||||
|
||||
@@ -35,7 +35,7 @@ class BlitPassGLES final : public BlitPass,
|
||||
bool IsValid() const override;
|
||||
|
||||
// |BlitPass|
|
||||
void OnSetLabel(std::string label) override;
|
||||
void OnSetLabel(std::string_view label) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool EncodeCommands(
|
||||
@@ -50,27 +50,27 @@ class BlitPassGLES final : public BlitPass,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect source_region,
|
||||
IPoint destination_origin,
|
||||
std::string label) override;
|
||||
std::string_view label) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool OnCopyTextureToBufferCommand(std::shared_ptr<Texture> source,
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
IRect source_region,
|
||||
size_t destination_offset,
|
||||
std::string label) override;
|
||||
std::string_view label) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool OnCopyBufferToTextureCommand(BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect destination_region,
|
||||
std::string label,
|
||||
std::string_view label,
|
||||
uint32_t mip_level,
|
||||
uint32_t slice,
|
||||
bool convert_to_read) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
|
||||
std::string label) override;
|
||||
std::string_view label) override;
|
||||
|
||||
BlitPassGLES(const BlitPassGLES&) = delete;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ CommandBufferGLES::CommandBufferGLES(std::weak_ptr<const Context> context,
|
||||
CommandBufferGLES::~CommandBufferGLES() = default;
|
||||
|
||||
// |CommandBuffer|
|
||||
void CommandBufferGLES::SetLabel(const std::string& label) const {
|
||||
void CommandBufferGLES::SetLabel(std::string_view label) const {
|
||||
// Cannot support.
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class CommandBufferGLES final : public CommandBuffer {
|
||||
ReactorGLES::Ref reactor);
|
||||
|
||||
// |CommandBuffer|
|
||||
void SetLabel(const std::string& label) const override;
|
||||
void SetLabel(std::string_view label) const override;
|
||||
|
||||
// |CommandBuffer|
|
||||
bool IsValid() const override;
|
||||
|
||||
@@ -110,13 +110,15 @@ bool DeviceBufferGLES::BindAndUploadDataIfNecessary(BindingType type) const {
|
||||
}
|
||||
|
||||
// |DeviceBuffer|
|
||||
bool DeviceBufferGLES::SetLabel(const std::string& label) {
|
||||
bool DeviceBufferGLES::SetLabel(std::string_view label) {
|
||||
#ifdef IMPELLER_DEBUG
|
||||
reactor_->SetDebugLabel(handle_, label);
|
||||
#endif // IMPELLER_DEBUG
|
||||
return true;
|
||||
}
|
||||
|
||||
// |DeviceBuffer|
|
||||
bool DeviceBufferGLES::SetLabel(const std::string& label, Range range) {
|
||||
bool DeviceBufferGLES::SetLabel(std::string_view label, Range range) {
|
||||
// Cannot support debug label on the range. Set the label for the entire
|
||||
// range.
|
||||
return SetLabel(label);
|
||||
|
||||
@@ -56,10 +56,10 @@ class DeviceBufferGLES final
|
||||
size_t offset) override;
|
||||
|
||||
// |DeviceBuffer|
|
||||
bool SetLabel(const std::string& label) override;
|
||||
bool SetLabel(std::string_view label) override;
|
||||
|
||||
// |DeviceBuffer|
|
||||
bool SetLabel(const std::string& label, Range range) override;
|
||||
bool SetLabel(std::string_view label, Range range) override;
|
||||
|
||||
DeviceBufferGLES(const DeviceBufferGLES&) = delete;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ static std::string GetShaderSource(const ProcTableGLES& gl, GLuint shader) {
|
||||
|
||||
static void LogShaderCompilationFailure(const ProcTableGLES& gl,
|
||||
GLuint shader,
|
||||
const std::string& name,
|
||||
std::string_view name,
|
||||
const fml::Mapping& source_mapping,
|
||||
ShaderStage stage) {
|
||||
std::stringstream stream;
|
||||
@@ -99,10 +99,9 @@ static bool LinkProgram(
|
||||
}
|
||||
|
||||
gl.SetDebugLabel(DebugResourceType::kShader, vert_shader,
|
||||
SPrintF("%s Vertex Shader", descriptor.GetLabel().c_str()));
|
||||
gl.SetDebugLabel(
|
||||
DebugResourceType::kShader, frag_shader,
|
||||
SPrintF("%s Fragment Shader", descriptor.GetLabel().c_str()));
|
||||
SPrintF("%s Vertex Shader", descriptor.GetLabel().data()));
|
||||
gl.SetDebugLabel(DebugResourceType::kShader, frag_shader,
|
||||
SPrintF("%s Fragment Shader", descriptor.GetLabel().data()));
|
||||
|
||||
fml::ScopedCleanupClosure delete_vert_shader(
|
||||
[&gl, vert_shader]() { gl.DeleteShader(vert_shader); });
|
||||
|
||||
@@ -275,7 +275,8 @@ void ReactorGLES::SetupDebugGroups() {
|
||||
}
|
||||
}
|
||||
|
||||
void ReactorGLES::SetDebugLabel(const HandleGLES& handle, std::string label) {
|
||||
void ReactorGLES::SetDebugLabel(const HandleGLES& handle,
|
||||
std::string_view label) {
|
||||
if (!can_set_debug_labels_) {
|
||||
return;
|
||||
}
|
||||
@@ -284,7 +285,7 @@ void ReactorGLES::SetDebugLabel(const HandleGLES& handle, std::string label) {
|
||||
}
|
||||
WriterLock handles_lock(handles_mutex_);
|
||||
if (auto found = handles_.find(handle); found != handles_.end()) {
|
||||
found->second.pending_debug_label = std::move(label);
|
||||
found->second.pending_debug_label = label;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ class ReactorGLES {
|
||||
/// @param[in] handle The handle
|
||||
/// @param[in] label The label
|
||||
///
|
||||
void SetDebugLabel(const HandleGLES& handle, std::string label);
|
||||
void SetDebugLabel(const HandleGLES& handle, std::string_view label);
|
||||
|
||||
using Operation = std::function<void(const ReactorGLES& reactor)>;
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ bool RenderPassGLES::IsValid() const {
|
||||
}
|
||||
|
||||
// |RenderPass|
|
||||
void RenderPassGLES::OnSetLabel(std::string label) {
|
||||
label_ = std::move(label);
|
||||
void RenderPassGLES::OnSetLabel(std::string_view label) {
|
||||
label_ = label;
|
||||
}
|
||||
|
||||
void ConfigureBlending(const ProcTableGLES& gl,
|
||||
|
||||
@@ -34,7 +34,7 @@ class RenderPassGLES final
|
||||
bool IsValid() const override;
|
||||
|
||||
// |RenderPass|
|
||||
void OnSetLabel(std::string label) override;
|
||||
void OnSetLabel(std::string_view label) override;
|
||||
|
||||
// |RenderPass|
|
||||
bool OnEncodeCommands(const Context& context) const override;
|
||||
|
||||
@@ -35,7 +35,7 @@ class BlitPassMTL final : public BlitPass {
|
||||
bool IsValid() const override;
|
||||
|
||||
// |BlitPass|
|
||||
void OnSetLabel(std::string label) override;
|
||||
void OnSetLabel(std::string_view label) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool EncodeCommands(
|
||||
@@ -50,26 +50,26 @@ class BlitPassMTL final : public BlitPass {
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect source_region,
|
||||
IPoint destination_origin,
|
||||
std::string label) override;
|
||||
std::string_view label) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool OnCopyTextureToBufferCommand(std::shared_ptr<Texture> source,
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
IRect source_region,
|
||||
size_t destination_offset,
|
||||
std::string label) override;
|
||||
std::string_view label) override;
|
||||
// |BlitPass|
|
||||
bool OnCopyBufferToTextureCommand(BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect destination_region,
|
||||
std::string label,
|
||||
std::string_view label,
|
||||
uint32_t mip_level,
|
||||
uint32_t slice,
|
||||
bool convert_to_read) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
|
||||
std::string label) override;
|
||||
std::string_view label) override;
|
||||
|
||||
BlitPassMTL(const BlitPassMTL&) = delete;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/metal/blit_pass_mtl.h"
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
#import <MetalPerformanceShaders/MetalPerformanceShaders.h>
|
||||
#include <cstdint>
|
||||
@@ -50,11 +51,11 @@ bool BlitPassMTL::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
void BlitPassMTL::OnSetLabel(std::string label) {
|
||||
void BlitPassMTL::OnSetLabel(std::string_view label) {
|
||||
if (label.empty()) {
|
||||
return;
|
||||
}
|
||||
[encoder_ setLabel:@(label.c_str())];
|
||||
[encoder_ setLabel:@(label.data())];
|
||||
}
|
||||
|
||||
bool BlitPassMTL::EncodeCommands(
|
||||
@@ -70,7 +71,7 @@ bool BlitPassMTL::OnCopyTextureToTextureCommand(
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect source_region,
|
||||
IPoint destination_origin,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
auto source_mtl = TextureMTL::Cast(*source).GetMTLTexture();
|
||||
if (!source_mtl) {
|
||||
return false;
|
||||
@@ -90,7 +91,7 @@ bool BlitPassMTL::OnCopyTextureToTextureCommand(
|
||||
|
||||
#ifdef IMPELLER_DEBUG
|
||||
if (is_metal_trace_active_) {
|
||||
[encoder_ pushDebugGroup:@(label.c_str())];
|
||||
[encoder_ pushDebugGroup:@(label.data())];
|
||||
}
|
||||
#endif // IMPELLER_DEBUG
|
||||
[encoder_ copyFromTexture:source_mtl
|
||||
@@ -139,7 +140,7 @@ bool BlitPassMTL::OnCopyTextureToBufferCommand(
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
IRect source_region,
|
||||
size_t destination_offset,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
auto source_mtl = TextureMTL::Cast(*source).GetMTLTexture();
|
||||
if (!source_mtl) {
|
||||
return false;
|
||||
@@ -164,7 +165,7 @@ bool BlitPassMTL::OnCopyTextureToBufferCommand(
|
||||
|
||||
#ifdef IMPELLER_DEBUG
|
||||
if (is_metal_trace_active_) {
|
||||
[encoder_ pushDebugGroup:@(label.c_str())];
|
||||
[encoder_ pushDebugGroup:@(label.data())];
|
||||
}
|
||||
#endif // IMPELLER_DEBUG
|
||||
[encoder_ copyFromTexture:source_mtl
|
||||
@@ -189,7 +190,7 @@ bool BlitPassMTL::OnCopyBufferToTextureCommand(
|
||||
BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect destination_region,
|
||||
std::string label,
|
||||
std::string_view label,
|
||||
uint32_t mip_level,
|
||||
uint32_t slice,
|
||||
bool convert_to_read) {
|
||||
@@ -215,7 +216,7 @@ bool BlitPassMTL::OnCopyBufferToTextureCommand(
|
||||
|
||||
#ifdef IMPELLER_DEBUG
|
||||
if (is_metal_trace_active_) {
|
||||
[encoder_ pushDebugGroup:@(label.c_str())];
|
||||
[encoder_ pushDebugGroup:@(label.data())];
|
||||
}
|
||||
#endif // IMPELLER_DEBUG
|
||||
[encoder_
|
||||
@@ -241,10 +242,10 @@ bool BlitPassMTL::OnCopyBufferToTextureCommand(
|
||||
|
||||
// |BlitPass|
|
||||
bool BlitPassMTL::OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
#ifdef IMPELLER_DEBUG
|
||||
if (is_metal_trace_active_) {
|
||||
[encoder_ pushDebugGroup:@(label.c_str())];
|
||||
[encoder_ pushDebugGroup:@(label.data())];
|
||||
}
|
||||
#endif // IMPELLER_DEBUG
|
||||
auto result = TextureMTL::Cast(*texture).GenerateMipmap(encoder_);
|
||||
|
||||
@@ -28,7 +28,7 @@ class CommandBufferMTL final : public CommandBuffer {
|
||||
id<MTLCommandQueue> queue);
|
||||
|
||||
// |CommandBuffer|
|
||||
void SetLabel(const std::string& label) const override;
|
||||
void SetLabel(std::string_view label) const override;
|
||||
|
||||
// |CommandBuffer|
|
||||
bool IsValid() const override;
|
||||
|
||||
@@ -140,12 +140,14 @@ bool CommandBufferMTL::IsValid() const {
|
||||
return buffer_ != nil;
|
||||
}
|
||||
|
||||
void CommandBufferMTL::SetLabel(const std::string& label) const {
|
||||
void CommandBufferMTL::SetLabel(std::string_view label) const {
|
||||
#ifdef IMPELLER_DEBUG
|
||||
if (label.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
[buffer_ setLabel:@(label.data())];
|
||||
#endif // IMPELLER_DEBUG
|
||||
}
|
||||
|
||||
static CommandBuffer::Status ToCommitResult(MTLCommandBufferStatus status) {
|
||||
|
||||
@@ -42,10 +42,10 @@ class DeviceBufferMTL final
|
||||
size_t offset) override;
|
||||
|
||||
// |DeviceBuffer|
|
||||
bool SetLabel(const std::string& label) override;
|
||||
bool SetLabel(std::string_view label) override;
|
||||
|
||||
// |DeviceBuffer|
|
||||
bool SetLabel(const std::string& label, Range range) override;
|
||||
bool SetLabel(std::string_view label, Range range) override;
|
||||
|
||||
// |DeviceBuffer|
|
||||
void Flush(std::optional<Range> range) const override;
|
||||
|
||||
@@ -64,20 +64,24 @@ void DeviceBufferMTL::Flush(std::optional<Range> range) const {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DeviceBufferMTL::SetLabel(const std::string& label) {
|
||||
bool DeviceBufferMTL::SetLabel(std::string_view label) {
|
||||
#ifdef IMPELLER_DEBUG
|
||||
if (label.empty()) {
|
||||
return false;
|
||||
}
|
||||
[buffer_ setLabel:@(label.c_str())];
|
||||
[buffer_ setLabel:@(label.data())];
|
||||
#endif // IMPELLER_DEBUG
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceBufferMTL::SetLabel(const std::string& label, Range range) {
|
||||
bool DeviceBufferMTL::SetLabel(std::string_view label, Range range) {
|
||||
#ifdef IMPELLER_DEBUG
|
||||
if (label.empty()) {
|
||||
return false;
|
||||
}
|
||||
[buffer_ addDebugMarker:@(label.c_str())
|
||||
[buffer_ addDebugMarker:@(label.data())
|
||||
range:NSMakeRange(range.offset, range.length)];
|
||||
#endif // IMPELLER_DEBUG
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ using Callback = std::function<void(MTLRenderPipelineDescriptor*)>;
|
||||
static void GetMTLRenderPipelineDescriptor(const PipelineDescriptor& desc,
|
||||
const Callback& callback) {
|
||||
auto descriptor = [[MTLRenderPipelineDescriptor alloc] init];
|
||||
descriptor.label = @(desc.GetLabel().c_str());
|
||||
descriptor.label = @(desc.GetLabel().data());
|
||||
descriptor.rasterSampleCount = static_cast<NSUInteger>(desc.GetSampleCount());
|
||||
bool created_specialized_function = false;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class RenderPassMTL final : public RenderPass {
|
||||
bool IsValid() const override;
|
||||
|
||||
// |RenderPass|
|
||||
void OnSetLabel(std::string label) override;
|
||||
void OnSetLabel(std::string_view label) override;
|
||||
|
||||
// |RenderPass|
|
||||
bool OnEncodeCommands(const Context& context) const override;
|
||||
|
||||
@@ -170,7 +170,7 @@ bool RenderPassMTL::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
void RenderPassMTL::OnSetLabel(std::string label) {
|
||||
void RenderPassMTL::OnSetLabel(std::string_view label) {
|
||||
#ifdef IMPELLER_DEBUG
|
||||
if (label.empty()) {
|
||||
return;
|
||||
|
||||
@@ -49,12 +49,7 @@ BlitPassVK::BlitPassVK(std::shared_ptr<CommandBufferVK> command_buffer)
|
||||
|
||||
BlitPassVK::~BlitPassVK() = default;
|
||||
|
||||
void BlitPassVK::OnSetLabel(std::string label) {
|
||||
if (label.empty()) {
|
||||
return;
|
||||
}
|
||||
label_ = std::move(label);
|
||||
}
|
||||
void BlitPassVK::OnSetLabel(std::string_view label) {}
|
||||
|
||||
// |BlitPass|
|
||||
bool BlitPassVK::IsValid() const {
|
||||
@@ -73,7 +68,7 @@ bool BlitPassVK::OnCopyTextureToTextureCommand(
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect source_region,
|
||||
IPoint destination_origin,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
const auto& cmd_buffer = command_buffer_->GetCommandBuffer();
|
||||
|
||||
const auto& src = TextureVK::Cast(*source);
|
||||
@@ -156,7 +151,7 @@ bool BlitPassVK::OnCopyTextureToBufferCommand(
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
IRect source_region,
|
||||
size_t destination_offset,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
const auto& cmd_buffer = command_buffer_->GetCommandBuffer();
|
||||
|
||||
// cast source and destination to TextureVK
|
||||
@@ -245,7 +240,7 @@ bool BlitPassVK::OnCopyBufferToTextureCommand(
|
||||
BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect destination_region,
|
||||
std::string label,
|
||||
std::string_view label,
|
||||
uint32_t mip_level,
|
||||
uint32_t slice,
|
||||
bool convert_to_read) {
|
||||
@@ -401,7 +396,7 @@ bool BlitPassVK::ResizeTexture(const std::shared_ptr<Texture>& source,
|
||||
|
||||
// |BlitPass|
|
||||
bool BlitPassVK::OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
auto& src = TextureVK::Cast(*texture);
|
||||
|
||||
const auto size = src.GetTextureDescriptor().size;
|
||||
|
||||
@@ -23,7 +23,6 @@ class BlitPassVK final : public BlitPass {
|
||||
friend class CommandBufferVK;
|
||||
|
||||
std::shared_ptr<CommandBufferVK> command_buffer_;
|
||||
std::string label_;
|
||||
|
||||
explicit BlitPassVK(std::shared_ptr<CommandBufferVK> command_buffer);
|
||||
|
||||
@@ -31,7 +30,7 @@ class BlitPassVK final : public BlitPass {
|
||||
bool IsValid() const override;
|
||||
|
||||
// |BlitPass|
|
||||
void OnSetLabel(std::string label) override;
|
||||
void OnSetLabel(std::string_view label) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool EncodeCommands(
|
||||
@@ -50,26 +49,26 @@ class BlitPassVK final : public BlitPass {
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect source_region,
|
||||
IPoint destination_origin,
|
||||
std::string label) override;
|
||||
std::string_view label) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool OnCopyTextureToBufferCommand(std::shared_ptr<Texture> source,
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
IRect source_region,
|
||||
size_t destination_offset,
|
||||
std::string label) override;
|
||||
std::string_view label) override;
|
||||
|
||||
// |BlitPass|
|
||||
bool OnCopyBufferToTextureCommand(BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect destination_region,
|
||||
std::string label,
|
||||
std::string_view label,
|
||||
uint32_t mip_level,
|
||||
uint32_t slice,
|
||||
bool convert_to_read) override;
|
||||
// |BlitPass|
|
||||
bool OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
|
||||
std::string label) override;
|
||||
std::string_view label) override;
|
||||
|
||||
BlitPassVK(const BlitPassVK&) = delete;
|
||||
|
||||
|
||||
@@ -31,12 +31,14 @@ CommandBufferVK::CommandBufferVK(
|
||||
|
||||
CommandBufferVK::~CommandBufferVK() = default;
|
||||
|
||||
void CommandBufferVK::SetLabel(const std::string& label) const {
|
||||
void CommandBufferVK::SetLabel(std::string_view label) const {
|
||||
#ifdef IMPELLER_DEBUG
|
||||
auto context = context_.lock();
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
ContextVK::Cast(*context).SetDebugName(GetCommandBuffer(), label);
|
||||
#endif // IMPELLER_DEBUG
|
||||
}
|
||||
|
||||
bool CommandBufferVK::IsValid() const {
|
||||
|
||||
@@ -95,7 +95,7 @@ class CommandBufferVK final
|
||||
std::shared_ptr<FenceWaiterVK> fence_waiter);
|
||||
|
||||
// |CommandBuffer|
|
||||
void SetLabel(const std::string& label) const override;
|
||||
void SetLabel(std::string_view label) const override;
|
||||
|
||||
// |CommandBuffer|
|
||||
bool IsValid() const override;
|
||||
|
||||
@@ -48,7 +48,8 @@ bool DeviceBufferVK::OnCopyHostBuffer(const uint8_t* source,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceBufferVK::SetLabel(const std::string& label) {
|
||||
bool DeviceBufferVK::SetLabel(std::string_view label) {
|
||||
#ifdef IMPELLER_DEBUG
|
||||
auto context = context_.lock();
|
||||
if (!context || !resource_->buffer.is_valid()) {
|
||||
// The context could have died at this point.
|
||||
@@ -57,11 +58,14 @@ bool DeviceBufferVK::SetLabel(const std::string& label) {
|
||||
|
||||
::vmaSetAllocationName(resource_->buffer.get().allocator, //
|
||||
resource_->buffer.get().allocation, //
|
||||
label.c_str() //
|
||||
label.data() //
|
||||
);
|
||||
|
||||
return ContextVK::Cast(*context).SetDebugName(resource_->buffer.get().buffer,
|
||||
label);
|
||||
#else
|
||||
return true;
|
||||
#endif // IMPELLER_DEBUG
|
||||
}
|
||||
|
||||
void DeviceBufferVK::Flush(std::optional<Range> range) const {
|
||||
@@ -78,7 +82,7 @@ void DeviceBufferVK::Invalidate(std::optional<Range> range) const {
|
||||
flush_range.offset, flush_range.length);
|
||||
}
|
||||
|
||||
bool DeviceBufferVK::SetLabel(const std::string& label, Range range) {
|
||||
bool DeviceBufferVK::SetLabel(std::string_view label, Range range) {
|
||||
// We do not have the ability to name ranges. Just name the whole thing.
|
||||
return SetLabel(label);
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ class DeviceBufferVK final : public DeviceBuffer,
|
||||
size_t offset) override;
|
||||
|
||||
// |DeviceBuffer|
|
||||
bool SetLabel(const std::string& label) override;
|
||||
bool SetLabel(std::string_view label) override;
|
||||
|
||||
// |DeviceBuffer|
|
||||
bool SetLabel(const std::string& label, Range range) override;
|
||||
bool SetLabel(std::string_view label, Range range) override;
|
||||
|
||||
// |DeviceBuffer|
|
||||
void Flush(std::optional<Range> range) const override;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "flutter/fml/make_copyable.h"
|
||||
#include "flutter/fml/status_or.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "impeller/base/strings.h"
|
||||
#include "impeller/base/timing.h"
|
||||
#include "impeller/renderer/backend/vulkan/capabilities_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/context_vk.h"
|
||||
@@ -159,8 +160,11 @@ static vk::UniqueRenderPass CreateCompatRenderPassForPipeline(
|
||||
return {};
|
||||
}
|
||||
|
||||
ContextVK::SetDebugName(device, pass.get(),
|
||||
"Compat Render Pass: " + desc.GetLabel());
|
||||
#ifdef IMPELLER_DEBUG
|
||||
ContextVK::SetDebugName(
|
||||
device, pass.get(),
|
||||
SPrintF("Compat Render Pass: %s", desc.GetLabel().data()));
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
return pass;
|
||||
}
|
||||
@@ -207,8 +211,11 @@ fml::StatusOr<vk::UniqueDescriptorSetLayout> MakeDescriptorSetLayout(
|
||||
"unable to create uniform descriptors")};
|
||||
}
|
||||
|
||||
ContextVK::SetDebugName(device_holder->GetDevice(), descs_layout.get(),
|
||||
"Descriptor Set Layout " + desc.GetLabel());
|
||||
#ifdef IMPELLER_DEBUG
|
||||
ContextVK::SetDebugName(
|
||||
device_holder->GetDevice(), descs_layout.get(),
|
||||
SPrintF("Descriptor Set Layout: %s", desc.GetLabel().data()));
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
return fml::StatusOr<vk::UniqueDescriptorSetLayout>(std::move(descs_layout));
|
||||
}
|
||||
@@ -229,8 +236,11 @@ fml::StatusOr<vk::UniquePipelineLayout> MakePipelineLayout(
|
||||
"Could not create pipeline layout for pipeline.")};
|
||||
}
|
||||
|
||||
ContextVK::SetDebugName(device_holder->GetDevice(), *pipeline_layout.value,
|
||||
"Pipeline Layout " + desc.GetLabel());
|
||||
#ifdef IMPELLER_DEBUG
|
||||
ContextVK::SetDebugName(
|
||||
device_holder->GetDevice(), *pipeline_layout.value,
|
||||
SPrintF("Pipeline Layout %s", desc.GetLabel().data()));
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
return std::move(pipeline_layout.value);
|
||||
}
|
||||
@@ -439,8 +449,10 @@ fml::StatusOr<vk::UniquePipeline> MakePipeline(
|
||||
ReportPipelineCreationFeedback(desc, feedback);
|
||||
}
|
||||
|
||||
#ifdef IMPELLER_DEBUG
|
||||
ContextVK::SetDebugName(device_holder->GetDevice(), *pipeline,
|
||||
"Pipeline " + desc.GetLabel());
|
||||
SPrintF("Pipeline %s", desc.GetLabel().data()));
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
return std::move(pipeline);
|
||||
}
|
||||
@@ -451,8 +463,7 @@ std::unique_ptr<PipelineVK> PipelineVK::Create(
|
||||
const std::shared_ptr<DeviceHolderVK>& device_holder,
|
||||
const std::weak_ptr<PipelineLibrary>& weak_library,
|
||||
std::shared_ptr<SamplerVK> immutable_sampler) {
|
||||
TRACE_EVENT1("flutter", "PipelineVK::Create", "Name",
|
||||
desc.GetLabel().c_str());
|
||||
TRACE_EVENT1("flutter", "PipelineVK::Create", "Name", desc.GetLabel().data());
|
||||
|
||||
auto library = weak_library.lock();
|
||||
|
||||
|
||||
@@ -238,10 +238,9 @@ bool RenderPassVK::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
void RenderPassVK::OnSetLabel(std::string label) {
|
||||
void RenderPassVK::OnSetLabel(std::string_view label) {
|
||||
#ifdef IMPELLER_DEBUG
|
||||
ContextVK::Cast(*context_).SetDebugName(render_pass_->Get(),
|
||||
std::string(label).c_str());
|
||||
ContextVK::Cast(*context_).SetDebugName(render_pass_->Get(), label.data());
|
||||
#endif // IMPELLER_DEBUG
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class RenderPassVK final : public RenderPass {
|
||||
bool IsValid() const override;
|
||||
|
||||
// |RenderPass|
|
||||
void OnSetLabel(std::string label) override;
|
||||
void OnSetLabel(std::string_view label) override;
|
||||
|
||||
// |RenderPass|
|
||||
bool OnEncodeCommands(const Context& context) const override;
|
||||
|
||||
@@ -16,18 +16,18 @@ BlitPass::BlitPass() {}
|
||||
|
||||
BlitPass::~BlitPass() = default;
|
||||
|
||||
void BlitPass::SetLabel(std::string label) {
|
||||
void BlitPass::SetLabel(std::string_view label) {
|
||||
if (label.empty()) {
|
||||
return;
|
||||
}
|
||||
OnSetLabel(std::move(label));
|
||||
OnSetLabel(label);
|
||||
}
|
||||
|
||||
bool BlitPass::AddCopy(std::shared_ptr<Texture> source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
std::optional<IRect> source_region,
|
||||
IPoint destination_origin,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
if (!source) {
|
||||
VALIDATION_LOG << "Attempted to add a texture blit with no source.";
|
||||
return false;
|
||||
@@ -77,14 +77,14 @@ bool BlitPass::AddCopy(std::shared_ptr<Texture> source,
|
||||
|
||||
return OnCopyTextureToTextureCommand(
|
||||
std::move(source), std::move(destination), source_region.value(),
|
||||
destination_origin, std::move(label));
|
||||
destination_origin, label);
|
||||
}
|
||||
|
||||
bool BlitPass::AddCopy(std::shared_ptr<Texture> source,
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
std::optional<IRect> source_region,
|
||||
size_t destination_offset,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
if (!source) {
|
||||
VALIDATION_LOG << "Attempted to add a texture blit with no source.";
|
||||
return false;
|
||||
@@ -117,13 +117,13 @@ bool BlitPass::AddCopy(std::shared_ptr<Texture> source,
|
||||
|
||||
return OnCopyTextureToBufferCommand(std::move(source), std::move(destination),
|
||||
source_region.value(), destination_offset,
|
||||
std::move(label));
|
||||
label);
|
||||
}
|
||||
|
||||
bool BlitPass::AddCopy(BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
std::optional<IRect> destination_region,
|
||||
std::string label,
|
||||
std::string_view label,
|
||||
uint32_t mip_level,
|
||||
uint32_t slice,
|
||||
bool convert_to_read) {
|
||||
@@ -162,9 +162,9 @@ bool BlitPass::AddCopy(BufferView source,
|
||||
return false;
|
||||
}
|
||||
|
||||
return OnCopyBufferToTextureCommand(
|
||||
std::move(source), std::move(destination), destination_region_value,
|
||||
std::move(label), mip_level, slice, convert_to_read);
|
||||
return OnCopyBufferToTextureCommand(std::move(source), std::move(destination),
|
||||
destination_region_value, label,
|
||||
mip_level, slice, convert_to_read);
|
||||
}
|
||||
|
||||
bool BlitPass::ConvertTextureToShaderRead(
|
||||
@@ -173,14 +173,14 @@ bool BlitPass::ConvertTextureToShaderRead(
|
||||
}
|
||||
|
||||
bool BlitPass::GenerateMipmap(std::shared_ptr<Texture> texture,
|
||||
std::string label) {
|
||||
std::string_view label) {
|
||||
if (!texture) {
|
||||
VALIDATION_LOG << "Attempted to add an invalid mipmap generation command "
|
||||
"with no texture.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return OnGenerateMipmapCommand(std::move(texture), std::move(label));
|
||||
return OnGenerateMipmapCommand(std::move(texture), label);
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -30,7 +30,7 @@ class BlitPass {
|
||||
|
||||
virtual bool IsValid() const = 0;
|
||||
|
||||
void SetLabel(std::string label);
|
||||
void SetLabel(std::string_view label);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief If the texture is not already in a shader read internal
|
||||
@@ -71,7 +71,7 @@ class BlitPass {
|
||||
std::shared_ptr<Texture> destination,
|
||||
std::optional<IRect> source_region = std::nullopt,
|
||||
IPoint destination_origin = {},
|
||||
std::string label = "");
|
||||
std::string_view label = "");
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Record a command to copy the contents of a texture to a
|
||||
@@ -94,7 +94,7 @@ class BlitPass {
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
std::optional<IRect> source_region = std::nullopt,
|
||||
size_t destination_offset = 0,
|
||||
std::string label = "");
|
||||
std::string_view label = "");
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Record a command to copy the contents of a buffer to a
|
||||
@@ -127,7 +127,7 @@ class BlitPass {
|
||||
bool AddCopy(BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
std::optional<IRect> destination_region = std::nullopt,
|
||||
std::string label = "",
|
||||
std::string_view label = "",
|
||||
uint32_t mip_level = 0,
|
||||
uint32_t slice = 0,
|
||||
bool convert_to_read = true);
|
||||
@@ -140,7 +140,8 @@ class BlitPass {
|
||||
///
|
||||
/// @return If the command was valid for subsequent commitment.
|
||||
///
|
||||
bool GenerateMipmap(std::shared_ptr<Texture> texture, std::string label = "");
|
||||
bool GenerateMipmap(std::shared_ptr<Texture> texture,
|
||||
std::string_view label = "");
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Encode the recorded commands to the underlying command buffer.
|
||||
@@ -156,33 +157,33 @@ class BlitPass {
|
||||
protected:
|
||||
explicit BlitPass();
|
||||
|
||||
virtual void OnSetLabel(std::string label) = 0;
|
||||
virtual void OnSetLabel(std::string_view label) = 0;
|
||||
|
||||
virtual bool OnCopyTextureToTextureCommand(
|
||||
std::shared_ptr<Texture> source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect source_region,
|
||||
IPoint destination_origin,
|
||||
std::string label) = 0;
|
||||
std::string_view label) = 0;
|
||||
|
||||
virtual bool OnCopyTextureToBufferCommand(
|
||||
std::shared_ptr<Texture> source,
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
IRect source_region,
|
||||
size_t destination_offset,
|
||||
std::string label) = 0;
|
||||
std::string_view label) = 0;
|
||||
|
||||
virtual bool OnCopyBufferToTextureCommand(
|
||||
BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect destination_region,
|
||||
std::string label,
|
||||
std::string_view label,
|
||||
uint32_t mip_level,
|
||||
uint32_t slice,
|
||||
bool convert_to_read) = 0;
|
||||
|
||||
virtual bool OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
|
||||
std::string label) = 0;
|
||||
std::string_view label) = 0;
|
||||
|
||||
private:
|
||||
BlitPass(const BlitPass&) = delete;
|
||||
|
||||
@@ -58,7 +58,7 @@ class CommandBuffer {
|
||||
|
||||
virtual bool IsValid() const = 0;
|
||||
|
||||
virtual void SetLabel(const std::string& label) const = 0;
|
||||
virtual void SetLabel(std::string_view label) const = 0;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Force execution of pending GPU commands.
|
||||
|
||||
@@ -33,8 +33,8 @@ bool ComputePipelineDescriptor::IsEqual(
|
||||
}
|
||||
|
||||
ComputePipelineDescriptor& ComputePipelineDescriptor::SetLabel(
|
||||
std::string label) {
|
||||
label_ = std::move(label);
|
||||
std::string_view label) {
|
||||
label_ = label;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class ComputePipelineDescriptor final
|
||||
|
||||
~ComputePipelineDescriptor();
|
||||
|
||||
ComputePipelineDescriptor& SetLabel(std::string label);
|
||||
ComputePipelineDescriptor& SetLabel(std::string_view label);
|
||||
|
||||
const std::string& GetLabel() const;
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ bool PipelineDescriptor::IsEqual(const PipelineDescriptor& other) const {
|
||||
specialization_constants_ == other.specialization_constants_;
|
||||
}
|
||||
|
||||
PipelineDescriptor& PipelineDescriptor::SetLabel(std::string label) {
|
||||
label_ = std::move(label);
|
||||
PipelineDescriptor& PipelineDescriptor::SetLabel(std::string_view label) {
|
||||
label_ = std::string(label);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ std::shared_ptr<const ShaderFunction> PipelineDescriptor::GetEntrypointForStage(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::string& PipelineDescriptor::GetLabel() const {
|
||||
std::string_view PipelineDescriptor::GetLabel() const {
|
||||
return label_;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ class PipelineDescriptor final : public Comparable<PipelineDescriptor> {
|
||||
|
||||
~PipelineDescriptor();
|
||||
|
||||
PipelineDescriptor& SetLabel(std::string label);
|
||||
PipelineDescriptor& SetLabel(std::string_view label);
|
||||
|
||||
const std::string& GetLabel() const;
|
||||
std::string_view GetLabel() const;
|
||||
|
||||
PipelineDescriptor& SetSampleCount(SampleCount samples);
|
||||
|
||||
|
||||
@@ -50,11 +50,11 @@ const Matrix& RenderPass::GetOrthographicTransform() const {
|
||||
return orthographic_;
|
||||
}
|
||||
|
||||
void RenderPass::SetLabel(std::string label) {
|
||||
void RenderPass::SetLabel(std::string_view label) {
|
||||
if (label.empty()) {
|
||||
return;
|
||||
}
|
||||
OnSetLabel(std::move(label));
|
||||
OnSetLabel(label);
|
||||
}
|
||||
|
||||
bool RenderPass::AddCommand(Command&& command) {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#define FLUTTER_IMPELLER_RENDERER_RENDER_PASS_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
#include "fml/status.h"
|
||||
#include "impeller/core/formats.h"
|
||||
@@ -45,7 +44,7 @@ class RenderPass : public ResourceBinder {
|
||||
|
||||
virtual bool IsValid() const = 0;
|
||||
|
||||
void SetLabel(std::string label);
|
||||
void SetLabel(std::string_view label);
|
||||
|
||||
/// @brief Reserve [command_count] commands in the HAL command buffer.
|
||||
///
|
||||
@@ -269,7 +268,7 @@ class RenderPass : public ResourceBinder {
|
||||
static bool ValidateIndexBuffer(const BufferView& index_buffer,
|
||||
IndexType index_type);
|
||||
|
||||
virtual void OnSetLabel(std::string label) = 0;
|
||||
virtual void OnSetLabel(std::string_view label) = 0;
|
||||
|
||||
virtual bool OnEncodeCommands(const Context& context) const = 0;
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ RenderTarget RenderTargetAllocator::CreateOffscreen(
|
||||
const Context& context,
|
||||
ISize size,
|
||||
int mip_count,
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
RenderTarget::AttachmentConfig color_attachment_config,
|
||||
std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config,
|
||||
const std::shared_ptr<Texture>& existing_color_texture,
|
||||
@@ -289,7 +289,9 @@ RenderTarget RenderTargetAllocator::CreateOffscreen(
|
||||
return {};
|
||||
}
|
||||
}
|
||||
color0_tex->SetLabel(SPrintF("%s Color Texture", label.c_str()));
|
||||
#ifdef IMPELLER_DEBUG
|
||||
color0_tex->SetLabel(SPrintF("%s Color Texture", label.data()));
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
ColorAttachment color0;
|
||||
color0.clear_color = color_attachment_config.clear_color;
|
||||
@@ -314,7 +316,7 @@ RenderTarget RenderTargetAllocator::CreateOffscreenMSAA(
|
||||
const Context& context,
|
||||
ISize size,
|
||||
int mip_count,
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
RenderTarget::AttachmentConfigMSAA color_attachment_config,
|
||||
std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config,
|
||||
const std::shared_ptr<Texture>& existing_color_msaa_texture,
|
||||
@@ -349,8 +351,10 @@ RenderTarget RenderTargetAllocator::CreateOffscreenMSAA(
|
||||
return {};
|
||||
}
|
||||
}
|
||||
#ifdef IMPELLER_DEBUG
|
||||
color0_msaa_tex->SetLabel(
|
||||
SPrintF("%s Color Texture (Multisample)", label.c_str()));
|
||||
SPrintF("%s Color Texture (Multisample)", label.data()));
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
// Create color resolve texture.
|
||||
std::shared_ptr<Texture> color0_resolve_tex;
|
||||
@@ -372,7 +376,9 @@ RenderTarget RenderTargetAllocator::CreateOffscreenMSAA(
|
||||
return {};
|
||||
}
|
||||
}
|
||||
color0_resolve_tex->SetLabel(SPrintF("%s Color Texture", label.c_str()));
|
||||
#ifdef IMPELLER_DEBUG
|
||||
color0_resolve_tex->SetLabel(SPrintF("%s Color Texture", label.data()));
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
// Color attachment.
|
||||
|
||||
@@ -415,7 +421,7 @@ void RenderTarget::SetupDepthStencilAttachments(
|
||||
Allocator& allocator,
|
||||
ISize size,
|
||||
bool msaa,
|
||||
const std::string& label,
|
||||
std::string_view label,
|
||||
RenderTarget::AttachmentConfig stencil_attachment_config,
|
||||
const std::shared_ptr<Texture>& existing_depth_stencil_texture) {
|
||||
std::shared_ptr<Texture> depth_stencil_texture;
|
||||
@@ -451,8 +457,9 @@ void RenderTarget::SetupDepthStencilAttachments(
|
||||
stencil0.clear_stencil = 0u;
|
||||
stencil0.texture = std::move(depth_stencil_texture);
|
||||
|
||||
stencil0.texture->SetLabel(
|
||||
SPrintF("%s Depth+Stencil Texture", label.c_str()));
|
||||
#ifdef IMPELLER_DEBUG
|
||||
stencil0.texture->SetLabel(SPrintF("%s Depth+Stencil Texture", label.data()));
|
||||
#endif // IMPELLER_DEBUG
|
||||
SetDepthAttachment(std::move(depth0));
|
||||
SetStencilAttachment(std::move(stencil0));
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class RenderTarget final {
|
||||
Allocator& allocator,
|
||||
ISize size,
|
||||
bool msaa,
|
||||
const std::string& label = "Offscreen",
|
||||
std::string_view label = "Offscreen",
|
||||
RenderTarget::AttachmentConfig stencil_attachment_config =
|
||||
RenderTarget::kDefaultStencilAttachmentConfig,
|
||||
const std::shared_ptr<Texture>& depth_stencil_texture = nullptr);
|
||||
@@ -149,7 +149,7 @@ class RenderTargetAllocator {
|
||||
const Context& context,
|
||||
ISize size,
|
||||
int mip_count,
|
||||
const std::string& label = "Offscreen",
|
||||
std::string_view label = "Offscreen",
|
||||
RenderTarget::AttachmentConfig color_attachment_config =
|
||||
RenderTarget::kDefaultColorAttachmentConfig,
|
||||
std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config =
|
||||
@@ -161,7 +161,7 @@ class RenderTargetAllocator {
|
||||
const Context& context,
|
||||
ISize size,
|
||||
int mip_count,
|
||||
const std::string& label = "Offscreen MSAA",
|
||||
std::string_view label = "Offscreen MSAA",
|
||||
RenderTarget::AttachmentConfigMSAA color_attachment_config =
|
||||
RenderTarget::kDefaultColorAttachmentConfigMSAA,
|
||||
std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config =
|
||||
|
||||
@@ -28,11 +28,11 @@ class MockDeviceBuffer : public DeviceBuffer {
|
||||
explicit MockDeviceBuffer(const DeviceBufferDescriptor& desc)
|
||||
: DeviceBuffer(desc) {}
|
||||
|
||||
MOCK_METHOD(bool, SetLabel, (const std::string& label), (override));
|
||||
MOCK_METHOD(bool, SetLabel, (std::string_view label), (override));
|
||||
|
||||
MOCK_METHOD(bool,
|
||||
SetLabel,
|
||||
(const std::string& label, Range range),
|
||||
(std::string_view label, Range range),
|
||||
(override));
|
||||
|
||||
MOCK_METHOD(uint8_t*, OnGetContents, (), (const, override));
|
||||
@@ -63,7 +63,7 @@ class MockBlitPass : public BlitPass {
|
||||
EncodeCommands,
|
||||
(const std::shared_ptr<Allocator>& transients_allocator),
|
||||
(const, override));
|
||||
MOCK_METHOD(void, OnSetLabel, (std::string label), (override));
|
||||
MOCK_METHOD(void, OnSetLabel, (std::string_view label), (override));
|
||||
|
||||
MOCK_METHOD(bool,
|
||||
ResizeTexture,
|
||||
@@ -77,7 +77,7 @@ class MockBlitPass : public BlitPass {
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect source_region,
|
||||
IPoint destination_origin,
|
||||
std::string label),
|
||||
std::string_view label),
|
||||
(override));
|
||||
|
||||
MOCK_METHOD(bool,
|
||||
@@ -86,21 +86,21 @@ class MockBlitPass : public BlitPass {
|
||||
std::shared_ptr<DeviceBuffer> destination,
|
||||
IRect source_region,
|
||||
size_t destination_offset,
|
||||
std::string label),
|
||||
std::string_view label),
|
||||
(override));
|
||||
MOCK_METHOD(bool,
|
||||
OnCopyBufferToTextureCommand,
|
||||
(BufferView source,
|
||||
std::shared_ptr<Texture> destination,
|
||||
IRect destination_rect,
|
||||
std::string label,
|
||||
std::string_view label,
|
||||
uint32_t mip_level,
|
||||
uint32_t slice,
|
||||
bool convert_to_read),
|
||||
(override));
|
||||
MOCK_METHOD(bool,
|
||||
OnGenerateMipmapCommand,
|
||||
(std::shared_ptr<Texture> texture, std::string label),
|
||||
(std::shared_ptr<Texture> texture, std::string_view label),
|
||||
(override));
|
||||
};
|
||||
|
||||
@@ -114,7 +114,7 @@ class MockRenderPass : public RenderPass {
|
||||
OnEncodeCommands,
|
||||
(const Context& context),
|
||||
(const, override));
|
||||
MOCK_METHOD(void, OnSetLabel, (std::string label), (override));
|
||||
MOCK_METHOD(void, OnSetLabel, (std::string_view label), (override));
|
||||
};
|
||||
|
||||
class MockCommandBuffer : public CommandBuffer {
|
||||
@@ -122,7 +122,7 @@ class MockCommandBuffer : public CommandBuffer {
|
||||
explicit MockCommandBuffer(std::weak_ptr<const Context> context)
|
||||
: CommandBuffer(std::move(context)) {}
|
||||
MOCK_METHOD(bool, IsValid, (), (const, override));
|
||||
MOCK_METHOD(void, SetLabel, (const std::string& label), (const, override));
|
||||
MOCK_METHOD(void, SetLabel, (std::string_view label), (const, override));
|
||||
MOCK_METHOD(std::shared_ptr<BlitPass>, OnCreateBlitPass, (), (override));
|
||||
MOCK_METHOD(bool,
|
||||
OnSubmitCommands,
|
||||
|
||||
@@ -44,9 +44,9 @@ class TestImpellerDeviceBuffer : public DeviceBuffer {
|
||||
~TestImpellerDeviceBuffer() { free(bytes_); }
|
||||
|
||||
private:
|
||||
bool SetLabel(const std::string& label) override { return true; }
|
||||
bool SetLabel(std::string_view label) override { return true; }
|
||||
|
||||
bool SetLabel(const std::string& label, Range range) override { return true; }
|
||||
bool SetLabel(std::string_view label, Range range) override { return true; }
|
||||
|
||||
uint8_t* OnGetContents() const override { return bytes_; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user