[Impeller] remove shared_ptr copy/release in main rendering loop. (flutter/engine#49801)

![image](https://github.com/flutter/engine/assets/8975114/7ce7c77e-fab3-483b-871f-437a681911c5)
This commit is contained in:
Jonah Williams
2024-01-16 13:25:16 -08:00
committed by GitHub
parent 6494f91cc5
commit 5083adf8f3
6 changed files with 11 additions and 10 deletions

View File

@@ -53,7 +53,7 @@ std::shared_ptr<Texture> Picture::RenderToTexture(
// This texture isn't host visible, but we might want to add host visible
// features to Image someday.
auto impeller_context = context.GetContext();
const std::shared_ptr<Context>& impeller_context = context.GetContext();
// Do not use the render target cache as the lifecycle of this texture
// will outlive a particular frame.
RenderTargetAllocator render_target_allocator =

View File

@@ -125,7 +125,6 @@ bool ClipContents::Render(const ContentContext& renderer,
options.primitive_type = geometry_result.type;
pass.SetPipeline(renderer.GetClipPipeline(options));
auto allocator = renderer.GetContext()->GetResourceAllocator();
pass.SetVertexBuffer(std::move(geometry_result.vertex_buffer));
info.mvp = geometry_result.transform;

View File

@@ -414,7 +414,7 @@ fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
ISize texture_size,
const SubpassCallback& subpass_callback,
bool msaa_enabled) const {
std::shared_ptr<Context> context = GetContext();
const std::shared_ptr<Context>& context = GetContext();
RenderTarget subpass_target;
if (context->GetCapabilities()->SupportsOffscreenMSAA() && msaa_enabled) {
subpass_target = RenderTarget::CreateOffscreenMSAA(
@@ -438,7 +438,7 @@ fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
const std::string& label,
const RenderTarget& subpass_target,
const SubpassCallback& subpass_callback) const {
std::shared_ptr<Context> context = GetContext();
const std::shared_ptr<Context>& context = GetContext();
auto subpass_texture = subpass_target.GetRenderTargetTexture();
if (!subpass_texture) {

View File

@@ -16,6 +16,7 @@
#include "impeller/entity/contents/clip_contents.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/runtime_effect.vert.h"
#include "impeller/renderer/capabilities.h"
#include "impeller/renderer/pipeline_library.h"
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/shader_function.h"
@@ -68,8 +69,8 @@ static std::shared_ptr<ShaderMetadata> MakeShaderMetadata(
bool RuntimeEffectContents::Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
auto context = renderer.GetContext();
auto library = context->GetShaderLibrary();
const std::shared_ptr<Context>& context = renderer.GetContext();
const std::shared_ptr<ShaderLibrary>& library = context->GetShaderLibrary();
//--------------------------------------------------------------------------
/// Get or register shader.
@@ -138,7 +139,7 @@ bool RuntimeEffectContents::Render(const ContentContext& renderer,
/// layouts are known from the uniforms.
///
const auto& caps = context->GetCapabilities();
const std::shared_ptr<const Capabilities>& caps = context->GetCapabilities();
const auto color_attachment_format = caps->GetDefaultColorFormat();
const auto stencil_attachment_format = caps->GetDefaultStencilFormat();

View File

@@ -249,7 +249,7 @@ static EntityPassTarget CreateRenderTarget(ContentContext& renderer,
ISize size,
int mip_count,
const Color& clear_color) {
auto context = renderer.GetContext();
const std::shared_ptr<Context>& context = renderer.GetContext();
/// All of the load/store actions are managed by `InlinePassContext` when
/// `RenderPasses` are created, so we just set them to `kDontCare` here.
@@ -843,7 +843,7 @@ bool EntityPass::OnRender(
collapsed_parent_pass) const {
TRACE_EVENT0("impeller", "EntityPass::OnRender");
auto context = renderer.GetContext();
const std::shared_ptr<Context>& context = renderer.GetContext();
InlinePassContext pass_context(context, pass_target,
GetTotalPassReads(renderer), GetElementCount(),
collapsed_parent_pass);

View File

@@ -20,7 +20,8 @@ RuntimeStagePlayground::~RuntimeStagePlayground() = default;
bool RuntimeStagePlayground::RegisterStage(const RuntimeStage& stage) {
std::promise<bool> registration;
auto future = registration.get_future();
auto library = GetContext()->GetShaderLibrary();
const std::shared_ptr<ShaderLibrary>& library =
GetContext()->GetShaderLibrary();
GetContext()->GetShaderLibrary()->RegisterFunction(
stage.GetEntrypoint(), ToShaderStage(stage.GetShaderStage()),
stage.GetCodeMapping(),