From 5735652166f24c122d1152b940333a487e58e8e6 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 31 Mar 2023 13:08:54 -0700 Subject: [PATCH] [Impeller] Declare gradient shader inputs as high precision to avoid overflows. (flutter/engine#40806) [Impeller] Declare gradient shader inputs as high precision to avoid overflows. --- .../entity/shaders/conical_gradient_fill.frag | 4 +- .../shaders/conical_gradient_ssbo_fill.frag | 4 +- .../entity/shaders/linear_gradient_fill.frag | 6 +- .../shaders/linear_gradient_ssbo_fill.frag | 6 +- .../entity/shaders/radial_gradient_fill.frag | 4 +- .../shaders/radial_gradient_ssbo_fill.frag | 4 +- .../entity/shaders/sweep_gradient_fill.frag | 4 +- .../shaders/sweep_gradient_ssbo_fill.frag | 4 +- engine/src/flutter/impeller/tools/malioc.json | 229 +++++++++--------- 9 files changed, 128 insertions(+), 137 deletions(-) diff --git a/engine/src/flutter/impeller/entity/shaders/conical_gradient_fill.frag b/engine/src/flutter/impeller/entity/shaders/conical_gradient_fill.frag index 3db916e3ba..b0400630d7 100644 --- a/engine/src/flutter/impeller/entity/shaders/conical_gradient_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/conical_gradient_fill.frag @@ -9,7 +9,7 @@ uniform sampler2D texture_sampler; uniform FragInfo { - vec2 center; + highp vec2 center; float radius; float tile_mode; float texture_sampler_y_coord_scale; @@ -20,7 +20,7 @@ uniform FragInfo { } frag_info; -in vec2 v_position; +highp in vec2 v_position; out vec4 frag_color; diff --git a/engine/src/flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag b/engine/src/flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag index 7fdc7b9e33..c633956b35 100644 --- a/engine/src/flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag @@ -17,7 +17,7 @@ layout(std140) readonly buffer ColorData { color_data; uniform FragInfo { - vec2 center; + highp vec2 center; float radius; float tile_mode; float alpha; @@ -27,7 +27,7 @@ uniform FragInfo { } frag_info; -in vec2 v_position; +highp in vec2 v_position; out vec4 frag_color; diff --git a/engine/src/flutter/impeller/entity/shaders/linear_gradient_fill.frag b/engine/src/flutter/impeller/entity/shaders/linear_gradient_fill.frag index f8a9a98695..d9deaba123 100644 --- a/engine/src/flutter/impeller/entity/shaders/linear_gradient_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/linear_gradient_fill.frag @@ -8,8 +8,8 @@ uniform sampler2D texture_sampler; uniform FragInfo { - vec2 start_point; - vec2 end_point; + highp vec2 start_point; + highp vec2 end_point; float tile_mode; float texture_sampler_y_coord_scale; float alpha; @@ -17,7 +17,7 @@ uniform FragInfo { } frag_info; -in vec2 v_position; +highp in vec2 v_position; out vec4 frag_color; diff --git a/engine/src/flutter/impeller/entity/shaders/linear_gradient_ssbo_fill.frag b/engine/src/flutter/impeller/entity/shaders/linear_gradient_ssbo_fill.frag index 45e4f9c7a0..183b3b7978 100644 --- a/engine/src/flutter/impeller/entity/shaders/linear_gradient_ssbo_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/linear_gradient_ssbo_fill.frag @@ -17,15 +17,15 @@ layout(std140) readonly buffer ColorData { color_data; uniform FragInfo { - vec2 start_point; - vec2 end_point; + highp vec2 start_point; + highp vec2 end_point; float alpha; float tile_mode; int colors_length; } frag_info; -in vec2 v_position; +highp in vec2 v_position; out vec4 frag_color; diff --git a/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.frag b/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.frag index 8ab1481711..e888562661 100644 --- a/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.frag @@ -8,7 +8,7 @@ uniform sampler2D texture_sampler; uniform FragInfo { - vec2 center; + highp vec2 center; float radius; float tile_mode; float texture_sampler_y_coord_scale; @@ -17,7 +17,7 @@ uniform FragInfo { } frag_info; -in vec2 v_position; +highp in vec2 v_position; out vec4 frag_color; diff --git a/engine/src/flutter/impeller/entity/shaders/radial_gradient_ssbo_fill.frag b/engine/src/flutter/impeller/entity/shaders/radial_gradient_ssbo_fill.frag index 6a05b4bdc5..d85ac4da04 100644 --- a/engine/src/flutter/impeller/entity/shaders/radial_gradient_ssbo_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/radial_gradient_ssbo_fill.frag @@ -17,7 +17,7 @@ layout(std140) readonly buffer ColorData { color_data; uniform FragInfo { - vec2 center; + highp vec2 center; float radius; float tile_mode; float alpha; @@ -25,7 +25,7 @@ uniform FragInfo { } frag_info; -in vec2 v_position; +highp in vec2 v_position; out vec4 frag_color; diff --git a/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.frag b/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.frag index ad896f5b1b..2c282bd8f1 100644 --- a/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.frag @@ -9,7 +9,7 @@ uniform sampler2D texture_sampler; uniform FragInfo { - vec2 center; + highp vec2 center; float bias; float scale; float tile_mode; @@ -19,7 +19,7 @@ uniform FragInfo { } frag_info; -in vec2 v_position; +highp in vec2 v_position; out vec4 frag_color; diff --git a/engine/src/flutter/impeller/entity/shaders/sweep_gradient_ssbo_fill.frag b/engine/src/flutter/impeller/entity/shaders/sweep_gradient_ssbo_fill.frag index 34bcb7415b..9e9f3e9748 100644 --- a/engine/src/flutter/impeller/entity/shaders/sweep_gradient_ssbo_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/sweep_gradient_ssbo_fill.frag @@ -18,7 +18,7 @@ layout(std140) readonly buffer ColorData { color_data; uniform FragInfo { - vec2 center; + highp vec2 center; float bias; float scale; float tile_mode; @@ -27,7 +27,7 @@ uniform FragInfo { } frag_info; -in vec2 v_position; +highp in vec2 v_position; out vec4 frag_color; diff --git a/engine/src/flutter/impeller/tools/malioc.json b/engine/src/flutter/impeller/tools/malioc.json index 9f6418dedd..98949f1969 100644 --- a/engine/src/flutter/impeller/tools/malioc.json +++ b/engine/src/flutter/impeller/tools/malioc.json @@ -1841,17 +1841,15 @@ "texture" ], "shortest_path_bound_pipelines": [ - "arith_total", - "arith_fma", - "arith_cvt" + "varying" ], "shortest_path_cycles": [ + 0.203125, 0.1875, - 0.1875, - 0.1875, + 0.203125, 0.0625, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ @@ -1859,12 +1857,12 @@ "arith_cvt" ], "total_cycles": [ - 0.421875, + 0.4375, 0.3125, - 0.421875, + 0.4375, 0.0625, 0.0, - 0.125, + 0.25, 0.25 ] }, @@ -1914,28 +1912,27 @@ "texture" ], "shortest_path_bound_pipelines": [ - "arith_total", - "arith_cvt" + "varying" ], "shortest_path_cycles": [ - 0.171875, + 0.1875, 0.140625, - 0.171875, + 0.1875, 0.0625, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ "load_store" ], "total_cycles": [ - 0.699999988079071, + 0.71875, 0.40625, - 0.699999988079071, + 0.71875, 0.125, 4.0, - 0.125, + 0.25, 0.0 ] }, @@ -6391,12 +6388,12 @@ "arith_cvt" ], "shortest_path_cycles": [ - 0.25, + 0.265625, 0.234375, - 0.25, + 0.265625, 0.1875, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ @@ -6404,12 +6401,12 @@ "arith_cvt" ], "total_cycles": [ - 0.59375, + 0.609375, 0.375, - 0.59375, + 0.609375, 0.1875, 0.0, - 0.125, + 0.25, 0.25 ] }, @@ -6460,7 +6457,7 @@ ] }, "thread_occupancy": 100, - "uniform_registers_used": 3, + "uniform_registers_used": 4, "work_registers_used": 2 } } @@ -7819,7 +7816,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 70, + "fp16_arithmetic": 52, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -7828,11 +7825,11 @@ ], "longest_path_cycles": [ 0.40625, - 0.28125, + 0.296875, 0.40625, 0.125, 0.0, - 0.125, + 0.25, 0.25 ], "pipelines": [ @@ -7845,16 +7842,15 @@ "texture" ], "shortest_path_bound_pipelines": [ - "arith_total", - "arith_cvt" + "varying" ], "shortest_path_cycles": [ 0.1875, - 0.171875, + 0.1875, 0.1875, 0.125, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ @@ -7863,17 +7859,17 @@ ], "total_cycles": [ 0.484375, - 0.3125, + 0.328125, 0.484375, 0.125, 0.0, - 0.125, + 0.25, 0.25 ] }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 12, + "uniform_registers_used": 14, "work_registers_used": 20 } } @@ -8802,7 +8798,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 55, + "fp16_arithmetic": 44, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -8810,12 +8806,12 @@ "arith_cvt" ], "longest_path_cycles": [ - 0.40625, + 0.4375, 0.3125, - 0.40625, + 0.4375, 0.1875, 0.0, - 0.125, + 0.25, 0.25 ], "pipelines": [ @@ -8828,16 +8824,15 @@ "texture" ], "shortest_path_bound_pipelines": [ - "arith_total", - "arith_fma" + "varying" ], "shortest_path_cycles": [ + 0.21875, 0.203125, - 0.203125, - 0.1875, + 0.21875, 0.1875, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ @@ -8845,18 +8840,18 @@ "arith_cvt" ], "total_cycles": [ - 0.484375, + 0.515625, 0.34375, - 0.484375, + 0.515625, 0.1875, 0.0, - 0.125, + 0.25, 0.25 ] }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 10, + "uniform_registers_used": 12, "work_registers_used": 20 } } @@ -8901,7 +8896,7 @@ ] }, "thread_occupancy": 100, - "uniform_registers_used": 2, + "uniform_registers_used": 3, "work_registers_used": 2 } } @@ -9851,20 +9846,21 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 15, + "fp16_arithmetic": 12, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "arith_total", + "arith_fma", "arith_cvt" ], "longest_path_cycles": [ - 0.5, - 0.453125, - 0.5, + 0.46875, + 0.46875, + 0.46875, 0.375, 0.0, - 0.125, + 0.25, 0.25 ], "pipelines": [ @@ -9882,11 +9878,11 @@ ], "shortest_path_cycles": [ 0.375, - 0.34375, - 0.28125, + 0.359375, + 0.25, 0.375, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ @@ -9894,12 +9890,12 @@ "arith_cvt" ], "total_cycles": [ - 0.59375, - 0.484375, - 0.59375, + 0.5625, + 0.5, + 0.5625, 0.375, 0.0, - 0.125, + 0.25, 0.25 ] }, @@ -11392,7 +11388,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 100, + "fp16_arithmetic": 90, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -11401,11 +11397,11 @@ ], "longest_path_cycles": [ 0.265625, - 0.21875, + 0.234375, 0.265625, 0.0, 0.0, - 0.125, + 0.25, 0.25 ], "pipelines": [ @@ -11418,18 +11414,15 @@ "texture" ], "shortest_path_bound_pipelines": [ - "arith_total", - "arith_fma", - "arith_cvt", "varying" ], "shortest_path_cycles": [ - 0.125, - 0.125, + 0.140625, + 0.140625, 0.125, 0.0, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ @@ -11438,11 +11431,11 @@ ], "total_cycles": [ 0.3125, - 0.25, + 0.265625, 0.3125, 0.0, 0.0, - 0.125, + 0.25, 0.25 ] }, @@ -11467,7 +11460,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 75, + "fp16_arithmetic": 70, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -11496,11 +11489,11 @@ ], "shortest_path_cycles": [ 0.109375, - 0.078125, + 0.09375, 0.109375, 0.0, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ @@ -11508,11 +11501,11 @@ ], "total_cycles": [ 0.59375, - 0.34375, + 0.359375, 0.59375, 0.0625, 4.0, - 0.125, + 0.25, 0.0 ] }, @@ -12130,7 +12123,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 73, + "fp16_arithmetic": 64, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -12138,12 +12131,12 @@ "arith_cvt" ], "longest_path_cycles": [ - 0.265625, + 0.296875, 0.25, - 0.265625, + 0.296875, 0.0625, 0.0, - 0.125, + 0.25, 0.25 ], "pipelines": [ @@ -12156,16 +12149,15 @@ "texture" ], "shortest_path_bound_pipelines": [ - "arith_total", - "arith_fma" + "varying" ], "shortest_path_cycles": [ 0.15625, 0.15625, - 0.125, + 0.15625, 0.0625, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ @@ -12173,18 +12165,18 @@ "arith_cvt" ], "total_cycles": [ - 0.3125, + 0.34375, 0.28125, - 0.3125, + 0.34375, 0.0625, 0.0, - 0.125, + 0.25, 0.25 ] }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 12, + "uniform_registers_used": 14, "work_registers_used": 6 } } @@ -12203,7 +12195,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 59, + "fp16_arithmetic": 52, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -12231,30 +12223,30 @@ "varying" ], "shortest_path_cycles": [ + 0.140625, 0.109375, - 0.109375, - 0.109375, + 0.140625, 0.0625, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ "load_store" ], "total_cycles": [ - 0.59375, + 0.625, 0.375, - 0.59375, + 0.625, 0.125, 4.0, - 0.125, + 0.25, 0.0 ] }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 10, + "uniform_registers_used": 12, "work_registers_used": 15 } } @@ -12889,7 +12881,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 18, + "fp16_arithmetic": 15, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -12897,12 +12889,12 @@ "arith_fma" ], "longest_path_cycles": [ - 0.40625, - 0.40625, - 0.390625, + 0.421875, + 0.421875, + 0.359375, 0.3125, 0.0, - 0.125, + 0.25, 0.25 ], "pipelines": [ @@ -12916,35 +12908,34 @@ ], "shortest_path_bound_pipelines": [ "arith_total", - "arith_fma", - "arith_sfu" + "arith_fma" ], "shortest_path_cycles": [ - 0.3125, - 0.3125, - 0.25, + 0.328125, + 0.328125, + 0.21875, 0.3125, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ "arith_total", - "arith_cvt" + "arith_fma" ], "total_cycles": [ 0.453125, - 0.4375, 0.453125, + 0.421875, 0.3125, 0.0, - 0.125, + 0.25, 0.25 ] }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 18, + "uniform_registers_used": 20, "work_registers_used": 16 } } @@ -12963,7 +12954,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 23, + "fp16_arithmetic": 20, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -12993,23 +12984,23 @@ ], "shortest_path_cycles": [ 0.3125, - 0.265625, - 0.21875, + 0.28125, + 0.1875, 0.3125, 0.0, - 0.125, + 0.25, 0.0 ], "total_bound_pipelines": [ "load_store" ], "total_cycles": [ - 0.71875, - 0.546875, - 0.71875, + 0.6875, + 0.5625, + 0.6875, 0.375, 4.0, - 0.125, + 0.25, 0.0 ] },