diff --git a/DEPS b/DEPS index d191c8088933f..b946c88c2fcce 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': '7901100ba2d984cb6c2e52e93533c9868d4e7913', + 'skia_revision': '5f54e9f84cff8c42fd645ec53c1727857bdb12ab', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. @@ -59,7 +59,7 @@ vars = { # Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS # You can use //tools/dart/create_updated_flutter_deps.py to produce # updated revision list of existing dependencies. - 'dart_revision': '21574eae3a693abda6b72933aad4bac5a2a59ca4', + 'dart_revision': 'd8efef525ce1d71e7c7b192d187705c59f0095a0', # WARNING: DO NOT EDIT MANUALLY # The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py @@ -73,7 +73,7 @@ vars = { 'dart_libprotobuf_rev': '24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb', 'dart_perfetto_rev': '13ce0c9e13b0940d2476cd0cff2301708a9a2e2b', 'dart_protobuf_gn_rev': 'ca669f79945418f6229e4fef89b666b2a88cbb10', - 'dart_protobuf_rev': 'dcec2eda9db4e6728e900928aa2e46944ba4fa6f', + 'dart_protobuf_rev': 'bb1977478458d070abbb4802ae73a1560233864d', 'dart_pub_rev': '1779628b386819675130f14326f1e8812901c48f', 'dart_root_certificates_rev': '692f6d6488af68e0121317a9c2c9eb393eb0ee50', 'dart_tools_rev': 'c63dcb5e93d4a222da0c52960bb6688030ddabc3', @@ -680,7 +680,7 @@ deps = { Var('chromium_git') + '/external/github.com/brendan-duncan/archive.git' + '@' + '9de7a0544457c6aba755ccb65abb41b0dc1db70d', # 3.1.2 'src/flutter/third_party/pkg/equatable': - Var('github_git') + '/felangel/equatable.git' + '@' + '2117551ff3054f8edb1a58f63ffe1832a8d25623', # 2.0.5 + Var('flutter_git') + '/third_party/equatable.git' + '@' + '2117551ff3054f8edb1a58f63ffe1832a8d25623', # 2.0.5 'src/flutter/third_party/pkg/flutter_packages': Var('flutter_git') + '/mirrors/packages' + '@' + '25454e63851fe7933f04d025606e68c1eac4fe0f', # various @@ -704,16 +704,16 @@ deps = { Var('dart_git') + '/external/github.com/google/vector_math.dart.git' + '@' + '0a5fd95449083d404df9768bc1b321b88a7d2eef', # 2.1.0 'src/flutter/third_party/imgui': - Var('github_git') + '/ocornut/imgui.git' + '@' + '3ea0fad204e994d669f79ed29dcaf61cd5cb571d', + Var('flutter_git') + '/third_party/imgui.git' + '@' + '3ea0fad204e994d669f79ed29dcaf61cd5cb571d', 'src/third_party/tinygltf': - Var('github_git') + '/syoyo/tinygltf.git' + '@' + '9bb5806df4055ac973b970ba5b3e27ce27d98148', + Var('flutter_git') + '/third_party/tinygltf.git' + '@' + '9bb5806df4055ac973b970ba5b3e27ce27d98148', 'src/third_party/json': - Var('github_git') + '/nlohmann/json.git' + '@' + '17d9eacd248f58b73f4d1be518ef649fe2295642', + Var('flutter_git') + '/third_party/json.git' + '@' + '17d9eacd248f58b73f4d1be518ef649fe2295642', 'src/third_party/stb': - Var('github_git') + '/nothings/stb.git' + '@' + '5736b15f7ea0ffb08dd38af21067c314d6a3aae9', + Var('flutter_git') + '/third_party/stb.git' + '@' + '5736b15f7ea0ffb08dd38af21067c314d6a3aae9', 'src/third_party/gradle': { 'packages': [ diff --git a/ci/licenses_golden/licenses_dart b/ci/licenses_golden/licenses_dart index 676e963df9460..f0a0186f9df5c 100644 --- a/ci/licenses_golden/licenses_dart +++ b/ci/licenses_golden/licenses_dart @@ -1,4 +1,4 @@ -Signature: c17d2eb7a04e921c4bdced9ef3fba2fd +Signature: 7f38d0c92f4afee2bc0fc2ad84dfeb8a ==================================================================================================== LIBRARY: dart diff --git a/ci/licenses_golden/licenses_skia b/ci/licenses_golden/licenses_skia index b91cb78487463..444e3b3beb226 100644 --- a/ci/licenses_golden/licenses_skia +++ b/ci/licenses_golden/licenses_skia @@ -1,4 +1,4 @@ -Signature: d495f5e3ffe4f301637eb9f5fae26750 +Signature: 1834371d1b225b6b6d1017adbe931616 ==================================================================================================== LIBRARY: etc1 @@ -1520,8 +1520,6 @@ ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkHRESULT.h + ../../../f ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkIStream.cpp + ../../../flutter/third_party/skia/LICENSE ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkIStream.h + ../../../flutter/third_party/skia/LICENSE ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkTScopedComPtr.h + ../../../flutter/third_party/skia/LICENSE -ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkWGL.h + ../../../flutter/third_party/skia/LICENSE -ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkWGL_win.cpp + ../../../flutter/third_party/skia/LICENSE ORIGIN: ../../../flutter/third_party/skia/src/xps/SkXPSDevice.cpp + ../../../flutter/third_party/skia/LICENSE ORIGIN: ../../../flutter/third_party/skia/src/xps/SkXPSDevice.h + ../../../flutter/third_party/skia/LICENSE TYPE: LicenseType.bsd @@ -1703,8 +1701,6 @@ FILE: ../../../flutter/third_party/skia/src/utils/win/SkHRESULT.h FILE: ../../../flutter/third_party/skia/src/utils/win/SkIStream.cpp FILE: ../../../flutter/third_party/skia/src/utils/win/SkIStream.h FILE: ../../../flutter/third_party/skia/src/utils/win/SkTScopedComPtr.h -FILE: ../../../flutter/third_party/skia/src/utils/win/SkWGL.h -FILE: ../../../flutter/third_party/skia/src/utils/win/SkWGL_win.cpp FILE: ../../../flutter/third_party/skia/src/xps/SkXPSDevice.cpp FILE: ../../../flutter/third_party/skia/src/xps/SkXPSDevice.h ---------------------------------------------------------------------------------------------------- @@ -9018,6 +9014,7 @@ ORIGIN: ../../../flutter/third_party/skia/src/text/gpu/SlugImpl.h + ../../../flu ORIGIN: ../../../flutter/third_party/skia/src/text/gpu/VertexFiller.cpp + ../../../flutter/third_party/skia/LICENSE ORIGIN: ../../../flutter/third_party/skia/src/text/gpu/VertexFiller.h + ../../../flutter/third_party/skia/LICENSE ORIGIN: ../../../flutter/third_party/skia/src/utils/SkTestCanvas.cpp + ../../../flutter/third_party/skia/LICENSE +ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkWGL_win.cpp + ../../../flutter/third_party/skia/LICENSE ORIGIN: ../../../flutter/third_party/skia/toolchain/android_trampolines/gen_trampolines/gen_trampolines.go + ../../../flutter/third_party/skia/LICENSE TYPE: LicenseType.bsd FILE: ../../../flutter/third_party/skia/fuzz/FuzzCubicRoots.cpp @@ -9300,6 +9297,7 @@ FILE: ../../../flutter/third_party/skia/src/text/gpu/SlugImpl.h FILE: ../../../flutter/third_party/skia/src/text/gpu/VertexFiller.cpp FILE: ../../../flutter/third_party/skia/src/text/gpu/VertexFiller.h FILE: ../../../flutter/third_party/skia/src/utils/SkTestCanvas.cpp +FILE: ../../../flutter/third_party/skia/src/utils/win/SkWGL_win.cpp FILE: ../../../flutter/third_party/skia/toolchain/android_trampolines/gen_trampolines/gen_trampolines.go ---------------------------------------------------------------------------------------------------- Copyright 2023 Google LLC diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 4cbe31d9676aa..81fabeb2f7033 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -2547,7 +2547,7 @@ TEST_P(AiksTest, OpacityPeepHoleApplicationTest) { Entity entity; entity.SetContents(SolidColorContents::Make( PathBuilder{}.AddRect(rect).TakePath(), Color::Red())); - entity_pass->AddEntity(entity); + entity_pass->AddEntity(std::move(entity)); paint.color = Color::Red().WithAlpha(0.5); delegate = std::make_shared(paint); @@ -3239,20 +3239,22 @@ TEST_P(AiksTest, OpaqueEntitiesGetCoercedToSource) { Picture picture = canvas.EndRecordingAsPicture(); // Extract the SolidColorSource. - Entity entity; + // Entity entity; + std::vector entity; std::shared_ptr contents; - picture.pass->IterateAllEntities([&e = entity, &contents](Entity& entity) { + picture.pass->IterateAllEntities([e = &entity, &contents](Entity& entity) { if (ScalarNearlyEqual(entity.GetTransform().GetScale().x, 1.618f)) { - e = entity; contents = std::static_pointer_cast(entity.GetContents()); + e->emplace_back(entity.Clone()); return false; } return true; }); + ASSERT_TRUE(entity.size() >= 1); ASSERT_TRUE(contents->IsOpaque()); - ASSERT_EQ(entity.GetBlendMode(), BlendMode::kSource); + ASSERT_EQ(entity[0].GetBlendMode(), BlendMode::kSource); } TEST_P(AiksTest, CanRenderDestructiveSaveLayer) { diff --git a/impeller/aiks/canvas.cc b/impeller/aiks/canvas.cc index 593c62bfa1e21..5b6953828f862 100644 --- a/impeller/aiks/canvas.cc +++ b/impeller/aiks/canvas.cc @@ -13,6 +13,8 @@ #include "impeller/aiks/paint_pass_delegate.h" #include "impeller/entity/contents/atlas_contents.h" #include "impeller/entity/contents/clip_contents.h" +#include "impeller/entity/contents/color_source_contents.h" +#include "impeller/entity/contents/filters/filter_contents.h" #include "impeller/entity/contents/solid_rrect_blur_contents.h" #include "impeller/entity/contents/text_contents.h" #include "impeller/entity/contents/texture_contents.h" @@ -23,6 +25,80 @@ namespace impeller { +namespace { + +static std::shared_ptr CreateContentsForGeometryWithFilters( + const Paint& paint, + std::shared_ptr geometry) { + std::shared_ptr contents = + paint.color_source.GetContents(paint); + + // Attempt to apply the color filter on the CPU first. + // Note: This is not just an optimization; some color sources rely on + // CPU-applied color filters to behave properly. + bool needs_color_filter = paint.HasColorFilter(); + if (needs_color_filter) { + auto color_filter = paint.GetColorFilter(); + if (contents->ApplyColorFilter(color_filter->GetCPUColorFilterProc())) { + needs_color_filter = false; + } + } + + contents->SetGeometry(std::move(geometry)); + if (paint.mask_blur_descriptor.has_value()) { + // If there's a mask blur and we need to apply the color filter on the GPU, + // we need to be careful to only apply the color filter to the source + // colors. CreateMaskBlur is able to handle this case. + return paint.mask_blur_descriptor->CreateMaskBlur( + contents, needs_color_filter ? paint.GetColorFilter() : nullptr); + } + + std::shared_ptr contents_copy = std::move(contents); + // Image input types will directly set their color filter, + // if any. See `TiledTextureContents.SetColorFilter`. + if (needs_color_filter && + paint.color_source.GetType() != ColorSource::Type::kImage) { + std::shared_ptr color_filter = paint.GetColorFilter(); + contents_copy = color_filter->WrapWithGPUColorFilter( + FilterInput::Make(std::move(contents_copy)), + ColorFilterContents::AbsorbOpacity::kYes); + } + + if (paint.image_filter) { + std::shared_ptr filter = paint.image_filter->WrapInput( + FilterInput::Make(std::move(contents_copy))); + filter->SetRenderingMode(Entity::RenderingMode::kDirect); + return filter; + } + + return contents_copy; +} + +static std::shared_ptr CreatePathContentsWithFilters( + const Paint& paint, + Path path = {}) { + std::shared_ptr geometry; + switch (paint.style) { + case Paint::Style::kFill: + geometry = Geometry::MakeFillPath(std::move(path)); + break; + case Paint::Style::kStroke: + geometry = Geometry::MakeStrokePath(std::move(path), paint.stroke_width, + paint.stroke_miter, paint.stroke_cap, + paint.stroke_join); + break; + } + + return CreateContentsForGeometryWithFilters(paint, std::move(geometry)); +} + +static std::shared_ptr CreateCoverContentsWithFilters( + const Paint& paint) { + return CreateContentsForGeometryWithFilters(paint, Geometry::MakeCover()); +} + +} // namespace + Canvas::Canvas() { Initialize(std::nullopt); } @@ -176,10 +252,9 @@ void Canvas::DrawPath(Path path, const Paint& paint) { entity.SetTransform(GetCurrentTransform()); entity.SetClipDepth(GetClipDepth()); entity.SetBlendMode(paint.blend_mode); - entity.SetContents( - paint.WithFilters(paint.CreateContentsForEntity(std::move(path)))); + entity.SetContents(CreatePathContentsWithFilters(paint, std::move(path))); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } void Canvas::DrawPaint(const Paint& paint) { @@ -187,9 +262,9 @@ void Canvas::DrawPaint(const Paint& paint) { entity.SetTransform(GetCurrentTransform()); entity.SetClipDepth(GetClipDepth()); entity.SetBlendMode(paint.blend_mode); - entity.SetContents(paint.CreateContentsForEntity({}, true)); + entity.SetContents(CreateCoverContentsWithFilters(paint)); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } bool Canvas::AttemptDrawBlurredRRect(const Rect& rect, @@ -227,7 +302,7 @@ bool Canvas::AttemptDrawBlurredRRect(const Rect& rect, entity.SetBlendMode(new_paint.blend_mode); entity.SetContents(new_paint.WithFilters(std::move(contents))); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); return true; } @@ -237,10 +312,10 @@ void Canvas::DrawLine(const Point& p0, const Point& p1, const Paint& paint) { entity.SetTransform(GetCurrentTransform()); entity.SetClipDepth(GetClipDepth()); entity.SetBlendMode(paint.blend_mode); - entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry( - Geometry::MakeLine(p0, p1, paint.stroke_width, paint.stroke_cap)))); + entity.SetContents(CreateContentsForGeometryWithFilters( + paint, Geometry::MakeLine(p0, p1, paint.stroke_width, paint.stroke_cap))); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } void Canvas::DrawRect(Rect rect, const Paint& paint) { @@ -257,10 +332,10 @@ void Canvas::DrawRect(Rect rect, const Paint& paint) { entity.SetTransform(GetCurrentTransform()); entity.SetClipDepth(GetClipDepth()); entity.SetBlendMode(paint.blend_mode); - entity.SetContents(paint.WithFilters( - paint.CreateContentsForGeometry(Geometry::MakeRect(rect)))); + entity.SetContents( + CreateContentsForGeometryWithFilters(paint, Geometry::MakeRect(rect))); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } void Canvas::DrawRRect(Rect rect, Point corner_radii, const Paint& paint) { @@ -278,10 +353,10 @@ void Canvas::DrawRRect(Rect rect, Point corner_radii, const Paint& paint) { entity.SetTransform(GetCurrentTransform()); entity.SetClipDepth(GetClipDepth()); entity.SetBlendMode(paint.blend_mode); - entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry( - Geometry::MakeFillPath(std::move(path))))); + entity.SetContents(CreateContentsForGeometryWithFilters( + paint, Geometry::MakeFillPath(std::move(path)))); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); return; } DrawPath(std::move(path), paint); @@ -304,9 +379,9 @@ void Canvas::DrawCircle(Point center, Scalar radius, const Paint& paint) { ? Geometry::MakeStrokedCircle(center, radius, paint.stroke_width) : Geometry::MakeCircle(center, radius); entity.SetContents( - paint.WithFilters(paint.CreateContentsForGeometry(geometry))); + CreateContentsForGeometryWithFilters(paint, std::move(geometry))); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } void Canvas::ClipPath(Path path, Entity::ClipOperation clip_op) { @@ -401,7 +476,7 @@ void Canvas::ClipGeometry(const std::shared_ptr& geometry, entity.SetContents(std::move(contents)); entity.SetClipDepth(GetClipDepth()); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); ++transform_stack_.back().clip_depth; transform_stack_.back().contains_clips = true; @@ -440,7 +515,7 @@ void Canvas::RestoreClip() { entity.SetContents(std::make_shared()); entity.SetClipDepth(GetClipDepth()); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } void Canvas::DrawPoints(std::vector points, @@ -455,11 +530,12 @@ void Canvas::DrawPoints(std::vector points, entity.SetTransform(GetCurrentTransform()); entity.SetClipDepth(GetClipDepth()); entity.SetBlendMode(paint.blend_mode); - entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry( + entity.SetContents(CreateContentsForGeometryWithFilters( + paint, Geometry::MakePointField(std::move(points), radius, - /*round=*/point_style == PointStyle::kRound)))); + /*round=*/point_style == PointStyle::kRound))); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } void Canvas::DrawPicture(const Picture& picture) { @@ -533,7 +609,7 @@ void Canvas::DrawImageRect(const std::shared_ptr& image, entity.SetContents(paint.WithFilters(contents)); entity.SetTransform(GetCurrentTransform()); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } Picture Canvas::EndRecordingAsPicture() { @@ -597,7 +673,7 @@ void Canvas::DrawTextFrame(const std::shared_ptr& text_frame, entity.SetContents( paint.WithFilters(paint.WithMaskBlur(std::move(text_contents), true))); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } static bool UseColorSourceContents( @@ -635,9 +711,8 @@ void Canvas::DrawVertices(const std::shared_ptr& vertices, // If there are no vertex color or texture coordinates. Or if there // are vertex coordinates then only if the contents are an image. if (UseColorSourceContents(vertices, paint)) { - auto contents = paint.CreateContentsForGeometry(vertices); - entity.SetContents(paint.WithFilters(std::move(contents))); - GetCurrentPass().AddEntity(entity); + entity.SetContents(CreateContentsForGeometryWithFilters(paint, vertices)); + GetCurrentPass().AddEntity(std::move(entity)); return; } @@ -675,7 +750,7 @@ void Canvas::DrawVertices(const std::shared_ptr& vertices, contents->SetSourceContents(std::move(src_contents)); entity.SetContents(paint.WithFilters(std::move(contents))); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } void Canvas::DrawAtlas(const std::shared_ptr& atlas, @@ -706,7 +781,7 @@ void Canvas::DrawAtlas(const std::shared_ptr& atlas, entity.SetBlendMode(paint.blend_mode); entity.SetContents(paint.WithFilters(contents)); - GetCurrentPass().AddEntity(entity); + GetCurrentPass().AddEntity(std::move(entity)); } } // namespace impeller diff --git a/impeller/aiks/paint.cc b/impeller/aiks/paint.cc index bfe3f9c39b1eb..2cf2d8c3db71a 100644 --- a/impeller/aiks/paint.cc +++ b/impeller/aiks/paint.cc @@ -26,24 +26,6 @@ constexpr ColorMatrix kColorInversion = { }; // clang-format on -std::shared_ptr Paint::CreateContentsForEntity(Path path, - bool cover) const { - std::shared_ptr geometry; - switch (style) { - case Style::kFill: - geometry = cover ? Geometry::MakeCover() - : Geometry::MakeFillPath(std::move(path)); - break; - case Style::kStroke: - geometry = cover ? Geometry::MakeCover() - : Geometry::MakeStrokePath(std::move(path), stroke_width, - stroke_miter, stroke_cap, - stroke_join); - break; - } - return CreateContentsForGeometry(geometry); -} - std::shared_ptr Paint::CreateContentsForGeometry( const std::shared_ptr& geometry) const { auto contents = color_source.GetContents(*this); diff --git a/impeller/aiks/paint.h b/impeller/aiks/paint.h index 29f9495a1e344..68608d3dce175 100644 --- a/impeller/aiks/paint.h +++ b/impeller/aiks/paint.h @@ -84,9 +84,6 @@ struct Paint { std::shared_ptr input, const Matrix& effect_transform = Matrix()) const; - std::shared_ptr CreateContentsForEntity(Path path = {}, - bool cover = false) const; - std::shared_ptr CreateContentsForGeometry( const std::shared_ptr& geometry) const; diff --git a/impeller/compiler/compiler_unittests.cc b/impeller/compiler/compiler_unittests.cc index 539db7cd32129..44ff9ebba8b7e 100644 --- a/impeller/compiler/compiler_unittests.cc +++ b/impeller/compiler/compiler_unittests.cc @@ -18,10 +18,6 @@ namespace testing { TEST(CompilerTest, ShaderKindMatchingIsSuccessful) { ASSERT_EQ(SourceTypeFromFileName("hello.vert"), SourceType::kVertexShader); ASSERT_EQ(SourceTypeFromFileName("hello.frag"), SourceType::kFragmentShader); - ASSERT_EQ(SourceTypeFromFileName("hello.tesc"), - SourceType::kTessellationControlShader); - ASSERT_EQ(SourceTypeFromFileName("hello.tese"), - SourceType::kTessellationEvaluationShader); ASSERT_EQ(SourceTypeFromFileName("hello.comp"), SourceType::kComputeShader); ASSERT_EQ(SourceTypeFromFileName("hello.msl"), SourceType::kUnknown); ASSERT_EQ(SourceTypeFromFileName("hello.glsl"), SourceType::kUnknown); @@ -57,24 +53,6 @@ TEST_P(CompilerTest, CanCompileHLSLWithMultipleStages) { SourceLanguage::kHLSL, "FragmentShader")); } -TEST_P(CompilerTest, CanCompileTessellationControlShader) { - if (GetParam() == TargetPlatform::kSkSL) { - GTEST_SKIP() << "Not supported with SkSL"; - } - ASSERT_TRUE(CanCompileAndReflect("sample.tesc")); - ASSERT_TRUE(CanCompileAndReflect("sample.tesc", - SourceType::kTessellationControlShader)); -} - -TEST_P(CompilerTest, CanCompileTessellationEvaluationShader) { - if (GetParam() == TargetPlatform::kSkSL) { - GTEST_SKIP() << "Not supported with SkSL"; - } - ASSERT_TRUE(CanCompileAndReflect("sample.tese")); - ASSERT_TRUE(CanCompileAndReflect("sample.tese", - SourceType::kTessellationEvaluationShader)); -} - TEST_P(CompilerTest, CanCompileComputeShader) { if (!TargetPlatformIsMetal(GetParam())) { GTEST_SKIP_("Only enabled on Metal backends till ES 3.2 support is added."); diff --git a/impeller/compiler/reflector.cc b/impeller/compiler/reflector.cc index d411422338466..4f9f9b1a76aa7 100644 --- a/impeller/compiler/reflector.cc +++ b/impeller/compiler/reflector.cc @@ -76,10 +76,6 @@ static std::string ExecutionModelToString(spv::ExecutionModel model) { return "vertex"; case spv::ExecutionModel::ExecutionModelFragment: return "fragment"; - case spv::ExecutionModel::ExecutionModelTessellationControl: - return "tessellation_control"; - case spv::ExecutionModel::ExecutionModelTessellationEvaluation: - return "tessellation_evaluation"; case spv::ExecutionModel::ExecutionModelGLCompute: return "compute"; default: @@ -96,14 +92,6 @@ static std::string StringToShaderStage(std::string str) { return "ShaderStage::kFragment"; } - if (str == "tessellation_control") { - return "ShaderStage::kTessellationControl"; - } - - if (str == "tessellation_evaluation") { - return "ShaderStage::kTessellationEvaluation"; - } - if (str == "compute") { return "ShaderStage::kCompute"; } diff --git a/impeller/compiler/runtime_stage_data.cc b/impeller/compiler/runtime_stage_data.cc index 942a08963a29d..95b35bcbbc1db 100644 --- a/impeller/compiler/runtime_stage_data.cc +++ b/impeller/compiler/runtime_stage_data.cc @@ -45,28 +45,20 @@ static std::optional ToStage(spv::ExecutionModel stage) { return fb::Stage::kFragment; case spv::ExecutionModel::ExecutionModelGLCompute: return fb::Stage::kCompute; - case spv::ExecutionModel::ExecutionModelTessellationControl: - return fb::Stage::kTessellationControl; - case spv::ExecutionModel::ExecutionModelTessellationEvaluation: - return fb::Stage::kTessellationEvaluation; default: return std::nullopt; } FML_UNREACHABLE(); } -static std::optional ToJsonStage(spv::ExecutionModel stage) { +static std::optional ToJsonStage(spv::ExecutionModel stage) { switch (stage) { case spv::ExecutionModel::ExecutionModelVertex: - return 0; // fb::Stage::kVertex; + return fb::Stage::kVertex; case spv::ExecutionModel::ExecutionModelFragment: - return 1; // fb::Stage::kFragment; + return fb::Stage::kFragment; case spv::ExecutionModel::ExecutionModelGLCompute: - return 2; // fb::Stage::kCompute; - case spv::ExecutionModel::ExecutionModelTessellationControl: - return 3; // fb::Stage::kTessellationControl; - case spv::ExecutionModel::ExecutionModelTessellationEvaluation: - return 4; // fb::Stage::kTessellationEvaluation; + return fb::Stage::kCompute; default: return std::nullopt; } @@ -246,7 +238,7 @@ std::shared_ptr RuntimeStageData::CreateJsonMapping() const { VALIDATION_LOG << "Invalid runtime stage."; return nullptr; } - root[kStageKey] = stage.value(); + root[kStageKey] = static_cast(stage.value()); const auto target_platform = ToJsonTargetPlatform(target_platform_); if (!target_platform.has_value()) { diff --git a/impeller/compiler/switches.cc b/impeller/compiler/switches.cc index 83c1ccaf3fb47..0e590a5c5c89a 100644 --- a/impeller/compiler/switches.cc +++ b/impeller/compiler/switches.cc @@ -31,8 +31,6 @@ static const std::map kKnownPlatforms = { static const std::map kKnownSourceTypes = { {"vert", SourceType::kVertexShader}, {"frag", SourceType::kFragmentShader}, - {"tesc", SourceType::kTessellationControlShader}, - {"tese", SourceType::kTessellationEvaluationShader}, {"comp", SourceType::kComputeShader}, }; diff --git a/impeller/compiler/types.cc b/impeller/compiler/types.cc index 310a685f4f2d5..77b40e9b6652e 100644 --- a/impeller/compiler/types.cc +++ b/impeller/compiler/types.cc @@ -35,14 +35,6 @@ SourceType SourceTypeFromFileName(const std::string& file_name) { return SourceType::kFragmentShader; } - if (StringEndWith(file_name, ".tesc")) { - return SourceType::kTessellationControlShader; - } - - if (StringEndWith(file_name, ".tese")) { - return SourceType::kTessellationEvaluationShader; - } - if (StringEndWith(file_name, ".comp")) { return SourceType::kComputeShader; } @@ -109,12 +101,6 @@ std::string EntryPointFunctionNameFromSourceName( case SourceType::kFragmentShader: stream << "fragment"; break; - case SourceType::kTessellationControlShader: - stream << "tess_control"; - break; - case SourceType::kTessellationEvaluationShader: - stream << "tess_eval"; - break; case SourceType::kComputeShader: stream << "compute"; break; @@ -172,10 +158,6 @@ shaderc_shader_kind ToShaderCShaderKind(SourceType type) { return shaderc_shader_kind::shaderc_vertex_shader; case SourceType::kFragmentShader: return shaderc_shader_kind::shaderc_fragment_shader; - case SourceType::kTessellationControlShader: - return shaderc_shader_kind::shaderc_tess_control_shader; - case SourceType::kTessellationEvaluationShader: - return shaderc_shader_kind::shaderc_tess_evaluation_shader; case SourceType::kComputeShader: return shaderc_shader_kind::shaderc_compute_shader; case SourceType::kUnknown: @@ -190,10 +172,6 @@ spv::ExecutionModel ToExecutionModel(SourceType type) { return spv::ExecutionModel::ExecutionModelVertex; case SourceType::kFragmentShader: return spv::ExecutionModel::ExecutionModelFragment; - case SourceType::kTessellationControlShader: - return spv::ExecutionModel::ExecutionModelTessellationControl; - case SourceType::kTessellationEvaluationShader: - return spv::ExecutionModel::ExecutionModelTessellationEvaluation; case SourceType::kComputeShader: return spv::ExecutionModel::ExecutionModelGLCompute; case SourceType::kUnknown: @@ -230,10 +208,6 @@ std::string SourceTypeToString(SourceType type) { return "vert"; case SourceType::kFragmentShader: return "frag"; - case SourceType::kTessellationControlShader: - return "tesc"; - case SourceType::kTessellationEvaluationShader: - return "tese"; case SourceType::kComputeShader: return "comp"; } diff --git a/impeller/compiler/types.h b/impeller/compiler/types.h index a475a8ebaaa43..0af2a5c403352 100644 --- a/impeller/compiler/types.h +++ b/impeller/compiler/types.h @@ -20,8 +20,6 @@ enum class SourceType { kUnknown, kVertexShader, kFragmentShader, - kTessellationControlShader, - kTessellationEvaluationShader, kComputeShader, }; diff --git a/impeller/core/runtime_types.h b/impeller/core/runtime_types.h index 2ef8512dbd8b4..67d66e978425e 100644 --- a/impeller/core/runtime_types.h +++ b/impeller/core/runtime_types.h @@ -30,8 +30,6 @@ enum class RuntimeShaderStage { kVertex, kFragment, kCompute, - kTessellationControl, - kTessellationEvaluation, }; struct RuntimeUniformDimensions { diff --git a/impeller/core/shader_types.h b/impeller/core/shader_types.h index 3fd9c718296ba..786759aca03f1 100644 --- a/impeller/core/shader_types.h +++ b/impeller/core/shader_types.h @@ -22,8 +22,6 @@ enum class ShaderStage { kUnknown, kVertex, kFragment, - kTessellationControl, - kTessellationEvaluation, kCompute, }; @@ -35,10 +33,6 @@ constexpr ShaderStage ToShaderStage(RuntimeShaderStage stage) { return ShaderStage::kFragment; case RuntimeShaderStage::kCompute: return ShaderStage::kCompute; - case RuntimeShaderStage::kTessellationControl: - return ShaderStage::kTessellationControl; - case RuntimeShaderStage::kTessellationEvaluation: - return ShaderStage::kTessellationEvaluation; } FML_UNREACHABLE(); } diff --git a/impeller/core/vertex_buffer.h b/impeller/core/vertex_buffer.h index 5ef934f4b82bf..7beac43d3c9b0 100644 --- a/impeller/core/vertex_buffer.h +++ b/impeller/core/vertex_buffer.h @@ -11,10 +11,20 @@ namespace impeller { struct VertexBuffer { BufferView vertex_buffer; + + //---------------------------------------------------------------------------- + /// The index buffer binding used by the vertex shader stage. BufferView index_buffer; - // The total count of vertices, either in the vertex_buffer if the - // index_type is IndexType::kNone or in the index_buffer otherwise. + + //---------------------------------------------------------------------------- + /// The total count of vertices, either in the vertex_buffer if the + /// index_type is IndexType::kNone or in the index_buffer otherwise. size_t vertex_count = 0u; + + //---------------------------------------------------------------------------- + /// The type of indices in the index buffer. The indices must be tightly + /// packed in the index buffer. + /// IndexType index_type = IndexType::kUnknown; constexpr explicit operator bool() const { diff --git a/impeller/entity/contents/atlas_contents.cc b/impeller/entity/contents/atlas_contents.cc index 412441b03be2c..c72f0c94344ef 100644 --- a/impeller/entity/contents/atlas_contents.cc +++ b/impeller/entity/contents/atlas_contents.cc @@ -244,12 +244,10 @@ bool AtlasContents::Render(const ContentContext& renderer, } } - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); - Command cmd; DEBUG_COMMAND_INFO( cmd, SPrintF("DrawAtlas Blend (%s)", BlendModeToString(blend_mode_))); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); cmd.stencil_reference = entity.GetClipDepth(); auto options = OptionsFromPass(pass); cmd.pipeline = renderer.GetPorterDuffBlendPipeline(options); diff --git a/impeller/entity/contents/clip_contents.cc b/impeller/entity/contents/clip_contents.cc index 7beee247cc20c..8779ab9b44a49 100644 --- a/impeller/entity/contents/clip_contents.cc +++ b/impeller/entity/contents/clip_contents.cc @@ -98,7 +98,7 @@ bool ClipContents::Render(const ContentContext& renderer, VertexBufferBuilder{} .AddVertices({{points[0]}, {points[1]}, {points[2]}, {points[3]}}) .CreateVertexBuffer(pass.GetTransientsBuffer()); - cmd.BindVertices(vertices); + cmd.BindVertices(std::move(vertices)); info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()); VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(info)); @@ -126,7 +126,7 @@ bool ClipContents::Render(const ContentContext& renderer, cmd.pipeline = renderer.GetClipPipeline(options); auto allocator = renderer.GetContext()->GetResourceAllocator(); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); info.mvp = geometry_result.transform; VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(info)); diff --git a/impeller/entity/contents/conical_gradient_contents.cc b/impeller/entity/contents/conical_gradient_contents.cc index 7b7d9119763ee..fbfe31a9c1174 100644 --- a/impeller/entity/contents/conical_gradient_contents.cc +++ b/impeller/entity/contents/conical_gradient_contents.cc @@ -107,7 +107,7 @@ bool ConicalGradientContents::RenderSSBO(const ContentContext& renderer, options.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetConicalGradientSSBOFillPipeline(options); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info)); FS::BindColorData(cmd, color_buffer); VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info)); @@ -173,7 +173,7 @@ bool ConicalGradientContents::RenderTexture(const ContentContext& renderer, options.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetConicalGradientFillPipeline(options); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info)); SamplerDescriptor sampler_desc; sampler_desc.min_filter = MinMagFilter::kLinear; diff --git a/impeller/entity/contents/filters/blend_filter_contents.cc b/impeller/entity/contents/filters/blend_filter_contents.cc index dc480f5e6cc7c..5fe7017df5eac 100644 --- a/impeller/entity/contents/filters/blend_filter_contents.cc +++ b/impeller/entity/contents/filters/blend_filter_contents.cc @@ -169,7 +169,7 @@ static std::optional AdvancedBlend( Command cmd; DEBUG_COMMAND_INFO(cmd, SPrintF("Advanced Blend Filter (%s)", BlendModeToString(blend_mode))); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(std::move(vtx_buffer)); cmd.pipeline = std::move(pipeline); typename FS::BlendInfo blend_info; @@ -289,7 +289,7 @@ std::optional BlendFilterContents::CreateForegroundAdvancedBlend( Command cmd; DEBUG_COMMAND_INFO(cmd, SPrintF("Foreground Advanced Blend Filter (%s)", BlendModeToString(blend_mode))); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(std::move(vtx_buffer)); cmd.stencil_reference = entity.GetClipDepth(); auto options = OptionsFromPass(pass); options.primitive_type = PrimitiveType::kTriangleStrip; @@ -460,7 +460,7 @@ std::optional BlendFilterContents::CreateForegroundPorterDuffBlend( Command cmd; DEBUG_COMMAND_INFO(cmd, SPrintF("Foreground PorterDuff Blend Filter (%s)", BlendModeToString(blend_mode))); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(std::move(vtx_buffer)); cmd.stencil_reference = entity.GetClipDepth(); auto options = OptionsFromPass(pass); options.primitive_type = PrimitiveType::kTriangleStrip; @@ -583,8 +583,7 @@ static std::optional PipelineBlend( {Point(0, size.height), Point(0, 1)}, {Point(size.width, size.height), Point(1, 1)}, }); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * diff --git a/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc b/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc index c653f54a23dbb..da21b9134940a 100644 --- a/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc @@ -102,7 +102,6 @@ std::optional BorderMaskBlurFilterContents::RenderFilter( coverage.origin.y + coverage.size.height}, input_uvs[3]}, }); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); Command cmd; DEBUG_COMMAND_INFO(cmd, "Border Mask Blur Filter"); @@ -110,7 +109,7 @@ std::optional BorderMaskBlurFilterContents::RenderFilter( options.primitive_type = PrimitiveType::kTriangleStrip; cmd.pipeline = renderer.GetBorderMaskBlurPipeline(options); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); cmd.stencil_reference = entity.GetClipDepth(); VS::FrameInfo frame_info; diff --git a/impeller/entity/contents/filters/color_matrix_filter_contents.cc b/impeller/entity/contents/filters/color_matrix_filter_contents.cc index f0d9cfe5f2f3a..2c159c803aac9 100644 --- a/impeller/entity/contents/filters/color_matrix_filter_contents.cc +++ b/impeller/entity/contents/filters/color_matrix_filter_contents.cc @@ -73,8 +73,7 @@ std::optional ColorMatrixFilterContents::RenderFilter( {Point(1, 1)}, }); auto& host_buffer = pass.GetTransientsBuffer(); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * diff --git a/impeller/entity/contents/filters/directional_gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/directional_gaussian_blur_filter_contents.cc index 4df745e1e4b18..cbda25181664f 100644 --- a/impeller/entity/contents/filters/directional_gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/directional_gaussian_blur_filter_contents.cc @@ -174,7 +174,6 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( {Point(0, 1), input_uvs[2]}, {Point(1, 1), input_uvs[3]}, }); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1)); @@ -195,7 +194,7 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( Command cmd; DEBUG_COMMAND_INFO(cmd, SPrintF("Gaussian Blur Filter (Radius=%.2f)", transformed_blur_radius_length)); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); auto options = OptionsFromPass(pass); options.primitive_type = PrimitiveType::kTriangleStrip; diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc index 27b2bd77dc404..61b14111f7b9c 100644 --- a/impeller/entity/contents/filters/filter_contents.cc +++ b/impeller/entity/contents/filters/filter_contents.cc @@ -202,7 +202,7 @@ std::optional FilterContents::GetLocalCoverage( } std::optional FilterContents::GetCoverage(const Entity& entity) const { - Entity entity_with_local_transform = entity; + Entity entity_with_local_transform = entity.Clone(); entity_with_local_transform.SetTransform(GetTransform(entity.GetTransform())); return GetLocalCoverage(entity_with_local_transform); @@ -269,7 +269,7 @@ std::optional FilterContents::GetEntity( const ContentContext& renderer, const Entity& entity, const std::optional& coverage_hint) const { - Entity entity_with_local_transform = entity; + Entity entity_with_local_transform = entity.Clone(); entity_with_local_transform.SetTransform(GetTransform(entity.GetTransform())); auto coverage = GetLocalCoverage(entity_with_local_transform); diff --git a/impeller/entity/contents/filters/filter_contents.h b/impeller/entity/contents/filters/filter_contents.h index 0b70e0ee3191a..b6aba377766ed 100644 --- a/impeller/entity/contents/filters/filter_contents.h +++ b/impeller/entity/contents/filters/filter_contents.h @@ -12,6 +12,7 @@ #include "impeller/core/formats.h" #include "impeller/entity/contents/filters/inputs/filter_input.h" #include "impeller/entity/entity.h" +#include "impeller/geometry/matrix.h" #include "impeller/geometry/sigma.h" namespace impeller { @@ -230,7 +231,7 @@ class FilterContents : public Contents { std::optional GetLocalCoverage(const Entity& local_entity) const; FilterInput::Vector inputs_; - Matrix effect_transform_; + Matrix effect_transform_ = Matrix(); FilterContents(const FilterContents&) = delete; diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 7b8f01cc90ab6..dd1d0256a921d 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -44,8 +44,7 @@ void BindVertices(Command& cmd, std::initializer_list&& vertices) { VertexBufferBuilder vtx_builder; vtx_builder.AddVertices(vertices); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); } Matrix MakeAnchorScale(const Point& anchor, Vector2 scale) { @@ -143,10 +142,13 @@ std::shared_ptr MakeBlurSubpass( {Point(1, 1), Point(1, 1)}, }); + SamplerDescriptor linear_sampler_descriptor = sampler_descriptor; + linear_sampler_descriptor.mag_filter = MinMagFilter::kLinear; + linear_sampler_descriptor.min_filter = MinMagFilter::kLinear; GaussianBlurFragmentShader::BindTextureSampler( cmd, input_texture, renderer.GetContext()->GetSamplerLibrary()->GetSampler( - sampler_descriptor)); + linear_sampler_descriptor)); GaussianBlurVertexShader::BindFrameInfo( cmd, host_buffer.EmplaceUniform(frame_info)); GaussianBlurFragmentShader::BindBlurInfo( @@ -254,6 +256,7 @@ std::optional GaussianBlurFilterContents::RenderFilter( // amount we are throwing away. ISize subpass_size = ISize(round(downsampled_size.x), round(downsampled_size.y)); + Vector2 effective_scalar = subpass_size / padded_size; Quad uvs = CalculateUVs(inputs[0], entity, input_snapshot->texture->GetSize()); @@ -268,8 +271,8 @@ std::optional GaussianBlurFilterContents::RenderFilter( renderer, pass1_out_texture, input_snapshot->sampler_descriptor, GaussianBlurFragmentShader::BlurInfo{ .blur_uv_offset = Point(0.0, pass1_pixel_size.y), - .blur_sigma = sigma_ * downsample_scalar.y, - .blur_radius = blur_radius * downsample_scalar.y, + .blur_sigma = sigma_ * effective_scalar.y, + .blur_radius = blur_radius * effective_scalar.y, .step_size = 1.0, }); @@ -278,8 +281,8 @@ std::optional GaussianBlurFilterContents::RenderFilter( renderer, pass2_out_texture, input_snapshot->sampler_descriptor, GaussianBlurFragmentShader::BlurInfo{ .blur_uv_offset = Point(pass1_pixel_size.x, 0.0), - .blur_sigma = sigma_ * downsample_scalar.x, - .blur_radius = blur_radius * downsample_scalar.x, + .blur_sigma = sigma_ * effective_scalar.x, + .blur_radius = blur_radius * effective_scalar.x, .step_size = 1.0, }); @@ -291,8 +294,7 @@ std::optional GaussianBlurFilterContents::RenderFilter( .texture = pass3_out_texture, .transform = input_snapshot->transform * Matrix::MakeTranslation({-padding.x, -padding.y, 0}) * - Matrix::MakeScale(padded_size / - Vector2(pass1_out_texture->GetSize())), + Matrix::MakeScale(1 / effective_scalar), .sampler_descriptor = sampler_desc, .opacity = input_snapshot->opacity}, entity.GetBlendMode(), entity.GetClipDepth()); diff --git a/impeller/entity/contents/filters/inputs/filter_input.cc b/impeller/entity/contents/filters/inputs/filter_input.cc index 880e4c6b6f382..b1459b7e200ee 100644 --- a/impeller/entity/contents/filters/inputs/filter_input.cc +++ b/impeller/entity/contents/filters/inputs/filter_input.cc @@ -61,7 +61,7 @@ Matrix FilterInput::GetLocalTransform(const Entity& entity) const { } std::optional FilterInput::GetLocalCoverage(const Entity& entity) const { - Entity local_entity = entity; + Entity local_entity = entity.Clone(); local_entity.SetTransform(GetLocalTransform(entity)); return GetCoverage(local_entity); } diff --git a/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc b/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc index b476a6739680e..64f13cdddf6a3 100644 --- a/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc +++ b/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc @@ -64,8 +64,7 @@ std::optional LinearToSrgbFilterContents::RenderFilter( }); auto& host_buffer = pass.GetTransientsBuffer(); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * diff --git a/impeller/entity/contents/filters/morphology_filter_contents.cc b/impeller/entity/contents/filters/morphology_filter_contents.cc index 0fb2760e6aa23..2aa8290830cd5 100644 --- a/impeller/entity/contents/filters/morphology_filter_contents.cc +++ b/impeller/entity/contents/filters/morphology_filter_contents.cc @@ -85,8 +85,6 @@ std::optional DirectionalMorphologyFilterContents::RenderFilter( {Point(1, 1), input_uvs[3]}, }); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); - VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1)); frame_info.texture_sampler_y_coord_scale = @@ -120,7 +118,7 @@ std::optional DirectionalMorphologyFilterContents::RenderFilter( options.primitive_type = PrimitiveType::kTriangleStrip; options.blend_mode = BlendMode::kSource; cmd.pipeline = renderer.GetMorphologyFilterPipeline(options); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); auto sampler_descriptor = input_snapshot->sampler_descriptor; if (renderer.GetDeviceCapabilities().SupportsDecalSamplerAddressMode()) { diff --git a/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc b/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc index 2da4cb00be0ae..38c6a2fe2842f 100644 --- a/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc +++ b/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc @@ -64,8 +64,7 @@ std::optional SrgbToLinearFilterContents::RenderFilter( }); auto& host_buffer = pass.GetTransientsBuffer(); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * diff --git a/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc b/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc index 53962ed9473ab..21ddf7ee82bf2 100644 --- a/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc +++ b/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc @@ -92,8 +92,7 @@ std::optional YUVToRGBFilterContents::RenderFilter( }); auto& host_buffer = pass.GetTransientsBuffer(); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * diff --git a/impeller/entity/contents/framebuffer_blend_contents.cc b/impeller/entity/contents/framebuffer_blend_contents.cc index 7edc478076499..867bc150c94a5 100644 --- a/impeller/entity/contents/framebuffer_blend_contents.cc +++ b/impeller/entity/contents/framebuffer_blend_contents.cc @@ -66,7 +66,6 @@ bool FramebufferBlendContents::Render(const ContentContext& renderer, {Point(0, size.height), Point(0, 1)}, {Point(size.width, size.height), Point(1, 1)}, }); - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); auto options = OptionsFromPass(pass); options.blend_mode = BlendMode::kSource; @@ -74,7 +73,7 @@ bool FramebufferBlendContents::Render(const ContentContext& renderer, Command cmd; DEBUG_COMMAND_INFO(cmd, "Framebuffer Advanced Blend Filter"); - cmd.BindVertices(vtx_buffer); + cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer)); cmd.stencil_reference = entity.GetClipDepth(); switch (blend_mode_) { diff --git a/impeller/entity/contents/linear_gradient_contents.cc b/impeller/entity/contents/linear_gradient_contents.cc index f1fc10d437dd8..d96525e7a0c0c 100644 --- a/impeller/entity/contents/linear_gradient_contents.cc +++ b/impeller/entity/contents/linear_gradient_contents.cc @@ -107,7 +107,7 @@ bool LinearGradientContents::RenderTexture(const ContentContext& renderer, options.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetLinearGradientFillPipeline(options); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info)); SamplerDescriptor sampler_desc; sampler_desc.min_filter = MinMagFilter::kLinear; @@ -169,7 +169,7 @@ bool LinearGradientContents::RenderSSBO(const ContentContext& renderer, options.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetLinearGradientSSBOFillPipeline(options); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info)); FS::BindColorData(cmd, color_buffer); VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info)); diff --git a/impeller/entity/contents/radial_gradient_contents.cc b/impeller/entity/contents/radial_gradient_contents.cc index a7020706f26e2..0eee4d448e8bb 100644 --- a/impeller/entity/contents/radial_gradient_contents.cc +++ b/impeller/entity/contents/radial_gradient_contents.cc @@ -106,7 +106,7 @@ bool RadialGradientContents::RenderSSBO(const ContentContext& renderer, options.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetRadialGradientSSBOFillPipeline(options); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info)); FS::BindColorData(cmd, color_buffer); VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info)); @@ -165,7 +165,7 @@ bool RadialGradientContents::RenderTexture(const ContentContext& renderer, options.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetRadialGradientFillPipeline(options); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info)); SamplerDescriptor sampler_desc; sampler_desc.min_filter = MinMagFilter::kLinear; diff --git a/impeller/entity/contents/runtime_effect_contents.cc b/impeller/entity/contents/runtime_effect_contents.cc index 502d6d044df8f..91c18a3b7e0ce 100644 --- a/impeller/entity/contents/runtime_effect_contents.cc +++ b/impeller/entity/contents/runtime_effect_contents.cc @@ -154,7 +154,7 @@ bool RuntimeEffectContents::Render(const ContentContext& renderer, DEBUG_COMMAND_INFO(cmd, "RuntimeEffectContents"); cmd.pipeline = pipeline; cmd.stencil_reference = entity.GetClipDepth(); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); //-------------------------------------------------------------------------- /// Vertex stage uniforms. diff --git a/impeller/entity/contents/solid_color_contents.cc b/impeller/entity/contents/solid_color_contents.cc index 99a7574f4ab8e..323da22797e7c 100644 --- a/impeller/entity/contents/solid_color_contents.cc +++ b/impeller/entity/contents/solid_color_contents.cc @@ -67,7 +67,7 @@ bool SolidColorContents::Render(const ContentContext& renderer, options.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetSolidFillPipeline(options); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); VS::FrameInfo frame_info; frame_info.mvp = capture.AddMatrix("Transform", geometry_result.transform); diff --git a/impeller/entity/contents/sweep_gradient_contents.cc b/impeller/entity/contents/sweep_gradient_contents.cc index caa29efd4b36f..f9b22e3c12e0d 100644 --- a/impeller/entity/contents/sweep_gradient_contents.cc +++ b/impeller/entity/contents/sweep_gradient_contents.cc @@ -112,7 +112,7 @@ bool SweepGradientContents::RenderSSBO(const ContentContext& renderer, options.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetSweepGradientSSBOFillPipeline(options); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info)); FS::BindColorData(cmd, color_buffer); VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info)); @@ -172,7 +172,7 @@ bool SweepGradientContents::RenderTexture(const ContentContext& renderer, options.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetSweepGradientFillPipeline(options); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info)); VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info)); SamplerDescriptor sampler_desc; diff --git a/impeller/entity/contents/tiled_texture_contents.cc b/impeller/entity/contents/tiled_texture_contents.cc index a9985d8ebab21..ef756577d2311 100644 --- a/impeller/entity/contents/tiled_texture_contents.cc +++ b/impeller/entity/contents/tiled_texture_contents.cc @@ -174,7 +174,7 @@ bool TiledTextureContents::Render(const ContentContext& renderer, : renderer.GetTexturePipeline(options); #endif // IMPELLER_ENABLE_OPENGLES - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info)); if (is_external_texture) { diff --git a/impeller/entity/contents/vertices_contents.cc b/impeller/entity/contents/vertices_contents.cc index fae8ed89b630b..47fdc1e9d1837 100644 --- a/impeller/entity/contents/vertices_contents.cc +++ b/impeller/entity/contents/vertices_contents.cc @@ -135,7 +135,7 @@ bool VerticesUVContents::Render(const ContentContext& renderer, opts.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetTexturePipeline(opts); cmd.stencil_reference = entity.GetClipDepth(); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); VS::FrameInfo frame_info; frame_info.mvp = geometry_result.transform; @@ -185,7 +185,7 @@ bool VerticesColorContents::Render(const ContentContext& renderer, opts.primitive_type = geometry_result.type; cmd.pipeline = renderer.GetGeometryColorPipeline(opts); cmd.stencil_reference = entity.GetClipDepth(); - cmd.BindVertices(geometry_result.vertex_buffer); + cmd.BindVertices(std::move(geometry_result.vertex_buffer)); VS::FrameInfo frame_info; frame_info.mvp = geometry_result.transform; diff --git a/impeller/entity/entity.cc b/impeller/entity/entity.cc index 339eabb606bb2..24bf0efa84958 100644 --- a/impeller/entity/entity.cc +++ b/impeller/entity/entity.cc @@ -174,6 +174,10 @@ Capture& Entity::GetCapture() const { return capture_; } +Entity Entity::Clone() const { + return Entity(*this); +} + void Entity::SetCapture(Capture capture) const { capture_ = std::move(capture); } diff --git a/impeller/entity/entity.h b/impeller/entity/entity.h index 43ee892a0a5bb..c5d98b5a11768 100644 --- a/impeller/entity/entity.h +++ b/impeller/entity/entity.h @@ -70,6 +70,8 @@ class Entity { ~Entity(); + Entity(Entity&&) = default; + /// @brief Get the global transform matrix for this Entity. const Matrix& GetTransform() const; @@ -113,7 +115,11 @@ class Entity { void SetCapture(Capture capture) const; + Entity Clone() const; + private: + Entity(const Entity&) = default; + Matrix transform_; std::shared_ptr contents_; BlendMode blend_mode_ = BlendMode::kSourceOver; diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index 3c0eb5f03affd..3e68449b4cc29 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc @@ -227,9 +227,10 @@ void EntityPass::AddSubpassInline(std::unique_ptr pass) { } FML_DCHECK(pass->superpass_ == nullptr); - elements_.insert(elements_.end(), - std::make_move_iterator(pass->elements_.begin()), - std::make_move_iterator(pass->elements_.end())); + std::vector& elements = pass->elements_; + for (auto i = 0u; i < elements.size(); i++) { + elements_.emplace_back(std::move(elements[i])); + } backdrop_filter_reads_from_pass_texture_ += pass->backdrop_filter_reads_from_pass_texture_; @@ -474,13 +475,11 @@ EntityPass::EntityResult EntityPass::GetEntityForElement( uint32_t pass_depth, ClipCoverageStack& clip_coverage_stack, size_t clip_depth_floor) const { - Entity element_entity; - //-------------------------------------------------------------------------- /// Setup entity element. /// if (const auto& entity = std::get_if(&element)) { - element_entity = *entity; + Entity element_entity = entity->Clone(); element_entity.SetCapture(capture.CreateChild("Entity")); if (!global_pass_position.IsZero()) { @@ -491,7 +490,7 @@ EntityPass::EntityResult EntityPass::GetEntityForElement( Matrix::MakeTranslation(Vector3(-global_pass_position)) * element_entity.GetTransform()); } - return EntityPass::EntityResult::Success(element_entity); + return EntityPass::EntityResult::Success(std::move(element_entity)); } //-------------------------------------------------------------------------- @@ -661,6 +660,7 @@ EntityPass::EntityResult EntityPass::GetEntityForElement( // right thing. return EntityPass::EntityResult::Failure(); } + Entity element_entity; Capture subpass_texture_capture = capture.CreateChild("Entity (Subpass texture)"); element_entity.SetCapture(subpass_texture_capture); @@ -671,7 +671,7 @@ EntityPass::EntityResult EntityPass::GetEntityForElement( "Transform", Matrix::MakeTranslation(Vector3(subpass_coverage->origin - global_pass_position)))); - return EntityPass::EntityResult::Success(element_entity); + return EntityPass::EntityResult::Success(std::move(element_entity)); } FML_UNREACHABLE(); } @@ -1084,7 +1084,7 @@ std::unique_ptr EntityPass::Clone() const { for (const auto& element : elements_) { if (auto entity = std::get_if(&element)) { - new_elements.push_back(*entity); + new_elements.push_back(entity->Clone()); continue; } if (auto subpass = std::get_if>(&element)) { @@ -1164,7 +1164,7 @@ void EntityPassClipRecorder::RecordEntity(const Entity& entity, case Contents::ClipCoverage::Type::kNoChange: return; case Contents::ClipCoverage::Type::kAppend: - rendered_clip_entities_.push_back(entity); + rendered_clip_entities_.push_back(entity.Clone()); break; case Contents::ClipCoverage::Type::kRestore: rendered_clip_entities_.pop_back(); diff --git a/impeller/entity/entity_pass.h b/impeller/entity/entity_pass.h index af169be276e48..08b34377a446f 100644 --- a/impeller/entity/entity_pass.h +++ b/impeller/entity/entity_pass.h @@ -72,6 +72,7 @@ class EntityPass { std::unique_ptr Clone() const; + /// @brief Add an entity to the current entity pass. void AddEntity(Entity entity); void SetElements(std::vector elements); @@ -183,7 +184,7 @@ class EntityPass { /// error while resolving the Entity. Status status = kFailure; - static EntityResult Success(const Entity& e) { return {e, kSuccess}; } + static EntityResult Success(Entity e) { return {std::move(e), kSuccess}; } static EntityResult Failure() { return {{}, kFailure}; } static EntityResult Skip() { return {{}, kSkip}; } }; diff --git a/impeller/entity/entity_unittests.cc b/impeller/entity/entity_unittests.cc index 8c0ab98d9eca7..8095b9c66b06b 100644 --- a/impeller/entity/entity_unittests.cc +++ b/impeller/entity/entity_unittests.cc @@ -103,7 +103,7 @@ auto CreatePassWithRectPath(Rect rect, Entity entity; entity.SetContents(SolidColorContents::Make( PathBuilder{}.AddRect(rect).TakePath(), Color::Red())); - subpass->AddEntity(entity); + subpass->AddEntity(std::move(entity)); subpass->SetDelegate(std::make_unique(collapse)); subpass->SetBoundsLimit(bounds_hint); return subpass; @@ -152,7 +152,7 @@ TEST_P(EntityTest, EntityPassCanMergeSubpassIntoParent) { contents->SetColor(Color::Blue()); entity.SetContents(std::move(contents)); - pass.AddEntity(entity); + pass.AddEntity(std::move(entity)); ASSERT_TRUE(OpenPlaygroundHere(pass)); } @@ -221,7 +221,7 @@ TEST_P(EntityTest, CanDrawRect) { entity.SetTransform(Matrix::MakeScale(GetContentScale())); entity.SetContents(contents); - ASSERT_TRUE(OpenPlaygroundHere(entity)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(entity))); } TEST_P(EntityTest, CanDrawRRect) { @@ -237,7 +237,7 @@ TEST_P(EntityTest, CanDrawRRect) { entity.SetTransform(Matrix::MakeScale(GetContentScale())); entity.SetContents(contents); - ASSERT_TRUE(OpenPlaygroundHere(entity)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(entity))); } TEST_P(EntityTest, GeometryBoundsAreTransformed) { @@ -264,7 +264,7 @@ TEST_P(EntityTest, ThreeStrokesInOnePath) { contents->SetGeometry(Geometry::MakeStrokePath(std::move(path), 5.0)); contents->SetColor(Color::Red()); entity.SetContents(std::move(contents)); - ASSERT_TRUE(OpenPlaygroundHere(entity)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(entity))); } TEST_P(EntityTest, StrokeWithTextureContents) { @@ -285,7 +285,7 @@ TEST_P(EntityTest, StrokeWithTextureContents) { contents->SetTexture(bridge); contents->SetTileModes(Entity::TileMode::kClamp, Entity::TileMode::kClamp); entity.SetContents(std::move(contents)); - ASSERT_TRUE(OpenPlaygroundHere(entity)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(entity))); } TEST_P(EntityTest, TriangleInsideASquare) { @@ -471,7 +471,7 @@ TEST_P(EntityTest, CubicCurveTest) { Entity entity; entity.SetTransform(Matrix::MakeScale(GetContentScale())); entity.SetContents(SolidColorContents::Make(std::move(path), Color::Red())); - ASSERT_TRUE(OpenPlaygroundHere(entity)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(entity))); } TEST_P(EntityTest, CanDrawCorrectlyWithRotatedTransform) { @@ -745,7 +745,7 @@ TEST_P(EntityTest, CubicCurveAndOverlapTest) { Entity entity; entity.SetTransform(Matrix::MakeScale(GetContentScale())); entity.SetContents(SolidColorContents::Make(std::move(path), Color::Red())); - ASSERT_TRUE(OpenPlaygroundHere(entity)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(entity))); } TEST_P(EntityTest, SolidColorContentsStrokeSetStrokeCapsAndJoins) { @@ -1360,7 +1360,7 @@ TEST_P(EntityTest, DrawAtlasNoColor) { e.SetTransform(Matrix::MakeScale(GetContentScale())); e.SetContents(contents); - ASSERT_TRUE(OpenPlaygroundHere(e)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(e))); } TEST_P(EntityTest, DrawAtlasWithColorAdvanced) { @@ -1395,7 +1395,7 @@ TEST_P(EntityTest, DrawAtlasWithColorAdvanced) { e.SetTransform(Matrix::MakeScale(GetContentScale())); e.SetContents(contents); - ASSERT_TRUE(OpenPlaygroundHere(e)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(e))); } TEST_P(EntityTest, DrawAtlasWithColorSimple) { @@ -1431,7 +1431,7 @@ TEST_P(EntityTest, DrawAtlasWithColorSimple) { e.SetTransform(Matrix::MakeScale(GetContentScale())); e.SetContents(contents); - ASSERT_TRUE(OpenPlaygroundHere(e)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(e))); } TEST_P(EntityTest, DrawAtlasUsesProvidedCullRectForCoverage) { @@ -1504,7 +1504,7 @@ TEST_P(EntityTest, DrawAtlasWithOpacity) { e.SetTransform(Matrix::MakeScale(GetContentScale())); e.SetContents(contents); - ASSERT_TRUE(OpenPlaygroundHere(e)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(e))); } TEST_P(EntityTest, DrawAtlasNoColorFullSize) { @@ -1524,7 +1524,7 @@ TEST_P(EntityTest, DrawAtlasNoColorFullSize) { e.SetTransform(Matrix::MakeScale(GetContentScale())); e.SetContents(contents); - ASSERT_TRUE(OpenPlaygroundHere(e)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(e))); } TEST_P(EntityTest, SolidFillCoverageIsCorrect) { @@ -2401,7 +2401,7 @@ TEST_P(EntityTest, ColorFilterContentsWithLargeGeometry) { BlendMode::kSourceOver, {FilterInput::Make(dst_contents, false), FilterInput::Make(src_contents, false)}); entity.SetContents(std::move(contents)); - ASSERT_TRUE(OpenPlaygroundHere(entity)); + ASSERT_TRUE(OpenPlaygroundHere(std::move(entity))); } TEST_P(EntityTest, TextContentsCeilsGlyphScaleToDecimal) { @@ -2465,7 +2465,7 @@ TEST_P(EntityTest, AdvancedBlendCoverageHintIsNotResetByEntityPass) { RenderTarget::kDefaultColorAttachmentConfig, stencil_config); auto content_context = ContentContext( GetContext(), TypographerContextSkia::Make(), test_allocator); - pass->AddEntity(entity); + pass->AddEntity(std::move(entity)); EXPECT_TRUE(pass->Render(content_context, rt)); diff --git a/impeller/fixtures/BUILD.gn b/impeller/fixtures/BUILD.gn index 566718ef270f5..073e3bee59f32 100644 --- a/impeller/fixtures/BUILD.gn +++ b/impeller/fixtures/BUILD.gn @@ -82,8 +82,6 @@ test_fixtures("file_fixtures") { "resources_limit.vert", "sample.comp", "sample.frag", - "sample.tesc", - "sample.tese", "sample.vert", "sample_with_binding.vert", "simple.vert.hlsl", diff --git a/impeller/fixtures/sample.tesc b/impeller/fixtures/sample.tesc deleted file mode 100644 index d6fe50408fe7a..0000000000000 --- a/impeller/fixtures/sample.tesc +++ /dev/null @@ -1,5 +0,0 @@ -layout(vertices = 4) out; - -void main() { - gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; -} diff --git a/impeller/fixtures/sample.tese b/impeller/fixtures/sample.tese deleted file mode 100644 index b47a8775e4416..0000000000000 --- a/impeller/fixtures/sample.tese +++ /dev/null @@ -1,12 +0,0 @@ -layout(quads, equal_spacing, ccw) in; - -void main() { - float u = gl_TessCoord.x; - float omu = 1 - u; - float v = gl_TessCoord.y; - float omv = 1 - v; - - gl_Position = omu * omv * gl_in[0].gl_Position + - u * omv * gl_in[1].gl_Position + u * v * gl_in[2].gl_Position + - omu * v * gl_in[3].gl_Position; -} diff --git a/impeller/playground/imgui/imgui_impl_impeller.cc b/impeller/playground/imgui/imgui_impl_impeller.cc index 449c9c7cf76ae..417e0c0067748 100644 --- a/impeller/playground/imgui/imgui_impl_impeller.cc +++ b/impeller/playground/imgui/imgui_impl_impeller.cc @@ -263,7 +263,7 @@ void ImGui_ImplImpeller_RenderDrawData(ImDrawData* draw_data, pcmd->ElemCount * sizeof(ImDrawIdx))}; vertex_buffer.vertex_count = pcmd->ElemCount; vertex_buffer.index_type = impeller::IndexType::k16bit; - cmd.BindVertices(vertex_buffer); + cmd.BindVertices(std::move(vertex_buffer)); cmd.base_vertex = pcmd->VtxOffset; render_pass.AddCommand(std::move(cmd)); diff --git a/impeller/renderer/backend/gles/buffer_bindings_gles.cc b/impeller/renderer/backend/gles/buffer_bindings_gles.cc index 69467f6800902..c96c4a5a04ac9 100644 --- a/impeller/renderer/backend/gles/buffer_bindings_gles.cc +++ b/impeller/renderer/backend/gles/buffer_bindings_gles.cc @@ -377,7 +377,7 @@ std::optional BufferBindingsGLES::BindTextures( /// If there is a sampler for the texture at the same index, configure the /// bound texture using that sampler. /// - const auto& sampler_gles = SamplerGLES::Cast(*data.second.sampler.resource); + const auto& sampler_gles = SamplerGLES::Cast(*data.second.sampler); if (!sampler_gles.ConfigureBoundTexture(texture_gles, gl)) { return std::nullopt; } diff --git a/impeller/renderer/backend/gles/capabilities_gles.cc b/impeller/renderer/backend/gles/capabilities_gles.cc index 57e4a7ff0ca09..e832aca15f276 100644 --- a/impeller/renderer/backend/gles/capabilities_gles.cc +++ b/impeller/renderer/backend/gles/capabilities_gles.cc @@ -126,8 +126,6 @@ size_t CapabilitiesGLES::GetMaxTextureUnits(ShaderStage stage) const { case ShaderStage::kFragment: return max_texture_image_units; case ShaderStage::kUnknown: - case ShaderStage::kTessellationControl: - case ShaderStage::kTessellationEvaluation: case ShaderStage::kCompute: return 0u; } diff --git a/impeller/renderer/backend/gles/pipeline_library_gles.cc b/impeller/renderer/backend/gles/pipeline_library_gles.cc index 85316e386dd12..14e395404efa5 100644 --- a/impeller/renderer/backend/gles/pipeline_library_gles.cc +++ b/impeller/renderer/backend/gles/pipeline_library_gles.cc @@ -63,12 +63,6 @@ static void LogShaderCompilationFailure(const ProcTableGLES& gl, case ShaderStage::kFragment: stream << "fragment"; break; - case ShaderStage::kTessellationControl: - stream << "tessellation control"; - break; - case ShaderStage::kTessellationEvaluation: - stream << "tessellation evaluation"; - break; case ShaderStage::kCompute: stream << "compute"; break; diff --git a/impeller/renderer/backend/gles/render_pass_gles.cc b/impeller/renderer/backend/gles/render_pass_gles.cc index 427225eb491df..efee4d68f6168 100644 --- a/impeller/renderer/backend/gles/render_pass_gles.cc +++ b/impeller/renderer/backend/gles/render_pass_gles.cc @@ -372,7 +372,7 @@ struct RenderPassData { break; } - if (command.index_type == IndexType::kUnknown) { + if (command.vertex_buffer.index_type == IndexType::kUnknown) { return false; } @@ -381,7 +381,7 @@ struct RenderPassData { //-------------------------------------------------------------------------- /// Bind vertex and index buffers. /// - auto vertex_buffer_view = command.GetVertexBuffer(); + auto& vertex_buffer_view = command.vertex_buffer.vertex_buffer; if (!vertex_buffer_view) { return false; @@ -441,11 +441,12 @@ struct RenderPassData { //-------------------------------------------------------------------------- /// Finally! Invoke the draw call. /// - if (command.index_type == IndexType::kNone) { - gl.DrawArrays(mode, command.base_vertex, command.vertex_count); + if (command.vertex_buffer.index_type == IndexType::kNone) { + gl.DrawArrays(mode, command.base_vertex, + command.vertex_buffer.vertex_count); } else { // Bind the index buffer if necessary. - auto index_buffer_view = command.index_buffer; + auto index_buffer_view = command.vertex_buffer.index_buffer; auto index_buffer = index_buffer_view.buffer->GetDeviceBuffer(*transients_allocator); const auto& index_buffer_gles = DeviceBufferGLES::Cast(*index_buffer); @@ -453,9 +454,9 @@ struct RenderPassData { DeviceBufferGLES::BindingType::kElementArrayBuffer)) { return false; } - gl.DrawElements(mode, // mode - command.vertex_count, // count - ToIndexType(command.index_type), // type + gl.DrawElements(mode, // mode + command.vertex_buffer.vertex_count, // count + ToIndexType(command.vertex_buffer.index_type), // type reinterpret_cast(static_cast( index_buffer_view.range.offset)) // indices ); diff --git a/impeller/renderer/backend/gles/shader_library_gles.cc b/impeller/renderer/backend/gles/shader_library_gles.cc index d56dc55316e3a..5acdcdfd4dc93 100644 --- a/impeller/renderer/backend/gles/shader_library_gles.cc +++ b/impeller/renderer/backend/gles/shader_library_gles.cc @@ -41,12 +41,6 @@ static std::string GLESShaderNameToShaderKeyName(const std::string& name, case ShaderStage::kFragment: stream << "_fragment_"; break; - case ShaderStage::kTessellationControl: - stream << "_tessellation_control_"; - break; - case ShaderStage::kTessellationEvaluation: - stream << "_tessellation_evaluation_"; - break; case ShaderStage::kCompute: stream << "_compute_"; break; diff --git a/impeller/renderer/backend/metal/compute_pass_mtl.mm b/impeller/renderer/backend/metal/compute_pass_mtl.mm index e22821485d97d..a55ec4fe07f60 100644 --- a/impeller/renderer/backend/metal/compute_pass_mtl.mm +++ b/impeller/renderer/backend/metal/compute_pass_mtl.mm @@ -231,7 +231,7 @@ static bool Bind(ComputePassBindingsCache& pass, } for (const auto& data : command.bindings.sampled_images) { - if (!Bind(pass_bindings, data.first, *data.second.sampler.resource, + if (!Bind(pass_bindings, data.first, *data.second.sampler, *data.second.texture.resource)) { return false; } diff --git a/impeller/renderer/backend/metal/render_pass_mtl.mm b/impeller/renderer/backend/metal/render_pass_mtl.mm index a63edda8f839e..f4fc37f0dfaf7 100644 --- a/impeller/renderer/backend/metal/render_pass_mtl.mm +++ b/impeller/renderer/backend/metal/render_pass_mtl.mm @@ -408,13 +408,6 @@ static bool Bind(PassBindingsCache& pass, auto bind_stage_resources = [&allocator, &pass_bindings]( const Bindings& bindings, ShaderStage stage) -> bool { - if (stage == ShaderStage::kVertex) { - if (!Bind(pass_bindings, *allocator, stage, - VertexDescriptor::kReservedVertexBufferIndex, - bindings.vertex_buffer.view.resource)) { - return false; - } - } for (const auto& buffer : bindings.buffers) { if (!Bind(pass_bindings, *allocator, stage, buffer.first, buffer.second.view.resource)) { @@ -422,7 +415,7 @@ static bool Bind(PassBindingsCache& pass, } } for (const auto& data : bindings.sampled_images) { - if (!Bind(pass_bindings, stage, data.first, *data.second.sampler.resource, + if (!Bind(pass_bindings, stage, data.first, *data.second.sampler, *data.second.texture.resource)) { return false; } @@ -434,13 +427,6 @@ static bool Bind(PassBindingsCache& pass, fml::closure pop_debug_marker = [encoder]() { [encoder popDebugGroup]; }; for (const auto& command : commands_) { - if (command.vertex_count == 0u) { - continue; - } - if (command.instance_count == 0u) { - continue; - } - #ifdef IMPELLER_DEBUG fml::ScopedCleanupClosure auto_pop_debug_marker(pop_debug_marker); if (!command.label.empty()) { @@ -479,6 +465,12 @@ static bool Bind(PassBindingsCache& pass, pipeline_desc.GetPolygonMode())]; [encoder setStencilReferenceValue:command.stencil_reference]; + if (!Bind(pass_bindings, *allocator, ShaderStage::kVertex, + VertexDescriptor::kReservedVertexBufferIndex, + command.vertex_buffer.vertex_buffer)) { + return false; + } + if (!bind_stage_resources(command.vertex_bindings, ShaderStage::kVertex)) { return false; } @@ -488,7 +480,7 @@ static bool Bind(PassBindingsCache& pass, } const PrimitiveType primitive_type = pipeline_desc.GetPrimitiveType(); - if (command.index_type == IndexType::kNone) { + if (command.vertex_buffer.index_type == IndexType::kNone) { if (command.instance_count != 1u) { #if TARGET_OS_SIMULATOR VALIDATION_LOG << "iOS Simulator does not support instanced rendering."; @@ -496,22 +488,22 @@ static bool Bind(PassBindingsCache& pass, #else // TARGET_OS_SIMULATOR [encoder drawPrimitives:ToMTLPrimitiveType(primitive_type) vertexStart:command.base_vertex - vertexCount:command.vertex_count + vertexCount:command.vertex_buffer.vertex_count instanceCount:command.instance_count baseInstance:0u]; #endif // TARGET_OS_SIMULATOR } else { [encoder drawPrimitives:ToMTLPrimitiveType(primitive_type) vertexStart:command.base_vertex - vertexCount:command.vertex_count]; + vertexCount:command.vertex_buffer.vertex_count]; } continue; } - if (command.index_type == IndexType::kUnknown) { + if (command.vertex_buffer.index_type == IndexType::kUnknown) { return false; } - auto index_buffer = command.index_buffer.buffer; + auto index_buffer = command.vertex_buffer.index_buffer.buffer; if (!index_buffer) { return false; } @@ -525,30 +517,34 @@ static bool Bind(PassBindingsCache& pass, return false; } - FML_DCHECK(command.vertex_count * - (command.index_type == IndexType::k16bit ? 2 : 4) == - command.index_buffer.range.length); + FML_DCHECK( + command.vertex_buffer.vertex_count * + (command.vertex_buffer.index_type == IndexType::k16bit ? 2 : 4) == + command.vertex_buffer.index_buffer.range.length); if (command.instance_count != 1u) { #if TARGET_OS_SIMULATOR VALIDATION_LOG << "iOS Simulator does not support instanced rendering."; return false; #else // TARGET_OS_SIMULATOR - [encoder drawIndexedPrimitives:ToMTLPrimitiveType(primitive_type) - indexCount:command.vertex_count - indexType:ToMTLIndexType(command.index_type) - indexBuffer:mtl_index_buffer - indexBufferOffset:command.index_buffer.range.offset - instanceCount:command.instance_count - baseVertex:command.base_vertex - baseInstance:0u]; + [encoder + drawIndexedPrimitives:ToMTLPrimitiveType(primitive_type) + indexCount:command.vertex_buffer.vertex_count + indexType:ToMTLIndexType(command.vertex_buffer.index_type) + indexBuffer:mtl_index_buffer + indexBufferOffset:command.vertex_buffer.index_buffer.range.offset + instanceCount:command.instance_count + baseVertex:command.base_vertex + baseInstance:0u]; #endif // TARGET_OS_SIMULATOR } else { - [encoder drawIndexedPrimitives:ToMTLPrimitiveType(primitive_type) - indexCount:command.vertex_count - indexType:ToMTLIndexType(command.index_type) - indexBuffer:mtl_index_buffer - indexBufferOffset:command.index_buffer.range.offset]; + [encoder + drawIndexedPrimitives:ToMTLPrimitiveType(primitive_type) + indexCount:command.vertex_buffer.vertex_count + indexType:ToMTLIndexType(command.vertex_buffer.index_type) + indexBuffer:mtl_index_buffer + indexBufferOffset:command.vertex_buffer.index_buffer.range + .offset]; } } return true; diff --git a/impeller/renderer/backend/metal/shader_library_mtl.mm b/impeller/renderer/backend/metal/shader_library_mtl.mm index 45eb5d5e3c40e..a1aedd9a54857 100644 --- a/impeller/renderer/backend/metal/shader_library_mtl.mm +++ b/impeller/renderer/backend/metal/shader_library_mtl.mm @@ -32,8 +32,6 @@ static MTLFunctionType ToMTLFunctionType(ShaderStage stage) { case ShaderStage::kFragment: return MTLFunctionTypeFragment; case ShaderStage::kUnknown: - case ShaderStage::kTessellationControl: - case ShaderStage::kTessellationEvaluation: case ShaderStage::kCompute: return MTLFunctionTypeKernel; } diff --git a/impeller/renderer/backend/vulkan/binding_helpers_vk.cc b/impeller/renderer/backend/vulkan/binding_helpers_vk.cc index 9acc128ee3201..e331ee7e8e7fa 100644 --- a/impeller/renderer/backend/vulkan/binding_helpers_vk.cc +++ b/impeller/renderer/backend/vulkan/binding_helpers_vk.cc @@ -26,7 +26,7 @@ static bool BindImages(const Bindings& bindings, for (const auto& [index, data] : bindings.sampled_images) { auto texture = data.texture.resource; const auto& texture_vk = TextureVK::Cast(*texture); - const SamplerVK& sampler = SamplerVK::Cast(*data.sampler.resource); + const SamplerVK& sampler = SamplerVK::Cast(*data.sampler); if (!encoder->Track(texture) || !encoder->Track(sampler.GetSharedSampler())) { diff --git a/impeller/renderer/backend/vulkan/formats_vk.h b/impeller/renderer/backend/vulkan/formats_vk.h index aa70f228634e3..f7d4c9d989c92 100644 --- a/impeller/renderer/backend/vulkan/formats_vk.h +++ b/impeller/renderer/backend/vulkan/formats_vk.h @@ -125,10 +125,6 @@ constexpr std::optional ToVKShaderStageFlagBits( return vk::ShaderStageFlagBits::eVertex; case ShaderStage::kFragment: return vk::ShaderStageFlagBits::eFragment; - case ShaderStage::kTessellationControl: - return vk::ShaderStageFlagBits::eTessellationControl; - case ShaderStage::kTessellationEvaluation: - return vk::ShaderStageFlagBits::eTessellationEvaluation; case ShaderStage::kCompute: return vk::ShaderStageFlagBits::eCompute; } @@ -259,10 +255,6 @@ constexpr vk::ShaderStageFlags ToVkShaderStage(ShaderStage stage) { return vk::ShaderStageFlagBits::eAll; case ShaderStage::kFragment: return vk::ShaderStageFlagBits::eFragment; - case ShaderStage::kTessellationControl: - return vk::ShaderStageFlagBits::eTessellationControl; - case ShaderStage::kTessellationEvaluation: - return vk::ShaderStageFlagBits::eTessellationEvaluation; case ShaderStage::kCompute: return vk::ShaderStageFlagBits::eCompute; case ShaderStage::kVertex: diff --git a/impeller/renderer/backend/vulkan/render_pass_vk.cc b/impeller/renderer/backend/vulkan/render_pass_vk.cc index 32ecf0534e67b..d720b8abf2330 100644 --- a/impeller/renderer/backend/vulkan/render_pass_vk.cc +++ b/impeller/renderer/backend/vulkan/render_pass_vk.cc @@ -351,10 +351,6 @@ static bool EncodeCommand(const Context& context, PassBindingsCache& command_buffer_cache, const ISize& target_size, const vk::DescriptorSet vk_desc_set) { - if (command.vertex_count == 0u || command.instance_count == 0u) { - return true; - } - #ifdef IMPELLER_DEBUG fml::ScopedCleanupClosure pop_marker( [&encoder]() { encoder.PopDebugGroup(); }); @@ -388,14 +384,13 @@ static bool EncodeCommand(const Context& context, command.stencil_reference); // Configure vertex and index and buffers for binding. - auto vertex_buffer_view = command.GetVertexBuffer(); + auto& vertex_buffer_view = command.vertex_buffer.vertex_buffer; if (!vertex_buffer_view) { return false; } auto& allocator = *context.GetResourceAllocator(); - auto vertex_buffer = vertex_buffer_view.buffer->GetDeviceBuffer(allocator); if (!vertex_buffer) { @@ -414,9 +409,9 @@ static bool EncodeCommand(const Context& context, vk::DeviceSize vertex_buffer_offsets[] = {vertex_buffer_view.range.offset}; cmd_buffer.bindVertexBuffers(0u, 1u, vertex_buffers, vertex_buffer_offsets); - if (command.index_type != IndexType::kNone) { + if (command.vertex_buffer.index_type != IndexType::kNone) { // Bind the index buffer. - auto index_buffer_view = command.index_buffer; + auto index_buffer_view = command.vertex_buffer.index_buffer; if (!index_buffer_view) { return false; } @@ -435,20 +430,20 @@ static bool EncodeCommand(const Context& context, auto index_buffer_handle = DeviceBufferVK::Cast(*index_buffer).GetBuffer(); cmd_buffer.bindIndexBuffer(index_buffer_handle, index_buffer_view.range.offset, - ToVKIndexType(command.index_type)); + ToVKIndexType(command.vertex_buffer.index_type)); // Engage! - cmd_buffer.drawIndexed(command.vertex_count, // index count + cmd_buffer.drawIndexed(command.vertex_buffer.vertex_count, // index count command.instance_count, // instance count 0u, // first index command.base_vertex, // vertex offset 0u // first instance ); } else { - cmd_buffer.draw(command.vertex_count, // vertex count - command.instance_count, // instance count - command.base_vertex, // vertex offset - 0u // first instance + cmd_buffer.draw(command.vertex_buffer.vertex_count, // vertex count + command.instance_count, // instance count + command.base_vertex, // vertex offset + 0u // first instance ); } return true; diff --git a/impeller/renderer/backend/vulkan/shader_library_vk.cc b/impeller/renderer/backend/vulkan/shader_library_vk.cc index 00d23ffa43aee..bd85f2559b72f 100644 --- a/impeller/renderer/backend/vulkan/shader_library_vk.cc +++ b/impeller/renderer/backend/vulkan/shader_library_vk.cc @@ -41,12 +41,6 @@ static std::string VKShaderNameToShaderKeyName(const std::string& name, case ShaderStage::kFragment: stream << "_fragment_"; break; - case ShaderStage::kTessellationControl: - stream << "_tessellation_control_"; - break; - case ShaderStage::kTessellationEvaluation: - stream << "_tessellation_evaluation_"; - break; case ShaderStage::kCompute: stream << "_compute_"; break; diff --git a/impeller/renderer/command.cc b/impeller/renderer/command.cc index 4a2ae532360ce..ed7fc0bc4960f 100644 --- a/impeller/renderer/command.cc +++ b/impeller/renderer/command.cc @@ -12,24 +12,16 @@ namespace impeller { -bool Command::BindVertices(const VertexBuffer& buffer) { +bool Command::BindVertices(VertexBuffer buffer) { if (buffer.index_type == IndexType::kUnknown) { VALIDATION_LOG << "Cannot bind vertex buffer with an unknown index type."; return false; } - vertex_bindings.vertex_buffer = - BufferAndUniformSlot{.slot = {}, .view = {nullptr, buffer.vertex_buffer}}; - index_buffer = buffer.index_buffer; - vertex_count = buffer.vertex_count; - index_type = buffer.index_type; + vertex_buffer = std::move(buffer); return true; } -BufferView Command::GetVertexBuffer() const { - return vertex_bindings.vertex_buffer.view.resource; -} - bool Command::BindResource(ShaderStage stage, const ShaderUniformSlot& slot, const ShaderMetadata& metadata, @@ -66,8 +58,6 @@ bool Command::DoBindResource(ShaderStage stage, return true; case ShaderStage::kCompute: VALIDATION_LOG << "Use ComputeCommands for compute shader stages."; - case ShaderStage::kTessellationControl: - case ShaderStage::kTessellationEvaluation: case ShaderStage::kUnknown: return false; } @@ -95,21 +85,19 @@ bool Command::BindResource(ShaderStage stage, vertex_bindings.sampled_images[slot.sampler_index] = TextureAndSampler{ .slot = slot, .texture = {&metadata, std::move(texture)}, - .sampler = {&metadata, std::move(sampler)}, + .sampler = std::move(sampler), }; return true; case ShaderStage::kFragment: fragment_bindings.sampled_images[slot.sampler_index] = TextureAndSampler{ .slot = slot, .texture = {&metadata, std::move(texture)}, - .sampler = {&metadata, std::move(sampler)}, + .sampler = std::move(sampler), }; return true; case ShaderStage::kCompute: VALIDATION_LOG << "Use ComputeCommands for compute shader stages."; case ShaderStage::kUnknown: - case ShaderStage::kTessellationControl: - case ShaderStage::kTessellationEvaluation: return false; } diff --git a/impeller/renderer/command.h b/impeller/renderer/command.h index 0c2d08ebe810b..d64215d134a43 100644 --- a/impeller/renderer/command.h +++ b/impeller/renderer/command.h @@ -60,13 +60,12 @@ struct Resource { using BufferResource = Resource; using TextureResource = Resource>; -using SamplerResource = Resource>; /// @brief combines the texture, sampler and sampler slot information. struct TextureAndSampler { SampledImageSlot slot; TextureResource texture; - SamplerResource sampler; + std::shared_ptr sampler; }; /// @brief combines the buffer resource and its uniform slot information. @@ -78,8 +77,6 @@ struct BufferAndUniformSlot { struct Bindings { std::map sampled_images; std::map buffers; - // This is only valid for vertex bindings. - BufferAndUniformSlot vertex_buffer; }; //------------------------------------------------------------------------------ @@ -111,29 +108,6 @@ struct Command : public ResourceBinder { /// stage. /// Bindings fragment_bindings; - //---------------------------------------------------------------------------- - /// The index buffer binding used by the vertex shader stage. Instead of - /// setting this directly, it usually easier to specify the vertex and index - /// buffer bindings directly via a single call to `BindVertices`. - /// - /// @see `BindVertices` - /// - BufferView index_buffer; - //---------------------------------------------------------------------------- - /// The number of vertices to draw. - /// - /// If the index_type is `IndexType::kNone`, this is a count into the vertex - /// buffer. Otherwise, it is a count into the index buffer. Set the vertex and - /// index buffers as well as the index count using a call to `BindVertices`. - /// - /// @see `BindVertices` - /// - size_t vertex_count = 0u; - //---------------------------------------------------------------------------- - /// The type of indices in the index buffer. The indices must be tightly - /// packed in the index buffer. - /// - IndexType index_type = IndexType::kUnknown; #ifdef IMPELLER_DEBUG //---------------------------------------------------------------------------- @@ -176,14 +150,19 @@ struct Command : public ResourceBinder { /// size_t instance_count = 1u; + //---------------------------------------------------------------------------- + /// The bound per-vertex data and optional index buffer. + VertexBuffer vertex_buffer; + //---------------------------------------------------------------------------- /// @brief Specify the vertex and index buffer to use for this command. /// - /// @param[in] buffer The vertex and index buffer definition. + /// @param[in] buffer The vertex and index buffer definition. If possible, + /// this value should be moved and not copied. /// /// @return returns if the binding was updated. /// - bool BindVertices(const VertexBuffer& buffer); + bool BindVertices(VertexBuffer buffer); // |ResourceBinder| bool BindResource(ShaderStage stage, @@ -203,8 +182,6 @@ struct Command : public ResourceBinder { std::shared_ptr texture, std::shared_ptr sampler) override; - BufferView GetVertexBuffer() const; - bool IsValid() const { return pipeline && pipeline->IsValid(); } private: diff --git a/impeller/renderer/compute_command.cc b/impeller/renderer/compute_command.cc index 902edcf470a4e..78b9fb99ec004 100644 --- a/impeller/renderer/compute_command.cc +++ b/impeller/renderer/compute_command.cc @@ -50,7 +50,7 @@ bool ComputeCommand::BindResource(ShaderStage stage, bindings.sampled_images[slot.sampler_index] = TextureAndSampler{ .slot = slot, .texture = {&metadata, std::move(texture)}, - .sampler = {&metadata, std::move(sampler)}, + .sampler = std::move(sampler), }; return false; diff --git a/impeller/renderer/compute_subgroup_unittests.cc b/impeller/renderer/compute_subgroup_unittests.cc index bec4030735911..b49968fcdb6d8 100644 --- a/impeller/renderer/compute_subgroup_unittests.cc +++ b/impeller/renderer/compute_subgroup_unittests.cc @@ -153,11 +153,10 @@ TEST_P(ComputeSubgroupTest, PathPlayground) { vertex_buffer_count->AsBufferView().contents) ->count; - VertexBuffer render_vertex_buffer{ - .vertex_buffer = vertex_buffer->AsBufferView(), - .vertex_count = count, - .index_type = IndexType::kNone}; - cmd.BindVertices(render_vertex_buffer); + cmd.BindVertices( + VertexBuffer{.vertex_buffer = vertex_buffer->AsBufferView(), + .vertex_count = count, + .index_type = IndexType::kNone}); VS::FrameInfo frame_info; auto world_matrix = Matrix::MakeScale(GetContentScale()); @@ -357,11 +356,10 @@ TEST_P(ComputeSubgroupTest, LargePath) { vertex_buffer_count->AsBufferView().contents) ->count; - VertexBuffer render_vertex_buffer{ - .vertex_buffer = vertex_buffer->AsBufferView(), - .vertex_count = count, - .index_type = IndexType::kNone}; - cmd.BindVertices(render_vertex_buffer); + cmd.BindVertices( + VertexBuffer{.vertex_buffer = vertex_buffer->AsBufferView(), + .vertex_count = count, + .index_type = IndexType::kNone}); VS::FrameInfo frame_info; auto world_matrix = Matrix::MakeScale(GetContentScale()); @@ -441,11 +439,10 @@ TEST_P(ComputeSubgroupTest, QuadAndCubicInOnePath) { vertex_buffer_count->AsBufferView().contents) ->count; - VertexBuffer render_vertex_buffer{ - .vertex_buffer = vertex_buffer->AsBufferView(), - .vertex_count = count, - .index_type = IndexType::kNone}; - cmd.BindVertices(render_vertex_buffer); + cmd.BindVertices( + VertexBuffer{.vertex_buffer = vertex_buffer->AsBufferView(), + .vertex_count = count, + .index_type = IndexType::kNone}); VS::FrameInfo frame_info; auto world_matrix = Matrix::MakeScale(GetContentScale()); diff --git a/impeller/renderer/render_pass.cc b/impeller/renderer/render_pass.cc index 8cc60b93eacdc..66b9551588743 100644 --- a/impeller/renderer/render_pass.cc +++ b/impeller/renderer/render_pass.cc @@ -74,13 +74,8 @@ bool RenderPass::AddCommand(Command&& command) { } } - if (command.vertex_count == 0u) { - // Essentially a no-op. Don't record the command but this is not necessary - // an error either. - return true; - } - - if (command.instance_count == 0u) { + if (command.vertex_buffer.vertex_count == 0u || + command.instance_count == 0u) { // Essentially a no-op. Don't record the command but this is not necessary // an error either. return true; diff --git a/impeller/renderer/renderer_unittests.cc b/impeller/renderer/renderer_unittests.cc index 9ca1ed2caebb8..a40735040278a 100644 --- a/impeller/renderer/renderer_unittests.cc +++ b/impeller/renderer/renderer_unittests.cc @@ -72,10 +72,6 @@ TEST_P(RendererTest, CanCreateBoxPrimitive) { {{800, 800, 0.0}, {1.0, 1.0}}, // 3 {{100, 800, 0.0}, {0.0, 1.0}}, // 4 }); - auto vertex_buffer = - vertex_builder.CreateVertexBuffer(*context->GetResourceAllocator()); - ASSERT_TRUE(vertex_buffer); - auto bridge = CreateTextureForFixture("bay_bridge.jpg"); auto boston = CreateTextureForFixture("boston.jpg"); ASSERT_TRUE(bridge && boston); @@ -96,7 +92,8 @@ TEST_P(RendererTest, CanCreateBoxPrimitive) { DEBUG_COMMAND_INFO(cmd, "Box"); cmd.pipeline = pipeline; - cmd.BindVertices(vertex_buffer); + cmd.BindVertices( + vertex_builder.CreateVertexBuffer(*context->GetResourceAllocator())); VS::UniformBuffer uniforms; uniforms.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * diff --git a/impeller/runtime_stage/runtime_stage.cc b/impeller/runtime_stage/runtime_stage.cc index 786dc7a88fa24..aed0e01509fcc 100644 --- a/impeller/runtime_stage/runtime_stage.cc +++ b/impeller/runtime_stage/runtime_stage.cc @@ -51,10 +51,6 @@ static RuntimeShaderStage ToShaderStage(fb::Stage stage) { return RuntimeShaderStage::kFragment; case fb::Stage::kCompute: return RuntimeShaderStage::kCompute; - case fb::Stage::kTessellationControl: - return RuntimeShaderStage::kTessellationControl; - case fb::Stage::kTessellationEvaluation: - return RuntimeShaderStage::kTessellationEvaluation; } FML_UNREACHABLE(); } diff --git a/impeller/runtime_stage/runtime_stage.fbs b/impeller/runtime_stage/runtime_stage.fbs index 6caca399d1927..fdb67c71917b5 100644 --- a/impeller/runtime_stage/runtime_stage.fbs +++ b/impeller/runtime_stage/runtime_stage.fbs @@ -8,8 +8,6 @@ enum Stage:byte { kVertex, kFragment, kCompute, - kTessellationControl, - kTessellationEvaluation, } enum TargetPlatform:byte { diff --git a/lib/gpu/formats.h b/lib/gpu/formats.h index e1a2a8d1d4a90..0b3001a8daf24 100644 --- a/lib/gpu/formats.h +++ b/lib/gpu/formats.h @@ -309,8 +309,6 @@ constexpr FlutterGPUShaderStage FromImpellerShaderStage( case impeller::ShaderStage::kFragment: return FlutterGPUShaderStage::kFragment; case impeller::ShaderStage::kUnknown: - case impeller::ShaderStage::kTessellationControl: - case impeller::ShaderStage::kTessellationEvaluation: case impeller::ShaderStage::kCompute: FML_LOG(FATAL) << "Invalid Flutter GPU ShaderStage " << static_cast(value); diff --git a/lib/gpu/render_pass.cc b/lib/gpu/render_pass.cc index 8dd9403d2935f..24e01f2ad2f12 100644 --- a/lib/gpu/render_pass.cc +++ b/lib/gpu/render_pass.cc @@ -395,10 +395,9 @@ bool InternalFlutterGpu_RenderPass_BindTexture( void InternalFlutterGpu_RenderPass_ClearBindings( flutter::gpu::RenderPass* wrapper) { auto& command = wrapper->GetCommand(); - command.vertex_count = 0; + command.vertex_buffer = {}; command.vertex_bindings = {}; command.fragment_bindings = {}; - command.index_buffer = {}; } void InternalFlutterGpu_RenderPass_SetColorBlendEnable( diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm index e84b5746d167f..ced139de2c9c1 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm @@ -8,8 +8,8 @@ #include "flutter/fml/platform/darwin/cf_utils.h" #import "flutter/shell/platform/darwin/ios/ios_surface.h" -static int kMaxPointsInVerb = 4; -static const NSUInteger kFlutterClippingMaskViewPoolCapacity = 5; +static constexpr int kMaxPointsInVerb = 4; +static constexpr NSUInteger kFlutterClippingMaskViewPoolCapacity = 5; namespace flutter { diff --git a/shell/platform/fuchsia/flutter/accessibility_bridge.cc b/shell/platform/fuchsia/flutter/accessibility_bridge.cc index c1f14df13ceac..c317a17b5497b 100644 --- a/shell/platform/fuchsia/flutter/accessibility_bridge.cc +++ b/shell/platform/fuchsia/flutter/accessibility_bridge.cc @@ -340,6 +340,14 @@ fuchsia::accessibility::semantics::States AccessibilityBridge::GetNodeStates( : fuchsia::accessibility::semantics::CheckedState::UNCHECKED); } + // Set enabled state. + if (node.HasFlag(flutter::SemanticsFlags::kHasEnabledState)) { + states.set_enabled_state( + node.HasFlag(flutter::SemanticsFlags::kIsEnabled) + ? fuchsia::accessibility::semantics::EnabledState::ENABLED + : fuchsia::accessibility::semantics::EnabledState::DISABLED); + } + // Set selected state. states.set_selected(node.HasFlag(flutter::SemanticsFlags::kIsSelected)); diff --git a/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc b/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc index 5ac2dd4da548c..fc4d0809e7633 100644 --- a/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc +++ b/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc @@ -483,6 +483,36 @@ TEST_F(AccessibilityBridgeTest, PopulatesToggledState) { EXPECT_FALSE(semantics_manager_.UpdateOverflowed()); } +TEST_F(AccessibilityBridgeTest, PopulatesEnabledState) { + flutter::SemanticsNode node0; + node0.id = 0; + // HasEnabledState = true + // IsEnabled = true + node0.flags |= static_cast(flutter::SemanticsFlags::kHasEnabledState); + node0.flags |= static_cast(flutter::SemanticsFlags::kIsEnabled); + node0.value = "value"; + + accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f); + RunLoopUntilIdle(); + + EXPECT_EQ(0, semantics_manager_.DeleteCount()); + EXPECT_EQ(1, semantics_manager_.UpdateCount()); + EXPECT_EQ(1, semantics_manager_.CommitCount()); + EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size()); + const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u); + EXPECT_EQ(fuchsia_node.node_id(), static_cast(node0.id)); + EXPECT_TRUE(fuchsia_node.has_states()); + const auto& states = fuchsia_node.states(); + EXPECT_TRUE(states.has_enabled_state()); + EXPECT_EQ(states.enabled_state(), + fuchsia::accessibility::semantics::EnabledState::ENABLED); + EXPECT_TRUE(states.has_value()); + EXPECT_EQ(states.value(), node0.value); + + EXPECT_FALSE(semantics_manager_.DeleteOverflowed()); + EXPECT_FALSE(semantics_manager_.UpdateOverflowed()); +} + TEST_F(AccessibilityBridgeTest, ApplyViewPixelRatioToRoot) { flutter::SemanticsNode node0; node0.id = 0; diff --git a/third_party/accessibility/ax/platform/ax_unique_id_unittest.cc b/third_party/accessibility/ax/platform/ax_unique_id_unittest.cc index 5f62ad3d115f7..d6e791ffc7d56 100644 --- a/third_party/accessibility/ax/platform/ax_unique_id_unittest.cc +++ b/third_party/accessibility/ax/platform/ax_unique_id_unittest.cc @@ -54,7 +54,7 @@ TEST(AXPlatformUniqueIdTest, UnassignedIdsAreReused) { } TEST(AXPlatformUniqueIdTest, DoesCreateCorrectId) { - int kLargerThanMaxId = kMaxId * 2; + constexpr int kLargerThanMaxId = kMaxId * 2; std::unique_ptr ids[kLargerThanMaxId]; // Creates and releases to fill up the internal static counter. for (int i = 0; i < kLargerThanMaxId; i++) {