[Impeller] Statically check stage interfaces for precision mismatches. (flutter/engine#54375)
Fixes https://github.com/flutter/flutter/issues/147078
This commit is contained in:
@@ -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<const ShaderStageIOSlot*, {{length(stage_outputs)}}> kAllShaderStageOutputs = {
|
||||
|
||||
@@ -655,12 +655,15 @@ std::optional<nlohmann::json::object_t> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 //
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -18,7 +18,7 @@ uniform FragInfo {
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in highp vec2 v_texture_coords;
|
||||
in mediump vec2 v_texture_coords;
|
||||
|
||||
out f16vec4 frag_color;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user