Flutter Engine
 
Loading...
Searching...
No Matches
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 <cstdint>
9#include <map>
10#include <memory>
14#include "fml/memory/ref_ptr.h"
22#include "lib/gpu/texture.h"
23
24namespace flutter {
25namespace gpu {
26
27class RenderPass : public RefCountedDartWrappable<RenderPass> {
28 DEFINE_WRAPPERTYPEINFO();
30
31 public:
33
34 ~RenderPass() override;
35
36 const std::shared_ptr<const impeller::Context>& GetContext() const;
37
40
42 size_t color_attachment_index);
43
45
47
49
51
52 bool Begin(flutter::gpu::CommandBuffer& command_buffer);
53
55
56 void ClearBindings();
57
58 bool Draw();
59
64
66 std::unordered_map<const flutter::gpu::Shader::UniformBinding*,
69 std::unordered_map<const flutter::gpu::Shader::TextureBinding*,
71
76
80 size_t element_count = 0;
81
82 uint32_t stencil_reference = 0;
83 std::optional<impeller::IRect32> scissor;
84 std::optional<impeller::Viewport> viewport;
85
86 // Helper flag to determine whether the vertex_count should override the
87 // element count. The index count takes precedent.
88 bool has_index_buffer = false;
89
90 private:
91 /// Lookup an Impeller pipeline by building a descriptor based on the current
92 /// command state.
93 std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>>
94 GetOrCreatePipeline();
95
96 impeller::RenderTarget render_target_;
97 std::shared_ptr<impeller::RenderPass> render_pass_;
98
99 // Command encoding state.
100 fml::RefPtr<RenderPipeline> render_pipeline_;
101 impeller::PipelineDescriptor pipeline_descriptor_;
102
103 // Pipeline descriptor layout state. We always keep track of this state,
104 // but we'll only apply it as necessary to match the RenderTarget.
105 std::map<size_t, impeller::ColorAttachmentDescriptor> color_descriptors_;
106 impeller::StencilAttachmentDescriptor stencil_front_desc_;
107 impeller::StencilAttachmentDescriptor stencil_back_desc_;
109
111};
112
113} // namespace gpu
114} // namespace flutter
115
116//----------------------------------------------------------------------------
117/// Exports
118///
119
120extern "C" {
121
123extern void InternalFlutterGpu_RenderPass_Initialize(Dart_Handle wrapper);
124
128 flutter::gpu::Context* context,
129 int color_attachment_index,
130 int load_action,
131 int store_action,
132 float clear_color_r,
133 float clear_color_g,
134 float clear_color_b,
135 float clear_color_a,
137 Dart_Handle resolve_texture_wrapper);
138
142 int depth_load_action,
143 int depth_store_action,
144 float depth_clear_value,
145 int stencil_load_action,
146 int stencil_store_action,
147 int stencil_clear_value,
149
151extern Dart_Handle InternalFlutterGpu_RenderPass_Begin(
153 flutter::gpu::CommandBuffer* command_buffer);
154
159
163 flutter::gpu::DeviceBuffer* device_buffer,
164 int offset_in_bytes,
165 int length_in_bytes,
166 int vertex_count);
167
171 flutter::gpu::DeviceBuffer* device_buffer,
172 int offset_in_bytes,
173 int length_in_bytes,
174 int index_type,
175 int index_count);
176
180 flutter::gpu::Shader* shader,
181 Dart_Handle uniform_name_handle,
182 flutter::gpu::DeviceBuffer* device_buffer,
183 int offset_in_bytes,
184 int length_in_bytes);
185
189 flutter::gpu::Shader* shader,
190 Dart_Handle uniform_name_handle,
192 int min_filter,
193 int mag_filter,
194 int mip_filter,
195 int width_address_mode,
196 int height_address_mode);
197
200 flutter::gpu::RenderPass* wrapper);
201
205 int color_attachment_index,
206 bool enable);
207
211 int color_attachment_index,
212 int color_blend_operation,
213 int source_color_blend_factor,
214 int destination_color_blend_factor,
215 int alpha_blend_operation,
216 int source_alpha_blend_factor,
217 int destination_alpha_blend_factor);
218
222 bool enable);
223
227 int compare_operation);
228
232 int stencil_reference);
233
237 int stencil_compare_operation,
238 int stencil_fail_operation,
239 int depth_fail_operation,
240 int depth_stencil_pass_operation,
241 int read_mask,
242 int write_mask,
243 int target);
244
248 int x,
249 int y,
250 int width,
251 int height);
252
256 int x,
257 int y,
258 int width,
259 int height,
260 float z_near,
261 float z_far);
262
266 int cull_mode);
267
271 int primitive_type);
272
276 int winding_order);
277
281 int polygon_mode);
282
285 flutter::gpu::RenderPass* wrapper);
286
287} // extern "C"
288
289#endif // FLUTTER_LIB_GPU_RENDER_PASS_H_
std::optional< impeller::Viewport > viewport
Definition render_pass.h:84
impeller::StencilAttachmentDescriptor & GetStencilBackAttachmentDescriptor()
void SetPipeline(fml::RefPtr< RenderPipeline > pipeline)
impeller::RenderTarget & GetRenderTarget()
bool Begin(flutter::gpu::CommandBuffer &command_buffer)
std::unordered_map< const flutter::gpu::Shader::UniformBinding *, BufferAndUniformSlot > BufferUniformMap
Definition render_pass.h:67
impeller::BufferView vertex_buffer
Definition render_pass.h:77
impeller::DepthAttachmentDescriptor & GetDepthAttachmentDescriptor()
std::unordered_map< const flutter::gpu::Shader::TextureBinding *, impeller::TextureAndSampler > TextureUniformMap
Definition render_pass.h:70
std::optional< impeller::IRect32 > scissor
Definition render_pass.h:83
TextureUniformMap fragment_texture_bindings
Definition render_pass.h:75
BufferUniformMap fragment_uniform_bindings
Definition render_pass.h:74
TextureUniformMap vertex_texture_bindings
Definition render_pass.h:73
BufferUniformMap vertex_uniform_bindings
Definition render_pass.h:72
impeller::IndexType index_buffer_type
Definition render_pass.h:79
impeller::StencilAttachmentDescriptor & GetStencilFrontAttachmentDescriptor()
impeller::ColorAttachmentDescriptor & GetColorAttachmentDescriptor(size_t color_attachment_index)
impeller::PipelineDescriptor & GetPipelineDescriptor()
const std::shared_ptr< const impeller::Context > & GetContext() const
impeller::BufferView index_buffer
Definition render_pass.h:78
An immutable collection of shaders loaded from a shader bundle asset.
Definition shader.h:23
int32_t x
uint32_t * target
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
#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)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetDepthCompareOperation(flutter::gpu::RenderPass *wrapper, int compare_operation)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_BindPipeline(flutter::gpu::RenderPass *wrapper, flutter::gpu::RenderPipeline *pipeline)
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)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetStencilConfig(flutter::gpu::RenderPass *wrapper, int stencil_compare_operation, int stencil_fail_operation, int depth_fail_operation, int depth_stencil_pass_operation, int read_mask, int write_mask, int target)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetPolygonMode(flutter::gpu::RenderPass *wrapper, int polygon_mode)
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)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetScissor(flutter::gpu::RenderPass *wrapper, int x, int y, int width, int height)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_Initialize(Dart_Handle wrapper)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetViewport(flutter::gpu::RenderPass *wrapper, int x, int y, int width, int height, float z_near, float z_far)
FLUTTER_GPU_EXPORT bool InternalFlutterGpu_RenderPass_Draw(flutter::gpu::RenderPass *wrapper)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetWindingOrder(flutter::gpu::RenderPass *wrapper, int winding_order)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetDepthWriteEnable(flutter::gpu::RenderPass *wrapper, bool enable)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_ClearBindings(flutter::gpu::RenderPass *wrapper)
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_RenderPass_Begin(flutter::gpu::RenderPass *wrapper, flutter::gpu::CommandBuffer *command_buffer)
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_RenderPass_SetColorAttachment(flutter::gpu::RenderPass *wrapper, flutter::gpu::Context *context, int color_attachment_index, int load_action, int store_action, float clear_color_r, float clear_color_g, float clear_color_b, float clear_color_a, flutter::gpu::Texture *texture, Dart_Handle resolve_texture_wrapper)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetCullMode(flutter::gpu::RenderPass *wrapper, int cull_mode)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetStencilReference(flutter::gpu::RenderPass *wrapper, int stencil_reference)
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)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetColorBlendEnable(flutter::gpu::RenderPass *wrapper, int color_attachment_index, bool enable)
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)
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)
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetPrimitiveType(flutter::gpu::RenderPass *wrapper, int primitive_type)
FlTexture * texture
double y
@ kNone
Does not use the index buffer.
#define FML_FRIEND_MAKE_REF_COUNTED(T)
int32_t height
int32_t width
Describe the color attachment that will be used with this pipeline.
Definition formats.h:518
Metadata required to bind a buffer.
combines the texture, sampler and sampler slot information.
Definition command.h:59