[Impeller] Add shader include with FlutterFragCoord for use by FragmentProgram (#114214)
This commit is contained in:
parent
9d64a0f40b
commit
e9c6212da0
@ -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 @@ float turbulence(vec2 uv) {
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -54,7 +54,7 @@ class DevelopmentShaderCompiler {
|
||||
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) {
|
||||
switch (platform) {
|
||||
case TargetPlatform.ios:
|
||||
_shaderTarget = enableImpeller ? ShaderTarget.impelleriOS : ShaderTarget.sksl;
|
||||
_shaderTarget = ShaderTarget.impelleriOS;
|
||||
break;
|
||||
case TargetPlatform.android_arm64:
|
||||
case TargetPlatform.android_x64:
|
||||
@ -175,6 +175,8 @@ class ShaderCompiler {
|
||||
);
|
||||
}
|
||||
|
||||
final String shaderLibPath = _fs.path.join(_fs.path.dirname(impellerc.path), 'shader_lib');
|
||||
|
||||
final List<String> cmd = <String>[
|
||||
impellerc.path,
|
||||
target.target,
|
||||
@ -186,6 +188,7 @@ class ShaderCompiler {
|
||||
'--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;
|
||||
|
@ -17,6 +17,8 @@ import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
||||
const String shaderLibDir = './shader_lib';
|
||||
|
||||
void main() {
|
||||
group('AssetBundle.build', () {
|
||||
late FileSystem testFileSystem;
|
||||
@ -452,6 +454,7 @@ flutter:
|
||||
'--input=/$shaderPath',
|
||||
'--input-type=frag',
|
||||
'--include=/$assetsPath',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
@ -498,6 +501,7 @@ flutter:
|
||||
'--input=/$shaderPath',
|
||||
'--input-type=frag',
|
||||
'--include=/$assetsPath',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
@ -538,6 +542,7 @@ flutter:
|
||||
'--input=${fileSystem.path.join(materialDir.path, 'shaders', 'ink_sparkle.frag')}',
|
||||
'--input-type=frag',
|
||||
'--include=${fileSystem.path.join(materialDir.path, 'shaders')}',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
|
@ -262,7 +262,8 @@ void main() {
|
||||
'--spirv=/App.framework/flutter_assets/shader.glsl.spirv',
|
||||
'--input=/shader.glsl',
|
||||
'--input-type=frag',
|
||||
'--include=/'
|
||||
'--include=/',
|
||||
'--include=./shader_lib',
|
||||
]),
|
||||
FakeCommand(command: <String>[
|
||||
'codesign',
|
||||
|
@ -16,6 +16,7 @@ import '../../../src/common.dart';
|
||||
import '../../../src/fake_process_manager.dart';
|
||||
|
||||
const String fragDir = '/shaders';
|
||||
const String shaderLibDir = './shader_lib';
|
||||
const String fragPath = '/shaders/my_shader.frag';
|
||||
const String notFragPath = '/shaders/not_a_frag.file';
|
||||
const String outputSpirvPath = '/output/shaders/my_shader.frag.spirv';
|
||||
@ -50,6 +51,7 @@ void main() {
|
||||
'--input=$fragPath',
|
||||
'--input-type=frag',
|
||||
'--include=$fragDir',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
@ -89,6 +91,7 @@ void main() {
|
||||
'--input=$fragPath',
|
||||
'--input-type=frag',
|
||||
'--include=$fragDir',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
@ -126,6 +129,7 @@ void main() {
|
||||
'--input=$fragPath',
|
||||
'--input-type=frag',
|
||||
'--include=$fragDir',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
@ -163,6 +167,7 @@ void main() {
|
||||
'--input=$notFragPath',
|
||||
'--input-type=frag',
|
||||
'--include=$fragDir',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
@ -202,6 +207,7 @@ void main() {
|
||||
'--input=$notFragPath',
|
||||
'--input-type=frag',
|
||||
'--include=$fragDir',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
stdout: 'impellerc stdout',
|
||||
stderr: 'impellerc stderr',
|
||||
@ -243,6 +249,7 @@ void main() {
|
||||
'--input=$fragPath',
|
||||
'--input-type=frag',
|
||||
'--include=$fragDir',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv').createSync();
|
||||
@ -287,6 +294,7 @@ void main() {
|
||||
'--input=$fragPath',
|
||||
'--input-type=frag',
|
||||
'--include=$fragDir',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv').createSync();
|
||||
@ -332,6 +340,7 @@ void main() {
|
||||
'--input=$fragPath',
|
||||
'--input-type=frag',
|
||||
'--include=$fragDir',
|
||||
'--include=$shaderLibDir',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv').createSync();
|
||||
|
Loading…
x
Reference in New Issue
Block a user