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 1 commit
Commits
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
Prev Previous commit
Next Next commit
rename to ssbo_fill, move to context
  • Loading branch information
jonahwilliams committed Nov 17, 2022
commit 377b3e57b795a3009639543e6353162f073b1946
6 changes: 3 additions & 3 deletions impeller/entity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ impeller_shaders("modern_entity_shaders") {
}

shaders = [
"shaders/linear_gradient_fixed_fill.frag",
"shaders/radial_gradient_fixed_fill.frag",
"shaders/sweep_gradient_fixed_fill.frag",
"shaders/linear_gradient_ssbo_fill.frag",
"shaders/radial_gradient_ssbo_fill.frag",
"shaders/sweep_gradient_ssbo_fill.frag",
]
}

Expand Down
21 changes: 8 additions & 13 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,25 +150,20 @@ ContentContext::ContentContext(std::shared_ptr<Context> context)
if (!context_ || !context_->IsValid()) {
return;
}
#ifdef FML_OS_ANDROID
backend_features_ = kLegacyBackendFeatures;
#else
backend_features_ = kModernBackendFeatures;
#endif // FML_OS_ANDROID

solid_fill_pipelines_[{}] =
CreateDefaultPipeline<SolidFillPipeline>(*context_);
linear_gradient_fill_pipelines_[{}] =
CreateDefaultPipeline<LinearGradientFillPipeline>(*context_);
radial_gradient_fill_pipelines_[{}] =
CreateDefaultPipeline<RadialGradientFillPipeline>(*context_);
if (backend_features_.ssbo_support) {
linear_gradient_fixed_fill_pipelines_[{}] =
CreateDefaultPipeline<LinearGradientFixedFillPipeline>(*context_);
radial_gradient_fixed_fill_pipelines_[{}] =
CreateDefaultPipeline<RadialGradientFixedFillPipeline>(*context_);
sweep_gradient_fixed_fill_pipelines_[{}] =
CreateDefaultPipeline<SweepGradientFixedFillPipeline>(*context_);
if (context_->GetBackendFeatures().ssbo_support) {
linear_gradient_ssbo_fill_pipelines_[{}] =
CreateDefaultPipeline<LinearGradientSSBOFillPipeline>(*context_);
radial_gradient_ssbo_fill_pipelines_[{}] =
CreateDefaultPipeline<RadialGradientSSBOFillPipeline>(*context_);
sweep_gradient_ssbo_fill_pipelines_[{}] =
CreateDefaultPipeline<SweepGradientSSBOFillPipeline>(*context_);
}
sweep_gradient_fill_pipelines_[{}] =
CreateDefaultPipeline<SweepGradientFillPipeline>(*context_);
Expand Down Expand Up @@ -317,7 +312,7 @@ std::shared_ptr<Context> ContentContext::GetContext() const {
}

const BackendFeatures& ContentContext::GetBackendFeatures() const {
return backend_features_;
return context_->GetBackendFeatures();
}

} // namespace impeller
51 changes: 24 additions & 27 deletions impeller/entity/contents/content_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@

#include "impeller/typographer/glyph_atlas.h"

#include "impeller/entity/linear_gradient_fixed_fill.frag.h"
#include "impeller/entity/radial_gradient_fixed_fill.frag.h"
#include "impeller/entity/sweep_gradient_fixed_fill.frag.h"

#include "impeller/entity/contents/backend_features.h"
#include "impeller/entity/linear_gradient_ssbo_fill.frag.h"
#include "impeller/entity/radial_gradient_ssbo_fill.frag.h"
#include "impeller/entity/sweep_gradient_ssbo_fill.frag.h"

