diff --git a/engine/src/flutter/impeller/runtime_stage/runtime_stage.cc b/engine/src/flutter/impeller/runtime_stage/runtime_stage.cc index 52c1470a6a..01955ee373 100644 --- a/engine/src/flutter/impeller/runtime_stage/runtime_stage.cc +++ b/engine/src/flutter/impeller/runtime_stage/runtime_stage.cc @@ -75,17 +75,18 @@ RuntimeStage::RuntimeStage(std::shared_ptr payload) stage_ = ToShaderStage(runtime_stage->stage()); entrypoint_ = runtime_stage->entrypoint()->str(); - for (auto i = runtime_stage->uniforms()->begin(), - end = runtime_stage->uniforms()->end(); - i != end; i++) { - RuntimeUniformDescription desc; - desc.name = i->name()->str(); - desc.location = i->location(); - desc.type = ToType(i->type()); - desc.dimensions = RuntimeUniformDimensions{ - static_cast(i->rows()), static_cast(i->columns())}; - desc.bit_width = i->bit_width(); - uniforms_.emplace_back(std::move(desc)); + auto* uniforms = runtime_stage->uniforms(); + if (uniforms) { + for (auto i = uniforms->begin(), end = uniforms->end(); i != end; i++) { + RuntimeUniformDescription desc; + desc.name = i->name()->str(); + desc.location = i->location(); + desc.type = ToType(i->type()); + desc.dimensions = RuntimeUniformDimensions{ + static_cast(i->rows()), static_cast(i->columns())}; + desc.bit_width = i->bit_width(); + uniforms_.emplace_back(std::move(desc)); + } } code_mapping_ = std::make_shared( diff --git a/engine/src/flutter/lib/spirv/test/general_shaders/BUILD.gn b/engine/src/flutter/lib/spirv/test/general_shaders/BUILD.gn index 596856fac8..4eb3fd746e 100644 --- a/engine/src/flutter/lib/spirv/test/general_shaders/BUILD.gn +++ b/engine/src/flutter/lib/spirv/test/general_shaders/BUILD.gn @@ -11,6 +11,7 @@ if (enable_unittests) { "blue_green_sampler.frag", "children_and_uniforms.frag", "functions.frag", + "no_uniforms.frag", "simple.frag", "uniforms.frag", "uniforms_sorted.frag", diff --git a/engine/src/flutter/lib/spirv/test/general_shaders/no_uniforms.frag b/engine/src/flutter/lib/spirv/test/general_shaders/no_uniforms.frag new file mode 100644 index 0000000000..a88db93039 --- /dev/null +++ b/engine/src/flutter/lib/spirv/test/general_shaders/no_uniforms.frag @@ -0,0 +1,13 @@ +#version 320 es + +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +precision highp float; + +layout(location = 0) out vec4 fragColor; + +void main() { + fragColor = vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/engine/src/flutter/testing/dart/fragment_shader_test.dart b/engine/src/flutter/testing/dart/fragment_shader_test.dart index 7cab4f1b71..9598ac3cd6 100644 --- a/engine/src/flutter/testing/dart/fragment_shader_test.dart +++ b/engine/src/flutter/testing/dart/fragment_shader_test.dart @@ -319,6 +319,14 @@ void main() { expect(throws, equals(true)); }); + test('iplr accepts a shader with no uniforms', () async { + final FragmentProgram program = FragmentProgram.fromAsset( + 'no_uniforms.frag.iplr', + ); + final Shader shader = program.shader(); + await _expectShaderRendersGreen(shader); + }); + // Test all supported GLSL ops. See lib/spirv/lib/src/constants.dart final Map supportedGLSLOpShaders = _loadShaders( path.join('supported_glsl_op_shaders', 'spirv'),