mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Reverts flutter/engine#50139 Initiated by: jonahwilliams This change reverts the following previous change: Original Description: The Impeller Vulkan backend benefits from batching submission to the vk graphics queue. Managing this automatically is non-trivial and adds surprising/fragile thread based behavior, see: https://github.com/flutter/engine/pull/49870 Instead, introduce an impeller::CommandQueue object that command buffers must be submitted to in lieu of CommandBuffer->Submit, which has been made private. TLDR old ```c++ buffer->Submit(); ``` new ```c++ context.GetQueue()->Submit({buffer}); ``` The Metal and GLES implementations internally just call the private CommandBuffer->Submit, though there may be future opportunities to simplify here. The Vulkan implementation is where the meat is. Aiks takes advantage of this by storing all command buffers on the aiks context while rendering a frame, and then performing one submit in aiks_context render. I don't think this will introduce any thread safety problems, as we don't guarantee much about aiks context - nor do we use it in a multithreaded context as far as I know. Other tasks such as image upload still just directly submit their command buffers via the queue. Fixes https://github.com/flutter/flutter/issues/141123
63 lines
1.6 KiB
C++
63 lines
1.6 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef FLUTTER_LIB_GPU_COMMAND_BUFFER_H_
|
|
#define FLUTTER_LIB_GPU_COMMAND_BUFFER_H_
|
|
|
|
#include "flutter/lib/gpu/context.h"
|
|
#include "flutter/lib/gpu/export.h"
|
|
#include "flutter/lib/ui/dart_wrapper.h"
|
|
#include "impeller/renderer/command_buffer.h"
|
|
|
|
namespace flutter {
|
|
namespace gpu {
|
|
|
|
class CommandBuffer : public RefCountedDartWrappable<CommandBuffer> {
|
|
DEFINE_WRAPPERTYPEINFO();
|
|
FML_FRIEND_MAKE_REF_COUNTED(CommandBuffer);
|
|
|
|
public:
|
|
explicit CommandBuffer(
|
|
std::shared_ptr<impeller::CommandBuffer> command_buffer);
|
|
|
|
std::shared_ptr<impeller::CommandBuffer> GetCommandBuffer();
|
|
|
|
void AddRenderPass(std::shared_ptr<impeller::RenderPass> render_pass);
|
|
|
|
bool Submit();
|
|
bool Submit(
|
|
const impeller::CommandBuffer::CompletionCallback& completion_callback);
|
|
|
|
~CommandBuffer() override;
|
|
|
|
private:
|
|
std::shared_ptr<impeller::CommandBuffer> command_buffer_;
|
|
std::vector<std::shared_ptr<impeller::RenderPass>> encodables_;
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(CommandBuffer);
|
|
};
|
|
|
|
} // namespace gpu
|
|
} // namespace flutter
|
|
|
|
//----------------------------------------------------------------------------
|
|
/// Exports
|
|
///
|
|
|
|
extern "C" {
|
|
|
|
FLUTTER_GPU_EXPORT
|
|
extern bool InternalFlutterGpu_CommandBuffer_Initialize(
|
|
Dart_Handle wrapper,
|
|
flutter::gpu::Context* contextWrapper);
|
|
|
|
FLUTTER_GPU_EXPORT
|
|
extern Dart_Handle InternalFlutterGpu_CommandBuffer_Submit(
|
|
flutter::gpu::CommandBuffer* wrapper,
|
|
Dart_Handle completion_callback);
|
|
|
|
} // extern "C"
|
|
|
|
#endif // FLUTTER_LIB_GPU_COMMAND_BUFFER_H_
|