Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
render_pipeline.cc File Reference
#include "flutter/lib/gpu/render_pipeline.h"
#include <array>
#include <cstdint>
#include <cstring>
#include <span>
#include <string_view>
#include "flutter/lib/gpu/shader.h"
#include "impeller/core/shader_types.h"
#include "impeller/renderer/pipeline_descriptor.h"
#include "impeller/renderer/vertex_descriptor.h"
#include "third_party/abseil-cpp/absl/status/status.h"
#include "third_party/abseil-cpp/absl/status/statusor.h"
#include "third_party/abseil-cpp/absl/strings/str_cat.h"
#include "third_party/tonic/typed_data/dart_byte_data.h"

Go to the source code of this file.

Namespaces

namespace  flutter
 
namespace  flutter::gpu
 

Functions

 flutter::gpu::IMPLEMENT_WRAPPERTYPEINFO (flutter_gpu, RenderPipeline)
 
Dart_Handle InternalFlutterGpu_RenderPipeline_Initialize (Dart_Handle wrapper, flutter::gpu::Context *gpu_context, flutter::gpu::Shader *vertex_shader, flutter::gpu::Shader *fragment_shader, Dart_Handle buffer_layouts_handle, Dart_Handle attributes_handle, Dart_Handle attribute_names_handle)
 

Function Documentation

◆ InternalFlutterGpu_RenderPipeline_Initialize()

Dart_Handle InternalFlutterGpu_RenderPipeline_Initialize ( Dart_Handle  wrapper,
flutter::gpu::Context gpu_context,
flutter::gpu::Shader vertex_shader,
flutter::gpu::Shader fragment_shader,
Dart_Handle  buffer_layouts_handle,
Dart_Handle  attributes_handle,
Dart_Handle  attribute_names_handle 
)

Exports

Definition at line 282 of file render_pipeline.cc.

289 {
290 // Lazily register the shaders synchronously if they haven't been already.
291 vertex_shader->RegisterSync(*gpu_context);
292 fragment_shader->RegisterSync(*gpu_context);
293
294 std::shared_ptr<impeller::VertexDescriptor> vertex_descriptor;
295
296 const bool buffer_layouts_provided = !Dart_IsNull(buffer_layouts_handle);
297 const bool attributes_provided = !Dart_IsNull(attributes_handle);
298 const bool attribute_names_provided = !Dart_IsNull(attribute_names_handle);
299 if (buffer_layouts_provided != attributes_provided ||
300 attributes_provided != attribute_names_provided) {
301 return tonic::ToDart(
302 "VertexLayout requires buffer layouts, attributes, and attribute "
303 "names to be provided together.");
304 }
305
306 if (buffer_layouts_provided) {
307 // Copy the packed Dart-side ByteData buffers into local vectors so the
308 // tonic::DartByteData typed-data handles are released before we make any
309 // call back into the Dart VM (e.g. tonic::ToDart for an error string).
310 // Holding a typed-data handle while calling into the VM raises
311 // "Callbacks into the Dart VM are currently prohibited." Errors raised
312 // inside the inner scope must therefore be deferred to a local string
313 // and returned only after the typed-data handles go out of scope.
314 std::vector<int32_t> buffer_layouts_ints;
315 std::vector<int32_t> attribute_ints;
316 std::vector<char> attribute_names_bytes;
317 std::string copy_error;
318 {
319 tonic::DartByteData buffer_layouts_data(buffer_layouts_handle);
320 tonic::DartByteData attributes_data(attributes_handle);
321 tonic::DartByteData attribute_names_data(attribute_names_handle);
322 if (buffer_layouts_data.length_in_bytes() %
323 (flutter::gpu::kBufferLayoutInts * sizeof(int32_t)) !=
324 0) {
325 copy_error =
326 "Internal error: buffer layouts ByteData has invalid length.";
327 } else if (attributes_data.length_in_bytes() %
328 (flutter::gpu::kAttributeInts * sizeof(int32_t)) !=
329 0) {
330 copy_error = "Internal error: attributes ByteData has invalid length.";
331 } else {
332 const auto* buffer_layouts_src =
333 static_cast<const int32_t*>(buffer_layouts_data.data());
334 const auto* attributes_src =
335 static_cast<const int32_t*>(attributes_data.data());
336 const auto* names_src =
337 static_cast<const char*>(attribute_names_data.data());
338 buffer_layouts_ints.assign(
339 buffer_layouts_src,
340 buffer_layouts_src +
341 buffer_layouts_data.length_in_bytes() / sizeof(int32_t));
342 attribute_ints.assign(
343 attributes_src, attributes_src + attributes_data.length_in_bytes() /
344 sizeof(int32_t));
345 attribute_names_bytes.assign(
346 names_src, names_src + attribute_names_data.length_in_bytes());
347 }
348 }
349 if (!copy_error.empty()) {
350 return tonic::ToDart(copy_error);
351 }
352
353 absl::StatusOr<std::shared_ptr<impeller::VertexDescriptor>> built =
354 flutter::gpu::BuildCustomVertexDescriptor(
355 *vertex_shader,
356 std::span<const int32_t>(buffer_layouts_ints.data(),
357 buffer_layouts_ints.size()),
358 std::span<const int32_t>(attribute_ints.data(),
359 attribute_ints.size()),
360 std::span<const char>(attribute_names_bytes.data(),
361 attribute_names_bytes.size()));
362 if (!built.ok()) {
363 return tonic::ToDart(std::string(built.status().message()));
364 }
365 vertex_descriptor = *std::move(built);
366 } else {
367 vertex_descriptor = vertex_shader->CreateVertexDescriptor();
368 }
369
370 auto res = fml::MakeRefCounted<flutter::gpu::RenderPipeline>(
371 fml::RefPtr<flutter::gpu::Shader>(vertex_shader), //
372 fml::RefPtr<flutter::gpu::Shader>(fragment_shader), //
373 std::move(vertex_descriptor));
374 res->AssociateWithDartWrapper(wrapper);
375
376 return Dart_Null();
377}
bool RegisterSync(Context &context)
Definition shader.cc:77
std::shared_ptr< impeller::VertexDescriptor > CreateVertexDescriptor() const
Definition shader.cc:97
Dart_Handle ToDart(const T &object)

References flutter::gpu::Shader::CreateVertexDescriptor(), tonic::DartByteData::data(), tonic::DartByteData::length_in_bytes(), flutter::gpu::Shader::RegisterSync(), and tonic::ToDart().

Variable Documentation

◆ bit_width

size_t bit_width

Definition at line 65 of file render_pipeline.cc.

◆ bytes_per_element

size_t bytes_per_element

Definition at line 67 of file render_pipeline.cc.

◆ type

Definition at line 64 of file render_pipeline.cc.

Referenced by base::internal::SaturateFastAsmOp< Dst, Src >::__attribute__(), impeller::ShaderArchiveWriter::AddShader(), FlutterTextInputPlugin()::addToInputParentViewIfNeeded:, tonic::AllowedInLeafCall(), ui::AXPosition< AXPositionType, AXNodeType >::AtEndOfParagraph(), ui::AXPosition< AXPositionType, AXNodeType >::AtStartOfParagraph(), impeller::AttachmentTypeString(), flutter::testing::DlSurfaceProvider::BackendName(), impeller::TextureGLES::Bind(), impeller::DeviceBufferGLES::BindAndUploadDataIfNecessary(), impeller::testing::RecordingRenderPass::BindDynamicResource(), impeller::testing::RecordingRenderPass::BindDynamicResource(), BindIndexBuffer(), impeller::testing::RecordingRenderPass::BindResource(), impeller::testing::RecordingRenderPass::BindResource(), flutter::BM_AdapterDispatchOverhead(), flutter::BM_Concat(), flutter::BM_DisplayListBuilderDefault(), flutter::BM_DisplayListBuilderWithClipRect(), flutter::BM_DisplayListBuilderWithGlobalSaveLayer(), flutter::BM_DisplayListBuilderWithPerspective(), flutter::BM_DisplayListBuilderWithSaveLayer(), flutter::BM_DisplayListBuilderWithSaveLayerAndImageFilter(), flutter::BM_DisplayListBuilderWithScaleAndTranslate(), flutter::BM_DisplayListDispatchByIndexDefault(), flutter::BM_DisplayListDispatchByIteratorDefault(), flutter::BM_DisplayListDispatchByVectorCull(), flutter::BM_DisplayListDispatchByVectorDefault(), flutter::BM_DisplayListDispatchCull(), flutter::BM_DisplayListDispatchDefault(), flutter::testing::BM_DrawDRRect(), flutter::testing::BM_DrawPath(), flutter::testing::BM_DrawRRect(), flutter::testing::BM_DrawRSE(), flutter::testing::BM_DrawShadow(), flutter::BM_InvertAndCheck(), flutter::BM_InvertUnchecked(), flutter::BM_Rotate(), flutter::BM_Scale(), flutter::BM_SetIdentity(), flutter::BM_SetPerspective(), flutter::BM_TransformAndClipRect(), flutter::BM_TransformPoint(), flutter::BM_TransformPoints(), flutter::BM_TransformRectFast(), flutter::BM_Translate(), tonic::FfiDispatcher< C, Return(C::*)(Args...), method >::Call(), tonic::FfiDispatcher< C, Return(C::*)(Args...) const, method >::Call(), tonic::FfiDispatcher< C, void(C::*)(Args...), method >::Call(), tonic::FfiDispatcher< void, Return(*)(Args...), function >::Call(), tonic::FfiDispatcher< void, void(*)(Args...), function >::Call(), ui::AXTreeObserver::Change::Change(), impeller::CompressionTypeToString(), impeller::RuntimeStage::Create(), tonic::DartWrappable::CreateDartWrapper(), impeller::compiler::ShaderBundleData::CreateFlatbuffer(), impeller::compiler::CreateGLSLCompiler(), impeller::testing::CreateGlyphAtlas(), impeller::testing::CreateGlyphAtlas(), impeller::TypographerContextSkia::CreateGlyphAtlas(), impeller::TypographerContextSkia::CreateGlyphAtlasContext(), impeller::ReactorGLES::CreateHandle(), ui::AXPosition< AXPositionType, AXNodeType >::CreateNextLeafTextPosition(), impeller::LazyGlyphAtlas::CreateOrGetGlyphAtlas(), impeller::ReactorGLES::CreateUntrackedHandle(), tonic::DartByteData::DartByteData(), impeller::DeleteFBO(), impeller::DeriveShaderFloatType(), impeller::DescribeFramebufferAttachment(), impeller::DeviceTypeToString(), base::internal::CheckedAddOp< T, U, typename std::enable_if< std::is_integral< T >::value &&std::is_integral< U >::value >::type >::Do(), base::internal::CheckedSubOp< T, U, typename std::enable_if< std::is_integral< T >::value &&std::is_integral< U >::value >::type >::Do(), flutter::elementSizeForFlutterStandardDataType(), flutter::testing::EmbedderTestBackingStoreProducerSoftware::EmbedderTestBackingStoreProducerSoftware(), impeller::BlitCopyTextureToBufferCommandGLES::Encode(), impeller::compiler::EntryPointFunctionNameFromSourceName(), flutter::testing::expectSoftwareRenderingOutputMatches(), FastReadValue(), flutter::testing::FilterMutationsByType(), flutter::testing::FilterMutationsByType(), fl_key_channel_responder_handle_event(), fl_key_event_channel_send(), fl_key_event_new_from_gdk_event(), fl_platform_channel_system_request_app_exit(), fl_standard_message_codec_read_value(), fl_standard_message_codec_read_value_of_type(), fl_standard_method_codec_decode_response(), fl_standard_method_codec_encode_error_envelope(), fl_standard_method_codec_encode_success_envelope(), fl_value_new(), fl_value_new_custom(), fl_value_new_custom_object(), fl_value_new_custom_object_take(), FlutterBackingStoreTypeToString(), FlutterEnginePostCallbackOnAllNativeThreads(), FlutterEngineSendKeyEvent(), FlutterLayerContentTypeToString(), FlutterOpenGLTargetTypeToString(), FlutterPlatformViewMutationTypeToString(), FlutterStandardCodecHelperReadValueOfType(), flutter::FlutterStandardFieldForDataType(), G_DECLARE_DERIVABLE_TYPE(), impeller::TextureGLES::GenerateMipmap(), flutter::testing::EmbedderTestMultiBackend::GetEmbedderContext(), impeller::compiler::UniqueIncluder::GetInclude(), flutter_runner::GetKindFromPointerType(), impeller::ShaderArchive::GetMapping(), impeller::ShaderFunctionMTL::GetMTLFunctionSpecialized(), flutter::DisplayList::GetOpCategory(), flutter::testing::DisplayListGeneralReceiver::GetOpsReceived(), flutter::testing::DisplayListRendering::GetProvider(), impeller::GetShaderType(), gtk_window_new(), impeller::HandleTypeIsShareable(), impeller::HandleTypeToString(), ui::AXPlatformRelationWin::Initialize(), impeller::interop::Context::IsBackend(), impeller::IsMultisampleCapable(), flutter::ThreadHost::ThreadHostConfig::isThreadNeeded(), flutter::KeyboardKeyEmbedderHandler::KeyboardHook(), impeller::android::HardwareBuffer::Lock(), tonic::LookupNonNullableType(), flutter::gpu::ShaderLibrary::MakeFromFlatbuffer(), impeller::MakeTextFrameFromTextBlobSkia(), flutter::MakeThreadConfig(), flutter::ThreadHost::ThreadHostConfig::MakeThreadName(), impeller::UniqueHandleGLES::MakeUntracked(), impeller::testing::mockReadPixels(), impeller::testing::mockTexImage2D(), impeller::testing::mockTexSubImage2D(), flutter::testing::MultiplyPath(), flutter_runner::TextDelegate::OnKeyEvent(), impeller::ShaderArchive::ShaderKey::Hash::operator()(), std::operator<<(), std::operator<<(), flutter::PlatformViewManager::PlatformViewManager(), flutter::EmbedderEngine::PostTaskOnEngineManagedNativeThreads(), flutter::CompositorOpenGL::Present(), process_message(), FlutterStandardReaderWriter::readerWithData:, impeller::compiler::ReadKnownScalarType(), flutter::StandardCodecSerializer::ReadValue(), flutter::StandardCodecSerializer::ReadValueOfType(), flutter::PointExtensionSerializer::ReadValueOfType(), flutter::SomeDataExtensionSerializer::ReadValueOfType(), flutter::testing::DisplayListGeneralReceiver::RecordByType(), flutter::FlutterWindowsTextureRegistrar::RegisterTexture(), impeller::BufferBindingsGLES::RegisterVertexStageInput(), impeller::TextContents::Render(), flutter::PlatformConfiguration::ReportTimings(), request_app_exit(), impeller::ResourceIsLive(), flutter::AndroidShellHolder::Screenshot(), flutter::Rasterizer::ScreenshotLastLayerTree(), impeller::ProcTableGLES::SetDebugLabel(), impeller::PipelineDescriptor::SetPrimitiveType(), flutter::testing::EmbedderTestCompositorGL::SetRenderTargetType(), flutter::testing::EmbedderTestCompositorMetal::SetRenderTargetType(), flutter::testing::EmbedderTestCompositorSoftware::SetRenderTargetType(), flutter::testing::EmbedderTestCompositorVulkan::SetRenderTargetType(), flutter::testing::EmbedderConfigBuilder::SetRenderTargetType(), ShouldShowSystemKeyboard(), impeller::SortUniforms(), impeller::compiler::SourceTypeToString(), synchronize_lock_states(), synthesize_simple_event(), system_exit_application(), system_exit_application(), system_sound_play(), system_sound_play(), TEST(), TEST(), TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::egl::ProcTable::TexImage2D(), impeller::TextureTypeToString(), impeller::ToArrayLayerCount(), tonic::DartConverter< TypedList< kTypeName, ElemType > >::ToDart(), impeller::ToDebugIdentifier(), impeller::ToDebugResourceType(), impeller::ToDeviceType(), impeller::compiler::ToExecutionModel(), impeller::ToHandleType(), impeller::interop::ToImpellerType(), impeller::ToIndexType(), impeller::compiler::ToInputType(), impeller::compiler::ToJsonType(), impeller::ToMTLBlendFactor(), impeller::ToMTLBlendOperation(), impeller::ToMTLColorWriteMask(), impeller::ToMTLIndexType(), impeller::ToMTLPrimitiveType(), impeller::ToMTLResourceOptions(), impeller::ToMTLTextureType(), flutter::ImageDecoderImpeller::ToPixelFormat(), impeller::compiler::ToShaderCShaderKind(), impeller::ToShaderStage(), impeller::interop::ToSkiaType(), impeller::ToStage(), ui::AXNodeData::ToString(), impeller::compiler::ToString(), impeller::ToTarget(), impeller::ToTextureTarget(), impeller::ToTextureType(), impeller::ToType(), ToUIKeyboardType(), ToUITextAutoCapitalizationType(), impeller::compiler::ToUniformType(), impeller::ToVertexAttribType(), impeller::ToVKColorComponentFlags(), impeller::ToVKDescriptorType(), impeller::ToVKImageCreateFlags(), impeller::ToVKImageViewType(), tonic::TypedList< kTypeName, ElemType >::TypedList(), impeller::UniqueHandleGLES::UniqueHandleGLES(), flutter::PlatformView::UpdateAssetResolverByType(), flutter::PlatformViewAndroid::UpdateAssetResolverByType(), flutter::RasterCache::UpdateCacheEntry(), flutter::AssetManager::UpdateResolverByType(), flutter::testing::VerbToString(), impeller::compiler::VertexTypeFromInputResource(), vulkan::VkDebugReportObjectTypeEXTToString(), flutter::DlPath::WithFillType(), tonic::WriteFfiArguments(), FlutterStandardWriter::writeValue:, impeller::BufferBindingsGLES::~BufferBindingsGLES(), impeller::ShaderArchive::~ShaderArchive(), and impeller::ShaderArchiveWriter::~ShaderArchiveWriter().

◆ vec_size

size_t vec_size

Definition at line 66 of file render_pipeline.cc.