-
Notifications
You must be signed in to change notification settings - Fork 6k
Conversation
Public SkSL (the flavor that's accepted by SkRuntimeEffect) only supports square matrices (because GLSL ES 1.00 only supports square matrices). |
cc @zanderso |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial notes on testing and benchmarking as I review the other bits in detail. These are mostly around process and integration:
- Authoring new tests currently requires
spirv-opt
andglslangValidator
on the developers paths. There are no instructions on how the developer might fetch these and which version of these tools may be necessary. However, these tools or their equivalents are already present in the source tree via the SwiftShader dependency. After adding GN rules for the appropriate targets, you can integrate this with generation of the goldens within the build and test process. This will avoid having to check in and maintain some (but not all) SPIRV goldens. These tests running from the GTest harness will also run in JIT and AOT modes automatically and integrate with the rest of the engine testing infrastructure monitored by sheriffs. - Instead of inventing a bespoke benchmarking harness, please use the engine Google Benchmarking harness. This harness is capable of running benchmarks automatically and submitting the results to dashboards that are already being monitored. Also, this harness will run in profile and release AOT modes whose results are more relevant to the end user (and also work around the “warm up” issues you mentioned in the current harness).
- The user experience for SPIRV that does not adhere to the rules specified in the README are not clear. Please add tests that assert failure modes.
- The exercise of depending on SPIRV as the portable container for shaders was partially derived from the fact that SKSL had no stability guarantees. Towards that end, having SKSL goldens in the repo makes us susceptible to breaking changes to the format causing manual out of band regeneration of SKSL goldens. Instead of checking in SKSL goldens, is it possible to generate SKSL from GLSL (via an intermediate SPIRV translation step) and adding a test that ensures that the SKSL is valid using the current Skia version with SKSL reflection reflection used for test assertions? @brianosman, is there a Skia API for SKSL reflection? If not, we should at least ensure that the SKSL is valid.
I think generating the intermediate goldens is fine - My plan here is to ensure conformance via flutter engine tests that applies each shader to a Canvas and checks to make sure each .spv file generates the correct colors, and catching any build issue on the way - so we'd have the exact build/compilation errors for each platform. The downside is that the tests are 'farther' from the code they're testing. Is that a reasonable approach? For your other comments I agree and I'll take a pass at making the changes |
I am not concerned about the SPIRV intermediates as that is stable anyway. I meant the
I see. The bit about using pixel tests to assert correctness was not clear to me. I was assuming that tests would reflect SKSL properties to ensure correctness of translation. Is reflection not possible at all with SKSL (perhaps @brianosman can answer this)? Pixel tests are harder to maintain but we can manage it. I am more concerned about tests that assert updates to SKSL that don't affect pixel output, or, affect them too subtly to make the error clear from just the pixel output. Also, stuff like optimizations like dead constant/block/function elimination, folding, etc.. I am not sure how much Skia optimizes the SKSL on its own as well. In any case, its fine to have this be an open question to be answered later.
Sounds good. Please reach out for references to existing harnesses you can repurpose. |
To address a few questions:
|
I've updated the PR with the following changes, based on offline discussions:
The following are things expected in follow-up PRs (order after #1 is flexible)
|
Does this need another review? |
I am taking a look now but its slow going since its a rather large patch. Will have initial comments soon. If Brian is able to chime in, that would be helpful as well. |
I'm OoO this week, just did a quick skim, but I'd really need to sit down and spend some more time. I'm curious about a few of the ops (composite assemble/extract, etc.), but without walking through the SPIRV spec (or SkSL's SPIRV backend), I can't say there's any problem. |
OK sounds good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked over this a bit better. As far as I can tell, things all make sense. I did point out one spot where opAccessChain assumes array indexing, which isn't always the case (although if you're not supporting structs yet, then it won't matter).
Can the pixel tests, along with the FragmentShader class, be landed in a followup PR (since this one is already quite large)? It is in progress |
@brianosman Thanks for the review- not supporting structs in this PR (for now) but I can add a comment to clarify @clocksmith, yes, that is my hope for follow up PRs.
|
That's a lot of Dart code on the engine side. Is it possible to pull it out as a package and just have the engine/dart boundary in this repo? (I didn't look very closely, maybe the whole of this Dart code is that boundary?) The reason I ask is that the more code we take out of the engine, the smaller the binary size footprint for users who aren't using this code, and the easier it is to fix bugs in the code going forward (e.g. the package can roll pretty independently). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure the Dart code is covered by the analyzer on CI by adding to https://github.com/flutter/engine/blob/master/ci/analyze.sh.
The transpiler is needed so that the public |
Ah, yeah, if the internal API is SkSL that makes sense. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
@chriscraws It looks like something about your branch has confused GitHub. I believe there are some git commands you can run locally to recover from this state, but it might be simpler to create a new PR. |
@christopherfujino suggested to me over chat that you can also re-create the branch locally from scratch, and then force push it over your existing feature branch on your mirror, and it will update the PR. |
It might also work to do a |
I was able to fix the diff by merging the latest master to the feature branch. Note, that when you merged your local |
This is the first step in implementing flutter.dev/go/shaders. Code changes originate from https://github.com/chriscraws/engine/tree/shader-cc, which has a working end-to-end draft implementation. This change includes a dart library intended to be included as an internal dependency (`dart:_spirv`) for `dart:ui`. Dart has been chosen over C++ for the following reasons: - Simpler to include with the HTML renderer. - Code will be tree-shaken for applications that don't use it. - AOT Dart performance is comparable to performance of C++ implementation. - Easier to read.
Ok I think I fixed the git weirdness. I do think it was from rebasing on to an older branch, and a lot of weird stuff happened 😅 It should all tree shake correctly since the transpiler is pure dart (no adding to the shared lib), so it should only be included if someone makes use of the dart:ui FragmentShader class (not in this PR) |
I've opened this PR to fix the remaining build failure: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm w/ suggested uses of constant maps instead of giant switch statements.
@chinmaygarde @zanderso @brianosman Can I merge this? |
Still lgtm. Feel free to merge when ready. |
@chriscraws I imagine this will work seamlessly with Vulkan? |
Yep - the SkSL should work on all of the back-ends that Skia supports (vulkan, metal, opengl, etc). The GLSL-ES output is still untested until |
This is the first step in implementing flutter.dev/go/shaders.
Code changes originate from https://github.com/chriscraws/engine/tree/shader-cc,
which has a working end-to-end draft implementation.
This change includes a dart library intended to be included as an
internal dependency (
dart:_spirv
) fordart:ui
.Dart has been chosen over C++ for the following reasons:
implementation.
The transpiler currently supports a minimal set of features - planned additions for later PRs are structured types, control flow, and 2d-sampling. This should be after the feature is fully integrated.
Golden shader files are tested manually, but will be tested fully
by Flutter engine unit tests as the library is included by
dart:ui
.Most of the files included in this change are tests and test-data.
flutter/flutter#58361
flutter/flutter#30763
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.