Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
dd20919a
Unverified
Commit
dd20919a
authored
Jul 22, 2022
by
Zachary Anderson
Committed by
GitHub
Jul 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Build shaders as .iplr and use FragmentProgram.fromAsset for ink_sparkle (#108071)
parent
cc62a5b9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
19 deletions
+30
-19
ink_sparkle.dart
packages/flutter/lib/src/material/ink_sparkle.dart
+1
-8
shader_compiler.dart
...r_tools/lib/src/build_system/targets/shader_compiler.dart
+6
-2
asset_bundle_test.dart
...s/flutter_tools/test/general.shard/asset_bundle_test.dart
+5
-2
shader_compiler_test.dart
...eral.shard/build_system/targets/shader_compiler_test.dart
+18
-7
No files found.
packages/flutter/lib/src/material/ink_sparkle.dart
View file @
dd20919a
...
@@ -7,7 +7,6 @@ import 'dart:math' as math;
...
@@ -7,7 +7,6 @@ import 'dart:math' as math;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'dart:ui'
as
ui
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
...
@@ -522,16 +521,10 @@ class FragmentShaderManager {
...
@@ -522,16 +521,10 @@ class FragmentShaderManager {
/// Creates an [FragmentShaderManager] with an [InkSparkle] effect.
/// Creates an [FragmentShaderManager] with an [InkSparkle] effect.
static
Future
<
FragmentShaderManager
>
inkSparkle
()
async
{
static
Future
<
FragmentShaderManager
>
inkSparkle
()
async
{
final
FragmentShaderManager
manager
=
FragmentShaderManager
.
_
();
final
FragmentShaderManager
manager
=
FragmentShaderManager
.
_
();
await
manager
.
_compile
(
);
_program
=
ui
.
FragmentProgram
.
fromAsset
(
'shaders/ink_sparkle.frag'
);
return
manager
;
return
manager
;
}
}
/// Compiles the spir-v bytecode into a shader program.
Future
<
void
>
_compile
()
async
{
final
ByteData
data
=
await
rootBundle
.
load
(
'shaders/ink_sparkle.frag'
);
_program
=
await
ui
.
FragmentProgram
.
compile
(
spirv:
data
.
buffer
);
}
/// Creates a shader with the original program and optional uniforms.
/// Creates a shader with the original program and optional uniforms.
///
///
/// A new shader must be made whenever the uniforms are updated.
/// A new shader must be made whenever the uniforms are updated.
...
...
packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart
View file @
dd20919a
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
'package:process/process.dart'
;
import
'package:process/process.dart'
;
import
'../../artifacts.dart'
;
import
'../../artifacts.dart'
;
import
'../../base/error_handling_io.dart'
;
import
'../../base/file_system.dart'
;
import
'../../base/file_system.dart'
;
import
'../../base/io.dart'
;
import
'../../base/io.dart'
;
import
'../../base/logger.dart'
;
import
'../../base/logger.dart'
;
...
@@ -64,8 +65,10 @@ class ShaderCompiler {
...
@@ -64,8 +65,10 @@ class ShaderCompiler {
// TODO(zanderso): When impeller is enabled, the correct flags for the
// TODO(zanderso): When impeller is enabled, the correct flags for the
// target backend will need to be passed.
// target backend will need to be passed.
// https://github.com/flutter/flutter/issues/102853
// https://github.com/flutter/flutter/issues/102853
'--flutter-spirv'
,
'--sksl'
,
'--spirv=
$outputPath
'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputPath
.spirv'
,
'--input=
${input.path}
'
,
'--input=
${input.path}
'
,
'--input-type=frag'
,
'--input-type=frag'
,
'--include=
${input.parent.path}
'
,
'--include=
${input.parent.path}
'
,
...
@@ -81,6 +84,7 @@ class ShaderCompiler {
...
@@ -81,6 +84,7 @@ class ShaderCompiler {
);
);
}
}
ErrorHandlingFileSystem
.
deleteIfExists
(
_fs
.
file
(
'
$outputPath
.spirv'
));
return
true
;
return
true
;
}
}
}
}
...
...
packages/flutter_tools/test/general.shard/asset_bundle_test.dart
View file @
dd20919a
...
@@ -443,14 +443,17 @@ flutter:
...
@@ -443,14 +443,17 @@ flutter:
FakeCommand
(
FakeCommand
(
command:
<
String
>[
command:
<
String
>[
impellerc
,
impellerc
,
'--flutter-spirv'
,
'--sksl'
,
'--spirv=
$outputPath
'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputPath
.spirv'
,
'--input=/
$shaderPath
'
,
'--input=/
$shaderPath
'
,
'--input-type=frag'
,
'--input-type=frag'
,
'--include=/
$assetsPath
'
,
'--include=/
$assetsPath
'
,
],
],
onRun:
()
{
onRun:
()
{
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'
$outputPath
.spirv'
).
createSync
(
recursive:
true
);
},
},
),
),
]),
]),
...
...
packages/flutter_tools/test/general.shard/build_system/targets/shader_compiler_test.dart
View file @
dd20919a
...
@@ -13,7 +13,8 @@ import '../../../src/fake_process_manager.dart';
...
@@ -13,7 +13,8 @@ import '../../../src/fake_process_manager.dart';
const
String
fragDir
=
'/shaders'
;
const
String
fragDir
=
'/shaders'
;
const
String
fragPath
=
'/shaders/my_shader.frag'
;
const
String
fragPath
=
'/shaders/my_shader.frag'
;
const
String
notFragPath
=
'/shaders/not_a_frag.file'
;
const
String
notFragPath
=
'/shaders/not_a_frag.file'
;
const
String
outputPath
=
'/output/shaders/my_shader.spv'
;
const
String
outputSpirvPath
=
'/output/shaders/my_shader.frag.spirv'
;
const
String
outputPath
=
'/output/shaders/my_shader.frag'
;
void
main
(
)
{
void
main
(
)
{
late
BufferLogger
logger
;
late
BufferLogger
logger
;
...
@@ -37,14 +38,17 @@ void main() {
...
@@ -37,14 +38,17 @@ void main() {
FakeCommand
(
FakeCommand
(
command:
<
String
>[
command:
<
String
>[
impellerc
,
impellerc
,
'--flutter-spirv'
,
'--sksl'
,
'--spirv=
$outputPath
'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputSpirvPath
'
,
'--input=
$fragPath
'
,
'--input=
$fragPath
'
,
'--input-type=frag'
,
'--input-type=frag'
,
'--include=
$fragDir
'
,
'--include=
$fragDir
'
,
],
],
onRun:
()
{
onRun:
()
{
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
outputSpirvPath
).
createSync
(
recursive:
true
);
},
},
),
),
]);
]);
...
@@ -63,6 +67,7 @@ void main() {
...
@@ -63,6 +67,7 @@ void main() {
true
,
true
,
);
);
expect
(
fileSystem
.
file
(
outputPath
).
existsSync
(),
true
);
expect
(
fileSystem
.
file
(
outputPath
).
existsSync
(),
true
);
expect
(
fileSystem
.
file
(
outputSpirvPath
).
existsSync
(),
false
);
});
});
testWithoutContext
(
'compileShader invokes impellerc for non-.frag files'
,
()
async
{
testWithoutContext
(
'compileShader invokes impellerc for non-.frag files'
,
()
async
{
...
@@ -70,14 +75,17 @@ void main() {
...
@@ -70,14 +75,17 @@ void main() {
FakeCommand
(
FakeCommand
(
command:
<
String
>[
command:
<
String
>[
impellerc
,
impellerc
,
'--flutter-spirv'
,
'--sksl'
,
'--spirv=
$outputPath
'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputSpirvPath
'
,
'--input=
$notFragPath
'
,
'--input=
$notFragPath
'
,
'--input-type=frag'
,
'--input-type=frag'
,
'--include=
$fragDir
'
,
'--include=
$fragDir
'
,
],
],
onRun:
()
{
onRun:
()
{
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
outputSpirvPath
).
createSync
(
recursive:
true
);
},
},
),
),
]);
]);
...
@@ -96,6 +104,7 @@ void main() {
...
@@ -96,6 +104,7 @@ void main() {
true
,
true
,
);
);
expect
(
fileSystem
.
file
(
outputPath
).
existsSync
(),
true
);
expect
(
fileSystem
.
file
(
outputPath
).
existsSync
(),
true
);
expect
(
fileSystem
.
file
(
outputSpirvPath
).
existsSync
(),
false
);
});
});
testWithoutContext
(
'compileShader throws an exception when impellerc fails'
,
()
async
{
testWithoutContext
(
'compileShader throws an exception when impellerc fails'
,
()
async
{
...
@@ -103,8 +112,10 @@ void main() {
...
@@ -103,8 +112,10 @@ void main() {
FakeCommand
(
FakeCommand
(
command:
<
String
>[
command:
<
String
>[
impellerc
,
impellerc
,
'--flutter-spirv'
,
'--sksl'
,
'--spirv=
$outputPath
'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputSpirvPath
'
,
'--input=
$notFragPath
'
,
'--input=
$notFragPath
'
,
'--input-type=frag'
,
'--input-type=frag'
,
'--include=
$fragDir
'
,
'--include=
$fragDir
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment