Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,16 @@ ORIGIN: ../../../flutter/impeller/core/platform.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/platform.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/range.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/range.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/resource_binder.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/resource_binder.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/runtime_types.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/runtime_types.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/sampler.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/sampler.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/sampler_descriptor.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/sampler_descriptor.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/shader_types.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/shader_types.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/texture.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/texture.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/texture_descriptor.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -1544,10 +1554,6 @@ ORIGIN: ../../../flutter/impeller/renderer/render_target.cc + ../../../flutter/L
ORIGIN: ../../../flutter/impeller/renderer/render_target.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/renderer.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/renderer.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/sampler.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/sampler.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/sampler_descriptor.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/sampler_descriptor.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/sampler_library.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/sampler_library.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/shader_function.cc + ../../../flutter/LICENSE
Expand All @@ -1556,8 +1562,6 @@ ORIGIN: ../../../flutter/impeller/renderer/shader_key.cc + ../../../flutter/LICE
ORIGIN: ../../../flutter/impeller/renderer/shader_key.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/shader_library.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/shader_library.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/shader_types.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/shader_types.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/snapshot.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/snapshot.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/stroke.comp + ../../../flutter/LICENSE
Expand All @@ -1572,8 +1576,6 @@ ORIGIN: ../../../flutter/impeller/runtime_stage/runtime_stage.fbs + ../../../flu
ORIGIN: ../../../flutter/impeller/runtime_stage/runtime_stage.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/runtime_stage/runtime_stage_playground.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/runtime_stage/runtime_stage_playground.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/runtime_stage/runtime_types.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/runtime_stage/runtime_types.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/scene/animation/animation.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/scene/animation/animation.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/scene/animation/animation_clip.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -3693,6 +3695,16 @@ FILE: ../../../flutter/impeller/core/platform.cc
FILE: ../../../flutter/impeller/core/platform.h
FILE: ../../../flutter/impeller/core/range.cc
FILE: ../../../flutter/impeller/core/range.h
FILE: ../../../flutter/impeller/core/resource_binder.cc
FILE: ../../../flutter/impeller/core/resource_binder.h
FILE: ../../../flutter/impeller/core/runtime_types.cc
FILE: ../../../flutter/impeller/core/runtime_types.h
FILE: ../../../flutter/impeller/core/sampler.cc
FILE: ../../../flutter/impeller/core/sampler.h
FILE: ../../../flutter/impeller/core/sampler_descriptor.cc
FILE: ../../../flutter/impeller/core/sampler_descriptor.h
FILE: ../../../flutter/impeller/core/shader_types.cc
FILE: ../../../flutter/impeller/core/shader_types.h
FILE: ../../../flutter/impeller/core/texture.cc
FILE: ../../../flutter/impeller/core/texture.h
FILE: ../../../flutter/impeller/core/texture_descriptor.cc
Expand Down Expand Up @@ -4113,10 +4125,6 @@ FILE: ../../../flutter/impeller/renderer/render_target.cc
FILE: ../../../flutter/impeller/renderer/render_target.h
FILE: ../../../flutter/impeller/renderer/renderer.cc
FILE: ../../../flutter/impeller/renderer/renderer.h
FILE: ../../../flutter/impeller/renderer/sampler.cc
FILE: ../../../flutter/impeller/renderer/sampler.h
FILE: ../../../flutter/impeller/renderer/sampler_descriptor.cc
FILE: ../../../flutter/impeller/renderer/sampler_descriptor.h
FILE: ../../../flutter/impeller/renderer/sampler_library.cc
FILE: ../../../flutter/impeller/renderer/sampler_library.h
FILE: ../../../flutter/impeller/renderer/shader_function.cc
Expand All @@ -4125,8 +4133,6 @@ FILE: ../../../flutter/impeller/renderer/shader_key.cc
FILE: ../../../flutter/impeller/renderer/shader_key.h
FILE: ../../../flutter/impeller/renderer/shader_library.cc
FILE: ../../../flutter/impeller/renderer/shader_library.h
FILE: ../../../flutter/impeller/renderer/shader_types.cc
FILE: ../../../flutter/impeller/renderer/shader_types.h
FILE: ../../../flutter/impeller/renderer/snapshot.cc
FILE: ../../../flutter/impeller/renderer/snapshot.h
FILE: ../../../flutter/impeller/renderer/stroke.comp
Expand All @@ -4141,8 +4147,6 @@ FILE: ../../../flutter/impeller/runtime_stage/runtime_stage.fbs
FILE: ../../../flutter/impeller/runtime_stage/runtime_stage.h
FILE: ../../../flutter/impeller/runtime_stage/runtime_stage_playground.cc
FILE: ../../../flutter/impeller/runtime_stage/runtime_stage_playground.h
FILE: ../../../flutter/impeller/runtime_stage/runtime_types.cc
FILE: ../../../flutter/impeller/runtime_stage/runtime_types.h
FILE: ../../../flutter/impeller/scene/animation/animation.cc
FILE: ../../../flutter/impeller/scene/animation/animation.h
FILE: ../../../flutter/impeller/scene/animation/animation_clip.cc
Expand Down
2 changes: 1 addition & 1 deletion impeller/aiks/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#include "impeller/aiks/image.h"
#include "impeller/aiks/paint.h"
#include "impeller/aiks/picture.h"
#include "impeller/core/sampler_descriptor.h"
#include "impeller/entity/entity_pass.h"
#include "impeller/entity/geometry.h"
#include "impeller/geometry/matrix.h"
#include "impeller/geometry/path.h"
#include "impeller/geometry/point.h"
#include "impeller/geometry/vector.h"
#include "impeller/renderer/sampler_descriptor.h"
#include "impeller/typographer/glyph_atlas.h"
#include "impeller/typographer/text_frame.h"

