-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] read from framebuffer for advanced blends on iOS. #39567
Conversation
Here is the colordodge shader compiled (abbreviated): #include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct BlendInfo
{
float dst_input_alpha;
float src_y_coord_scale;
float color_factor;
float4 color;
};
struct framebuffer_blend_colordodge_fragment_main_out
{
float4 frag_color [[color(0)]];
};
struct framebuffer_blend_colordodge_fragment_main_in
{
float2 v_src_texture_coords [[user(locn0)]];
};
fragment framebuffer_blend_colordodge_fragment_main_out framebuffer_blend_colordodge_fragment_main(framebuffer_blend_colordodge_fragment_main_in in [[stage_in]], constant BlendInfo& blend_info [[buffer(0)]], float4 uSub [[color(0)]], texture2d<float> texture_sampler_src [[texture(0)]], sampler texture_sampler_srcSmplr [[sampler(0)]])
{
framebuffer_blend_colordodge_fragment_main_out out = {};
float4 _380 = uSub;
...
return out;
}
Of course this is resulting in solid black output. note I did leave some deb |
This now works on simple examples but fails on wonderous. Probably some coverage/transform/stencil issue I haven't shaken out yet. Also note that I made an effort to exclude the framebuffer shaders on non ios platforms but did not make an effort to remove the regular advanced blends. TBD if we want to do that. |
@@ -83,6 +83,7 @@ def main(): | |||
'-ffast-math', | |||
# Record symbols in a separate *.metallibsym file. | |||
'-frecord-sources=flat', | |||
'-g', |
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.
Note to self: remember to remove
@bdero WDUT about the approximate approach here? (Also checking if you can spot the bug before I do 🦅 ) |
frame debugger has the geometry in the right place, and it worked for simpler examples. i made the coverage a huge rect. 🤔 |
Overall approach LGTM! 👍 I glanced through and didn't spot the geometry bug. Is stuff getting partially cut off or getting culled away completely? Do the UV values reasonable in the frame debugger? |
Wait, am I actually adding this correctly or am I actually just replacing the last entity. |
Well I guess yes, since I call renderToSnapshot on the contents I replace. |
ahh, just forgot to set the stencil 🤦 |
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Looks like I also need to disable this on iOS simulators. |
b72f058
to
0c4c6d6
Compare
0c4c6d6
to
a587464
Compare
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!
@@ -437,6 +506,83 @@ class ContentContext { | |||
ContentContextOptions opts) const { | |||
return GetPipeline(blend_softlight_pipelines_, opts); | |||
} | |||
#if FML_OS_PHYSICAL_IOS |
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.
So reading from the framebuffer wouldn't happen to work on Apple silicon macs, would it? :)
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.
it might be, but from the errors I hit it sounds like it needs a substantially higher MSL version:
@@ -35,6 +35,7 @@ static CompilerBackend CreateMSLCompiler(const spirv_cross::ParsedIR& ir, | |||
// Metal to AIR must be updated as well. | |||
sl_options.msl_version = | |||
spirv_cross::CompilerMSL::Options::make_msl_version(1, 2); | |||
sl_options.use_framebuffer_fetch_subpasses = true; |
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.
Oh, well that turned out simpler than I was expecting!
…120761) * ab2dec516 Roll Skia from 8de7f68a3661 to 67a8177742e6 (4 revisions) (flutter/engine#39623) * a7ec1e50f Remove libpng dependency in the APNG decoder (flutter/engine#39622) * cb5393336 Add more info to malioc_diff.py output (flutter/engine#39625) * 60c199501 Roll Dart SDK from ea59504416a8 to 22ad11262460 (2 revisions) (flutter/engine#39624) * b1f76fbb0 [Impeller] Avoid stringstream usage in CreateUniformMemberKey (flutter/engine#39606) * a85220d2f Fix a flake in EmbedderTest.CompositorRenderTargetsNotRecycledWhenAvoidsCacheSet (flutter/engine#39596) * 3141b116d [impeller] Refactored backend specific feature checks to capabilities (flutter/engine#39598) * bf667254f [impellerc] Generate GLSL output for the runtime-stage-gles target (flutter/engine#39602) * 57e83aa16 [Impeller] Special case color filter in tiled texture. (flutter/engine#39445) * e1325a9de Roll Skia from 67a8177742e6 to a3fe5233eb10 (9 revisions) (flutter/engine#39627) * 9f2c4db50 Add app anatomy diagram (flutter/engine#39628) * e8c14e436 Roll Fuchsia Linux SDK from mWwKhmxRlXNJATVmu... to A15Lg2MzGSkbj33mo... (flutter/engine#39631) * 9bd50b706 [Impeller] read from framebuffer for advanced blends on iOS. (flutter/engine#39567) * 66715c928 Fix build output path of the malioc core list (flutter/engine#39629) * 727500b12 Roll Skia from a3fe5233eb10 to b7508e2f2577 (3 revisions) (flutter/engine#39634) * f193de9cc [Impeller] Make RenderTarget::CreateOffscreen utilities have a stencil by default (flutter/engine#39636) * 76b51e33a Roll Skia from b7508e2f2577 to 5974e36ea190 (4 revisions) (flutter/engine#39639) * aba44ff0b Roll Dart SDK from 22ad11262460 to 1dc26efa3c4c (1 revision) (flutter/engine#39640) * 657102f87 Roll Fuchsia Mac SDK from EFcCpAxOuQllDqP0F... to jsnm3dngrd9MveHrB... (flutter/engine#39641) * 44e36c9c0 Roll Skia from 5974e36ea190 to 2a7644cf4bd7 (1 revision) (flutter/engine#39642)
Work towards flutter/flutter#120223 for iOS. This dramatically improves performance of the pull quote on wonderous by reducing the number of subpasses and removing the required full screen fill. from 8ms down to 2-3 ms, vs 1.5-2ms for Skia. So pretty fast, and with less memory too
Note that this excludes the shaders from non iOS platforms but does not exclude the normal advanced blend shaders from iOS. Since we're not doing this in filter contents I've decided to punt on whether or not we should refactor that to take advantage of this - speciifically for drawVertices/drawAtlas there would be more followup work
I also left out support for a foreground color, but we should probably add that back and find some way to detect offscreen solid color contents. Or just always convert SolidColorContents into a 1x1 texture of that solid color when calling RenderToSnapshot.
Here is a fun test app for this change: