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
++
  • Loading branch information
jonahwilliams committed Jul 24, 2024
commit 4b68381771cd510feeaf20101f24ca5383de7785
2 changes: 2 additions & 0 deletions impeller/renderer/backend/metal/context_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,12 @@ new ContextMTL(device, command_queue,
return command_queue_ip_;
}

#ifdef IMPELLER_DEBUG
const std::shared_ptr<ImpellerMetalCaptureManager>
ContextMTL::GetCaptureManager() const {
return capture_manager_;
}
#endif // IMPELLER_DEBUG

ImpellerMetalCaptureManager::ImpellerMetalCaptureManager(id<MTLDevice> device) {
current_capture_scope_ = [[MTLCaptureManager sharedCaptureManager]
Expand Down
9 changes: 1 addition & 8 deletions impeller/renderer/backend/metal/surface_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,7 @@ - (void)flutterPrepareForPresent:(nonnull id<MTLCommandBuffer>)commandBuffer;
source_texture_(std::move(source_texture)),
destination_texture_(std::move(destination_texture)),
requires_blit_(requires_blit),
clip_rect_(clip_rect) {
#ifdef IMPELLER_DEBUG
auto mtl_context = context_.lock();
if (mtl_context) {
ContextMTL::Cast(mtl_context.get())->GetCaptureManager()->StartCapture();
}
#endif // IMPELLER_DEBUG
}
clip_rect_(clip_rect) {}

// |Surface|
SurfaceMTL::~SurfaceMTL() = default;
Expand Down
8 changes: 8 additions & 0 deletions shell/gpu/gpu_surface_metal_impeller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
last_texture_.reset([drawable.texture retain]);
}

#ifdef IMPELLER_DEBUG
impeller::ContextMTL::Cast(*impeller_renderer_->GetContext()).GetCaptureManager()->StartCapture();
#endif // IMPELLER_DEBUG

id<MTLTexture> last_texture = static_cast<id<MTLTexture>>(last_texture_);
SurfaceFrame::SubmitCallback submit_callback =
fml::MakeCopyable([damage = damage_,
Expand Down Expand Up @@ -234,6 +238,10 @@
last_texture_.reset([mtl_texture retain]);
}

#ifdef IMPELLER_DEBUG
impeller::ContextMTL::Cast(*impeller_renderer_->GetContext()).GetCaptureManager()->StartCapture();
#endif // IMPELLER_DEBUG

SurfaceFrame::SubmitCallback submit_callback =
fml::MakeCopyable([disable_partial_repaint = disable_partial_repaint_, //
damage = damage_,
Expand Down
2 changes: 2 additions & 0 deletions shell/gpu/gpu_surface_metal_impeller_unittests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override
EXPECT_EQ(host_buffer.GetStateForTest().current_frame, 1u);
}

#ifdef IMPELLER_DEBUG
TEST(GPUSurfaceMetalImpeller, CreatesImpellerCaptureScope) {
auto delegate = std::make_shared<TestGPUSurfaceMetalDelegate>();
delegate->SetDevice();
Expand Down Expand Up @@ -151,6 +152,7 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override
ASSERT_TRUE(frame_2->Submit());
EXPECT_FALSE(context->GetCaptureManager()->CaptureScopeActive());
}
#endif // IMPELLER_DEBUG

} // namespace testing
} // namespace flutter