diff --git a/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc b/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc index 38512778cbed9..b9b72143045d4 100644 --- a/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc @@ -5,6 +5,7 @@ #include "impeller/entity/contents/filters/border_mask_blur_filter_contents.h" #include "impeller/entity/contents/content_context.h" +#include "impeller/entity/contents/anonymous_contents.h" #include "impeller/entity/contents/contents.h" #include "impeller/renderer/render_pass.h" #include "impeller/renderer/sampler_library.h" @@ -68,6 +69,7 @@ std::optional BorderMaskBlurFilterContents::RenderFilter( if (!input_snapshot.has_value()) { return std::nullopt; } + auto maybe_input_uvs = input_snapshot->GetCoverageUVs(coverage); if (!maybe_input_uvs.has_value()) { return std::nullopt; @@ -75,43 +77,53 @@ std::optional BorderMaskBlurFilterContents::RenderFilter( auto input_uvs = maybe_input_uvs.value(); //---------------------------------------------------------------------------- - /// Render to texture. + /// Create AnonymousContents for rendering. /// - ContentContext::SubpassCallback callback = [&](const ContentContext& renderer, - RenderPass& pass) { + auto sigma = effect_transform * Vector2(sigma_x_.sigma, sigma_y_.sigma); + RenderProc render_proc = [coverage, input_snapshot, input_uvs = input_uvs, + src_color_factor = src_color_factor_, + inner_blur_factor = inner_blur_factor_, + outer_blur_factor = outer_blur_factor_, sigma]( + const ContentContext& renderer, + const Entity& entity, RenderPass& pass) -> bool { auto& host_buffer = pass.GetTransientsBuffer(); VertexBufferBuilder vtx_builder; vtx_builder.AddVertices({ - {Point(0, 0), input_uvs[0]}, - {Point(1, 0), input_uvs[1]}, - {Point(1, 1), input_uvs[3]}, - {Point(0, 0), input_uvs[0]}, - {Point(1, 1), input_uvs[3]}, - {Point(0, 1), input_uvs[2]}, + {coverage.origin, input_uvs[0]}, + {{coverage.origin.x + coverage.size.width, coverage.origin.y}, + input_uvs[1]}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + input_uvs[3]}, + {coverage.origin, input_uvs[0]}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + input_uvs[3]}, + {{coverage.origin.x, coverage.origin.y + coverage.size.height}, + input_uvs[2]}, }); auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); Command cmd; cmd.label = "Border Mask Blur Filter"; - auto options = OptionsFromPass(pass); - options.blend_mode = BlendMode::kSource; + auto options = OptionsFromPassAndEntity(pass, entity); + cmd.pipeline = renderer.GetBorderMaskBlurPipeline(options); cmd.BindVertices(vtx_buffer); + cmd.stencil_reference = entity.GetStencilDepth(); VS::FrameInfo frame_info; - frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1)); + frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()); frame_info.texture_sampler_y_coord_scale = input_snapshot->texture->GetYCoordScale(); - auto sigma = effect_transform * Vector2(sigma_x_.sigma, sigma_y_.sigma); - FS::FragInfo frag_info; frag_info.sigma_uv = sigma.Abs() / input_snapshot->texture->GetSize(); - frag_info.src_factor = src_color_factor_; - frag_info.inner_blur_factor = inner_blur_factor_; - frag_info.outer_blur_factor = outer_blur_factor_; + frag_info.src_factor = src_color_factor; + frag_info.inner_blur_factor = inner_blur_factor; + frag_info.outer_blur_factor = outer_blur_factor; FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info)); VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info)); @@ -122,17 +134,19 @@ std::optional BorderMaskBlurFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = renderer.MakeSubpass("Border Mask Blur Filter", - ISize(coverage.size), callback); - if (!out_texture) { - return std::nullopt; - } + CoverageProc coverage_proc = + [coverage](const Entity& entity) -> std::optional { + return coverage; + }; + + auto contents = AnonymousContents::Make(render_proc, coverage_proc); - return Entity::FromSnapshot( - Snapshot{.texture = out_texture, - .transform = Matrix::MakeTranslation(coverage.origin), - .opacity = input_snapshot->opacity}, - entity.GetBlendMode(), entity.GetStencilDepth()); + Entity sub_entity; + sub_entity.SetContents(std::move(contents)); + sub_entity.SetStencilDepth(entity.GetStencilDepth()); + sub_entity.SetTransformation(entity.GetTransformation()); + sub_entity.SetBlendMode(entity.GetBlendMode()); + return sub_entity; } std::optional BorderMaskBlurFilterContents::GetFilterCoverage( diff --git a/impeller/entity/contents/filters/color_matrix_filter_contents.cc b/impeller/entity/contents/filters/color_matrix_filter_contents.cc index 41336099b7803..88e7487318b6c 100644 --- a/impeller/entity/contents/filters/color_matrix_filter_contents.cc +++ b/impeller/entity/contents/filters/color_matrix_filter_contents.cc @@ -6,6 +6,7 @@ #include +#include "impeller/entity/contents/anonymous_contents.h" #include "impeller/entity/contents/content_context.h" #include "impeller/entity/contents/contents.h" #include "impeller/geometry/point.h" @@ -46,38 +47,45 @@ std::optional ColorMatrixFilterContents::RenderFilter( } //---------------------------------------------------------------------------- - /// Render to texture. + /// Create AnonymousContents for rendering. /// - - ContentContext::SubpassCallback callback = [&](const ContentContext& renderer, - RenderPass& pass) { + RenderProc render_proc = [input_snapshot, color_matrix = matrix_, coverage, + absorb_opacity = GetAbsorbOpacity()]( + const ContentContext& renderer, + const Entity& entity, RenderPass& pass) -> bool { Command cmd; cmd.label = "Color Matrix Filter"; + cmd.stencil_reference = entity.GetStencilDepth(); - auto options = OptionsFromPass(pass); - options.blend_mode = BlendMode::kSource; + auto options = OptionsFromPassAndEntity(pass, entity); cmd.pipeline = renderer.GetColorMatrixColorFilterPipeline(options); VertexBufferBuilder vtx_builder; vtx_builder.AddVertices({ - {Point(0, 0)}, - {Point(1, 0)}, - {Point(1, 1)}, - {Point(0, 0)}, - {Point(1, 1)}, - {Point(0, 1)}, + {coverage.origin, Point(0, 0)}, + {{coverage.origin.x + coverage.size.width, coverage.origin.y}, + Point(1, 0)}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + Point(1, 1)}, + {coverage.origin, Point(0, 0)}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + Point(1, 1)}, + {{coverage.origin.x, coverage.origin.y + coverage.size.height}, + Point(0, 1)}, }); auto& host_buffer = pass.GetTransientsBuffer(); auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); cmd.BindVertices(vtx_buffer); VS::FrameInfo frame_info; - frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1)); + frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()); frame_info.texture_sampler_y_coord_scale = input_snapshot->texture->GetYCoordScale(); FS::FragInfo frag_info; - const float* matrix = matrix_.array; + const float* matrix = color_matrix.array; frag_info.color_v = Vector4(matrix[4], matrix[9], matrix[14], matrix[19]); // clang-format off frag_info.color_m = Matrix( @@ -87,7 +95,7 @@ std::optional ColorMatrixFilterContents::RenderFilter( matrix[3], matrix[8], matrix[13], matrix[18] ); // clang-format on - frag_info.input_alpha = GetAbsorbOpacity() ? input_snapshot->opacity : 1.0f; + frag_info.input_alpha = absorb_opacity ? input_snapshot->opacity : 1.0f; auto sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler({}); FS::BindInputTexture(cmd, input_snapshot->texture, sampler); FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info)); @@ -97,18 +105,20 @@ std::optional ColorMatrixFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = renderer.MakeSubpass( - "Color Matrix Filter", input_snapshot->texture->GetSize(), callback); - if (!out_texture) { - return std::nullopt; - } + CoverageProc coverage_proc = + [coverage](const Entity& entity) -> std::optional { + return coverage; + }; + + auto contents = AnonymousContents::Make(render_proc, coverage_proc); - return Entity::FromSnapshot( - Snapshot{.texture = out_texture, - .transform = input_snapshot->transform, - .sampler_descriptor = input_snapshot->sampler_descriptor, - .opacity = GetAbsorbOpacity() ? 1.0f : input_snapshot->opacity}, - entity.GetBlendMode(), entity.GetStencilDepth()); + Entity sub_entity; + sub_entity.SetContents(std::move(contents)); + sub_entity.SetStencilDepth(entity.GetStencilDepth()); + sub_entity.SetTransformation(Matrix::MakeTranslation(coverage.origin) * + entity.GetTransformation()); + sub_entity.SetBlendMode(entity.GetBlendMode()); + return sub_entity; } } // namespace impeller diff --git a/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc b/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc index a749f0a5e9e10..f4c2afd21897e 100644 --- a/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc +++ b/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc @@ -4,6 +4,7 @@ #include "impeller/entity/contents/filters/linear_to_srgb_filter_contents.h" +#include "impeller/entity/contents/anonymous_contents.h" #include "impeller/entity/contents/content_context.h" #include "impeller/entity/contents/contents.h" #include "impeller/geometry/point.h" @@ -35,23 +36,40 @@ std::optional LinearToSrgbFilterContents::RenderFilter( return std::nullopt; } - ContentContext::SubpassCallback callback = [&](const ContentContext& renderer, - RenderPass& pass) { + auto maybe_input_uvs = input_snapshot->GetCoverageUVs(coverage); + if (!maybe_input_uvs.has_value()) { + return std::nullopt; + } + auto input_uvs = maybe_input_uvs.value(); + + //---------------------------------------------------------------------------- + /// Create AnonymousContents for rendering. + /// + RenderProc render_proc = [input_snapshot, coverage, input_uvs, + absorb_opacity = GetAbsorbOpacity()]( + const ContentContext& renderer, + const Entity& entity, RenderPass& pass) -> bool { Command cmd; cmd.label = "Linear to sRGB Filter"; + cmd.stencil_reference = entity.GetStencilDepth(); - auto options = OptionsFromPass(pass); - options.blend_mode = BlendMode::kSource; + auto options = OptionsFromPassAndEntity(pass, entity); cmd.pipeline = renderer.GetLinearToSrgbFilterPipeline(options); VertexBufferBuilder vtx_builder; vtx_builder.AddVertices({ - {Point(0, 0)}, - {Point(1, 0)}, - {Point(1, 1)}, - {Point(0, 0)}, - {Point(1, 1)}, - {Point(0, 1)}, + {coverage.origin, input_uvs[0]}, + {{coverage.origin.x + coverage.size.width, coverage.origin.y}, + input_uvs[1]}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + input_uvs[3]}, + {coverage.origin, input_uvs[0]}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + input_uvs[3]}, + {{coverage.origin.x, coverage.origin.y + coverage.size.height}, + input_uvs[2]}, }); auto& host_buffer = pass.GetTransientsBuffer(); @@ -59,12 +77,12 @@ std::optional LinearToSrgbFilterContents::RenderFilter( cmd.BindVertices(vtx_buffer); VS::FrameInfo frame_info; - frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1)); + frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()); frame_info.texture_sampler_y_coord_scale = input_snapshot->texture->GetYCoordScale(); FS::FragInfo frag_info; - frag_info.input_alpha = GetAbsorbOpacity() ? input_snapshot->opacity : 1.0f; + frag_info.input_alpha = absorb_opacity ? input_snapshot->opacity : 1.0f; auto sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler({}); FS::BindInputTexture(cmd, input_snapshot->texture, sampler); @@ -74,18 +92,19 @@ std::optional LinearToSrgbFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = renderer.MakeSubpass( - "Linear to sRGB Filter", input_snapshot->texture->GetSize(), callback); - if (!out_texture) { - return std::nullopt; - } + CoverageProc coverage_proc = + [coverage](const Entity& entity) -> std::optional { + return coverage; + }; + + auto contents = AnonymousContents::Make(render_proc, coverage_proc); - return Entity::FromSnapshot( - Snapshot{.texture = out_texture, - .transform = input_snapshot->transform, - .sampler_descriptor = input_snapshot->sampler_descriptor, - .opacity = GetAbsorbOpacity() ? 1.0f : input_snapshot->opacity}, - entity.GetBlendMode(), entity.GetStencilDepth()); + Entity sub_entity; + sub_entity.SetContents(std::move(contents)); + sub_entity.SetStencilDepth(entity.GetStencilDepth()); + sub_entity.SetTransformation(entity.GetTransformation()); + sub_entity.SetBlendMode(entity.GetBlendMode()); + return sub_entity; } } // namespace impeller diff --git a/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc b/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc index 940b6f4c335e6..70576924acfbf 100644 --- a/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc +++ b/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc @@ -4,6 +4,7 @@ #include "impeller/entity/contents/filters/srgb_to_linear_filter_contents.h" +#include "impeller/entity/contents/anonymous_contents.h" #include "impeller/entity/contents/content_context.h" #include "impeller/entity/contents/contents.h" #include "impeller/geometry/point.h" @@ -35,23 +36,40 @@ std::optional SrgbToLinearFilterContents::RenderFilter( return std::nullopt; } - ContentContext::SubpassCallback callback = [&](const ContentContext& renderer, - RenderPass& pass) { + auto maybe_input_uvs = input_snapshot->GetCoverageUVs(coverage); + if (!maybe_input_uvs.has_value()) { + return std::nullopt; + } + auto input_uvs = maybe_input_uvs.value(); + + //---------------------------------------------------------------------------- + /// Create AnonymousContents for rendering. + /// + RenderProc render_proc = [input_snapshot, coverage, input_uvs, + absorb_opacity = GetAbsorbOpacity()]( + const ContentContext& renderer, + const Entity& entity, RenderPass& pass) -> bool { Command cmd; cmd.label = "sRGB to Linear Filter"; + cmd.stencil_reference = entity.GetStencilDepth(); - auto options = OptionsFromPass(pass); - options.blend_mode = BlendMode::kSource; + auto options = OptionsFromPassAndEntity(pass, entity); cmd.pipeline = renderer.GetSrgbToLinearFilterPipeline(options); VertexBufferBuilder vtx_builder; vtx_builder.AddVertices({ - {Point(0, 0)}, - {Point(1, 0)}, - {Point(1, 1)}, - {Point(0, 0)}, - {Point(1, 1)}, - {Point(0, 1)}, + {coverage.origin, input_uvs[0]}, + {{coverage.origin.x + coverage.size.width, coverage.origin.y}, + input_uvs[1]}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + input_uvs[3]}, + {coverage.origin, input_uvs[0]}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + input_uvs[3]}, + {{coverage.origin.x, coverage.origin.y + coverage.size.height}, + input_uvs[2]}, }); auto& host_buffer = pass.GetTransientsBuffer(); @@ -59,12 +77,12 @@ std::optional SrgbToLinearFilterContents::RenderFilter( cmd.BindVertices(vtx_buffer); VS::FrameInfo frame_info; - frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1)); + frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()); frame_info.texture_sampler_y_coord_scale = input_snapshot->texture->GetYCoordScale(); FS::FragInfo frag_info; - frag_info.input_alpha = GetAbsorbOpacity() ? input_snapshot->opacity : 1.0f; + frag_info.input_alpha = absorb_opacity ? input_snapshot->opacity : 1.0f; auto sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler({}); FS::BindInputTexture(cmd, input_snapshot->texture, sampler); @@ -74,18 +92,19 @@ std::optional SrgbToLinearFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = renderer.MakeSubpass( - "sRGB to Linear Filter", input_snapshot->texture->GetSize(), callback); - if (!out_texture) { - return std::nullopt; - } + CoverageProc coverage_proc = + [coverage](const Entity& entity) -> std::optional { + return coverage; + }; + + auto contents = AnonymousContents::Make(render_proc, coverage_proc); - return Entity::FromSnapshot( - Snapshot{.texture = out_texture, - .transform = input_snapshot->transform, - .sampler_descriptor = input_snapshot->sampler_descriptor, - .opacity = GetAbsorbOpacity() ? 1.0f : input_snapshot->opacity}, - entity.GetBlendMode(), entity.GetStencilDepth()); + Entity sub_entity; + sub_entity.SetContents(std::move(contents)); + sub_entity.SetStencilDepth(entity.GetStencilDepth()); + sub_entity.SetTransformation(entity.GetTransformation()); + sub_entity.SetBlendMode(entity.GetBlendMode()); + return sub_entity; } } // namespace impeller diff --git a/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc b/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc index fd725ca4f34d4..0b79cc5b10ded 100644 --- a/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc +++ b/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc @@ -5,6 +5,7 @@ #include "impeller/entity/contents/filters/yuv_to_rgb_filter_contents.h" #include "impeller/core/formats.h" +#include "impeller/entity/contents/anonymous_contents.h" #include "impeller/entity/contents/content_context.h" #include "impeller/geometry/matrix.h" #include "impeller/renderer/render_pass.h" @@ -55,6 +56,12 @@ std::optional YUVToRGBFilterContents::RenderFilter( return std::nullopt; } + auto maybe_input_uvs = y_input_snapshot->GetCoverageUVs(coverage); + if (!maybe_input_uvs.has_value()) { + return std::nullopt; + } + auto input_uvs = maybe_input_uvs.value(); + if (y_input_snapshot->texture->GetTextureDescriptor().format != PixelFormat::kR8UNormInt || uv_input_snapshot->texture->GetTextureDescriptor().format != @@ -62,23 +69,34 @@ std::optional YUVToRGBFilterContents::RenderFilter( return std::nullopt; } - ContentContext::SubpassCallback callback = [&](const ContentContext& renderer, - RenderPass& pass) { + //---------------------------------------------------------------------------- + /// Create AnonymousContents for rendering. + /// + RenderProc render_proc = [y_input_snapshot, uv_input_snapshot, coverage, + yuv_color_space = yuv_color_space_, input_uvs]( + const ContentContext& renderer, + const Entity& entity, RenderPass& pass) -> bool { Command cmd; cmd.label = "YUV to RGB Filter"; + cmd.stencil_reference = entity.GetStencilDepth(); - auto options = OptionsFromPass(pass); - options.blend_mode = BlendMode::kSource; + auto options = OptionsFromPassAndEntity(pass, entity); cmd.pipeline = renderer.GetYUVToRGBFilterPipeline(options); VertexBufferBuilder vtx_builder; vtx_builder.AddVertices({ - {Point(0, 0)}, - {Point(1, 0)}, - {Point(1, 1)}, - {Point(0, 0)}, - {Point(1, 1)}, - {Point(0, 1)}, + {coverage.origin, input_uvs[0]}, + {{coverage.origin.x + coverage.size.width, coverage.origin.y}, + input_uvs[1]}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + input_uvs[3]}, + {coverage.origin, input_uvs[0]}, + {{coverage.origin.x + coverage.size.width, + coverage.origin.y + coverage.size.height}, + input_uvs[3]}, + {{coverage.origin.x, coverage.origin.y + coverage.size.height}, + input_uvs[2]}, }); auto& host_buffer = pass.GetTransientsBuffer(); @@ -86,13 +104,13 @@ std::optional YUVToRGBFilterContents::RenderFilter( cmd.BindVertices(vtx_buffer); VS::FrameInfo frame_info; - frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1)); + frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()); frame_info.texture_sampler_y_coord_scale = y_input_snapshot->texture->GetYCoordScale(); FS::FragInfo frag_info; - frag_info.yuv_color_space = static_cast(yuv_color_space_); - switch (yuv_color_space_) { + frag_info.yuv_color_space = static_cast(yuv_color_space); + switch (yuv_color_space) { case YUVColorSpace::kBT601LimitedRange: frag_info.matrix = kMatrixBT601LimitedRange; break; @@ -111,14 +129,19 @@ std::optional YUVToRGBFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = renderer.MakeSubpass( - "YUV to RGB Filter", y_input_snapshot->texture->GetSize(), callback); - if (!out_texture) { - return std::nullopt; - } + CoverageProc coverage_proc = + [coverage](const Entity& entity) -> std::optional { + return coverage; + }; + + auto contents = AnonymousContents::Make(render_proc, coverage_proc); - return Entity::FromSnapshot(Snapshot{.texture = out_texture}, - entity.GetBlendMode(), entity.GetStencilDepth()); + Entity sub_entity; + sub_entity.SetContents(std::move(contents)); + sub_entity.SetStencilDepth(entity.GetStencilDepth()); + sub_entity.SetTransformation(entity.GetTransformation()); + sub_entity.SetBlendMode(entity.GetBlendMode()); + return sub_entity; } } // namespace impeller diff --git a/impeller/entity/shaders/border_mask_blur.frag b/impeller/entity/shaders/border_mask_blur.frag index 88abc3fc64d08..033cb61b48a46 100644 --- a/impeller/entity/shaders/border_mask_blur.frag +++ b/impeller/entity/shaders/border_mask_blur.frag @@ -21,12 +21,13 @@ uniform FragInfo { float16_t src_factor; float16_t inner_blur_factor; float16_t outer_blur_factor; + float16_t alpha; f16vec2 sigma_uv; } frag_info; -in vec2 v_texture_coords; +in highp vec2 v_texture_coords; out f16vec4 frag_color; diff --git a/impeller/entity/shaders/border_mask_blur.vert b/impeller/entity/shaders/border_mask_blur.vert index bff59a4747e65..16282a24151c4 100644 --- a/impeller/entity/shaders/border_mask_blur.vert +++ b/impeller/entity/shaders/border_mask_blur.vert @@ -7,18 +7,17 @@ uniform FrameInfo { mat4 mvp; - float texture_sampler_y_coord_scale; } frame_info; -in vec2 vertices; -in vec2 texture_coords; +in vec2 position; +in highp vec2 texture_coords; -out vec2 v_texture_coords; +out highp vec2 v_texture_coords; void main() { - gl_Position = frame_info.mvp * vec4(vertices, 0.0, 1.0); + gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0); v_texture_coords = IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale); } diff --git a/impeller/entity/shaders/color_matrix_color_filter.frag b/impeller/entity/shaders/color_matrix_color_filter.frag index 64c5d6048f293..8177f211a7ff9 100644 --- a/impeller/entity/shaders/color_matrix_color_filter.frag +++ b/impeller/entity/shaders/color_matrix_color_filter.frag @@ -38,12 +38,12 @@ frag_info; uniform f16sampler2D input_texture; -in highp vec2 v_position; +in highp vec2 v_texture_coords; out f16vec4 frag_color; void main() { f16vec4 input_color = - texture(input_texture, v_position) * frag_info.input_alpha; + texture(input_texture, v_texture_coords) * frag_info.input_alpha; // unpremultiply first, as filter inputs are premultiplied. f16vec4 color = IPHalfUnpremultiply(input_color); diff --git a/impeller/entity/shaders/color_matrix_color_filter.vert b/impeller/entity/shaders/color_matrix_color_filter.vert index 69681f21bf4e1..16282a24151c4 100644 --- a/impeller/entity/shaders/color_matrix_color_filter.vert +++ b/impeller/entity/shaders/color_matrix_color_filter.vert @@ -11,11 +11,13 @@ uniform FrameInfo { } frame_info; -in highp vec2 position; -out highp vec2 v_position; +in vec2 position; +in highp vec2 texture_coords; + +out highp vec2 v_texture_coords; void main() { - v_position = - IPRemapCoords(position, frame_info.texture_sampler_y_coord_scale); gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0); + v_texture_coords = + IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale); } diff --git a/impeller/entity/shaders/linear_to_srgb_filter.frag b/impeller/entity/shaders/linear_to_srgb_filter.frag index 60c22f602ac41..92b90ac617ea5 100644 --- a/impeller/entity/shaders/linear_to_srgb_filter.frag +++ b/impeller/entity/shaders/linear_to_srgb_filter.frag @@ -16,13 +16,13 @@ uniform FragInfo { } frag_info; -in highp vec2 v_position; +in highp vec2 texture_coords; out f16vec4 frag_color; void main() { f16vec4 input_color = - texture(input_texture, v_position) * frag_info.input_alpha; + texture(input_texture, texture_coords) * frag_info.input_alpha; f16vec4 color = IPHalfUnpremultiply(input_color); for (int i = 0; i < 3; i++) { diff --git a/impeller/entity/shaders/linear_to_srgb_filter.vert b/impeller/entity/shaders/linear_to_srgb_filter.vert index 69681f21bf4e1..16282a24151c4 100644 --- a/impeller/entity/shaders/linear_to_srgb_filter.vert +++ b/impeller/entity/shaders/linear_to_srgb_filter.vert @@ -11,11 +11,13 @@ uniform FrameInfo { } frame_info; -in highp vec2 position; -out highp vec2 v_position; +in vec2 position; +in highp vec2 texture_coords; + +out highp vec2 v_texture_coords; void main() { - v_position = - IPRemapCoords(position, frame_info.texture_sampler_y_coord_scale); gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0); + v_texture_coords = + IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale); } diff --git a/impeller/entity/shaders/srgb_to_linear_filter.frag b/impeller/entity/shaders/srgb_to_linear_filter.frag index ab75111267c13..f29dc15c30940 100644 --- a/impeller/entity/shaders/srgb_to_linear_filter.frag +++ b/impeller/entity/shaders/srgb_to_linear_filter.frag @@ -16,11 +16,12 @@ uniform FragInfo { } frag_info; -in vec2 v_position; +in highp vec2 texture_coords; out vec4 frag_color; void main() { - vec4 input_color = texture(input_texture, v_position) * frag_info.input_alpha; + vec4 input_color = + texture(input_texture, texture_coords) * frag_info.input_alpha; vec4 color = IPUnpremultiply(input_color); for (int i = 0; i < 3; i++) { diff --git a/impeller/entity/shaders/srgb_to_linear_filter.vert b/impeller/entity/shaders/srgb_to_linear_filter.vert index 10b56bb6549c2..16282a24151c4 100644 --- a/impeller/entity/shaders/srgb_to_linear_filter.vert +++ b/impeller/entity/shaders/srgb_to_linear_filter.vert @@ -12,10 +12,12 @@ uniform FrameInfo { frame_info; in vec2 position; -out vec2 v_position; +in highp vec2 texture_coords; + +out highp vec2 v_texture_coords; void main() { - v_position = - IPRemapCoords(position, frame_info.texture_sampler_y_coord_scale); gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0); + v_texture_coords = + IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale); } diff --git a/impeller/entity/shaders/yuv_to_rgb_filter.frag b/impeller/entity/shaders/yuv_to_rgb_filter.frag index 41a1882f92e5d..708a2c0c037ab 100644 --- a/impeller/entity/shaders/yuv_to_rgb_filter.frag +++ b/impeller/entity/shaders/yuv_to_rgb_filter.frag @@ -20,7 +20,7 @@ uniform FragInfo { } frag_info; -in highp vec2 v_position; +in highp vec2 texture_coords; out f16vec4 frag_color; @@ -31,7 +31,7 @@ void main() { yuv_offset.x = 16.0hf / 255.0hf; } - yuv.x = texture(y_texture, v_position).r; - yuv.yz = texture(uv_texture, v_position).rg; + yuv.x = texture(y_texture, texture_coords).r; + yuv.yz = texture(uv_texture, texture_coords).rg; frag_color = f16mat4(frag_info.matrix) * f16vec4(yuv - yuv_offset, 1.0hf); } diff --git a/impeller/entity/shaders/yuv_to_rgb_filter.vert b/impeller/entity/shaders/yuv_to_rgb_filter.vert index 69681f21bf4e1..16282a24151c4 100644 --- a/impeller/entity/shaders/yuv_to_rgb_filter.vert +++ b/impeller/entity/shaders/yuv_to_rgb_filter.vert @@ -11,11 +11,13 @@ uniform FrameInfo { } frame_info; -in highp vec2 position; -out highp vec2 v_position; +in vec2 position; +in highp vec2 texture_coords; + +out highp vec2 v_texture_coords; void main() { - v_position = - IPRemapCoords(position, frame_info.texture_sampler_y_coord_scale); gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0); + v_texture_coords = + IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale); } diff --git a/impeller/tools/malioc.json b/impeller/tools/malioc.json index 10a0e4494f423..08e437e9f02aa 100644 --- a/impeller/tools/malioc.json +++ b/impeller/tools/malioc.json @@ -1532,9 +1532,9 @@ "load_store" ], "longest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -1551,9 +1551,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -1562,9 +1562,9 @@ "load_store" ], "total_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -1573,7 +1573,7 @@ "stack_spill_bytes": 0, "thread_occupancy": 100, "uniform_registers_used": 16, - "work_registers_used": 7 + "work_registers_used": 9 } } } @@ -1665,16 +1665,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 0, + "fp16_arithmetic": 100, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.125, - 0.125, - 0.0, + 0.0625, + 0.0625, + 0.0625, 0.0, 2.0, 0.0 @@ -1691,9 +1691,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.125, - 0.125, - 0.0, + 0.0625, + 0.0625, + 0.0625, 0.0, 2.0, 0.0 @@ -1702,9 +1702,9 @@ "load_store" ], "total_cycles": [ - 0.125, - 0.125, - 0.0, + 0.0625, + 0.0625, + 0.0625, 0.0, 2.0, 0.0 @@ -1712,7 +1712,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 30, + "uniform_registers_used": 20, "work_registers_used": 32 }, "Varying": { @@ -1723,9 +1723,9 @@ "load_store" ], "longest_path_cycles": [ - 0.078125, + 0.0625, 0.015625, - 0.078125, + 0.0625, 0.0, 3.0, 0.0 @@ -1742,9 +1742,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.078125, + 0.0625, 0.015625, - 0.078125, + 0.0625, 0.0, 3.0, 0.0 @@ -1753,9 +1753,9 @@ "load_store" ], "total_cycles": [ - 0.078125, + 0.0625, 0.015625, - 0.078125, + 0.0625, 0.0, 3.0, 0.0 @@ -1763,7 +1763,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 22, + "uniform_registers_used": 16, "work_registers_used": 9 } } @@ -5773,7 +5773,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 86, + "fp16_arithmetic": 81, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -5781,9 +5781,9 @@ "arith_fma" ], "longest_path_cycles": [ - 0.90625, - 0.90625, - 0.265625, + 0.9375, + 0.9375, + 0.296875, 0.25, 0.0, 0.25, @@ -5803,9 +5803,9 @@ "arith_fma" ], "shortest_path_cycles": [ - 0.90625, - 0.90625, - 0.234375, + 0.9375, + 0.9375, + 0.265625, 0.25, 0.0, 0.25, @@ -5816,9 +5816,9 @@ "arith_fma" ], "total_cycles": [ - 0.90625, - 0.90625, - 0.265625, + 0.9375, + 0.9375, + 0.296875, 0.25, 0.0, 0.25, @@ -5827,7 +5827,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 12, + "uniform_registers_used": 10, "work_registers_used": 29 } } @@ -5845,7 +5845,7 @@ "arithmetic" ], "longest_path_cycles": [ - 8.90999984741211, + 8.579999923706055, 1.0, 1.0 ], @@ -5858,7 +5858,7 @@ "arithmetic" ], "shortest_path_cycles": [ - 8.90999984741211, + 8.579999923706055, 1.0, 1.0 ], @@ -5866,14 +5866,14 @@ "arithmetic" ], "total_cycles": [ - 9.333333015441895, + 9.0, 1.0, 1.0 ] }, "thread_occupancy": 100, "uniform_registers_used": 1, - "work_registers_used": 2 + "work_registers_used": 3 } } } @@ -5937,16 +5937,16 @@ "work_registers_used": 32 }, "Varying": { - "fp16_arithmetic": 100, + "fp16_arithmetic": 0, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.03125, + 0.078125, 0.015625, - 0.03125, + 0.078125, 0.0, 3.0, 0.0 @@ -5963,9 +5963,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.03125, - 0.015625, - 0.03125, + 0.0625, + 0.0, + 0.0625, 0.0, 3.0, 0.0 @@ -5974,9 +5974,9 @@ "load_store" ], "total_cycles": [ - 0.03125, + 0.078125, 0.015625, - 0.03125, + 0.078125, 0.0, 3.0, 0.0 @@ -5985,7 +5985,7 @@ "stack_spill_bytes": 0, "thread_occupancy": 100, "uniform_registers_used": 10, - "work_registers_used": 7 + "work_registers_used": 9 } } }, @@ -6167,16 +6167,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 0, + "fp16_arithmetic": 80, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.140625, - 0.140625, - 0.0, + 0.078125, + 0.078125, + 0.046875, 0.0, 2.0, 0.0 @@ -6193,9 +6193,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.140625, - 0.140625, - 0.0, + 0.078125, + 0.078125, + 0.046875, 0.0, 2.0, 0.0 @@ -6204,9 +6204,9 @@ "load_store" ], "total_cycles": [ - 0.140625, - 0.140625, - 0.0, + 0.078125, + 0.078125, + 0.046875, 0.0, 2.0, 0.0 @@ -6214,7 +6214,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 20, + "uniform_registers_used": 16, "work_registers_used": 32 }, "Varying": { @@ -6284,7 +6284,7 @@ ], "longest_path_cycles": [ 2.9700000286102295, - 4.0, + 5.0, 0.0 ], "pipelines": [ @@ -6297,7 +6297,7 @@ ], "shortest_path_cycles": [ 2.9700000286102295, - 4.0, + 5.0, 0.0 ], "total_bound_pipelines": [ @@ -6305,7 +6305,7 @@ ], "total_cycles": [ 3.0, - 4.0, + 5.0, 0.0 ] }, @@ -8018,16 +8018,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 0, + "fp16_arithmetic": 80, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.140625, - 0.140625, - 0.0, + 0.078125, + 0.078125, + 0.046875, 0.0, 2.0, 0.0 @@ -8044,9 +8044,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.140625, - 0.140625, - 0.0, + 0.078125, + 0.078125, + 0.046875, 0.0, 2.0, 0.0 @@ -8055,9 +8055,9 @@ "load_store" ], "total_cycles": [ - 0.140625, - 0.140625, - 0.0, + 0.078125, + 0.078125, + 0.046875, 0.0, 2.0, 0.0 @@ -8065,7 +8065,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 20, + "uniform_registers_used": 16, "work_registers_used": 32 }, "Varying": { @@ -8135,7 +8135,7 @@ ], "longest_path_cycles": [ 2.9700000286102295, - 4.0, + 5.0, 0.0 ], "pipelines": [ @@ -8148,7 +8148,7 @@ ], "shortest_path_cycles": [ 2.9700000286102295, - 4.0, + 5.0, 0.0 ], "total_bound_pipelines": [ @@ -8156,7 +8156,7 @@ ], "total_cycles": [ 3.0, - 4.0, + 5.0, 0.0 ] }, @@ -9706,16 +9706,16 @@ "work_registers_used": 32 }, "Varying": { - "fp16_arithmetic": 100, + "fp16_arithmetic": 0, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.03125, + 0.078125, 0.015625, - 0.03125, + 0.078125, 0.0, 3.0, 0.0 @@ -9732,9 +9732,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.03125, - 0.015625, - 0.03125, + 0.0625, + 0.0, + 0.0625, 0.0, 3.0, 0.0 @@ -9743,9 +9743,9 @@ "load_store" ], "total_cycles": [ - 0.03125, + 0.078125, 0.015625, - 0.03125, + 0.078125, 0.0, 3.0, 0.0 @@ -9754,7 +9754,7 @@ "stack_spill_bytes": 0, "thread_occupancy": 100, "uniform_registers_used": 10, - "work_registers_used": 7 + "work_registers_used": 9 } } }, @@ -9772,7 +9772,7 @@ ], "longest_path_cycles": [ 2.9700000286102295, - 4.0, + 5.0, 0.0 ], "pipelines": [ @@ -9785,7 +9785,7 @@ ], "shortest_path_cycles": [ 2.9700000286102295, - 4.0, + 5.0, 0.0 ], "total_bound_pipelines": [ @@ -9793,7 +9793,7 @@ ], "total_cycles": [ 3.0, - 4.0, + 5.0, 0.0 ] }, @@ -10718,16 +10718,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 0, + "fp16_arithmetic": 80, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.140625, - 0.140625, - 0.0, + 0.078125, + 0.078125, + 0.046875, 0.0, 2.0, 0.0 @@ -10744,9 +10744,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.140625, - 0.140625, - 0.0, + 0.078125, + 0.078125, + 0.046875, 0.0, 2.0, 0.0 @@ -10755,9 +10755,9 @@ "load_store" ], "total_cycles": [ - 0.140625, - 0.140625, - 0.0, + 0.078125, + 0.078125, + 0.046875, 0.0, 2.0, 0.0 @@ -10765,7 +10765,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 20, + "uniform_registers_used": 16, "work_registers_used": 32 }, "Varying": { @@ -10835,7 +10835,7 @@ ], "longest_path_cycles": [ 2.9700000286102295, - 4.0, + 5.0, 0.0 ], "pipelines": [ @@ -10848,7 +10848,7 @@ ], "shortest_path_cycles": [ 2.9700000286102295, - 4.0, + 5.0, 0.0 ], "total_bound_pipelines": [ @@ -10856,7 +10856,7 @@ ], "total_cycles": [ 3.0, - 4.0, + 5.0, 0.0 ] }, @@ -11569,16 +11569,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 0, + "fp16_arithmetic": 100, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.125, - 0.125, - 0.0, + 0.0625, + 0.0625, + 0.0625, 0.0, 2.0, 0.0 @@ -11595,9 +11595,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.125, - 0.125, - 0.0, + 0.0625, + 0.0625, + 0.0625, 0.0, 2.0, 0.0 @@ -11606,9 +11606,9 @@ "load_store" ], "total_cycles": [ - 0.125, - 0.125, - 0.0, + 0.0625, + 0.0625, + 0.0625, 0.0, 2.0, 0.0 @@ -11616,7 +11616,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 30, + "uniform_registers_used": 20, "work_registers_used": 32 }, "Varying": { @@ -11627,9 +11627,9 @@ "load_store" ], "longest_path_cycles": [ - 0.078125, + 0.0625, 0.015625, - 0.078125, + 0.0625, 0.0, 3.0, 0.0 @@ -11646,9 +11646,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.078125, + 0.0625, 0.015625, - 0.078125, + 0.0625, 0.0, 3.0, 0.0 @@ -11657,9 +11657,9 @@ "load_store" ], "total_cycles": [ - 0.078125, + 0.0625, 0.015625, - 0.078125, + 0.0625, 0.0, 3.0, 0.0 @@ -11667,7 +11667,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 22, + "uniform_registers_used": 16, "work_registers_used": 9 } } @@ -12793,9 +12793,9 @@ "load_store" ], "longest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -12812,9 +12812,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -12823,9 +12823,9 @@ "load_store" ], "total_cycles": [ - 0.03125, + 0.0625, 0.015625, - 0.03125, + 0.0625, 0.0, 3.0, 0.0 @@ -12834,7 +12834,7 @@ "stack_spill_bytes": 0, "thread_occupancy": 100, "uniform_registers_used": 16, - "work_registers_used": 7 + "work_registers_used": 9 } } } @@ -13503,16 +13503,16 @@ "type": "Vertex", "variants": { "Position": { - "fp16_arithmetic": 0, + "fp16_arithmetic": 100, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "load_store" ], "longest_path_cycles": [ - 0.125, - 0.125, - 0.0, + 0.0625, + 0.0625, + 0.0625, 0.0, 2.0, 0.0 @@ -13529,9 +13529,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.125, - 0.125, - 0.0, + 0.0625, + 0.0625, + 0.0625, 0.0, 2.0, 0.0 @@ -13540,9 +13540,9 @@ "load_store" ], "total_cycles": [ - 0.125, - 0.125, - 0.0, + 0.0625, + 0.0625, + 0.0625, 0.0, 2.0, 0.0 @@ -13550,7 +13550,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 30, + "uniform_registers_used": 20, "work_registers_used": 32 }, "Varying": { @@ -13561,9 +13561,9 @@ "load_store" ], "longest_path_cycles": [ - 0.078125, + 0.0625, 0.015625, - 0.078125, + 0.0625, 0.0, 3.0, 0.0 @@ -13580,9 +13580,9 @@ "load_store" ], "shortest_path_cycles": [ - 0.078125, + 0.0625, 0.015625, - 0.078125, + 0.0625, 0.0, 3.0, 0.0 @@ -13591,9 +13591,9 @@ "load_store" ], "total_cycles": [ - 0.078125, + 0.0625, 0.015625, - 0.078125, + 0.0625, 0.0, 3.0, 0.0 @@ -13601,7 +13601,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 22, + "uniform_registers_used": 16, "work_registers_used": 9 } }