-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Impeller] Vulkan runtime effects/fragment program API #49543
Conversation
@@ -79,15 +68,6 @@ static std::shared_ptr<ShaderMetadata> MakeShaderMetadata( | |||
bool RuntimeEffectContents::Render(const ContentContext& renderer, |
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.
A nit on the current design. We should be able to pull together the descriptor set layouts when registering the shader/pipeline somehow. i'm not 100% certain how PipelineDescriptor equality works and I'd be slightly worredi that we would recreate pipelines on each frame.
This isn't blocking of course, but a follow up issue to make this more efficient would be appreciated.
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.
Filed flutter/flutter#141222
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 with nit
auto label is removed for flutter/engine/49543, due to - The status or check suite Mac mac_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label. |
We talked a bit offline and found that the runtime effect wasn't caching the compiled pipeline, which needs to be kept alive for Vulkan. I suggested a RuntimeEffect pipeline cache on the content context that could be used with a cache key composed of descriptor + shader name. |
Implemented the cache and updated a test for it in 2b1d8c2 |
|
||
struct Hash { | ||
std::size_t operator()(const RuntimeEffectPipelineKey& key) const { | ||
return fml::HashCombine(key.unique_entrypoint_name, |
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.
Perhaps we should just have std::hash
specializations for fml::HashCombine and friends can work without having to specify the Hash
struct.
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.
Would that be a specialization on impeller::Comparable<T>
? Or did you have something else in mind?
@@ -141,7 +141,7 @@ void ShaderLibraryGLES::UnregisterFunction(std::string name, | |||
const auto key = ShaderKey{name, stage}; | |||
|
|||
auto found = functions_.find(key); | |||
if (found != functions_.end()) { | |||
if (found == functions_.end()) { |
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.
Whoa
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.
Yeah this code was just not tested lol
#include "flutter/testing/testing.h" | ||
#include "gmock/gmock.h" |
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.
Did you mean to import this?
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.
Needed for EXPECT_THAT
to make it easier to compare vectors.
@@ -18,6 +18,8 @@ namespace impeller { | |||
|
|||
class RuntimeStage { | |||
public: | |||
static const char* kVulkanUBOName; |
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.
Can you add a docstring for this? Something like "The made-up name of the struct used to the contain the non-opaque uniforms specified directly by the user in the custom runtime fragment stage. Vulkan cannot support non-opaque uniforms which is why these must be moved into a UBO with this name."
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.
Or something like that.
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.
Done
@@ -729,10 +729,42 @@ class ContentContext { | |||
return render_target_cache_; | |||
} | |||
|
|||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetCachedRuntimeEffectPipeline( |
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.
The immediate thought that came to mind was, "Aren't all runtime stage entrypoints just called 'main'?" I suppose we mangle taking into account the name of the stage. But that still means that different stages with the same name will collide. I am not sure if that issue is purely hypothetical but it will be hard to debug if we run into it.
I suppose we could hash the name and the structure of the inputs before in the compiler and include that in the fbs. Or just generate a UUID.
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.
How the uniqueness of the entrypoint is guaranteed today would be good to add to a docstring.
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.
I'll try to document this. We build up the entrypoint name from the file name in the compiler.
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.
I was going to try to plumb through the asset name for this but realized we basically already have that in the entrypoint name.
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.
A single type-4 UUID would be fine honestly. But I suspect this works fine for now. Filing a followup works.
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.
auto label is removed for flutter/engine/49543, due to - The status or check suite Windows windows_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label.
|
auto label is removed for flutter/engine/49543, due to Pull request flutter/engine/49543 is not in a mergeable state. |
auto label is removed for flutter/engine/49543, due to - The status or check suite Linux linux_web_engine has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. |
…141337) flutter/engine@42e3e02...ade9f18 2024-01-11 [email protected] [Impeller] Vulkan runtime effects/fragment program API (flutter/engine#49543) 2024-01-11 [email protected] Roll Dart SDK from 9f5a6a2ccace to 3245b92a5930 (1 revision) (flutter/engine#49700) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
I broke this in #49543 While investigating flutter/flutter#141235 I realized that the specific things that were wrong there were probably artifacts of some intermediate issue in the previous patch - they no longer appear. However, I had broken hot reload. This patch fixes it and updates the `EntityTest.RuntimeEffect` to artificially run the rendering callback a few times simulating a hot reload. The test fails without my changes here.
Fixes flutter/flutter#122823
Fixes flutter/flutter#129659
Fixes flutter/flutter#123741
This patch makes runtime stage/fragment program stuff work on Vulkan for Android.
It will need flutter/flutter#140976 for that to become a reality for flutter_tools users.
Compiling with relaxed Vulkan semantics still has an issue: shaders that use
sampler2D
with an explicitly setlocation
on thelayout
will fail to compile with an error documented in flutter/flutter#141219.I think there might still be some issues with fragment programs on Vulkan, but this should at least be a good starting point and unblocks ink_sparkle.frag usage in the framework.
I've deleted some runtime_stage related code that would never get used - for example, enum related code that indicates we might support a bunch of data types that we do not and probably never will support in this API.