diff --git a/engine/src/flutter/BUILD.gn b/engine/src/flutter/BUILD.gn index 9b1d448ba2..9519cbcb46 100644 --- a/engine/src/flutter/BUILD.gn +++ b/engine/src/flutter/BUILD.gn @@ -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", diff --git a/engine/src/flutter/impeller/compiler/spirv_sksl.cc b/engine/src/flutter/impeller/compiler/spirv_sksl.cc index a16f93476c..cbad7d96e4 100644 --- a/engine/src/flutter/impeller/compiler/spirv_sksl.cc +++ b/engine/src/flutter/impeller/compiler/spirv_sksl.cc @@ -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) + "'"); } diff --git a/engine/src/flutter/lib/spirv/test/BUILD.gn b/engine/src/flutter/lib/spirv/test/BUILD.gn index 522392c2f1..667e696c31 100644 --- a/engine/src/flutter/lib/spirv/test/BUILD.gn +++ b/engine/src/flutter/lib/spirv/test/BUILD.gn @@ -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" + } } diff --git a/engine/src/flutter/testing/dart/fragment_shader_test.dart b/engine/src/flutter/testing/dart/fragment_shader_test.dart index 87d8be1f7f..8bc4927cb2 100644 --- a/engine/src/flutter/testing/dart/fragment_shader_test.dart +++ b/engine/src/flutter/testing/dart/fragment_shader_test.dart @@ -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 supportedGLSLOpShaders = _loadShaders( path.join('supported_glsl_op_shaders', 'spirv'),