diff --git a/impeller/compiler/code_gen_template.h b/impeller/compiler/code_gen_template.h index dbef3017c0e41..785043493a4bb 100644 --- a/impeller/compiler/code_gen_template.h +++ b/impeller/compiler/code_gen_template.h @@ -88,6 +88,7 @@ struct {{camel_case(shader_name)}}{{camel_case(shader_stage)}}Shader { {{stage_input.type.vec_size}}u, // vec size {{stage_input.type.columns}}u, // number of columns {{stage_input.offset}}u, // offset for interleaved layout + {{stage_input.relaxed_precision}}, // relaxed precision }; {% endfor %} {% endif %} @@ -140,7 +141,9 @@ struct {{camel_case(shader_name)}}{{camel_case(shader_stage)}}Shader { {{stage_output.type.type_name}}, // type {{stage_output.type.bit_width}}u, // bit width of type {{stage_output.type.vec_size}}u, // vec size - {{stage_output.type.columns}}u // number of columns + {{stage_output.type.columns}}u, // number of columns + {{stage_output.offset}}u, // offset for interleaved layout + {{stage_output.relaxed_precision}}, // relaxed precision }; {% endfor %} static constexpr std::array kAllShaderStageOutputs = { diff --git a/impeller/compiler/reflector.cc b/impeller/compiler/reflector.cc index d3ce90e396a39..23792ea6924ba 100644 --- a/impeller/compiler/reflector.cc +++ b/impeller/compiler/reflector.cc @@ -655,12 +655,15 @@ std::optional Reflector::ReflectResource( CompilerBackend::ExtendedResourceIndex::kPrimary, resource.id); result["ext_res_1"] = compiler_.GetExtendedMSLResourceBinding( CompilerBackend::ExtendedResourceIndex::kSecondary, resource.id); + result["relaxed_precision"] = + compiler_->get_decoration( + resource.id, spv::Decoration::DecorationRelaxedPrecision) == 1; + result["offset"] = offset.value_or(0u); auto type = ReflectType(resource.type_id); if (!type.has_value()) { return std::nullopt; } result["type"] = std::move(type.value()); - result["offset"] = offset.value_or(0u); return result; } diff --git a/impeller/core/shader_types.h b/impeller/core/shader_types.h index 25c405b1f0cb9..f3759552f4877 100644 --- a/impeller/core/shader_types.h +++ b/impeller/core/shader_types.h @@ -119,22 +119,25 @@ struct ShaderStageIOSlot { size_t vec_size; size_t columns; size_t offset; + bool relaxed_precision; constexpr size_t GetHash() const { return fml::HashCombine(name, location, set, binding, type, bit_width, - vec_size, columns, offset); + vec_size, columns, offset, relaxed_precision); } constexpr bool operator==(const ShaderStageIOSlot& other) const { - return name == other.name && // - location == other.location && // - set == other.set && // - binding == other.binding && // - type == other.type && // - bit_width == other.bit_width && // - vec_size == other.vec_size && // - columns == other.columns && // - offset == other.offset; + return name == other.name && // + location == other.location && // + set == other.set && // + binding == other.binding && // + type == other.type && // + bit_width == other.bit_width && // + vec_size == other.vec_size && // + columns == other.columns && // + offset == other.offset && // + relaxed_precision == other.relaxed_precision // + ; } }; diff --git a/impeller/entity/shaders/blending/porter_duff_blend.vert b/impeller/entity/shaders/blending/porter_duff_blend.vert index f7fe022c14a3d..56c115e23df2c 100644 --- a/impeller/entity/shaders/blending/porter_duff_blend.vert +++ b/impeller/entity/shaders/blending/porter_duff_blend.vert @@ -15,7 +15,7 @@ in vec2 vertices; in vec2 texture_coords; in vec4 color; -out vec2 v_texture_coords; +out mediump vec2 v_texture_coords; out mediump f16vec4 v_color; void main() { diff --git a/impeller/entity/shaders/blending/vertices_uber.frag b/impeller/entity/shaders/blending/vertices_uber.frag index fd66cae06b3b4..46d578192b293 100644 --- a/impeller/entity/shaders/blending/vertices_uber.frag +++ b/impeller/entity/shaders/blending/vertices_uber.frag @@ -19,7 +19,7 @@ frag_info; uniform f16sampler2D texture_sampler; -in highp vec2 v_texture_coords; +in mediump vec2 v_texture_coords; in mediump f16vec4 v_color; out f16vec4 frag_color; diff --git a/impeller/entity/shaders/texture_uv_fill.vert b/impeller/entity/shaders/texture_uv_fill.vert index 11e91d833c7bf..786aedd042280 100644 --- a/impeller/entity/shaders/texture_uv_fill.vert +++ b/impeller/entity/shaders/texture_uv_fill.vert @@ -16,7 +16,7 @@ frame_info; in vec2 position; -out vec2 v_texture_coords; +out mediump vec2 v_texture_coords; void main() { gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0); diff --git a/impeller/entity/shaders/tiled_texture_fill.frag b/impeller/entity/shaders/tiled_texture_fill.frag index 25b2af3526ecf..8061712591792 100644 --- a/impeller/entity/shaders/tiled_texture_fill.frag +++ b/impeller/entity/shaders/tiled_texture_fill.frag @@ -18,7 +18,7 @@ uniform FragInfo { } frag_info; -in highp vec2 v_texture_coords; +in mediump vec2 v_texture_coords; out f16vec4 frag_color; diff --git a/impeller/renderer/shader_stage_compatibility_checker.h b/impeller/renderer/shader_stage_compatibility_checker.h index 666b58c61290c..f8fc35336fc05 100644 --- a/impeller/renderer/shader_stage_compatibility_checker.h +++ b/impeller/renderer/shader_stage_compatibility_checker.h @@ -47,7 +47,8 @@ class ShaderStageCompatibilityChecker { input_slot->bit_width != output_slot->bit_width || input_slot->vec_size != output_slot->vec_size || input_slot->columns != output_slot->columns || - input_slot->offset != output_slot->offset) { + input_slot->offset != output_slot->offset || + input_slot->relaxed_precision != output_slot->relaxed_precision) { return false; } } diff --git a/impeller/tools/malioc.json b/impeller/tools/malioc.json index 55e276afed8e8..c6e8eb402db34 100644 --- a/impeller/tools/malioc.json +++ b/impeller/tools/malioc.json @@ -3628,9 +3628,9 @@ "load_store" ], "longest_path_cycles": [ + 0.109375, 0.015625, - 0.015625, - 0.015625, + 0.109375, 0.0, 4.0, 0.0 @@ -3647,9 +3647,9 @@ "load_store" ], "shortest_path_cycles": [ + 0.109375, 0.015625, - 0.015625, - 0.015625, + 0.109375, 0.0, 4.0, 0.0 @@ -3658,9 +3658,9 @@ "load_store" ], "total_cycles": [ + 0.109375, 0.015625, - 0.015625, - 0.015625, + 0.109375, 0.0, 4.0, 0.0 @@ -5321,7 +5321,7 @@ "longest_path_cycles": [ 0.078125, 0.078125, - 0.015625, + 0.078125, 0.0, 3.0, 0.0 @@ -5340,7 +5340,7 @@ "shortest_path_cycles": [ 0.078125, 0.078125, - 0.015625, + 0.078125, 0.0, 3.0, 0.0 @@ -5351,7 +5351,7 @@ "total_cycles": [ 0.078125, 0.078125, - 0.015625, + 0.078125, 0.0, 3.0, 0.0 @@ -5360,7 +5360,7 @@ "stack_spill_bytes": 0, "thread_occupancy": 100, "uniform_registers_used": 16, - "work_registers_used": 9 + "work_registers_used": 8 } } }, @@ -6605,9 +6605,9 @@ "load_store" ], "longest_path_cycles": [ + 0.078125, 0.015625, - 0.015625, - 0.015625, + 0.078125, 0.0, 4.0, 0.0 @@ -6624,9 +6624,9 @@ "load_store" ], "shortest_path_cycles": [ + 0.078125, 0.015625, - 0.015625, - 0.015625, + 0.078125, 0.0, 4.0, 0.0 @@ -6635,9 +6635,9 @@ "load_store" ], "total_cycles": [ + 0.078125, 0.015625, - 0.015625, - 0.015625, + 0.078125, 0.0, 4.0, 0.0 @@ -6646,7 +6646,7 @@ "stack_spill_bytes": 0, "thread_occupancy": 100, "uniform_registers_used": 22, - "work_registers_used": 9 + "work_registers_used": 8 } } } @@ -7840,7 +7840,7 @@ "longest_path_cycles": [ 0.078125, 0.078125, - 0.015625, + 0.078125, 0.0, 3.0, 0.0 @@ -7859,7 +7859,7 @@ "shortest_path_cycles": [ 0.078125, 0.078125, - 0.015625, + 0.078125, 0.0, 3.0, 0.0 @@ -7870,7 +7870,7 @@ "total_cycles": [ 0.078125, 0.078125, - 0.015625, + 0.078125, 0.0, 3.0, 0.0 @@ -7879,7 +7879,7 @@ "stack_spill_bytes": 0, "thread_occupancy": 100, "uniform_registers_used": 32, - "work_registers_used": 9 + "work_registers_used": 8 } } }