Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
18573ad
Add FragmentShader dart API
clocksmith May 26, 2021
0bac429
Add fragment_shader.h and fragment_shader.cc
clocksmith May 26, 2021
735bb08
Add and fix fragment_shader_test.dart
clocksmith May 27, 2021
ebd002e
test
clocksmith Jun 2, 2021
652c316
typos
clocksmith Jun 3, 2021
997baa9
Add some more ops tests
clocksmith Jun 14, 2021
1140840
testing shaderc
clocksmith Jun 15, 2021
8009ac0
add configurations so that engine can build with FragmentShader
clocksmith Jun 15, 2021
49466d6
Uncomment glsl_to_spirv build rules
clocksmith Jun 16, 2021
9e49583
Add more op sources and iterate on glsl_to_spirv
clocksmith Jun 16, 2021
63459ea
revert DEPS
clocksmith Jun 16, 2021
005273d
revert DEPS
clocksmith Jun 16, 2021
b8cc199
revert DEPS
clocksmith Jun 16, 2021
7f9394a
revert DEPS
clocksmith Jun 16, 2021
e05634f
Update existing e2e tests
clocksmith Jun 16, 2021
22dcac3
add shaderc opts
clocksmith Jun 16, 2021
43b871e
Add simple test
clocksmith Jun 16, 2021
8c606b0
iterate on pixel test infra
clocksmith Jun 17, 2021
59c4790
Update tests
clocksmith Jun 24, 2021
0c525bd
update build rules
clocksmith Jun 24, 2021
f174190
Clean up tests, add glsl tests, add opTypeInt
clocksmith Jun 27, 2021
4a46174
uncomment tests and adjust README
clocksmith Jun 27, 2021
a4908e7
Remove benchmarks from this branch, can be added sep
clocksmith Jun 27, 2021
02875af
formatting
clocksmith Jun 27, 2021
dca3c5e
formatting
clocksmith Jun 27, 2021
99a704a
fix typo
clocksmith Jun 27, 2021
3ab467e
formatting
clocksmith Jun 27, 2021
5572332
formatting
clocksmith Jun 27, 2021
2675bb5
formatting
clocksmith Jun 27, 2021
94667fb
formatting
clocksmith Jun 27, 2021
438354a
formatting
clocksmith Jun 28, 2021
f1288e4
fix painting.dart and add opTypeInt test
clocksmith Jun 28, 2021
89d2bc8
Refactor fragment_shader_test.dart
clocksmith Jun 28, 2021
290f641
formatting
clocksmith Jun 28, 2021
1f21768
Expand testing in README
clocksmith Jun 28, 2021
edc9997
Expand testing in README
clocksmith Jun 28, 2021
11fde01
Add glsl trunc op test
clocksmith Jun 28, 2021
12ec656
Add glsl abs op test
clocksmith Jun 28, 2021
def9426
Add glsl sign op test
clocksmith Jun 28, 2021
852910e
Add glsl ceil and floor op tests
clocksmith Jun 28, 2021
f0f9646
Add glsl fract op tests
clocksmith Jun 28, 2021
42b7aee
Add glsl degrees and radians op tests
clocksmith Jun 28, 2021
fd7de36
Add glsl acos, asin, atan op tests, and remove unneeded variables fro…
clocksmith Jun 28, 2021
b1e3d4d
start to add atan2 through inversesqrt tests
clocksmith Jun 28, 2021
c2400cd
UPdated README and finished up to inversesqrt
clocksmith Jun 29, 2021
82f7a95
Added a bunch of glsl tests, formatted them, commented some, alphabet…
clocksmith Jun 30, 2021
192d677
only reflect, step, and smoothstep left for glsl
clocksmith Jun 30, 2021
2eae8a8
added more comments to tests
clocksmith Jun 30, 2021
45ebcd0
better color comparison, use string instead of int for debugging
clocksmith Jun 30, 2021
a97ee0a
fix smoothstep
clocksmith Jun 30, 2021
af70bdc
reflect still fails, but closer
clocksmith Jun 30, 2021
2b60721
Replaced TODOs with github issues, ones left as TODO(clocksmith) shou…
clocksmith Jun 30, 2021
7c49a86
c fix
clocksmith Jun 30, 2021
f2bcb16
c fix
clocksmith Jun 30, 2021
165c0a0
reflect todo
clocksmith Jun 30, 2021
2d6f106
reflect test
clocksmith Jul 1, 2021
03ca6af
refactor tests
clocksmith Jul 1, 2021
ba13fca
dart 2.12 and test refactoring
clocksmith Jul 1, 2021
e1aa6d7
format
clocksmith Jul 1, 2021
89bb19e
Add matrix to docs for FragmentShader
clocksmith Jul 1, 2021
c7f790e
Add matrix to docs for FragmentShader
clocksmith Jul 1, 2021
4d38e84
Add tester for checking that specific ops are used WIP
clocksmith Jul 26, 2021
7bfab3b
Tests all have uniforms and pass.
chriscraws Jul 27, 2021
54f7ee7
pass format check
chriscraws Jul 27, 2021
e5b63f1
Added some test documentation on the uniforms and fixed // comments t…
clocksmith Jul 27, 2021
4db6cf0
Add note for API not working on web
clocksmith Jul 27, 2021
bac06eb
whitespace
clocksmith Jul 27, 2021
2804014
add copyright header to test shaders
chriscraws Jul 28, 2021
80ee6ba
add back _embedder.yaml
chriscraws Jul 29, 2021
b684b1c
sync DEPS with master branch
chriscraws Jul 29, 2021
8e274ab
remove trailing whitespace
chriscraws Jul 29, 2021
e9a2b8d
update licenses golden
chriscraws Jul 29, 2021
6ba9647
revert license, use 2013 for fragment_shader.h
chriscraws Jul 29, 2021
df1be2b
update license golden
chriscraws Jul 29, 2021
dbf765e
fix glsl formatting
chriscraws Jul 29, 2021
efad032
ensure transpiler is included in dart:ui
chriscraws Jul 29, 2021
8570f95
make sure glsl_to_spirv.cc uses null-terminated strings
chriscraws Jul 29, 2021
750354e
update fuchsia runner libraries
chriscraws Jul 29, 2021
6cbd73d
fix path for _spirv in fuchsia shell libraries.yaml
chriscraws Jul 29, 2021
26723cb
get files from the current build
chriscraws Jul 29, 2021
24a7cf4
Merge branch 'master' of https://github.com/flutter/engine into fragm…
clocksmith Jul 29, 2021
dd57cb1
reformat TODOs
chriscraws Jul 29, 2021
11ab168
Merge branch 'fragment-shader' of github.com:chriscraws/engine into a…
chriscraws Jul 29, 2021
048e885
update analyzer script
chriscraws Jul 29, 2021
029ec9f
Merge remote-tracking branch 'flutter/master' into add-op-tests
chriscraws Jul 29, 2021
e376772
fix analysis script for dart:ui
chriscraws Jul 30, 2021
6b79e49
fix analysis issues for fragment_shader_test.dart
chriscraws Jul 30, 2021
c521139
do not call isNotEmpty matcher on Map
chriscraws Jul 30, 2021
3985fa5
merge
clocksmith Jul 30, 2021
8ab1061
restore env change in run_tests.py after merge
chriscraws Jul 30, 2021
6553562
add stub FragmentShader to web_ui
chriscraws Jul 30, 2021
e002307
fix constructor for FragmentShader
chriscraws Jul 30, 2021
2ff5778
ignore unused parameters in web_ui FragmentShader
chriscraws Jul 30, 2021
aed999a
exception and documentation updates
chriscraws Jul 31, 2021
fc63d47
add one more missing
chriscraws Jul 31, 2021
f3e9559
Merge remote-tracking branch 'flutter/master' into fragment-shader
chriscraws Aug 3, 2021
600b9ad
ignore directives on each line
chriscraws Aug 3, 2021
bf3ba74
Merge branch 'master' of https://github.com/flutter/engine into fragm…
clocksmith Aug 9, 2021
1365001
Resolve comments
clocksmith Aug 10, 2021
5af00c7
Merge branch 'master' of https://github.com/flutter/engine into fragm…
clocksmith Aug 10, 2021
9b002f5
license
clocksmith Aug 10, 2021
4aac2e5
merge
clocksmith Aug 16, 2021
4745980
address some comments
clocksmith Aug 16, 2021
96c8114
address comments
clocksmith Aug 17, 2021
84df32f
license
clocksmith Aug 17, 2021
2023a58
comments
clocksmith Aug 17, 2021
ebd8ba1
whitespace
clocksmith Aug 17, 2021
a6a6ead
reset licenses to generate new patch from CI
clocksmith Aug 17, 2021
efb7e8d
license
clocksmith Aug 17, 2021
1e8b9ee
license
clocksmith Aug 17, 2021
656bea6
merge
clocksmith Aug 17, 2021
5d94212
license
clocksmith Aug 17, 2021
983e649
whitespace
clocksmith Aug 17, 2021
166b1ad
whitespace
clocksmith Aug 17, 2021
6228591
Merge branch 'master' of https://github.com/flutter/engine into fragm…
clocksmith Aug 17, 2021
067e7de
Add shared shader test file utils
clocksmith Aug 17, 2021
865099e
Add shared shader test file utils
clocksmith Aug 17, 2021
c823296
Make sky BUILD rule for spirv match others
clocksmith Aug 18, 2021
c03a5c7
whitespace
clocksmith Aug 18, 2021
703af9c
whitespace
clocksmith Aug 18, 2021
b0c6620
revert FlutterActivityDelegate
clocksmith Aug 18, 2021
6749392
change signature in license to foo to help debug the error from CI
clocksmith Aug 18, 2021
898f6c5
license
clocksmith Aug 18, 2021
678573e
revert sky
clocksmith Aug 18, 2021
5c49dde
unrevert sky and remove newline from license signature
clocksmith Aug 18, 2021
e1f01f5
newlines
clocksmith Aug 18, 2021
719e9c9
Merge branch 'master' of https://github.com/flutter/engine into fragm…
clocksmith Aug 18, 2021
9524d6e
revert sky engine build to only use directory
clocksmith Aug 18, 2021
306aac0
merge
clocksmith Aug 18, 2021
cf625fd
new license signature
clocksmith Aug 18, 2021
de27a79
Merge branch 'master' of https://github.com/flutter/engine into fragm…
clocksmith Aug 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ group("flutter") {
"//flutter/flow:flow_unittests",
"//flutter/fml:fml_unittests",
"//flutter/lib/spirv/test/exception_shaders:spirv_compile_exception_shaders",
"//flutter/lib/spirv/test/general_shaders:spirv_compile_general_shaders",
"//flutter/lib/spirv/test/supported_glsl_op_shaders:spirv_compile_supported_glsl_shaders",
"//flutter/lib/spirv/test/supported_op_shaders:spirv_compile_supported_op_shaders",
"//flutter/lib/ui:ui_unittests",
"//flutter/runtime:no_dart_plugin_registrant_unittests",
"//flutter/runtime:runtime_unittests",
Expand Down
4 changes: 3 additions & 1 deletion ci/analyze.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function follow_links() (
SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")
SRC_DIR="$(cd "$SCRIPT_DIR/../.."; pwd -P)"
FLUTTER_DIR="$SRC_DIR/flutter"
SKY_ENGINE_DIR="$SRC_DIR/out/host_debug_unopt/gen/dart-pkg/sky_engine"
DART_BIN="$SRC_DIR/out/host_debug_unopt/dart-sdk/bin"
DART="$DART_BIN/dart"

Expand All @@ -46,7 +47,8 @@ echo "Using dart from $DART_BIN"
"$DART" --version
echo ""

"$DART" analyze "$FLUTTER_DIR/lib/ui"
(cd $SKY_ENGINE_DIR && "$DART" pub get --offline)
"$DART" analyze "$SKY_ENGINE_DIR/lib/ui/ui.dart"

"$DART" analyze "$FLUTTER_DIR/lib/spirv"

Expand Down
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ FILE: ../../../flutter/lib/ui/painting/color_filter.cc
FILE: ../../../flutter/lib/ui/painting/color_filter.h
FILE: ../../../flutter/lib/ui/painting/engine_layer.cc
FILE: ../../../flutter/lib/ui/painting/engine_layer.h
FILE: ../../../flutter/lib/ui/painting/fragment_shader.cc
FILE: ../../../flutter/lib/ui/painting/fragment_shader.h
FILE: ../../../flutter/lib/ui/painting/gradient.cc
FILE: ../../../flutter/lib/ui/painting/gradient.h
FILE: ../../../flutter/lib/ui/painting/image.cc
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: 2b08c736bc3af2c5d770099c53112c83
Signature: e892e715f8184778851c5efcb6a1323a

3 changes: 3 additions & 0 deletions lib/snapshot/libraries.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
"uri": "../../../third_party/dart/sdk/lib/typed_data/typed_data.dart",
"patches": "../../../third_party/dart/sdk/lib/_internal/vm/lib/typed_data_patch.dart"
},
"_spirv": {
"uri": "../../lib/spirv/lib/spirv.dart"
},
"ui": {
"uri": "../../lib/ui/ui.dart"
},
Expand Down
3 changes: 3 additions & 0 deletions lib/snapshot/libraries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ flutter:
uri: "../../../third_party/dart/sdk/lib/typed_data/typed_data.dart"
patches: "../../../third_party/dart/sdk/lib/_internal/vm/lib/typed_data_patch.dart"

_spirv:
uri: "../../lib/spirv/lib/spirv.dart"

ui:
uri: "../../lib/ui/ui.dart"

Expand Down
35 changes: 31 additions & 4 deletions lib/spirv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,40 @@ Support for textures, control flow, and structured types is planned, but not cur

## Testing

## Exception Tests
### Exception Tests

These tests rely on the `.spvasm` (SPIR-V Assembly) and `.glsl` files contained under `test/exception_shaders` in this directory. They are compiled to binary SPIR-V using `spirv-asm`, from the SwiftShader dependency. They are tested by testing/dart/spirv_exception_test.dart as part of the normal suite of dart tests. The purpose of these tests is to exercise every explicit failure path for shader transpilation. Each `glsl` or `spvasm` file should include a comment describing the failure that it is testing. The given files should be valid apart from the single failure case they are testing.

## Pixel Tests
To test the exception tests directly: `./testing/run_tests.py --type dart --dart-filter spirv_exception_test.dart`

Pixel test are not yet checked in, and should run as part of unit-testing for each implementation of `dart:ui`. These tests aim to validate the correctness of transpilation to each target language. Each shader should render the color green #00FF00 for a correct transpilation, and any other color for failure. They will be a combination of `.spvasm` files and more-readable GLSL files that are compiled to SPIR-V via `glslang`, provided by the SwiftShader dependency. Information for pixel tests will be expanded in a follow-up PR.
### Pixel Tests

These tests will be able to be run alone by executing `./ui_unittests` in the build-output directory.
Pixel tests should run as part of unit-testing for each implementation of `dart:ui`. Currently, FragmentShader is only supported in C++. These tests aim to validate the correctness of transpilation to each target language. Each shader should render the color green for a correct transpilation, and any other color for failure. They will be a GLSL files that are compiled to SPIR-V via `shaderc`. Therefor, the `fragColor` should resolve to `vec4(0.0, 1.0, 0.0, 1.0)`
for all tests.

In each test, the uniform `a` is initialized with the value of 1.0.
This is important so that expressions are not simplified during GLSL to SPIR-V compilation, which may result in the removal of the op being tested.

To test the pixel tests directly: `./testing/run_tests.py --type dart --dart-filter fragment_shader_test.dart`

#### A Note on Test Isolation

Even the simplest GLSL program tests several instructions, so no test us completely isolated
to a single op. Also, some of the GLSL 450 op tests will use addition in subtraction, along with the
actual op being tested. However, the GLSL program for each test file is kept as simple as possible,
to satisfy these conditions: pass if the op works, and fail if the op does not work. In some tests,
it is sufficient to only call the GLSL op once, while other may need more calls to more completelty
test the op. Many ops support scalars, vectors, or a combination as parameters. Most tests default
to using scalars as params, but vec2, vec3, and vec4 parameters are also tested.

- vec2 is tested as a paramter in glsl_op_normalize.glsl
- vec3 is tested as a parameter in glsl_op_cross.glsl
- vec4 is tested as a parameter in glsl_op_length.glsl

### Adding New Tests

To add a new test, add a glsl (fragment shader tests) or spvasm (spirv exception tests) src file to a `lib/spirv/test/` subfolder, and add the file as a source to the corresponding `BUILD.gn`.

- New files in `exception_shaders` are automatically tested in `testing/dart/spirv_exception_test`.
- New files in `supported_op_shaders` and `supported_glsl_op_shaders` are automatically tested in `testing/dart/fragment_shader_test`.
- New files in `general_shaders` are not automatically tested and must add a new manual test case in `testing/dart/fragment_shader_test`.
20 changes: 16 additions & 4 deletions lib/spirv/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ const int _decorationLocation = 30;
// Explicitly supported builtin types
const int _builtinFragCoord = 15;

// Ops that have no semantic meaning in output and can be safely ignored
const int _opSource = 3;
const int _opSourceExtension = 4;
const int _opName = 5;
const int _opMemberName = 6;
const int _opString = 7;
const int _opLine = 8;

// Supported instructions
const int _opExtInstImport = 11;
const int _opExtInst = 12;
Expand All @@ -43,17 +51,21 @@ const int _opExecutionMode = 16;
const int _opCapability = 17;
const int _opTypeVoid = 19;
const int _opTypeBool = 20;
const int _opTypeInt = 21;
const int _opTypeFloat = 22;
const int _opTypeVector = 23;
const int _opTypeMatrix = 24;
const int _opTypePointer = 32;
const int _opTypeFunction = 33;
const int _opConstantTrue = 41;
const int _opConstantFalse = 42;
const int _opConstant = 43;
const int _opConstantComposite = 44;
const int _opFunction = 54;
const int _opFunctionParameter = 55;
const int _opFunctionEnd = 56;
const int _opFunctionCall = 57;
const int _opFUnordNotEqual = 183;
const int _opVariable = 59;
const int _opLoad = 61;
const int _opStore = 62;
Expand All @@ -62,6 +74,8 @@ const int _opDecorate = 71;
const int _opVectorShuffle = 79;
const int _opCompositeConstruct = 80;
const int _opCompositeExtract = 81;
const int _opConvertFToS = 110;
const int _opConvertSToF = 111;
const int _opFNegate = 127;
const int _opFAdd = 129;
const int _opFSub = 131;
Expand All @@ -74,6 +88,7 @@ const int _opVectorTimesMatrix = 144;
const int _opMatrixTimesVector = 145;
const int _opMatrixTimesMatrix = 146;
const int _opDot = 148;
const int _opSelect = 169;
const int _opLabel = 248;
const int _opReturn = 253;
const int _opReturnValue = 254;
Expand All @@ -85,7 +100,6 @@ const int _opReturnValue = 254;
const String _glslStd450 = 'GLSL.std.450';

// Supported GLSL ops
const int _glslStd450Trunc = 3;
const int _glslStd450FAbs = 4;
const int _glslStd450FSign = 6;
const int _glslStd450Floor = 8;
Expand Down Expand Up @@ -121,7 +135,6 @@ const int _glslStd450FaceForward = 70;
const int _glslStd450Reflect = 71;

const Map<int, String> _glslStd450OpNames = <int, String>{
_glslStd450Trunc: 'trunc',
_glslStd450FAbs: 'abs',
_glslStd450FSign: 'sign',
_glslStd450Floor: 'floor',
Expand Down Expand Up @@ -158,7 +171,6 @@ const Map<int, String> _glslStd450OpNames = <int, String>{
};

const Map<int, int> _glslStd450OpArgc = <int, int>{
_glslStd450Trunc: 1,
_glslStd450FAbs: 1,
_glslStd450FSign: 1,
_glslStd450Floor: 1,
Expand All @@ -174,7 +186,7 @@ const Map<int, int> _glslStd450OpArgc = <int, int>{
_glslStd450Atan: 1,
_glslStd450Atan2: 2,
_glslStd450Pow: 2,
_glslStd450Exp: 2,
_glslStd450Exp: 1,
_glslStd450Log: 1,
_glslStd450Exp2: 1,
_glslStd450Log2: 1,
Expand Down
Loading