Flutter Engine
The Flutter Engine
render_pipeline.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/lib/gpu/render_pipeline.h"
6
7#include "flutter/lib/gpu/shader.h"
9
10namespace flutter {
11namespace gpu {
12
14
18 : vertex_shader_(std::move(vertex_shader)),
19 fragment_shader_(std::move(fragment_shader)) {}
20
24 auto vertex_descriptor = vertex_shader_->CreateVertexDescriptor();
25 vertex_descriptor->RegisterDescriptorSetLayouts(
26 vertex_shader_->GetDescriptorSetLayouts().data(),
27 vertex_shader_->GetDescriptorSetLayouts().size());
28 vertex_descriptor->RegisterDescriptorSetLayouts(
29 fragment_shader_->GetDescriptorSetLayouts().data(),
30 fragment_shader_->GetDescriptorSetLayouts().size());
31 desc.SetVertexDescriptor(vertex_descriptor);
32
33 desc.AddStageEntrypoint(vertex_shader_->GetFunctionFromLibrary(library));
34 desc.AddStageEntrypoint(fragment_shader_->GetFunctionFromLibrary(library));
35}
36
38
39} // namespace gpu
40} // namespace flutter
41
42//----------------------------------------------------------------------------
43/// Exports
44///
45
47 Dart_Handle wrapper,
48 flutter::gpu::Context* gpu_context,
49 flutter::gpu::Shader* vertex_shader,
50 flutter::gpu::Shader* fragment_shader) {
51 // Lazily register the shaders synchronously if they haven't been already.
52 vertex_shader->RegisterSync(*gpu_context);
53 fragment_shader->RegisterSync(*gpu_context);
54
55 auto res = fml::MakeRefCounted<flutter::gpu::RenderPipeline>(
56 fml::RefPtr<flutter::gpu::Shader>(vertex_shader), //
57 fml::RefPtr<flutter::gpu::Shader>(fragment_shader));
58 res->AssociateWithDartWrapper(wrapper);
59
60 return Dart_Null();
61}
RenderPipeline(fml::RefPtr< flutter::gpu::Shader > vertex_shader, fml::RefPtr< flutter::gpu::Shader > fragment_shader)
void BindToPipelineDescriptor(impeller::ShaderLibrary &library, impeller::PipelineDescriptor &desc)
An immutable collection of shaders loaded from a shader bundle asset.
Definition: shader.h:23
bool RegisterSync(Context &context)
Definition: shader.cc:70
std::shared_ptr< impeller::VertexDescriptor > CreateVertexDescriptor() const
Definition: shader.cc:90
const std::vector< impeller::DescriptorSetLayout > & GetDescriptorSetLayouts() const
Definition: shader.cc:102
std::shared_ptr< const impeller::ShaderFunction > GetFunctionFromLibrary(impeller::ShaderLibrary &library)
Definition: shader.cc:60
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DART_EXPORT Dart_Handle Dart_Null(void)
IMPLEMENT_WRAPPERTYPEINFO(flutter_gpu, CommandBuffer)
Definition: ref_ptr.h:256
Dart_Handle InternalFlutterGpu_RenderPipeline_Initialize(Dart_Handle wrapper, flutter::gpu::Context *gpu_context, flutter::gpu::Shader *vertex_shader, flutter::gpu::Shader *fragment_shader)