Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 67c01d5

Browse files
authored
[Impeller] Remove StC flag. (#51992)
It is time.
1 parent 5dca50d commit 67c01d5

11 files changed

+21
-140
lines changed

impeller/entity/contents/clip_contents.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,7 @@ bool ClipContents::Render(const ContentContext& renderer,
250250
if (!geometry_) {
251251
return true;
252252
}
253-
if constexpr (ContentContext::kEnableStencilThenCover) {
254-
return RenderDepthClip(renderer, entity, pass, clip_op_, *geometry_);
255-
} else {
256-
return RenderStencilClip(renderer, entity, pass, clip_op_, *geometry_);
257-
}
253+
return RenderDepthClip(renderer, entity, pass, clip_op_, *geometry_);
258254
}
259255

260256
/*******************************************************************************

impeller/entity/contents/clip_contents_unittests.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ namespace testing {
2222
using EntityTest = EntityPlayground;
2323

2424
TEST_P(EntityTest, ClipContentsOptimizesFullScreenIntersectClips) {
25-
if (!ContentContext::kEnableStencilThenCover) {
26-
GTEST_SKIP();
27-
return;
28-
}
29-
3025
// Set up mock environment.
3126

3227
auto content_context = GetContentContext();

impeller/entity/contents/color_source_contents.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,7 @@ class ColorSourceContents : public Contents {
203203
options.stencil_mode =
204204
ContentContextOptions::StencilMode::kLegacyClipIncrement;
205205
}
206-
if constexpr (ContentContext::kEnableStencilThenCover) {
207-
pass.SetStencilReference(0);
208-
} else {
209-
pass.SetStencilReference(entity.GetClipDepth());
210-
}
206+
pass.SetStencilReference(0);
211207

212208
VertexShaderT::BindFrameInfo(
213209
pass, renderer.GetTransientsBuffer().EmplaceUniform(frame_info));
@@ -232,13 +228,9 @@ class ColorSourceContents : public Contents {
232228
if (geometry_result.mode == GeometryResult::Mode::kPreventOverdraw) {
233229
auto restore = ClipRestoreContents();
234230
restore.SetRestoreCoverage(GetCoverage(entity));
235-
if constexpr (ContentContext::kEnableStencilThenCover) {
236-
Entity restore_entity = entity.Clone();
237-
restore_entity.SetClipDepth(0);
238-
return restore.Render(renderer, restore_entity, pass);
239-
} else {
240-
return restore.Render(renderer, entity, pass);
241-
}
231+
Entity restore_entity = entity.Clone();
232+
restore_entity.SetClipDepth(0);
233+
return restore.Render(renderer, restore_entity, pass);
242234
}
243235
return true;
244236
}

impeller/entity/contents/content_context.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,16 +397,6 @@ class ContentContext {
397397

398398
bool IsValid() const;
399399

400-
/// This setting does two things:
401-
/// 1. Enables clipping with the depth buffer, freeing up the stencil buffer.
402-
/// See also: https://github.com/flutter/flutter/issues/138460
403-
/// 2. Switches the generic tessellation fallback to use stencil-then-cover.
404-
/// See also: https://github.com/flutter/flutter/issues/123671
405-
///
406-
// TODO(bdero): Remove this setting once StC is fully de-risked
407-
// https://github.com/flutter/flutter/issues/123671
408-
static constexpr bool kEnableStencilThenCover = true;
409-
410400
#if IMPELLER_ENABLE_3D
411401
std::shared_ptr<scene::SceneContext> GetSceneContext() const;
412402
#endif // IMPELLER_ENABLE_3D

impeller/entity/contents/contents.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ ContentContextOptions OptionsFromPass(const RenderPass& pass) {
2727
FML_DCHECK(pass.HasDepthAttachment() == pass.HasStencilAttachment());
2828

2929
opts.has_depth_stencil_attachments = has_depth_stencil_attachments;
30-
if constexpr (ContentContext::kEnableStencilThenCover) {
31-
opts.depth_compare = CompareFunction::kGreater;
32-
opts.stencil_mode = ContentContextOptions::StencilMode::kIgnore;
33-
}
30+
opts.depth_compare = CompareFunction::kGreater;
31+
opts.stencil_mode = ContentContextOptions::StencilMode::kIgnore;
3432
return opts;
3533
}
3634

impeller/entity/contents/filters/gaussian_blur_filter_contents.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,6 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation,
232232
blur_entity.SetNewClipDepth(entity.GetNewClipDepth());
233233
blur_entity.SetTransform(entity.GetTransform() * blur_transform);
234234
result = blur_entity.Render(renderer, pass) && result;
235-
if constexpr (!ContentContext::kEnableStencilThenCover) {
236-
result = restore->Render(renderer, entity, pass) && result;
237-
}
238235
return result;
239236
});
240237
auto coverage =

impeller/entity/entity_pass.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,6 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
756756
static void SetClipScissor(std::optional<Rect> clip_coverage,
757757
RenderPass& pass,
758758
Point global_pass_position) {
759-
if constexpr (!ContentContext::kEnableStencilThenCover) {
760-
return;
761-
}
762759
// Set the scissor to the clip coverage area. We do this prior to rendering
763760
// the clip itself and all its contents.
764761
IRect scissor;

impeller/entity/entity_pass_clip_stack.cc

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,11 @@ EntityPassClipStack::ClipStateResult EntityPassClipStack::ApplyClipState(
101101
subpass_state.clip_coverage.resize(restoration_index + 1);
102102
result.clip_did_change = true;
103103

104-
if constexpr (ContentContext::kEnableStencilThenCover) {
105-
// Skip all clip restores when stencil-then-cover is enabled.
106-
if (subpass_state.clip_coverage.back().coverage.has_value()) {
107-
RecordEntity(entity, global_clip_coverage.type, Rect());
108-
}
109-
return result;
104+
// Skip all clip restores when stencil-then-cover is enabled.
105+
if (subpass_state.clip_coverage.back().coverage.has_value()) {
106+
RecordEntity(entity, global_clip_coverage.type, Rect());
110107
}
111-
112-
if (!subpass_state.clip_coverage.back().coverage.has_value()) {
113-
// Running this restore op won't make anything renderable, so skip it.
114-
return result;
115-
}
116-
117-
auto restore_contents =
118-
static_cast<ClipRestoreContents*>(entity.GetContents().get());
119-
restore_contents->SetRestoreCoverage(restore_coverage);
108+
return result;
120109

121110
} break;
122111
}

impeller/entity/entity_unittests.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,11 +2795,7 @@ TEST_P(EntityTest, FillPathGeometryGetPositionBufferReturnsExpectedMode) {
27952795
.Close()
27962796
.TakePath();
27972797
GeometryResult result = get_result(path);
2798-
if constexpr (ContentContext::kEnableStencilThenCover) {
2799-
EXPECT_EQ(result.mode, GeometryResult::Mode::kNonZero);
2800-
} else {
2801-
EXPECT_EQ(result.mode, GeometryResult::Mode::kNormal);
2802-
}
2798+
EXPECT_EQ(result.mode, GeometryResult::Mode::kNonZero);
28032799
}
28042800
}
28052801

impeller/entity/geometry/fill_path_geometry.cc

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,6 @@ GeometryResult FillPathGeometry::GetPositionBuffer(
3737
}
3838

3939
VertexBuffer vertex_buffer;
40-
if constexpr (!ContentContext::kEnableStencilThenCover) {
41-
if (!path_.IsConvex()) {
42-
auto tesselation_result = renderer.GetTessellator()->Tessellate(
43-
path_, entity.GetTransform().GetMaxBasisLength(),
44-
[&vertex_buffer, &host_buffer](
45-
const float* vertices, size_t vertices_count,
46-
const uint16_t* indices, size_t indices_count) {
47-
vertex_buffer.vertex_buffer = host_buffer.Emplace(
48-
vertices, vertices_count * sizeof(float) * 2, alignof(float));
49-
if (indices != nullptr) {
50-
vertex_buffer.index_buffer = host_buffer.Emplace(
51-
indices, indices_count * sizeof(uint16_t), alignof(uint16_t));
52-
vertex_buffer.vertex_count = indices_count;
53-
vertex_buffer.index_type = IndexType::k16bit;
54-
} else {
55-
vertex_buffer.index_buffer = {};
56-
vertex_buffer.vertex_count = vertices_count;
57-
vertex_buffer.index_type = IndexType::kNone;
58-
}
59-
return true;
60-
});
61-
if (tesselation_result != Tessellator::Result::kSuccess) {
62-
return {};
63-
}
64-
return GeometryResult{
65-
.type = PrimitiveType::kTriangle,
66-
.vertex_buffer = vertex_buffer,
67-
.transform = entity.GetShaderTransform(pass),
68-
};
69-
}
70-
}
7140

7241
auto points = renderer.GetTessellator()->TessellateConvex(
7342
path_, entity.GetTransform().GetMaxBasisLength());
@@ -111,41 +80,6 @@ GeometryResult FillPathGeometry::GetPositionUVBuffer(
11180
auto uv_transform =
11281
texture_coverage.GetNormalizingTransform() * effect_transform;
11382

114-
if constexpr (!ContentContext::kEnableStencilThenCover) {
115-
if (!path_.IsConvex()) {
116-
VertexBufferBuilder<VS::PerVertexData> vertex_builder;
117-
auto tesselation_result = renderer.GetTessellator()->Tessellate(
118-
path_, entity.GetTransform().GetMaxBasisLength(),
119-
[&vertex_builder, &uv_transform](
120-
const float* vertices, size_t vertices_count,
121-
const uint16_t* indices, size_t indices_count) {
122-
for (auto i = 0u; i < vertices_count * 2; i += 2) {
123-
VS::PerVertexData data;
124-
Point vtx = {vertices[i], vertices[i + 1]};
125-
data.position = vtx;
126-
data.texture_coords = uv_transform * vtx;
127-
vertex_builder.AppendVertex(data);
128-
}
129-
FML_DCHECK(vertex_builder.GetVertexCount() == vertices_count);
130-
if (indices != nullptr) {
131-
for (auto i = 0u; i < indices_count; i++) {
132-
vertex_builder.AppendIndex(indices[i]);
133-
}
134-
}
135-
return true;
136-
});
137-
if (tesselation_result != Tessellator::Result::kSuccess) {
138-
return {};
139-
}
140-
return GeometryResult{
141-
.type = PrimitiveType::kTriangle,
142-
.vertex_buffer =
143-
vertex_builder.CreateVertexBuffer(renderer.GetTransientsBuffer()),
144-
.transform = entity.GetShaderTransform(pass),
145-
};
146-
}
147-
}
148-
14983
auto points = renderer.GetTessellator()->TessellateConvex(
15084
path_, entity.GetTransform().GetMaxBasisLength());
15185

@@ -169,7 +103,7 @@ GeometryResult FillPathGeometry::GetPositionUVBuffer(
169103

170104
GeometryResult::Mode FillPathGeometry::GetResultMode() const {
171105
const auto& bounding_box = path_.GetBoundingBox();
172-
if (!ContentContext::kEnableStencilThenCover || path_.IsConvex() ||
106+
if (path_.IsConvex() ||
173107
(bounding_box.has_value() && bounding_box->IsEmpty())) {
174108
return GeometryResult::Mode::kNormal;
175109
}

impeller/entity/inline_pass_context.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,16 @@ InlinePassContext::RenderPassResult InlinePassContext::GetRenderPass(
151151
color0.store_action =
152152
is_msaa ? StoreAction::kMultisampleResolve : StoreAction::kStore;
153153

154-
if (ContentContext::kEnableStencilThenCover) {
155-
auto depth = pass_target_.GetRenderTarget().GetDepthAttachment();
156-
if (!depth.has_value()) {
157-
VALIDATION_LOG << "Depth attachment unexpectedly missing from the "
158-
"EntityPass render target.";
159-
return {};
160-
}
161-
depth->load_action = LoadAction::kClear;
162-
depth->store_action = StoreAction::kDontCare;
163-
pass_target_.target_.SetDepthAttachment(depth.value());
154+
auto depth = pass_target_.GetRenderTarget().GetDepthAttachment();
155+
if (!depth.has_value()) {
156+
VALIDATION_LOG << "Depth attachment unexpectedly missing from the "
157+
"EntityPass render target.";
158+
return {};
164159
}
160+
depth->load_action = LoadAction::kClear;
161+
depth->store_action = StoreAction::kDontCare;
162+
pass_target_.target_.SetDepthAttachment(depth.value());
165163

166-
auto depth = pass_target_.GetRenderTarget().GetDepthAttachment();
167164
auto stencil = pass_target_.GetRenderTarget().GetStencilAttachment();
168165
if (!depth.has_value() || !stencil.has_value()) {
169166
VALIDATION_LOG << "Stencil/Depth attachment unexpectedly missing from the "

0 commit comments

Comments
 (0)