Flutter Engine
The Flutter Engine
render_pass.h
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#ifndef FLUTTER_LIB_GPU_RENDER_PASS_H_
6#define FLUTTER_LIB_GPU_RENDER_PASS_H_
7
8#include <map>
9#include <memory>
10#include "flutter/lib/gpu/command_buffer.h"
11#include "flutter/lib/gpu/export.h"
12#include "flutter/lib/ui/dart_wrapper.h"
13#include "fml/memory/ref_ptr.h"
20#include "lib/gpu/host_buffer.h"
22#include "lib/gpu/texture.h"
23
24namespace flutter {
25namespace gpu {
26
27class RenderPass : public RefCountedDartWrappable<RenderPass> {
28 DEFINE_WRAPPERTYPEINFO();
29 FML_FRIEND_MAKE_REF_COUNTED(RenderPass);
30
31 public:
32 RenderPass();
33
34 ~RenderPass() override;
35
36 const std::shared_ptr<const impeller::Context>& GetContext() const;
37
39 const impeller::Command& GetCommand() const;
40
43
45 size_t color_attachment_index);
46
48
50
51 bool Begin(flutter::gpu::CommandBuffer& command_buffer);
52
54
55 /// Lookup an Impeller pipeline by building a descriptor based on the current
56 /// command state.
57 std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>>
59
61
62 bool Draw();
63
64 private:
65 impeller::RenderTarget render_target_;
66 std::shared_ptr<impeller::RenderPass> render_pass_;
67
68 // Command encoding state.
69 impeller::Command command_;
70 fml::RefPtr<RenderPipeline> render_pipeline_;
71 impeller::PipelineDescriptor pipeline_descriptor_;
72
73 // Pipeline descriptor layout state. We always keep track of this state, but
74 // we'll only apply it as necessary to match the RenderTarget.
75 std::map<size_t, impeller::ColorAttachmentDescriptor> color_descriptors_;
76 impeller::StencilAttachmentDescriptor stencil_front_desc_;
79
80 // Command state.
81 impeller::VertexBuffer vertex_buffer_;
82
83 FML_DISALLOW_COPY_AND_ASSIGN(RenderPass);
84};
85
86} // namespace gpu
87} // namespace flutter
88
89//----------------------------------------------------------------------------
90/// Exports
91///
92
93extern "C" {
94
97
101 int color_attachment_index,
102 int load_action,
103 int store_action,
104 int clear_color,
106 Dart_Handle resolve_texture_wrapper);
107
111 int depth_load_action,
112 int depth_store_action,
113 float depth_clear_value,
114 int stencil_load_action,
115 int stencil_store_action,
116 int stencil_clear_value,
118
122 flutter::gpu::CommandBuffer* command_buffer);
123
128
132 flutter::gpu::DeviceBuffer* device_buffer,
133 int offset_in_bytes,
134 int length_in_bytes,
135 int vertex_count);
136
140 flutter::gpu::HostBuffer* host_buffer,
141 int offset_in_bytes,
142 int length_in_bytes,
143 int vertex_count);
144
148 flutter::gpu::DeviceBuffer* device_buffer,
149 int offset_in_bytes,
150 int length_in_bytes,
151 int index_type,
152 int index_count);
153
157 flutter::gpu::HostBuffer* host_buffer,
158 int offset_in_bytes,
159 int length_in_bytes,
160 int index_type,
161 int index_count);
162
166 flutter::gpu::Shader* shader,
167 Dart_Handle uniform_name_handle,
168 flutter::gpu::DeviceBuffer* device_buffer,
169 int offset_in_bytes,
170 int length_in_bytes);
171
175 flutter::gpu::Shader* shader,
176 Dart_Handle uniform_name_handle,
177 flutter::gpu::HostBuffer* host_buffer,
178 int offset_in_bytes,
179 int length_in_bytes);
180
184 flutter::gpu::Shader* shader,
185 Dart_Handle uniform_name_handle,
187 int min_filter,
188 int mag_filter,
189 int mip_filter,
190 int width_address_mode,
191 int height_address_mode);
192
195 flutter::gpu::RenderPass* wrapper);
196
200 int color_attachment_index,
201 bool enable);
202
206 int color_attachment_index,
207 int color_blend_operation,
208 int source_color_blend_factor,
209 int destination_color_blend_factor,
210 int alpha_blend_operation,
211 int source_alpha_blend_factor,
212 int destination_alpha_blend_factor);
213
217 bool enable);
218
222 int compare_operation);
223
226 flutter::gpu::RenderPass* wrapper);
227
228} // extern "C"
229
230#endif // FLUTTER_LIB_GPU_RENDER_PASS_H_
impeller::Command & GetCommand()
Definition: render_pass.cc:35
void SetPipeline(fml::RefPtr< RenderPipeline > pipeline)
Definition: render_pass.cc:79
impeller::RenderTarget & GetRenderTarget()
Definition: render_pass.cc:43
bool Begin(flutter::gpu::CommandBuffer &command_buffer)
Definition: render_pass.cc:69
std::shared_ptr< impeller::Pipeline< impeller::PipelineDescriptor > > GetOrCreatePipeline()
Definition: render_pass.cc:84
impeller::DepthAttachmentDescriptor & GetDepthAttachmentDescriptor()
Definition: render_pass.cc:61
impeller::Command ProvisionRasterCommand()
Definition: render_pass.cc:129
impeller::VertexBuffer & GetVertexBuffer()
Definition: render_pass.cc:65
impeller::ColorAttachmentDescriptor & GetColorAttachmentDescriptor(size_t color_attachment_index)
Definition: render_pass.cc:51
const std::shared_ptr< const impeller::Context > & GetContext() const
Definition: render_pass.cc:31
An immutable collection of shaders loaded from a shader bundle asset.
Definition: shader.h:23
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
#define FLUTTER_GPU_EXPORT
Definition: export.h:13
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetColorBlendEquation(flutter::gpu::RenderPass *wrapper, int color_attachment_index, int color_blend_operation, int source_color_blend_factor, int destination_color_blend_factor, int alpha_blend_operation, int source_alpha_blend_factor, int destination_alpha_blend_factor)
Definition: render_pass.cc:475
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_RenderPass_SetColorAttachment(flutter::gpu::RenderPass *wrapper, int color_attachment_index, int load_action, int store_action, int clear_color, flutter::gpu::Texture *texture, Dart_Handle resolve_texture_wrapper)
Definition: render_pass.cc:199
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetDepthCompareOperation(flutter::gpu::RenderPass *wrapper, int compare_operation)
Definition: render_pass.cc:506
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_BindPipeline(flutter::gpu::RenderPass *wrapper, flutter::gpu::RenderPipeline *pipeline)
Definition: render_pass.cc:261
FLUTTER_GPU_EXPORT bool InternalFlutterGpu_RenderPass_BindTexture(flutter::gpu::RenderPass *wrapper, flutter::gpu::Shader *shader, Dart_Handle uniform_name_handle, flutter::gpu::Texture *texture, int min_filter, int mag_filter, int mip_filter, int width_address_mode, int height_address_mode)
Definition: render_pass.cc:422
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_BindIndexBufferDevice(flutter::gpu::RenderPass *wrapper, flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int length_in_bytes, int index_type, int index_count)
Definition: render_pass.cc:336
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_BindVertexBufferHost(flutter::gpu::RenderPass *wrapper, flutter::gpu::HostBuffer *host_buffer, int offset_in_bytes, int length_in_bytes, int vertex_count)
Definition: render_pass.cc:302
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_Initialize(Dart_Handle wrapper)
Definition: render_pass.cc:194
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_BindIndexBufferHost(flutter::gpu::RenderPass *wrapper, flutter::gpu::HostBuffer *host_buffer, int offset_in_bytes, int length_in_bytes, int index_type, int index_count)
Definition: render_pass.cc:347
FLUTTER_GPU_EXPORT bool InternalFlutterGpu_RenderPass_Draw(flutter::gpu::RenderPass *wrapper)
Definition: render_pass.cc:514
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetDepthWriteEnable(flutter::gpu::RenderPass *wrapper, bool enable)
Definition: render_pass.cc:499
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_ClearBindings(flutter::gpu::RenderPass *wrapper)
Definition: render_pass.cc:459
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_RenderPass_Begin(flutter::gpu::RenderPass *wrapper, flutter::gpu::CommandBuffer *command_buffer)
Definition: render_pass.cc:252
FLUTTER_GPU_EXPORT bool InternalFlutterGpu_RenderPass_BindUniformHost(flutter::gpu::RenderPass *wrapper, flutter::gpu::Shader *shader, Dart_Handle uniform_name_handle, flutter::gpu::HostBuffer *host_buffer, int offset_in_bytes, int length_in_bytes)
Definition: render_pass.cc:404
FLUTTER_GPU_EXPORT bool InternalFlutterGpu_RenderPass_BindUniformDevice(flutter::gpu::RenderPass *wrapper, flutter::gpu::Shader *shader, Dart_Handle uniform_name_handle, flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int length_in_bytes)
Definition: render_pass.cc:392
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetColorBlendEnable(flutter::gpu::RenderPass *wrapper, int color_attachment_index, bool enable)
Definition: render_pass.cc:467
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_RenderPass_SetDepthStencilAttachment(flutter::gpu::RenderPass *wrapper, int depth_load_action, int depth_store_action, float depth_clear_value, int stencil_load_action, int stencil_store_action, int stencil_clear_value, flutter::gpu::Texture *texture)
Definition: render_pass.cc:222
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_BindVertexBufferDevice(flutter::gpu::RenderPass *wrapper, flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int length_in_bytes, int vertex_count)
Definition: render_pass.cc:292
FlTexture * texture
Describe the color attachment that will be used with this pipeline.
Definition: formats.h:512
An object used to specify work to the GPU along with references to resources the GPU will used when d...
Definition: command.h:92