namespace impeller {

Expand All @@ -88,15 +86,15 @@ using RadialGradientFillPipeline =
RenderPipelineT<GradientFillVertexShader, RadialGradientFillFragmentShader>;
using SweepGradientFillPipeline =
RenderPipelineT<GradientFillVertexShader, SweepGradientFillFragmentShader>;
using LinearGradientFixedFillPipeline =
using LinearGradientSSBOFillPipeline =
RenderPipelineT<GradientFillVertexShader,
LinearGradientFixedFillFragmentShader>;
using RadialGradientFixedFillPipeline =
LinearGradientSsboFillFragmentShader>;
using RadialGradientSSBOFillPipeline =
RenderPipelineT<GradientFillVertexShader,
RadialGradientFixedFillFragmentShader>;
using SweepGradientFixedFillPipeline =
RadialGradientSsboFillFragmentShader>;
using SweepGradientSSBOFillPipeline =
RenderPipelineT<GradientFillVertexShader,
SweepGradientFixedFillFragmentShader>;
SweepGradientSsboFillFragmentShader>;
using BlendPipeline = RenderPipelineT<BlendVertexShader, BlendFragmentShader>;
using RRectBlurPipeline =
RenderPipelineT<RrectBlurVertexShader, RrectBlurFragmentShader>;
Expand Down Expand Up @@ -226,21 +224,21 @@ class ContentContext {
}

std::shared_ptr<Pipeline<PipelineDescriptor>>
GetLinearGradientFixedFillPipeline(ContentContextOptions opts) const {
FML_DCHECK(backend_features_.ssbo_support);
return GetPipeline(linear_gradient_fixed_fill_pipelines_, opts);
GetLinearGradientSSBOFillPipeline(ContentContextOptions opts) const {
FML_DCHECK(GetBackendFeatures().ssbo_support);
return GetPipeline(linear_gradient_ssbo_fill_pipelines_, opts);
}

std::shared_ptr<Pipeline<PipelineDescriptor>>
GetRadialGradientFixedFillPipeline(ContentContextOptions opts) const {
FML_DCHECK(backend_features_.ssbo_support);
return GetPipeline(radial_gradient_fixed_fill_pipelines_, opts);
GetRadialGradientSSBOFillPipeline(ContentContextOptions opts) const {
FML_DCHECK(GetBackendFeatures().ssbo_support);
return GetPipeline(radial_gradient_ssbo_fill_pipelines_, opts);
}

std::shared_ptr<Pipeline<PipelineDescriptor>>
GetSweepGradientFixedFillPipeline(ContentContextOptions opts) const {
FML_DCHECK(backend_features_.ssbo_support);
return GetPipeline(sweep_gradient_fixed_fill_pipelines_, opts);
GetSweepGradientSSBOFillPipeline(ContentContextOptions opts) const {
FML_DCHECK(GetBackendFeatures().ssbo_support);
return GetPipeline(sweep_gradient_ssbo_fill_pipelines_, opts);
}

std::shared_ptr<Pipeline<PipelineDescriptor>> GetRadialGradientFillPipeline(
Expand Down Expand Up @@ -451,12 +449,12 @@ class ContentContext {
mutable Variants<LinearGradientFillPipeline> linear_gradient_fill_pipelines_;
mutable Variants<RadialGradientFillPipeline> radial_gradient_fill_pipelines_;
mutable Variants<SweepGradientFillPipeline> sweep_gradient_fill_pipelines_;
mutable Variants<LinearGradientFixedFillPipeline>
linear_gradient_fixed_fill_pipelines_;
mutable Variants<RadialGradientFixedFillPipeline>
radial_gradient_fixed_fill_pipelines_;
mutable Variants<SweepGradientFixedFillPipeline>
sweep_gradient_fixed_fill_pipelines_;
mutable Variants<LinearGradientSSBOFillPipeline>
linear_gradient_ssbo_fill_pipelines_;
mutable Variants<RadialGradientSSBOFillPipeline>
radial_gradient_ssbo_fill_pipelines_;
mutable Variants<SweepGradientSSBOFillPipeline>
sweep_gradient_ssbo_fill_pipelines_;
mutable Variants<RRectBlurPipeline> rrect_blur_pipelines_;
mutable Variants<BlendPipeline> texture_blend_pipelines_;
mutable Variants<TexturePipeline> texture_pipelines_;
Expand Down Expand Up @@ -524,7 +522,6 @@ class ContentContext {
bool is_valid_ = false;
std::shared_ptr<Tessellator> tessellator_;
std::shared_ptr<GlyphAtlasContext> glyph_atlas_context_;
BackendFeatures backend_features_;

FML_DISALLOW_COPY_AND_ASSIGN(ContentContext);
};
Expand Down
8 changes: 4 additions & 4 deletions impeller/entity/contents/linear_gradient_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ bool LinearGradientContents::RenderTexture(const ContentContext& renderer,
bool LinearGradientContents::RenderSSBO(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
using VS = LinearGradientFixedFillPipeline::VertexShader;
using FS = LinearGradientFixedFillPipeline::FragmentShader;
using VS = LinearGradientSSBOFillPipeline::VertexShader;
using FS = LinearGradientSSBOFillPipeline::FragmentShader;

FS::GradientInfo gradient_info;
gradient_info.start_point = start_point_;
Expand All @@ -141,7 +141,7 @@ bool LinearGradientContents::RenderSSBO(const ContentContext& renderer,
frame_info.matrix = GetInverseMatrix();

Command cmd;
cmd.label = "LinearGradientFixedFill";
cmd.label = "LinearGradientSSBOFill";
cmd.stencil_reference = entity.GetStencilDepth();

auto geometry_result =
Expand All @@ -152,7 +152,7 @@ bool LinearGradientContents::RenderSSBO(const ContentContext& renderer,
options.stencil_operation = StencilOperation::kIncrementClamp;
}
options.primitive_type = geometry_result.type;
cmd.pipeline = renderer.GetLinearGradientFixedFillPipeline(options);
cmd.pipeline = renderer.GetLinearGradientSSBOFillPipeline(options);

cmd.BindVertices(geometry_result.vertex_buffer);
FS::BindGradientInfo(
Expand Down
8 changes: 4 additions & 4 deletions impeller/entity/contents/radial_gradient_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ bool RadialGradientContents::Render(const ContentContext& renderer,
bool RadialGradientContents::RenderSSBO(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
using VS = RadialGradientFixedFillPipeline::VertexShader;
using FS = RadialGradientFixedFillPipeline::FragmentShader;
using VS = RadialGradientSSBOFillPipeline::VertexShader;
using FS = RadialGradientSSBOFillPipeline::FragmentShader;

FS::GradientInfo gradient_info;
gradient_info.center = center_;
Expand All @@ -79,7 +79,7 @@ bool RadialGradientContents::RenderSSBO(const ContentContext& renderer,
frame_info.matrix = GetInverseMatrix();

Command cmd;
cmd.label = "RadialGradientFixedFill";
cmd.label = "RadialGradientSSBOFill";
cmd.stencil_reference = entity.GetStencilDepth();

auto geometry_result =
Expand All @@ -90,7 +90,7 @@ bool RadialGradientContents::RenderSSBO(const ContentContext& renderer,
options.stencil_operation = StencilOperation::kIncrementClamp;
}
options.primitive_type = geometry_result.type;
cmd.pipeline = renderer.GetRadialGradientFixedFillPipeline(options);
cmd.pipeline = renderer.GetRadialGradientSSBOFillPipeline(options);

cmd.BindVertices(geometry_result.vertex_buffer);
FS::BindGradientInfo(
Expand Down
8 changes: 4 additions & 4 deletions impeller/entity/contents/sweep_gradient_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ bool SweepGradientContents::Render(const ContentContext& renderer,
bool SweepGradientContents::RenderSSBO(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
using VS = SweepGradientFixedFillPipeline::VertexShader;
using FS = SweepGradientFixedFillPipeline::FragmentShader;
using VS = SweepGradientSSBOFillPipeline::VertexShader;
using FS = SweepGradientSSBOFillPipeline::FragmentShader;

FS::GradientInfo gradient_info;
gradient_info.center = center_;
Expand All @@ -85,7 +85,7 @@ bool SweepGradientContents::RenderSSBO(const ContentContext& renderer,
frame_info.matrix = GetInverseMatrix();

Command cmd;
cmd.label = "SweepGradientFixedFill";
cmd.label = "SweepGradientSSBOFill";
cmd.stencil_reference = entity.GetStencilDepth();
auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);
Expand All @@ -96,7 +96,7 @@ bool SweepGradientContents::RenderSSBO(const ContentContext& renderer,
options.stencil_operation = StencilOperation::kIncrementClamp;
}
options.primitive_type = geometry_result.type;
cmd.pipeline = renderer.GetSweepGradientFixedFillPipeline(options);
cmd.pipeline = renderer.GetSweepGradientSSBOFillPipeline(options);

cmd.BindVertices(geometry_result.vertex_buffer);
FS::BindGradientInfo(
Expand Down
5 changes: 5 additions & 0 deletions impeller/renderer/backend/gles/context_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,9 @@ bool ContextGLES::SupportsOffscreenMSAA() const {
return false;
}

// |Context|
const BackendFeatures& ContextGLES::GetBackendFeatures() const {
return kLegacyBackendFeatures;
}

} // namespace impeller
3 changes: 3 additions & 0 deletions impeller/renderer/backend/gles/context_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class ContextGLES final : public Context,
// |Context|
bool SupportsOffscreenMSAA() const override;

// |Context|
const BackendFeatures& GetBackendFeatures() const override;

FML_DISALLOW_COPY_AND_ASSIGN(ContextGLES);
};

Expand Down
3 changes: 3 additions & 0 deletions impeller/renderer/backend/metal/context_mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class ContextMTL final : public Context,
// |Context|
bool SupportsOffscreenMSAA() const override;

// |Context|
const BackendFeatures& GetBackendFeatures() const override;

std::shared_ptr<CommandBuffer> CreateCommandBufferInQueue(
id<MTLCommandQueue> queue) const;

Expand Down
5 changes: 5 additions & 0 deletions impeller/renderer/backend/metal/context_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,9 @@
return true;
}

// |Context|
const BackendFeatures& ContextMTL::GetBackendFeatures() const {
return kModernBackendFeatures;
}

} // namespace impeller
5 changes: 5 additions & 0 deletions impeller/renderer/backend/vulkan/context_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "impeller/renderer/backend/vulkan/surface_producer_vk.h"
#include "impeller/renderer/backend/vulkan/swapchain_details_vk.h"
#include "impeller/renderer/backend/vulkan/vk.h"
#include "impeller/renderer/backend_features.h"

VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE

Expand Down Expand Up @@ -588,4 +589,8 @@ PixelFormat ContextVK::GetColorAttachmentPixelFormat() const {
return ToPixelFormat(surface_format_);
}

const BackendFeatures& ContextVK::GetBackendFeatures() const {
return kModernBackendFeatures;
}

} // namespace impeller
3 changes: 3 additions & 0 deletions impeller/renderer/backend/vulkan/context_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ class ContextVK final : public Context, public BackendCast<ContextVK, Context> {
// |Context|
bool SupportsOffscreenMSAA() const override;

// |Context|
const BackendFeatures& GetBackendFeatures() const override;

FML_DISALLOW_COPY_AND_ASSIGN(ContextVK);
};

Expand Down
3 changes: 3 additions & 0 deletions impeller/renderer/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <string>

#include "flutter/fml/macros.h"
#include "impeller/renderer/backend_features.h"
#include "impeller/renderer/formats.h"

namespace impeller {
Expand Down Expand Up @@ -52,6 +53,8 @@ class Context : public std::enable_shared_from_this<Context> {

virtual bool SupportsOffscreenMSAA() const = 0;

virtual const BackendFeatures& GetBackendFeatures() const = 0;

protected:
Context();

Expand Down