Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] Encode render passes concurrently on iOS. #42028

Merged
merged 23 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
6 changes: 1 addition & 5 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,7 @@ std::shared_ptr<Texture> ContentContext::MakeSubpass(
return nullptr;
}

if (!sub_renderpass->EncodeCommands()) {
return nullptr;
}

if (!sub_command_buffer->SubmitCommands()) {
if (!sub_command_buffer->SubmitCommandsAsync(std::move(sub_renderpass))) {
return nullptr;
}

Expand Down
12 changes: 3 additions & 9 deletions impeller/entity/inline_pass_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,9 @@ bool InlinePassContext::EndPass() {
return true;
}

if (!pass_->EncodeCommands()) {
VALIDATION_LOG
<< "Failed to encode commands while ending the current render pass.";
return false;
}

if (!command_buffer_->SubmitCommands()) {
VALIDATION_LOG
<< "Failed to submit command buffer while ending render pass.";
if (!command_buffer_->SubmitCommandsAsync(std::move(pass_))) {
VALIDATION_LOG << "Failed to encode and submit command buffer while ending "
"render pass.";
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions impeller/playground/backend/metal/playground_impl_mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <memory>

#include "flutter/fml/concurrent_message_loop.h"
#include "flutter/fml/macros.h"
#include "impeller/playground/playground_impl.h"

Expand All @@ -27,6 +28,7 @@ class PlaygroundImplMTL final : public PlaygroundImpl {
// To ensure that ObjC stuff doesn't leak into C++ TUs.
std::unique_ptr<Data> data_;
std::shared_ptr<Context> context_;
std::shared_ptr<fml::ConcurrentMessageLoop> concurrent_loop_;

// |PlaygroundImpl|
std::shared_ptr<Context> GetContext() const override;
Expand Down
6 changes: 4 additions & 2 deletions impeller/playground/backend/metal/playground_impl_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,18 @@
PlaygroundImplMTL::PlaygroundImplMTL(PlaygroundSwitches switches)
: PlaygroundImpl(switches),
handle_(nullptr, &DestroyWindowHandle),
data_(std::make_unique<Data>()) {
data_(std::make_unique<Data>()),
concurrent_loop_(fml::ConcurrentMessageLoop::Create()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more or less duplicating the problem that the VKContext has wherein we should only be creating a single concurrent message loop once per engine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW We switched around ContextVK so that it is made to support sharing a concurrent message loop. There's no known problem. This came from Chinmay's design goal of wanting to share these. I'm not sure what that means for your PR, I'm just clarifying that point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look at ContextVK then, when I started this PR ContextVK was still creating its own message loop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContextVK is still creating its own concurrent message loop?

workers_(fml::ConcurrentMessageLoop::Create()) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContextVK takes in a shared_ptr to a task queue which can be shared across multiple engines, but currently is not:

std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner;

I had a PR out that made ContextVK own a single concurrent message loop but we decided we didn't want to shut the door on sharing concurrent message loops between engines. I haven't read this PR through, I'm just responding to the comment "the problem that the VKContext has wherein we should only be creating a single concurrent message loop once per engine". There is no problem that I know of with Vulkan and we made sure of that with our recent work. Let me know if you want me review this PR if you think it would be helpful.

::glfwDefaultWindowHints();
::glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
::glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
auto window = ::glfwCreateWindow(1, 1, "Test", nullptr, nullptr);
if (!window) {
return;
}
auto worker_task_runner = concurrent_loop_->GetTaskRunner();
auto context = ContextMTL::Create(ShaderLibraryMappingsForPlayground(),
"Playground Library");
worker_task_runner, "Playground Library");
if (!context) {
return;
}
Expand Down
3 changes: 3 additions & 0 deletions impeller/renderer/backend/metal/command_buffer_mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class CommandBufferMTL final : public CommandBuffer {
// |CommandBuffer|
void OnWaitUntilScheduled() override;

// |CommandBuffer|
bool SubmitCommandsAsync(std::shared_ptr<RenderPass> render_pass) override;

// |CommandBuffer|
std::shared_ptr<RenderPass> OnCreateRenderPass(RenderTarget target) override;

Expand Down
52 changes: 52 additions & 0 deletions impeller/renderer/backend/metal/command_buffer_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@

#include "impeller/renderer/backend/metal/command_buffer_mtl.h"

#include "flutter/fml/make_copyable.h"
#include "flutter/fml/synchronization/semaphore.h"
#include "flutter/fml/trace_event.h"

#include "impeller/renderer/backend/metal/blit_pass_mtl.h"
#include "impeller/renderer/backend/metal/compute_pass_mtl.h"
#include "impeller/renderer/backend/metal/context_mtl.h"
#include "impeller/renderer/backend/metal/render_pass_mtl.h"

namespace impeller {
Expand Down Expand Up @@ -171,6 +176,53 @@ static bool LogMTLCommandBufferErrorIfPresent(id<MTLCommandBuffer> buffer) {
return true;
}

bool CommandBufferMTL::SubmitCommandsAsync(
std::shared_ptr<RenderPass> render_pass) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this only works for the render pass but could optionally take the blit and compute passes too. I moved this functionality to the command buffer to make ownership of the render pass data more obvious - the closure keeps the shared_ptr for the render pass alive while the command buffer itself only requires the buffer.

TRACE_EVENT0("impeller", "CommandBufferMTL::SubmitCommandsAsync");
if (!IsValid() || !render_pass->IsValid()) {
return false;
}
auto context = context_.lock();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is more or less what ended up being the fix for problems around ownership in Vulkan backend.

if (!context) {
return false;
}
[buffer_ enqueue];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enquing on the main therad ensures the order

auto buffer = buffer_;
buffer_ = nil;

auto worker_task_runner = ContextMTL::Cast(*context).GetWorkerTaskRunner();

auto mtl_render_pass = static_cast<RenderPassMTL*>(render_pass.get());

// Render command encoder creation has been observed to exceed the stack size
// limit for worker threads, and therefore is intentionally constructed on the
// raster thread.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not bump the stack size limit for worker threads?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I try that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's platform specific code, we'd need a pthreads and a win32 implementation at the least.

auto render_command_encoder =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a frustrating discovery because it prevents us from doing the obvious thing and just calling RenderPass::Encode in the closure.

[buffer renderCommandEncoderWithDescriptor:mtl_render_pass->desc_];
if (!render_command_encoder) {
return false;
}

auto task = fml::MakeCopyable(
[render_pass, buffer, render_command_encoder, context]() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we instead capture the weak_ptr to context and make sure it's still lockable in the callback here?

The advantage being that if the context has otherwise gone away, we avoid doing work.

Otherwise, I think we might need to have something about the GPU sync switch in here to make sure we're not doing encoding work when the GPU is unavailable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, capturing the context seems reasonable. I'm not sure what the buffer itself will do, I guess we should probably assume it won't handle anything gracefully.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

auto mtl_render_pass = static_cast<RenderPassMTL*>(render_pass.get());
if (!mtl_render_pass->label_.empty()) {
[render_command_encoder setLabel:@(mtl_render_pass->label_.c_str())];
}

auto result = mtl_render_pass->EncodeCommands(
context->GetResourceAllocator(), render_command_encoder);
[render_command_encoder endEncoding];
if (result) {
[buffer commit];
} else {
VALIDATION_LOG << "Failed to encode command buffer";
}
});
worker_task_runner->PostTask(task);
return true;
}

void CommandBufferMTL::OnWaitUntilScheduled() {}

std::shared_ptr<RenderPass> CommandBufferMTL::OnCreateRenderPass(
Expand Down
12 changes: 10 additions & 2 deletions impeller/renderer/backend/metal/context_mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>
#include <vector>

#include "flutter/fml/concurrent_message_loop.h"
#include "flutter/fml/macros.h"
#include "impeller/base/backend_cast.h"
#include "impeller/core/sampler.h"
Expand All @@ -26,10 +27,12 @@ class ContextMTL final : public Context,
public std::enable_shared_from_this<ContextMTL> {
public:
static std::shared_ptr<ContextMTL> Create(
const std::vector<std::string>& shader_library_paths);
const std::vector<std::string>& shader_library_paths,
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner);

static std::shared_ptr<ContextMTL> Create(
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_data,
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner,
const std::string& label);

// |Context|
Expand Down Expand Up @@ -66,6 +69,8 @@ class ContextMTL final : public Context,

id<MTLCommandBuffer> CreateMTLCommandBuffer() const;

const std::shared_ptr<fml::ConcurrentTaskRunner>& GetWorkerTaskRunner() const;

private:
id<MTLDevice> device_ = nullptr;
id<MTLCommandQueue> command_queue_ = nullptr;
Expand All @@ -74,9 +79,12 @@ class ContextMTL final : public Context,
std::shared_ptr<SamplerLibrary> sampler_library_;
std::shared_ptr<AllocatorMTL> resource_allocator_;
std::shared_ptr<const Capabilities> device_capabilities_;
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner_;
bool is_valid_ = false;

ContextMTL(id<MTLDevice> device, NSArray<id<MTLLibrary>>* shader_libraries);
ContextMTL(id<MTLDevice> device,
NSArray<id<MTLLibrary>>* shader_libraries,
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner);

std::shared_ptr<CommandBuffer> CreateCommandBufferInQueue(
id<MTLCommandQueue> queue) const;
Expand Down
23 changes: 17 additions & 6 deletions impeller/renderer/backend/metal/context_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
.Build();
}

ContextMTL::ContextMTL(id<MTLDevice> device,
NSArray<id<MTLLibrary>>* shader_libraries)
: device_(device) {
ContextMTL::ContextMTL(
id<MTLDevice> device,
NSArray<id<MTLLibrary>>* shader_libraries,
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner)
: device_(device), worker_task_runner_(std::move(worker_task_runner)) {
// Validate device.
if (!device_) {
VALIDATION_LOG << "Could not setup valid Metal device.";
Expand Down Expand Up @@ -200,10 +202,12 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
}

std::shared_ptr<ContextMTL> ContextMTL::Create(
const std::vector<std::string>& shader_library_paths) {
const std::vector<std::string>& shader_library_paths,
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner) {
auto device = CreateMetalDevice();
auto context = std::shared_ptr<ContextMTL>(new ContextMTL(
device, MTLShaderLibraryFromFilePaths(device, shader_library_paths)));
device, MTLShaderLibraryFromFilePaths(device, shader_library_paths),
std::move(worker_task_runner)));
if (!context->IsValid()) {
FML_LOG(ERROR) << "Could not create Metal context.";
return nullptr;
Expand All @@ -213,11 +217,13 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {

std::shared_ptr<ContextMTL> ContextMTL::Create(
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_data,
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner,
const std::string& label) {
auto device = CreateMetalDevice();
auto context = std::shared_ptr<ContextMTL>(new ContextMTL(
device,
MTLShaderLibraryFromFileData(device, shader_libraries_data, label)));
MTLShaderLibraryFromFileData(device, shader_libraries_data, label),
worker_task_runner));
if (!context->IsValid()) {
FML_LOG(ERROR) << "Could not create Metal context.";
return nullptr;
Expand Down Expand Up @@ -257,6 +263,11 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
return CreateCommandBufferInQueue(command_queue_);
}

const std::shared_ptr<fml::ConcurrentTaskRunner>&
ContextMTL::GetWorkerTaskRunner() const {
return worker_task_runner_;
}

std::shared_ptr<CommandBuffer> ContextMTL::CreateCommandBufferInQueue(
id<MTLCommandQueue> queue) const {
if (!IsValid()) {
Expand Down
2 changes: 2 additions & 0 deletions impeller/renderer/backend/metal/render_pass_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

#include "flutter/fml/closure.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/make_copyable.h"
#include "flutter/fml/trace_event.h"
#include "impeller/base/backend_cast.h"
#include "impeller/core/formats.h"
#include "impeller/core/host_buffer.h"
#include "impeller/core/shader_types.h"
#include "impeller/renderer/backend/metal/context_mtl.h"
#include "impeller/renderer/backend/metal/device_buffer_mtl.h"
#include "impeller/renderer/backend/metal/formats_mtl.h"
#include "impeller/renderer/backend/metal/pipeline_mtl.h"
Expand Down
3 changes: 3 additions & 0 deletions impeller/renderer/backend/metal/surface_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
}
}

#if ((FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I observed using wonderous that the waitUntilScheduled was only necessary on simulator and (speculatively) on macOS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that with this patch or without?

If you've observed this without the changes in this patch, can we move this to a separate patch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I can split this out. Though we need both of these changes to see much of an improvement, otherwise the final scheduling just takes longer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved here: #42160

// If a transaction is present, `presentDrawable` will present too early. And
// so we wait on an empty command buffer to get scheduled instead, which
// forces us to also wait for all of the previous command buffers in the queue
Expand All @@ -187,6 +188,8 @@
ContextMTL::Cast(context.get())->CreateMTLCommandBuffer();
[command_buffer commit];
[command_buffer waitUntilScheduled];
#endif // (FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) (not iPhone)

[drawable_ present];

return true;
Expand Down
15 changes: 15 additions & 0 deletions impeller/renderer/command_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ void CommandBuffer::WaitUntilScheduled() {
return OnWaitUntilScheduled();
}

bool CommandBuffer::SubmitCommandsAsync(
std::shared_ptr<RenderPass>
render_pass // NOLINT(performance-unnecessary-value-param)
) {
TRACE_EVENT0("impeller", "CommandBuffer::SubmitCommandsAsync");
if (!render_pass->IsValid() || !IsValid()) {
return false;
}
if (!render_pass->EncodeCommands()) {
return false;
}

return SubmitCommands(nullptr);
}

std::shared_ptr<RenderPass> CommandBuffer::CreateRenderPass(
const RenderTarget& render_target) {
auto pass = OnCreateRenderPass(render_target);
Expand Down
14 changes: 13 additions & 1 deletion impeller/renderer/command_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class CommandBuffer {

//----------------------------------------------------------------------------
/// @brief Schedule the command encoded by render passes within this
/// command buffer on the GPU.
/// command buffer on the GPU. The encoding of these commnands is
/// performed immediately on the calling thread.
///
/// A command buffer may only be committed once.
///
Expand All @@ -65,6 +66,17 @@ class CommandBuffer {

[[nodiscard]] bool SubmitCommands();

//----------------------------------------------------------------------------
/// @brief Schedule the command encoded by render passes within this
/// command buffer on the GPU. The enqueing of this buffer is
/// performed immediately but encoding is pushed to a worker
/// thread if possible.
///
/// A command buffer may only be committed once.
///
[[nodiscard]] virtual bool SubmitCommandsAsync(
std::shared_ptr<RenderPass> render_pass);

//----------------------------------------------------------------------------
/// @brief Force execution of pending GPU commands.
///
Expand Down
1 change: 1 addition & 0 deletions impeller/renderer/render_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string>

#include "impeller/renderer/command.h"
#include "impeller/renderer/command_buffer.h"
#include "impeller/renderer/render_target.h"

namespace impeller {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>

#include "flutter/fml/concurrent_message_loop.h"
#include "flutter/fml/platform/darwin/cf_utils.h"
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h"
#import "flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.h"
Expand All @@ -34,10 +35,15 @@ NS_ASSUME_NONNULL_BEGIN
texture:(NSObject<FlutterTexture>*)texture;

/**
* Impeller context;
* Impeller context.
*/
@property(nonatomic, readonly) std::shared_ptr<impeller::ContextMTL> context;

/**
* Concurrent message loop.
*/
@property(nonatomic, readonly) std::shared_ptr<fml::ConcurrentMessageLoop> workers;

/*
* Texture cache for external textures.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

FLUTTER_ASSERT_ARC

static std::shared_ptr<impeller::ContextMTL> CreateImpellerContext() {
static std::shared_ptr<impeller::ContextMTL> CreateImpellerContext(
const std::shared_ptr<fml::ConcurrentMessageLoop>& concurrent_loop) {
std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
impeller_entity_shaders_length),
Expand All @@ -27,7 +28,9 @@
std::make_shared<fml::NonOwnedMapping>(impeller_framebuffer_blend_shaders_data,
impeller_framebuffer_blend_shaders_length),
};
auto context = impeller::ContextMTL::Create(shader_mappings, "Impeller Library");
auto worker_task_runner = concurrent_loop->GetTaskRunner();
auto context =
impeller::ContextMTL::Create(shader_mappings, worker_task_runner, "Impeller Library");
if (!context) {
FML_LOG(ERROR) << "Could not create Metal Impeller Context.";
return nullptr;
Expand All @@ -42,7 +45,8 @@ @implementation FlutterDarwinContextMetalImpeller
- (instancetype)init {
self = [super init];
if (self != nil) {
_context = CreateImpellerContext();
_workers = fml::ConcurrentMessageLoop::Create();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't create a message loop here. Instead, we should be getting the concurrent loop the engine creates already and passing it in as a parameter here.

That means we should mark the default initializer as unavailable and make a new one like initWithMessageLoop, or alternatively just initWithTaskRunner since that's all we actually need here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure exactly how to do this. It looks like ImpellerContext is setup without any references to the current engine. Is this something we can/should change, or should I look at providing the message loop some other way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd flow through PlatformViewIOS (ctor) -> IOSContext::Create -> IOSContextMetalImpeller (ctor)

Looks like there's something left to figure out there though and we're not doing this on Android right now (we create a special concurrent loop for the context to use there in android_context_vulkan_impeller.cc

Maybe for now we can file a bug for this. We shouldn't really be creating multiple concurrent message loops. But there might need to be some refactoring in the shell/platformview/engine setup to make sure that ownership and sharing of the loop is handled properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed flutter/flutter#127160. I'm ambivalent about whether resolving that blocks this or not, but if it turns out to be not too hard to resolve that then we should do it before creating another violating of it here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should figure out the concurrent loop stuff first.

_context = CreateImpellerContext(_workers);
id<MTLDevice> device = _context->GetMTLDevice();
if (!device) {
FML_DLOG(ERROR) << "Could not acquire Metal device.";
Expand Down