diff --git a/impeller/compiler/shader_lib/impeller/types.glsl b/impeller/compiler/shader_lib/impeller/types.glsl index b0ce4188d08ee..ad1a0e86cf93f 100644 --- a/impeller/compiler/shader_lib/impeller/types.glsl +++ b/impeller/compiler/shader_lib/impeller/types.glsl @@ -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; diff --git a/impeller/entity/contents/solid_color_contents.cc b/impeller/entity/contents/solid_color_contents.cc index a823b603179b9..cb41781729f8f 100644 --- a/impeller/entity/contents/solid_color_contents.cc +++ b/impeller/entity/contents/solid_color_contents.cc @@ -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( 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; }); diff --git a/impeller/entity/entity_unittests.cc b/impeller/entity/entity_unittests.cc index 3025eec1d9364..6605ea81da3b1 100644 --- a/impeller/entity/entity_unittests.cc +++ b/impeller/entity/entity_unittests.cc @@ -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 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(); }; diff --git a/impeller/entity/shaders/solid_fill.frag b/impeller/entity/shaders/solid_fill.frag index ed376a71d85bb..b00d69b2db7e0 100644 --- a/impeller/entity/shaders/solid_fill.frag +++ b/impeller/entity/shaders/solid_fill.frag @@ -6,10 +6,13 @@ precision mediump float; #include -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; } diff --git a/impeller/entity/shaders/solid_fill.vert b/impeller/entity/shaders/solid_fill.vert index edbdb8c1436ff..4d8e67e74a2ef 100644 --- a/impeller/entity/shaders/solid_fill.vert +++ b/impeller/entity/shaders/solid_fill.vert @@ -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); } diff --git a/impeller/renderer/shader_stage_compatibility_checker.h b/impeller/renderer/shader_stage_compatibility_checker.h index 5d59422ecde6b..666b58c61290c 100644 --- a/impeller/renderer/shader_stage_compatibility_checker.h +++ b/impeller/renderer/shader_stage_compatibility_checker.h @@ -5,6 +5,10 @@ #ifndef FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_ #define FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_ +#include + +#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 class ShaderStageCompatibilityChecker { public: static constexpr bool Check() { return true; } }; +template +class ShaderStageCompatibilityChecker { + public: + static constexpr bool Check() { return true; } +}; } // namespace impeller #endif // FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_ diff --git a/impeller/tools/malioc.json b/impeller/tools/malioc.json index 7d0be585bf7b4..b0ac489c58bb2 100644 --- a/impeller/tools/malioc.json +++ b/impeller/tools/malioc.json @@ -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.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.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.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.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 } } } diff --git a/impeller/tools/malioc_diff.py b/impeller/tools/malioc_diff.py index 7df66e5190c59..c48c515084758 100755 --- a/impeller/tools/malioc_diff.py +++ b/impeller/tools/malioc_diff.py @@ -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