From f67fd036d661cbb99c85772448f753aa396a78be Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Fri, 31 Mar 2023 13:56:01 -0700 Subject: [PATCH] [Impeller] Increase precision of texture coordinate input (flutter/engine#40803) [Impeller] Increase precision of texture coordinate input --- .../compiler/shader_lib/impeller/texture.glsl | 8 +- .../impeller/entity/shaders/texture_fill.frag | 2 +- .../impeller/entity/shaders/texture_fill.vert | 8 +- .../entity/shaders/tiled_texture_fill.frag | 2 +- .../entity/shaders/tiled_texture_fill.vert | 10 +- engine/src/flutter/impeller/tools/malioc.json | 154 +++++++++--------- 6 files changed, 91 insertions(+), 93 deletions(-) diff --git a/engine/src/flutter/impeller/compiler/shader_lib/impeller/texture.glsl b/engine/src/flutter/impeller/compiler/shader_lib/impeller/texture.glsl index 3bbb580fb27..a952c0b9c64 100644 --- a/engine/src/flutter/impeller/compiler/shader_lib/impeller/texture.glsl +++ b/engine/src/flutter/impeller/compiler/shader_lib/impeller/texture.glsl @@ -100,13 +100,11 @@ const float16_t kTileModeDecalHf = 3.0hf; /// This is useful for Impeller graphics backend that don't have native support /// for Decal. f16vec4 IPHalfSampleWithTileMode(f16sampler2D tex, - f16vec2 coords, + vec2 coords, float16_t x_tile_mode, float16_t y_tile_mode) { - if (x_tile_mode == kTileModeDecalHf && - (coords.x < 0.0hf || coords.x >= 1.0hf) || - y_tile_mode == kTileModeDecalHf && - (coords.y < 0.0hf || coords.y >= 1.0hf)) { + if (x_tile_mode == kTileModeDecalHf && (coords.x < 0.0 || coords.x >= 1.0) || + y_tile_mode == kTileModeDecalHf && (coords.y < 0.0 || coords.y >= 1.0)) { return f16vec4(0.0hf); } diff --git a/engine/src/flutter/impeller/entity/shaders/texture_fill.frag b/engine/src/flutter/impeller/entity/shaders/texture_fill.frag index 85aae42445b..ecefa0c1058 100644 --- a/engine/src/flutter/impeller/entity/shaders/texture_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/texture_fill.frag @@ -11,7 +11,7 @@ uniform FragInfo { } frag_info; -in f16vec2 v_texture_coords; +in highp vec2 v_texture_coords; out f16vec4 frag_color; diff --git a/engine/src/flutter/impeller/entity/shaders/texture_fill.vert b/engine/src/flutter/impeller/entity/shaders/texture_fill.vert index b6af412649d..7adf4eef64c 100644 --- a/engine/src/flutter/impeller/entity/shaders/texture_fill.vert +++ b/engine/src/flutter/impeller/entity/shaders/texture_fill.vert @@ -11,13 +11,13 @@ uniform FrameInfo { } frame_info; -in vec2 position; +in highp vec2 position; in vec2 texture_coords; -out f16vec2 v_texture_coords; +out highp vec2 v_texture_coords; void main() { gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0); - v_texture_coords = f16vec2( - IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale)); + v_texture_coords = + IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale); } diff --git a/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.frag b/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.frag index 9d4a916a88f..39c135a72e8 100644 --- a/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.frag @@ -14,7 +14,7 @@ uniform FragInfo { } frag_info; -in f16vec2 v_texture_coords; +in highp vec2 v_texture_coords; out f16vec4 frag_color; diff --git a/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.vert b/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.vert index b6af412649d..bed2cb80be4 100644 --- a/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.vert +++ b/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.vert @@ -11,13 +11,13 @@ uniform FrameInfo { } frame_info; -in vec2 position; -in vec2 texture_coords; +in highp vec2 position; +in highp vec2 texture_coords; -out f16vec2 v_texture_coords; +out highp vec2 v_texture_coords; void main() { gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0); - v_texture_coords = f16vec2( - IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale)); + v_texture_coords = + IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale); } diff --git a/engine/src/flutter/impeller/tools/malioc.json b/engine/src/flutter/impeller/tools/malioc.json index 98949f19696..6c9fc4d8546 100644 --- a/engine/src/flutter/impeller/tools/malioc.json +++ b/engine/src/flutter/impeller/tools/malioc.json @@ -10083,16 +10083,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 80, + "fp16_arithmetic": 0, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.078125, - 0.078125, - 0.046875, + 0.140625, + 0.140625, + 0.0, 0.0, 2.0, 0.0 @@ -10109,9 +10109,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.078125, - 0.078125, - 0.046875, + 0.140625, + 0.140625, + 0.0, 0.0, 2.0, 0.0 @@ -10120,9 +10120,9 @@ "load_store" ], "total_cycles": [ - 0.078125, - 0.078125, - 0.046875, + 0.140625, + 0.140625, + 0.0, 0.0, 2.0, 0.0 @@ -10130,7 +10130,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 16, + "uniform_registers_used": 20, "work_registers_used": 32 }, "Varying": { @@ -10141,9 +10141,9 @@ "load_store" ], "longest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -10160,9 +10160,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -10171,9 +10171,9 @@ "load_store" ], "total_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -10182,7 +10182,7 @@ "stack_spill_bytes": 0, "thread_occupancy": 100, "uniform_registers_used": 10, - "work_registers_used": 7 + "work_registers_used": 9 } } }, @@ -10358,16 +10358,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 80, + "fp16_arithmetic": 0, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.078125, - 0.078125, - 0.046875, + 0.140625, + 0.140625, + 0.0, 0.0, 2.0, 0.0 @@ -10384,9 +10384,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.078125, - 0.078125, - 0.046875, + 0.140625, + 0.140625, + 0.0, 0.0, 2.0, 0.0 @@ -10395,9 +10395,9 @@ "load_store" ], "total_cycles": [ - 0.078125, - 0.078125, - 0.046875, + 0.140625, + 0.140625, + 0.0, 0.0, 2.0, 0.0 @@ -10405,20 +10405,20 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 16, + "uniform_registers_used": 20, "work_registers_used": 32 }, "Varying": { - "fp16_arithmetic": 100, + "fp16_arithmetic": 0, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.03125, + 0.078125, 0.015625, - 0.03125, + 0.078125, 0.0, 3.0, 0.0 @@ -10435,9 +10435,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.03125, - 0.015625, - 0.03125, + 0.0625, + 0.0, + 0.0625, 0.0, 3.0, 0.0 @@ -10446,9 +10446,9 @@ "load_store" ], "total_cycles": [ - 0.03125, + 0.078125, 0.015625, - 0.03125, + 0.078125, 0.0, 3.0, 0.0 @@ -10457,7 +10457,7 @@ "stack_spill_bytes": 0, "thread_occupancy": 100, "uniform_registers_used": 10, - "work_registers_used": 7 + "work_registers_used": 9 } } }, @@ -10502,7 +10502,7 @@ }, "thread_occupancy": 100, "uniform_registers_used": 4, - "work_registers_used": 2 + "work_registers_used": 3 } } } @@ -13093,16 +13093,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 100, + "fp16_arithmetic": 0, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.0625, - 0.0625, - 0.0625, + 0.125, + 0.125, + 0.0, 0.0, 2.0, 0.0 @@ -13119,9 +13119,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.0625, - 0.0625, - 0.0625, + 0.125, + 0.125, + 0.0, 0.0, 2.0, 0.0 @@ -13130,9 +13130,9 @@ "load_store" ], "total_cycles": [ - 0.0625, - 0.0625, - 0.0625, + 0.125, + 0.125, + 0.0, 0.0, 2.0, 0.0 @@ -13140,7 +13140,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 20, + "uniform_registers_used": 30, "work_registers_used": 32 }, "Varying": { @@ -13151,9 +13151,9 @@ "load_store" ], "longest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -13170,9 +13170,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -13181,9 +13181,9 @@ "load_store" ], "total_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -13191,8 +13191,8 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 16, - "work_registers_used": 7 + "uniform_registers_used": 22, + "work_registers_used": 9 } } } @@ -13277,16 +13277,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 100, + "fp16_arithmetic": 0, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.0625, - 0.0625, - 0.0625, + 0.125, + 0.125, + 0.0, 0.0, 2.0, 0.0 @@ -13303,9 +13303,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.0625, - 0.0625, - 0.0625, + 0.125, + 0.125, + 0.0, 0.0, 2.0, 0.0 @@ -13314,9 +13314,9 @@ "load_store" ], "total_cycles": [ - 0.0625, - 0.0625, - 0.0625, + 0.125, + 0.125, + 0.0, 0.0, 2.0, 0.0 @@ -13324,7 +13324,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 20, + "uniform_registers_used": 30, "work_registers_used": 32 }, "Varying": { @@ -13335,9 +13335,9 @@ "load_store" ], "longest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -13354,9 +13354,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -13365,9 +13365,9 @@ "load_store" ], "total_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -13375,8 +13375,8 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 16, - "work_registers_used": 7 + "uniform_registers_used": 22, + "work_registers_used": 9 } } }