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

This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user