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;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
...
...
@@ -522,16 +521,10 @@ class FragmentShaderManager {
/// Creates an [FragmentShaderManager] with an [InkSparkle] effect.
static
Future
<
FragmentShaderManager
>
inkSparkle
()
async
{
final
FragmentShaderManager
manager
=
FragmentShaderManager
.
_
();
await
manager
.
_compile
(
);
_program
=
ui
.
FragmentProgram
.
fromAsset
(
'shaders/ink_sparkle.frag'
);
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.
///
/// 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 @@
import
'package:process/process.dart'
;
import
'../../artifacts.dart'
;
import
'../../base/error_handling_io.dart'
;
import
'../../base/file_system.dart'
;
import
'../../base/io.dart'
;
import
'../../base/logger.dart'
;
...
...
@@ -64,8 +65,10 @@ class ShaderCompiler {
// TODO(zanderso): When impeller is enabled, the correct flags for the
// target backend will need to be passed.
// https://github.com/flutter/flutter/issues/102853
'--flutter-spirv'
,
'--spirv=
$outputPath
'
,
'--sksl'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputPath
.spirv'
,
'--input=
${input.path}
'
,
'--input-type=frag'
,
'--include=
${input.parent.path}
'
,
...
...
@@ -81,6 +84,7 @@ class ShaderCompiler {
);
}
ErrorHandlingFileSystem
.
deleteIfExists
(
_fs
.
file
(
'
$outputPath
.spirv'
));
return
true
;
}
}
...
...
packages/flutter_tools/test/general.shard/asset_bundle_test.dart
View file @
dd20919a
...
...
@@ -443,14 +443,17 @@ flutter:
FakeCommand
(
command:
<
String
>[
impellerc
,
'--flutter-spirv'
,
'--spirv=
$outputPath
'
,
'--sksl'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputPath
.spirv'
,
'--input=/
$shaderPath
'
,
'--input-type=frag'
,
'--include=/
$assetsPath
'
,
],
onRun:
()
{
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';
const
String
fragDir
=
'/shaders'
;
const
String
fragPath
=
'/shaders/my_shader.frag'
;
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
(
)
{
late
BufferLogger
logger
;
...
...
@@ -37,14 +38,17 @@ void main() {
FakeCommand
(
command:
<
String
>[
impellerc
,
'--flutter-spirv'
,
'--spirv=
$outputPath
'
,
'--sksl'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputSpirvPath
'
,
'--input=
$fragPath
'
,
'--input-type=frag'
,
'--include=
$fragDir
'
,
],
onRun:
()
{
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
outputSpirvPath
).
createSync
(
recursive:
true
);
},
),
]);
...
...
@@ -63,6 +67,7 @@ void main() {
true
,
);
expect
(
fileSystem
.
file
(
outputPath
).
existsSync
(),
true
);
expect
(
fileSystem
.
file
(
outputSpirvPath
).
existsSync
(),
false
);
});
testWithoutContext
(
'compileShader invokes impellerc for non-.frag files'
,
()
async
{
...
...
@@ -70,14 +75,17 @@ void main() {
FakeCommand
(
command:
<
String
>[
impellerc
,
'--flutter-spirv'
,
'--spirv=
$outputPath
'
,
'--sksl'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputSpirvPath
'
,
'--input=
$notFragPath
'
,
'--input-type=frag'
,
'--include=
$fragDir
'
,
],
onRun:
()
{
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
outputSpirvPath
).
createSync
(
recursive:
true
);
},
),
]);
...
...
@@ -96,6 +104,7 @@ void main() {
true
,
);
expect
(
fileSystem
.
file
(
outputPath
).
existsSync
(),
true
);
expect
(
fileSystem
.
file
(
outputSpirvPath
).
existsSync
(),
false
);
});
testWithoutContext
(
'compileShader throws an exception when impellerc fails'
,
()
async
{
...
...
@@ -103,8 +112,10 @@ void main() {
FakeCommand
(
command:
<
String
>[
impellerc
,
'--flutter-spirv'
,
'--spirv=
$outputPath
'
,
'--sksl'
,
'--iplr'
,
'--sl=
$outputPath
'
,
'--spirv=
$outputSpirvPath
'
,
'--input=
$notFragPath
'
,
'--input-type=frag'
,
'--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