Expand Down
8 changes: 3 additions & 5 deletions impeller/compiler/code_gen_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ constexpr std::string_view kReflectionHeaderTemplate =
{# file itself and the no-check declarations will be stripped in generated files.#}
#include "impeller/core/buffer_view.h" {# // nogncheck #}

#include "impeller/renderer/command.h" {# // nogncheck #}
#include "impeller/core/sampler.h" {# // nogncheck #}

#include "impeller/renderer/compute_command.h" {# // nogncheck #}
#include "impeller/core/shader_types.h" {# // nogncheck #}

#include "impeller/renderer/sampler.h" {# // nogncheck #}

#include "impeller/renderer/shader_types.h" {# // nogncheck #}
#include "impeller/core/resource_binder.h" {# // nogncheck #}

#include "impeller/core/texture.h" {# // nogncheck #}

Expand Down
21 changes: 3 additions & 18 deletions impeller/compiler/reflector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,6 @@ static std::string ExecutionModelToString(spv::ExecutionModel model) {
}
}

static std::string ExecutionModelToCommandTypeName(
spv::ExecutionModel execution_model) {
switch (execution_model) {
case spv::ExecutionModel::ExecutionModelVertex:
case spv::ExecutionModel::ExecutionModelFragment:
case spv::ExecutionModel::ExecutionModelTessellationControl:
case spv::ExecutionModel::ExecutionModelTessellationEvaluation:
return "Command&";
case spv::ExecutionModel::ExecutionModelGLCompute:
return "ComputeCommand&";
default:
return "unsupported";
}
}

