[impellerc] SkSL backend fix for the ink_sparkle shader (flutter/engine#34670)

This commit is contained in:
Zachary Anderson
2022-07-14 12:45:18 -07:00
committed by GitHub
parent da5e08bbae
commit c0170658ed
4 changed files with 66 additions and 5 deletions

View File

@@ -160,10 +160,7 @@ group("unittests") {
"//flutter/display_list:display_list_unittests",
"//flutter/flow:flow_unittests",
"//flutter/fml:fml_unittests",
"//flutter/lib/spirv/test/exception_shaders:spirv_compile_exception_shaders",
"//flutter/lib/spirv/test/general_shaders",
"//flutter/lib/spirv/test/supported_glsl_op_shaders",
"//flutter/lib/spirv/test/supported_op_shaders",
"//flutter/lib/spirv/test",
"//flutter/lib/ui:ui_unittests",
"//flutter/runtime:dart_plugin_registrant_unittests",
"//flutter/runtime:no_dart_plugin_registrant_unittests",

View File

@@ -306,7 +306,7 @@ void CompilerSkSL::emit_interface_block(const SPIRVariable& var) {
statement(variable_decl(type, to_name(var.self), var.self), ";");
if (output_name_.empty()) {
output_name_ = to_name(var.self);
} else {
} else if (to_name(var.self) != output_name_) {
SPIRV_CROSS_THROW("Only one output variable is supported: '" +
to_name(var.self) + "'");
}

View File

@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//flutter/impeller/tools/impeller.gni")
import("//flutter/testing/testing.gni")
if (enable_unittests) {
@@ -18,4 +19,28 @@ if (enable_unittests) {
"//third_party/vulkan-deps/spirv-tools/src:spvtools_val",
]
}
group("test") {
deps = [
":sksl_ink_sparkle",
":spirv_ink_sparkle",
"//flutter/lib/spirv/test/exception_shaders:spirv_compile_exception_shaders",
"//flutter/lib/spirv/test/general_shaders",
"//flutter/lib/spirv/test/supported_glsl_op_shaders",
"//flutter/lib/spirv/test/supported_op_shaders",
]
}
impellerc("spirv_ink_sparkle") {
shaders = [ "//flutter/impeller/fixtures/ink_sparkle.frag" ]
shader_target_flag = "--flutter-spirv"
intermediates_subdir = "spirv"
}
impellerc("sksl_ink_sparkle") {
shaders = [ "//flutter/impeller/fixtures/ink_sparkle.frag" ]
shader_target_flag = "--sksl"
intermediates_subdir = "sksl"
sl_file_extension = "sksl"
}
}

View File

@@ -184,6 +184,45 @@ void main() {
expect(toFloat(renderedBytes.getUint8(3)), closeTo(1.0, epsilon));
});
test('spirv for the ink_sparkle shader is accepted', () async {
final Uint8List spirv = await shaderFile(
path.join('spirv'),
'ink_sparkle.frag.spirv',
).readAsBytes();
final FragmentProgram program = await FragmentProgram.compile(
spirv: spirv.buffer,
);
final Shader shader = program.shader(
floatUniforms: Float32List(32),
);
await _imageByteDataFromShader(shader: shader);
// Testing that no exceptions are thrown. Tests that the ink_sparkle shader
// produces the correct pixels are in the framework.
});
test('sksl for the ink_sparkle shader is accepted', () async {
final Uint8List sksl = await shaderFile(
path.join('sksl'),
'ink_sparkle.frag.sksl',
).readAsBytes();
final FragmentProgram program = await FragmentProgram.compile(
raw: sksl.buffer,
uniformFloatCount: 32,
);
final Shader shader = program.shader(
floatUniforms: Float32List(32),
);
await _imageByteDataFromShader(shader: shader);
// Testing that no exceptions are thrown. Tests that the ink_sparkle shader
// produces the correct pixels are in the framework.
});
// Test all supported GLSL ops. See lib/spirv/lib/src/constants.dart
final Map<String, ByteBuffer> supportedGLSLOpShaders = _loadShaders(
path.join('supported_glsl_op_shaders', 'spirv'),