Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
[Impeller] remove shared_ptr copy/release in main rendering loop. (#4…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams authored Jan 16, 2024
1 parent eab7bd3 commit d4b6b7e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion impeller/aiks/picture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
1 change: 0 additions & 1 deletion impeller/entity/contents/clip_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions impeller/entity/contents/runtime_effect_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion impeller/runtime_stage/runtime_stage_playground.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit d4b6b7e

Please sign in to comment.