Better names for device objects.

This commit is contained in:
Chinmay Garde 2021-06-22 13:18:37 -07:00 committed by Dan Field
parent e968f9a9ee
commit 8fb7637115
10 changed files with 88 additions and 2 deletions

View File

@ -8,6 +8,7 @@ config("impeller_public_config") {
group("impeller") {
deps = [
"base",
"compiler",
"compositor",
"entity",

View File

@ -0,0 +1,17 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("../tools/impeller.gni")
impeller_component("base") {
# Only the umbrella header may be imported.
public = [ "base.h" ]
sources = [
"base.h",
"config.h",
"strings.cc",
"strings.h",
]
}

View File

@ -0,0 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include "impeller/base/strings.h"

View File

@ -0,0 +1,20 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include "flutter/fml/build_config.h"
#if defined(__GNUC__) || defined(__clang__)
#define IMPELLER_COMPILER_CLANG 1
#else // defined(__GNUC__) || defined(__clang__)
#define IMPELLER_COMPILER_CLANG 0
#endif // defined(__GNUC__) || defined(__clang__)
#if IMPELLER_COMPILER_CLANG
#define IMPELLER_PRINTF_FORMAT(format_number, args_number) \
__attribute__((format(printf, format_number, args_number)))
#else // IMPELLER_COMPILER_CLANG
#define IMPELLER_PRINTF_FORMAT(format_number, args_number)
#endif // IMPELLER_COMPILER_CLANG

View File

@ -0,0 +1,21 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "impeller/base/strings.h"
#include <cstdarg>
namespace impeller {
IMPELLER_PRINTF_FORMAT(1, 2)
std::string SPrintF(const char* format, ...) {
va_list list;
va_start(list, format);
char buffer[64] = {0};
::vsnprintf(buffer, sizeof(buffer), format, list);
va_end(list);
return buffer;
}
} // namespace impeller

View File

@ -0,0 +1,16 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include <string>
#include "impeller/base/config.h"
namespace impeller {
IMPELLER_PRINTF_FORMAT(1, 2)
std::string SPrintF(const char* format, ...);
} // namespace impeller

View File

@ -59,6 +59,7 @@ impeller_component("compositor") {
]
public_deps = [
"../base",
"../geometry",
"../shader_glue",
]

View File

@ -6,6 +6,7 @@
#include "flutter/fml/closure.h"
#include "flutter/fml/logging.h"
#include "impeller/base/base.h"
#include "impeller/compositor/device_buffer.h"
#include "impeller/compositor/formats_metal.h"
#include "impeller/shader_glue/shader_types.h"
@ -139,6 +140,7 @@ bool RenderPass::IsValid() const {
void RenderPass::SetLabel(std::string label) {
label_ = std::move(label);
transients_buffer_->SetLabel(SPrintF("%s Transients", label_.c_str()));
}
bool RenderPass::FinishEncoding(Allocator& transients_allocator) const {

View File

@ -37,7 +37,7 @@ bool EntityRenderer::OnIsValid() const {
}
bool EntityRenderer::OnRender(RenderPass& pass) {
pass.SetLabel("EntityRenderer");
pass.SetLabel("EntityRenderer Render Pass");
shader::BoxVertexInfo::UniformBuffer uniforms;
uniforms.mvp = Matrix::MakeOrthographic({800, 600});

View File

@ -7,6 +7,7 @@
#include <memory>
#include "flutter/fml/logging.h"
#include "impeller/base/base.h"
#include "impeller/compositor/pipeline_descriptor.h"
#include "impeller/compositor/shader_library.h"
#include "impeller/compositor/vertex_descriptor.h"
@ -16,7 +17,7 @@ namespace impeller {
BoxPrimitive::BoxPrimitive(std::shared_ptr<Context> context)
: Primitive(context) {
PipelineDescriptor desc;
desc.SetLabel(shader::BoxVertexInfo::kLabel);
desc.SetLabel(SPrintF("%s Pipeline", shader::BoxVertexInfo::kLabel.data()));
{
auto fragment_function = context->GetShaderLibrary()->GetFunction(