Add shader include with FlutterFragCoord
diff --git a/packages/flutter/lib/src/material/shaders/ink_sparkle.frag b/packages/flutter/lib/src/material/shaders/ink_sparkle.frag
index b94541d..aa82583 100644
--- a/packages/flutter/lib/src/material/shaders/ink_sparkle.frag
+++ b/packages/flutter/lib/src/material/shaders/ink_sparkle.frag
@@ -6,6 +6,8 @@
precision highp float;
+#include <flutter/runtime_effect.glsl>
+
// TODO(antrob): Put these in a more logical order (e.g. separate consts vs varying, etc)
layout(location = 0) uniform vec4 u_color;
@@ -88,7 +90,7 @@
}
void main() {
- vec2 p = gl_FragCoord.xy;
+ vec2 p = FlutterFragCoord();
vec2 uv = p * u_resolution_scale;
vec2 density_uv = uv - mod(p, u_noise_scale);
float radius = u_max_radius * u_radius_scale;
diff --git a/packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart b/packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart
index b63307f..f36ff9a 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'dart:io' show Platform;
import 'dart:math' as math;
import 'dart:typed_data';
import 'package:meta/meta.dart';
import 'package:pool/pool.dart';
+import "package:path/path.dart" show dirname, join;
import 'package:process/process.dart';
-
import '../../artifacts.dart';
import '../../base/error_handling_io.dart';
import '../../base/file_system.dart';
@@ -168,6 +169,10 @@
);
}
+ // TODO(bdero): This path is intended to be identical to `impeller/compiler/shader_lib` in the engine.
+ // Update this path once the shader lib ships in the engine artifacts.
+ final String shaderLibPath = join(dirname(Platform.script.path), '../../shader_lib');
+
final List<String> cmd = <String>[
impellerc.path,
target.target,
@@ -177,6 +182,7 @@
'--input=${input.path}',
'--input-type=frag',
'--include=${input.parent.path}',
+ '--include=$shaderLibPath',
];
final Process impellercProcess = await _processManager.start(cmd);
final int code = await impellercProcess.exitCode;
diff --git a/shader_lib/flutter/runtime_effect.glsl b/shader_lib/flutter/runtime_effect.glsl
new file mode 100644
index 0000000..e72ba4f
--- /dev/null
+++ b/shader_lib/flutter/runtime_effect.glsl
@@ -0,0 +1,20 @@
+// 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.
+
+#if defined(IMPELLER_GRAPHICS_BACKEND)
+
+in vec2 _fragCoord;
+vec2 FlutterFragCoord() {
+ return _fragCoord;
+}
+
+#elif defined(SKIA_GRAPHICS_BACKEND)
+
+vec2 FlutterFragCoord() {
+ return gl_FragCoord.xy;
+}
+
+#else
+#error "Runtime effect builtins are not supported for this graphics backend."
+#endif