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

Commit 192a897

Browse files
author
Jonah Williams
authored
[Impeller] remove varying interpolation for solid colors. (#53281)
This was an early attempt to support batching that ended up not being important, as well as an attempted work around for high memory reads that ended being unrelated (it was blending) Since its not a performance improvement and just makes things more complicated, remove the feature.
1 parent 6315b24 commit 192a897

File tree

8 files changed

+87
-174
lines changed

8 files changed

+87
-174
lines changed

impeller/compiler/shader_lib/impeller/types.glsl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
#extension GL_AMD_gpu_shader_half_float_fetch : enable
1010
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable
1111

12-
#ifdef IMPELLER_TARGET_OPENGLES
13-
#define IMPELLER_MAYBE_FLAT
14-
#else
15-
#define IMPELLER_MAYBE_FLAT flat
16-
#endif
17-
1812
#ifndef IMPELLER_TARGET_METAL_IOS
1913

2014
precision mediump sampler2D;

impeller/entity/contents/solid_color_contents.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ bool SolidColorContents::Render(const ContentContext& renderer,
4949
const Entity& entity,
5050
RenderPass& pass) const {
5151
using VS = SolidFillPipeline::VertexShader;
52+
using FS = SolidFillPipeline::FragmentShader;
53+
auto& host_buffer = renderer.GetTransientsBuffer();
5254

5355
VS::FrameInfo frame_info;
54-
frame_info.color =
56+
FS::FragInfo frag_info;
57+
frag_info.color =
5558
GetColor().Premultiply() * GetGeometry()->ComputeAlphaCoverage(entity);
5659

5760
PipelineBuilderCallback pipeline_callback =
@@ -60,7 +63,8 @@ bool SolidColorContents::Render(const ContentContext& renderer,
6063
};
6164
return ColorSourceContents::DrawGeometry<VS>(
6265
renderer, entity, pass, pipeline_callback, frame_info,
63-
[](RenderPass& pass) {
66+
[&frag_info, &host_buffer](RenderPass& pass) {
67+
FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
6468
pass.SetCommandLabel("Solid Fill");
6569
return true;
6670
});

impeller/entity/entity_unittests.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ TEST_P(EntityTest, BlendingModeOptions) {
923923
auto draw_rect = [&context, &pass, &world_matrix](
924924
Rect rect, Color color, BlendMode blend_mode) -> bool {
925925
using VS = SolidFillPipeline::VertexShader;
926+
using FS = SolidFillPipeline::FragmentShader;
926927

927928
VertexBufferBuilder<VS::PerVertexData> vtx_builder;
928929
{
@@ -947,10 +948,12 @@ TEST_P(EntityTest, BlendingModeOptions) {
947948

948949
VS::FrameInfo frame_info;
949950
frame_info.mvp = pass.GetOrthographicTransform() * world_matrix;
950-
frame_info.color = color.Premultiply();
951951
VS::BindFrameInfo(
952952
pass, context.GetTransientsBuffer().EmplaceUniform(frame_info));
953-
953+
FS::FragInfo frag_info;
954+
frag_info.color = color.Premultiply();
955+
FS::BindFragInfo(
956+
pass, context.GetTransientsBuffer().EmplaceUniform(frame_info));
954957
return pass.Draw().ok();
955958
};
956959

impeller/entity/shaders/solid_fill.frag

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ precision mediump float;
66

77
#include <impeller/types.glsl>
88

9-
IMPELLER_MAYBE_FLAT in f16vec4 v_color;
9+
uniform FragInfo {
10+
vec4 color;
11+
}
12+
frag_info;
1013

11-
out f16vec4 frag_color;
14+
out vec4 frag_color;
1215

1316
void main() {
14-
frag_color = v_color;
17+
frag_color = frag_info.color;
1518
}

impeller/entity/shaders/solid_fill.vert

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@
66

77
uniform FrameInfo {
88
mat4 mvp;
9-
f16vec4 color;
109
}
1110
frame_info;
1211

1312
in vec2 position;
1413

15-
IMPELLER_MAYBE_FLAT out mediump f16vec4 v_color;
16-
1714
void main() {
18-
v_color = frame_info.color;
1915
gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0);
2016
}

impeller/renderer/shader_stage_compatibility_checker.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#ifndef FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_
66
#define FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_
77

8+
#include <cstddef>
9+
10+
#include "impeller/core/shader_types.h"
11+
812
namespace impeller {
913
/// This is a classed use to check that the input slots of fragment shaders
1014
/// match the output slots of the vertex shaders.
@@ -58,11 +62,17 @@ class ShaderStageCompatibilityChecker {
5862
// TODO(https://github.com/flutter/flutter/issues/146852): Make impellerc emit
5963
// an empty array for output slots.
6064
struct ClipVertexShader;
65+
struct SolidFillVertexShader;
6166

6267
template <typename FragmentShaderT>
6368
class ShaderStageCompatibilityChecker<ClipVertexShader, FragmentShaderT> {
6469
public:
6570
static constexpr bool Check() { return true; }
6671
};
72+
template <typename FragmentShaderT>
73+
class ShaderStageCompatibilityChecker<SolidFillVertexShader, FragmentShaderT> {
74+
public:
75+
static constexpr bool Check() { return true; }
76+
};
6777
} // namespace impeller
6878
#endif // FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_

0 commit comments

Comments
 (0)