static std::string StringToShaderStage(std::string str) {
if (str == "vertex") {
return "ShaderStage::kVertex";
Expand Down Expand Up @@ -1126,7 +1111,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
proto.docstring = stream.str();
}
proto.args.push_back(BindPrototypeArgument{
.type_name = ExecutionModelToCommandTypeName(execution_model),
.type_name = "ResourceBinder&",
.argument_name = "command",
});
proto.args.push_back(BindPrototypeArgument{
Expand All @@ -1145,7 +1130,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
proto.docstring = stream.str();
}
proto.args.push_back(BindPrototypeArgument{
.type_name = ExecutionModelToCommandTypeName(execution_model),
.type_name = "ResourceBinder&",
.argument_name = "command",
});
proto.args.push_back(BindPrototypeArgument{
Expand All @@ -1164,7 +1149,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
proto.docstring = stream.str();
}
proto.args.push_back(BindPrototypeArgument{
.type_name = ExecutionModelToCommandTypeName(execution_model),
.type_name = "ResourceBinder&",
.argument_name = "command",
});
proto.args.push_back(BindPrototypeArgument{
Expand Down
10 changes: 10 additions & 0 deletions impeller/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ impeller_component("core") {
"platform.h",
"range.cc",
"range.h",
"resource_binder.cc",
"resource_binder.h",
"runtime_types.cc",
"runtime_types.h",
"sampler.cc",
"sampler.h",
"sampler_descriptor.cc",
"sampler_descriptor.h",
"shader_types.cc",
"shader_types.h",
"texture.cc",
"texture.h",
"texture_descriptor.cc",
Expand Down
11 changes: 11 additions & 0 deletions impeller/core/resource_binder.cc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file and impeller/core/vertex_buffer_builder.cc are basically empty, should they be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vertex_buffer_builder.cc was meant to be deleted.

But this follows the style of other TUs in this repository (particularyl in impeller)

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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/core/resource_binder.h"

namespace impeller {

//

} // namespace impeller
52 changes: 52 additions & 0 deletions impeller/core/resource_binder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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 <map>
#include <memory>
#include <optional>
#include <string>

#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"
#include "impeller/core/buffer_view.h"
#include "impeller/core/formats.h"
#include "impeller/core/sampler.h"
#include "impeller/core/shader_types.h"
#include "impeller/core/texture.h"

namespace impeller {

//------------------------------------------------------------------------------
/// @brief An interface for binding resources. This is implemented by
/// |Command| and |ComputeCommand| to make CPU resources available
/// to the GPU.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be more accurate to say it makes GPU resources (via handles) available to a given command's pipeline, since you can bind device private resources that never had a host buffer too (like we do with subpass render targets).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is causing friction for the Flutter-at-Google team I'm going to merge this and follow up with a doc fix.

///
struct ResourceBinder {
virtual ~ResourceBinder() = default;
Copy link
Member

@bdero bdero Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not strongly opposed to adding this pure virtual interface, but it may cause some confusion/friction down the road for whoever ends up adding the next command type.

We're sort of lucky that the bindings match up between raster and compute commands right now, but if we add support for ray trace commands, the bindings won't perfectly match up anymore because we'll need to bind acceleration structures, and so we'll probably wind up needing to refactor anything that comes to rely on this polymorphism.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in that case we'd make a RayTraceCommand not implement ResourceBinder and instead implement some other type from core.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, in that scenario we could make ResourceBinder not be pure virtual.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand. What is the purpose of ResourceBinder? If it's not being used as a generic interface for commands, what is it useful for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


virtual bool BindResource(ShaderStage stage,
const ShaderUniformSlot& slot,
const ShaderMetadata& metadata,
const BufferView& view) = 0;

virtual bool BindResource(ShaderStage stage,
const SampledImageSlot& slot,
const ShaderMetadata& metadata,
const std::shared_ptr<const Texture>& texture) = 0;

virtual bool BindResource(ShaderStage stage,
const SampledImageSlot& slot,
const ShaderMetadata& metadata,
const std::shared_ptr<const Sampler>& sampler) = 0;

virtual bool BindResource(ShaderStage stage,
const SampledImageSlot& slot,
const ShaderMetadata& metadata,
const std::shared_ptr<const Texture>& texture,
const std::shared_ptr<const Sampler>& sampler) = 0;
};

} // namespace impeller
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "impeller/runtime_stage/runtime_types.h"
#include "impeller/core/runtime_types.h"

namespace impeller {

Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/sampler.cc → impeller/core/sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "impeller/renderer/sampler.h"
#include "impeller/core/sampler.h"

namespace impeller {

Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/sampler.h → impeller/core/sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include "flutter/fml/macros.h"
#include "impeller/renderer/sampler_descriptor.h"
#include "impeller/core/sampler_descriptor.h"

namespace impeller {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "impeller/renderer/sampler_descriptor.h"
#include "impeller/core/sampler_descriptor.h"

#include "fml/logging.h"

namespace impeller {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "impeller/renderer/shader_types.h"
#include "impeller/core/shader_types.h"

namespace impeller {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "flutter/fml/hash_combine.h"
#include "flutter/fml/logging.h"
#include "impeller/core/runtime_types.h"
#include "impeller/geometry/half.h"
#include "impeller/geometry/matrix.h"
#include "impeller/runtime_stage/runtime_types.h"

namespace impeller {

Expand Down
2 changes: 1 addition & 1 deletion impeller/display_list/nine_patch_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "impeller/aiks/canvas.h"
#include "impeller/aiks/image.h"
#include "impeller/aiks/paint.h"
#include "impeller/core/sampler_descriptor.h"
#include "impeller/geometry/path.h"
#include "impeller/renderer/sampler_descriptor.h"

namespace impeller {

Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/contents/atlas_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include <vector>

#include "flutter/fml/macros.h"
#include "impeller/core/sampler_descriptor.h"
#include "impeller/entity/contents/contents.h"
#include "impeller/entity/entity.h"
#include "impeller/renderer/sampler_descriptor.h"

namespace impeller {

Expand Down
3 changes: 2 additions & 1 deletion impeller/entity/contents/color_source_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "color_source_contents.h"
#include "impeller/entity/contents/color_source_contents.h"

#include "impeller/entity/entity.h"
#include "impeller/geometry/matrix.h"
#include "impeller/geometry/point.h"

namespace impeller {

Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/contents/contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <vector>

#include "flutter/fml/macros.h"
#include "impeller/core/sampler_descriptor.h"
#include "impeller/core/texture.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/rect.h"
#include "impeller/renderer/sampler_descriptor.h"
#include "impeller/renderer/snapshot.h"

namespace impeller {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#include "impeller/base/strings.h"
#include "impeller/base/validation.h"
#include "impeller/core/formats.h"
#include "impeller/core/sampler_descriptor.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/contents/filters/filter_contents.h"
#include "impeller/geometry/rect.h"
#include "impeller/geometry/scalar.h"
#include "impeller/renderer/command_buffer.h"
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/render_target.h"
#include "impeller/renderer/sampler_descriptor.h"
#include "impeller/renderer/sampler_library.h"

namespace impeller {
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/contents/gradient_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

#include "flutter/fml/macros.h"
#include "flutter/impeller/core/texture.h"
#include "impeller/core/shader_types.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/gradient.h"
#include "impeller/geometry/path.h"
#include "impeller/geometry/point.h"
#include "impeller/renderer/shader_types.h"

namespace impeller {

Expand Down
Loading