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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()));
Expand Down
12 changes: 10 additions & 2 deletions impeller/entity/geometry/point_field_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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<Rect> PointFieldGeometry::GetCoverage(
const Matrix& transform) const {
Expand Down
3 changes: 3 additions & 0 deletions impeller/entity/geometry/point_field_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down