[Impeller] remove varying interpolation for solid colors. (flutter/engine#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.
This commit is contained in:
Jonah Williams
2024-06-11 10:36:22 -07:00
committed by GitHub
parent c3bf7cd875
commit 51c8b05cff
8 changed files with 91 additions and 178 deletions

View File

@@ -9,12 +9,6 @@
#extension GL_AMD_gpu_shader_half_float_fetch : enable
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable
#ifdef IMPELLER_TARGET_OPENGLES
#define IMPELLER_MAYBE_FLAT
#else
#define IMPELLER_MAYBE_FLAT flat
#endif
#ifndef IMPELLER_TARGET_METAL_IOS
precision mediump sampler2D;

View File

@@ -49,9 +49,12 @@ bool SolidColorContents::Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
using VS = SolidFillPipeline::VertexShader;
using FS = SolidFillPipeline::FragmentShader;
auto& host_buffer = renderer.GetTransientsBuffer();
VS::FrameInfo frame_info;
frame_info.color =
FS::FragInfo frag_info;
frag_info.color =
GetColor().Premultiply() * GetGeometry()->ComputeAlphaCoverage(entity);
PipelineBuilderCallback pipeline_callback =
@@ -60,7 +63,8 @@ bool SolidColorContents::Render(const ContentContext& renderer,
};
return ColorSourceContents::DrawGeometry<VS>(
renderer, entity, pass, pipeline_callback, frame_info,
[](RenderPass& pass) {
[&frag_info, &host_buffer](RenderPass& pass) {
FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
pass.SetCommandLabel("Solid Fill");
return true;
});

View File

@@ -923,6 +923,7 @@ TEST_P(EntityTest, BlendingModeOptions) {
auto draw_rect = [&context, &pass, &world_matrix](
Rect rect, Color color, BlendMode blend_mode) -> bool {
using VS = SolidFillPipeline::VertexShader;
using FS = SolidFillPipeline::FragmentShader;
VertexBufferBuilder<VS::PerVertexData> vtx_builder;
{
@@ -947,10 +948,12 @@ TEST_P(EntityTest, BlendingModeOptions) {
VS::FrameInfo frame_info;
frame_info.mvp = pass.GetOrthographicTransform() * world_matrix;
frame_info.color = color.Premultiply();
VS::BindFrameInfo(
pass, context.GetTransientsBuffer().EmplaceUniform(frame_info));
FS::FragInfo frag_info;
frag_info.color = color.Premultiply();
FS::BindFragInfo(
pass, context.GetTransientsBuffer().EmplaceUniform(frame_info));
return pass.Draw().ok();
};

View File

@@ -6,10 +6,13 @@ precision mediump float;
#include <impeller/types.glsl>
IMPELLER_MAYBE_FLAT in f16vec4 v_color;
uniform FragInfo {
vec4 color;
}
frag_info;
out f16vec4 frag_color;
out vec4 frag_color;
void main() {
frag_color = v_color;
frag_color = frag_info.color;
}

View File

@@ -6,15 +6,11 @@
uniform FrameInfo {
mat4 mvp;
f16vec4 color;
}
frame_info;
in vec2 position;
IMPELLER_MAYBE_FLAT out mediump f16vec4 v_color;
void main() {
v_color = frame_info.color;
gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0);
}

View File

@@ -5,6 +5,10 @@
#ifndef FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_
#define FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_
#include <cstddef>
#include "impeller/core/shader_types.h"
namespace impeller {
/// This is a classed use to check that the input slots of fragment shaders
/// match the output slots of the vertex shaders.
@@ -58,11 +62,17 @@ class ShaderStageCompatibilityChecker {
// TODO(https://github.com/flutter/flutter/issues/146852): Make impellerc emit
// an empty array for output slots.
struct ClipVertexShader;
struct SolidFillVertexShader;
template <typename FragmentShaderT>
class ShaderStageCompatibilityChecker<ClipVertexShader, FragmentShaderT> {
public:
static constexpr bool Check() { return true; }
};
template <typename FragmentShaderT>
class ShaderStageCompatibilityChecker<SolidFillVertexShader, FragmentShaderT> {
public:
static constexpr bool Check() { return true; }
};
} // namespace impeller
#endif // FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_

View File

@@ -4285,15 +4285,16 @@
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
"varying"
"arith_total",
"arith_cvt"
],
"longest_path_cycles": [
0.03125,
0.0625,
0.0,
0.0625,
0.0,
0.03125,
0.0,
0.0,
0.25,
0.0
],
"pipelines": [
@@ -4306,34 +4307,36 @@
"texture"
],
"shortest_path_bound_pipelines": [
"varying"
"arith_total",
"arith_cvt"
],
"shortest_path_cycles": [
0.03125,
0.0,
0.03125,
0.0,
0.0,
0.0,
0.0,
0.0,
0.25,
0.0
],
"total_bound_pipelines": [
"varying"
"arith_total",
"arith_cvt"
],
"total_cycles": [
0.03125,
0.0625,
0.0,
0.0625,
0.0,
0.03125,
0.0,
0.0,
0.25,
0.0
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 0,
"work_registers_used": 19
"uniform_registers_used": 2,
"work_registers_used": 18
}
}
},
@@ -4347,12 +4350,11 @@
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
"arithmetic",
"load_store"
"arithmetic"
],
"longest_path_cycles": [
1.0,
1.0,
0.0,
0.0
],
"pipelines": [
@@ -4361,25 +4363,24 @@
"texture"
],
"shortest_path_bound_pipelines": [
"arithmetic",
"load_store"
"arithmetic"
],
"shortest_path_cycles": [
1.0,
1.0,
0.0,
0.0
],
"total_bound_pipelines": [
"load_store"
"arithmetic"
],
"total_cycles": [
0.6666666865348816,
1.0,
0.0,
0.0
]
},
"thread_occupancy": 100,
"uniform_registers_used": 0,
"uniform_registers_used": 1,
"work_registers_used": 2
}
}
@@ -4389,7 +4390,7 @@
"Mali-G78": {
"core": "Mali-G78",
"filename": "flutter/impeller/entity/gles/solid_fill.vert.gles",
"has_uniform_computation": true,
"has_uniform_computation": false,
"type": "Vertex",
"variants": {
"Position": {
@@ -4440,59 +4441,8 @@
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 22,
"uniform_registers_used": 20,
"work_registers_used": 32
},
"Varying": {
"fp16_arithmetic": null,
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
"load_store"
],
"longest_path_cycles": [
0.03125,
0.0,
0.03125,
0.0,
2.0,
0.0
],
"pipelines": [
"arith_total",
"arith_fma",
"arith_cvt",
"arith_sfu",
"load_store",
"texture"
],
"shortest_path_bound_pipelines": [
"load_store"
],
"shortest_path_cycles": [
0.03125,
0.0,
0.03125,
0.0,
2.0,
0.0
],
"total_bound_pipelines": [
"load_store"
],
"total_cycles": [
0.03125,
0.0,
0.03125,
0.0,
2.0,
0.0
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 10,
"work_registers_used": 5
}
}
},
@@ -4510,7 +4460,7 @@
],
"longest_path_cycles": [
2.640000104904175,
4.0,
3.0,
0.0
],
"pipelines": [
@@ -4523,7 +4473,7 @@
],
"shortest_path_cycles": [
2.640000104904175,
4.0,
3.0,
0.0
],
"total_bound_pipelines": [
@@ -4531,12 +4481,12 @@
],
"total_cycles": [
2.6666667461395264,
4.0,
3.0,
0.0
]
},
"thread_occupancy": 100,
"uniform_registers_used": 6,
"uniform_registers_used": 5,
"work_registers_used": 2
}
}
@@ -7026,7 +6976,7 @@
"core": "Mali-G78",
"filename": "flutter/impeller/entity/solid_fill.frag.vkspv",
"has_side_effects": false,
"has_uniform_computation": false,
"has_uniform_computation": true,
"modifies_coverage": false,
"reads_color_buffer": false,
"type": "Fragment",
@@ -7038,15 +6988,16 @@
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
"varying"
"arith_total",
"arith_cvt"
],
"longest_path_cycles": [
0.0625,
0.0,
0.0625,
0.0,
0.0,
0.0,
0.0,
0.0,
0.25,
0.0
],
"pipelines": [
@@ -7059,34 +7010,36 @@
"texture"
],
"shortest_path_bound_pipelines": [
"varying"
"arith_total",
"arith_cvt"
],
"shortest_path_cycles": [
0.0625,
0.0,
0.0625,
0.0,
0.0,
0.0,
0.0,
0.0,
0.25,
0.0
],
"total_bound_pipelines": [
"varying"
"arith_total",
"arith_cvt"
],
"total_cycles": [
0.0625,
0.0,
0.0625,
0.0,
0.0,
0.0,
0.0,
0.0,
0.25,
0.0
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 0,
"work_registers_used": 3
"uniform_registers_used": 4,
"work_registers_used": 5
}
}
}
@@ -7146,59 +7099,8 @@
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 30,
"uniform_registers_used": 28,
"work_registers_used": 32
},
"Varying": {
"fp16_arithmetic": null,
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
"load_store"
],
"longest_path_cycles": [
0.03125,
0.0,
0.03125,
0.0,
2.0,
0.0
],
"pipelines": [
"arith_total",
"arith_fma",
"arith_cvt",
"arith_sfu",
"load_store",
"texture"
],
"shortest_path_bound_pipelines": [
"load_store"
],
"shortest_path_cycles": [
0.03125,
0.0,
0.03125,
0.0,
2.0,
0.0
],
"total_bound_pipelines": [
"load_store"
],
"total_cycles": [
0.03125,
0.0,
0.03125,
0.0,
2.0,
0.0
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 22,
"work_registers_used": 5
}
}
}

View File

@@ -246,20 +246,21 @@ def compare_performance(variant, before, after):
def compare_variants(befores, afters):
differences = []
for variant_name, before_variant in befores.items():
after_variant = afters[variant_name]
for variant_key, before_variant_val in before_variant.items():
after_variant_val = after_variant[variant_key]
if variant_key == 'performance':
differences += compare_performance(variant_name, before_variant_val, after_variant_val)
elif before_variant_val != after_variant_val:
differences += [
'In variant {}:\n {vkey}: {} <- before\n {vkey}: {} <- after'.format(
variant_name,
before_variant_val,
after_variant_val,
vkey=variant_key,
)
]
if variant_name in afters:
after_variant = afters[variant_name]
for variant_key, before_variant_val in before_variant.items():
after_variant_val = after_variant[variant_key]
if variant_key == 'performance':
differences += compare_performance(variant_name, before_variant_val, after_variant_val)
elif before_variant_val != after_variant_val:
differences += [
'In variant {}:\n {vkey}: {} <- before\n {vkey}: {} <- after'.format(
variant_name,
before_variant_val,
after_variant_val,
vkey=variant_key,
)
]
return differences