diff --git a/impeller/entity/entity_unittests.cc b/impeller/entity/entity_unittests.cc index 4cb0c416d5121..916a7367c0cda 100644 --- a/impeller/entity/entity_unittests.cc +++ b/impeller/entity/entity_unittests.cc @@ -40,6 +40,7 @@ #include "impeller/geometry/color.h" #include "impeller/geometry/geometry_asserts.h" #include "impeller/geometry/path_builder.h" +#include "impeller/geometry/point.h" #include "impeller/geometry/sigma.h" #include "impeller/geometry/vector.h" #include "impeller/playground/playground.h" @@ -2425,6 +2426,11 @@ TEST_P(EntityTest, PointFieldGeometryCoverage) { Rect::MakeLTRB(35, 15, 135, 205)); } +TEST_P(EntityTest, PointFieldCanUseCompute) { + EXPECT_EQ(PointFieldGeometry::CanUseCompute(*GetContentContext()), + GetContext()->GetBackendType() == Context::BackendType::kMetal); +} + TEST_P(EntityTest, ColorFilterContentsWithLargeGeometry) { Entity entity; entity.SetTransform(Matrix::MakeScale(GetContentScale())); diff --git a/impeller/entity/geometry/point_field_geometry.cc b/impeller/entity/geometry/point_field_geometry.cc index cd1c5791e9642..f4e18da1b6373 100644 --- a/impeller/entity/geometry/point_field_geometry.cc +++ b/impeller/entity/geometry/point_field_geometry.cc @@ -18,7 +18,7 @@ GeometryResult PointFieldGeometry::GetPositionBuffer( const ContentContext& renderer, const Entity& entity, RenderPass& pass) const { - if (renderer.GetDeviceCapabilities().SupportsCompute()) { + if (CanUseCompute(renderer)) { return GetPositionBufferGPU(renderer, entity, pass); } auto vtx_builder = GetPositionBufferCPU(renderer, entity, pass); @@ -42,7 +42,7 @@ GeometryResult PointFieldGeometry::GetPositionUVBuffer( const ContentContext& renderer, const Entity& entity, RenderPass& pass) const { - if (renderer.GetDeviceCapabilities().SupportsCompute()) { + if (CanUseCompute(renderer)) { return GetPositionBufferGPU(renderer, entity, pass, texture_coverage, effect_transform); } @@ -275,6 +275,14 @@ GeometryVertexType PointFieldGeometry::GetVertexType() const { return GeometryVertexType::kPosition; } +// Compute is disabled for Vulkan because the barriers are incorrect, see +// also: https://github.com/flutter/flutter/issues/140798 . +bool PointFieldGeometry::CanUseCompute(const ContentContext& renderer) { + return renderer.GetDeviceCapabilities().SupportsCompute() && + renderer.GetContext()->GetBackendType() == + Context::BackendType::kMetal; +} + // |Geometry| std::optional PointFieldGeometry::GetCoverage( const Matrix& transform) const { diff --git a/impeller/entity/geometry/point_field_geometry.h b/impeller/entity/geometry/point_field_geometry.h index 9d43f07cb9fbe..a8c296adfc3c6 100644 --- a/impeller/entity/geometry/point_field_geometry.h +++ b/impeller/entity/geometry/point_field_geometry.h @@ -17,6 +17,9 @@ class PointFieldGeometry final : public Geometry { static size_t ComputeCircleDivisions(Scalar scaled_radius, bool round); + /// If the platform can use compute safely. + static bool CanUseCompute(const ContentContext& renderer); + private: // |Geometry| GeometryResult GetPositionBuffer(const ContentContext& renderer,