Flutter Engine
The Flutter Engine
Classes | Namespaces | Functions
render_pass.h File Reference
#include <map>
#include <memory>
#include "flutter/lib/gpu/command_buffer.h"
#include "flutter/lib/gpu/export.h"
#include "flutter/lib/ui/dart_wrapper.h"
#include "fml/memory/ref_ptr.h"
#include "impeller/core/formats.h"
#include "impeller/core/vertex_buffer.h"
#include "impeller/renderer/command.h"
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/render_target.h"
#include "lib/gpu/device_buffer.h"
#include "lib/gpu/host_buffer.h"
#include "lib/gpu/render_pipeline.h"
#include "lib/gpu/texture.h"

Go to the source code of this file.

Classes

class  flutter::gpu::RenderPass
 

Namespaces

namespace  flutter
 
namespace  flutter::gpu
 

Functions

FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_Initialize (Dart_Handle wrapper)
 
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)
 
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 Dart_Handle InternalFlutterGpu_RenderPass_Begin (flutter::gpu::RenderPass *wrapper, flutter::gpu::CommandBuffer *command_buffer)
 
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_BindPipeline (flutter::gpu::RenderPass *wrapper, flutter::gpu::RenderPipeline *pipeline)
 
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_BindVertexBufferHost (flutter::gpu::RenderPass *wrapper, flutter::gpu::HostBuffer *host_buffer, int offset_in_bytes, int length_in_bytes, int vertex_count)
 
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_BindIndexBufferHost (flutter::gpu::RenderPass *wrapper, flutter::gpu::HostBuffer *host_buffer, int offset_in_bytes, int length_in_bytes, int index_type, int index_count)
 
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 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)
 
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_ClearBindings (flutter::gpu::RenderPass *wrapper)
 
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetColorBlendEnable (flutter::gpu::RenderPass *wrapper, int color_attachment_index, bool enable)
 
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_SetDepthWriteEnable (flutter::gpu::RenderPass *wrapper, bool enable)
 
FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetDepthCompareOperation (flutter::gpu::RenderPass *wrapper, int compare_operation)
 
FLUTTER_GPU_EXPORT bool InternalFlutterGpu_RenderPass_Draw (flutter::gpu::RenderPass *wrapper)
 

Function Documentation

◆ InternalFlutterGpu_RenderPass_Begin()

FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_RenderPass_Begin ( flutter::gpu::RenderPass wrapper,
flutter::gpu::CommandBuffer command_buffer 
)

Definition at line 252 of file render_pass.cc.

254 {
255 if (!wrapper->Begin(*command_buffer)) {
256 return tonic::ToDart("Failed to begin RenderPass");
257 }
258 return Dart_Null();
259}
bool Begin(flutter::gpu::CommandBuffer &command_buffer)
Definition: render_pass.cc:69
DART_EXPORT Dart_Handle Dart_Null(void)
Dart_Handle ToDart(const T &object)

◆ InternalFlutterGpu_RenderPass_BindIndexBufferDevice()

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 at line 336 of file render_pass.cc.

342 {
343 BindIndexBuffer(wrapper, device_buffer->GetBuffer(), offset_in_bytes,
344 length_in_bytes, index_type, index_count);
345}
std::shared_ptr< impeller::DeviceBuffer > GetBuffer()
static void BindIndexBuffer(flutter::gpu::RenderPass *wrapper, TBuffer buffer, int offset_in_bytes, int length_in_bytes, int index_type, int index_count)
Definition: render_pass.cc:321

◆ InternalFlutterGpu_RenderPass_BindIndexBufferHost()

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 at line 347 of file render_pass.cc.

353 {
354 auto view = host_buffer->GetBufferViewForOffset(offset_in_bytes);
355 if (!view.has_value()) {
357 << "Failed to bind index buffer due to invalid HostBuffer offset: "
358 << offset_in_bytes;
359 return;
360 }
361 BindIndexBuffer(wrapper, view->buffer, view->range.offset, view->range.length,
362 index_type, index_count);
363}
std::optional< impeller::BufferView > GetBufferViewForOffset(size_t offset)
Definition: host_buffer.cc:39
#define FML_LOG(severity)
Definition: logging.h:82
#define ERROR(message)
Definition: elf_loader.cc:260

◆ InternalFlutterGpu_RenderPass_BindPipeline()

FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_BindPipeline ( flutter::gpu::RenderPass wrapper,
flutter::gpu::RenderPipeline pipeline 
)

Definition at line 261 of file render_pass.cc.

263 {
265 wrapper->SetPipeline(std::move(ref));
266}
void SetPipeline(fml::RefPtr< RenderPipeline > pipeline)
Definition: render_pass.cc:79

◆ InternalFlutterGpu_RenderPass_BindTexture()

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 at line 422 of file render_pass.cc.

431 {
432 auto& command = wrapper->GetCommand();
433
434 auto uniform_name = tonic::StdStringFromDart(uniform_name_handle);
435 const impeller::SampledImageSlot* image_slot =
436 shader->GetUniformTexture(uniform_name);
437 // TODO(bdero): Return an error string stating that no uniform texture with
438 // this name exists and throw an exception.
439 if (!image_slot) {
440 return false;
441 }
442
443 impeller::SamplerDescriptor sampler_desc;
444 sampler_desc.min_filter = flutter::gpu::ToImpellerMinMagFilter(min_filter);
445 sampler_desc.mag_filter = flutter::gpu::ToImpellerMinMagFilter(mag_filter);
446 sampler_desc.mip_filter = flutter::gpu::ToImpellerMipFilter(mip_filter);
447 sampler_desc.width_address_mode =
449 sampler_desc.height_address_mode =
451 const std::unique_ptr<const impeller::Sampler>& sampler =
452 wrapper->GetContext()->GetSamplerLibrary()->GetSampler(sampler_desc);
453
454 return command.BindResource(
456 *image_slot, impeller::ShaderMetadata{}, texture->GetTexture(), sampler);
457}
impeller::Command & GetCommand()
Definition: render_pass.cc:35
const std::shared_ptr< const impeller::Context > & GetContext() const
Definition: render_pass.cc:31
impeller::ShaderStage GetShaderStage() const
Definition: shader.cc:97
const impeller::SampledImageSlot * GetUniformTexture(const std::string &name) const
Definition: shader.cc:115
FlTexture * texture
constexpr impeller::SamplerAddressMode ToImpellerSamplerAddressMode(FlutterGPUSamplerAddressMode value)
Definition: formats.h:365
constexpr impeller::MipFilter ToImpellerMipFilter(FlutterGPUMipFilter value)
Definition: formats.h:346
constexpr impeller::MinMagFilter ToImpellerMinMagFilter(FlutterGPUMinMagFilter value)
Definition: formats.h:327
std::string StdStringFromDart(Dart_Handle handle)
list command
Definition: valgrind.py:24
Metadata required to bind a combined texture and sampler.
Definition: shader_types.h:98
SamplerAddressMode width_address_mode
SamplerAddressMode height_address_mode

◆ InternalFlutterGpu_RenderPass_BindUniformDevice()

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 at line 392 of file render_pass.cc.

398 {
399 return BindUniform(wrapper, shader, uniform_name_handle,
400 device_buffer->GetBuffer(), offset_in_bytes,
401 length_in_bytes);
402}
static bool BindUniform(flutter::gpu::RenderPass *wrapper, flutter::gpu::Shader *shader, Dart_Handle uniform_name_handle, TBuffer buffer, int offset_in_bytes, int length_in_bytes)
Definition: render_pass.cc:366

◆ InternalFlutterGpu_RenderPass_BindUniformHost()

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 at line 404 of file render_pass.cc.

410 {
411 auto view = host_buffer->GetBufferViewForOffset(offset_in_bytes);
412 if (!view.has_value()) {
414 << "Failed to bind index buffer due to invalid HostBuffer offset: "
415 << offset_in_bytes;
416 return false;
417 }
418 return BindUniform(wrapper, shader, uniform_name_handle, view->buffer,
419 view->range.offset, view->range.length);
420}

◆ InternalFlutterGpu_RenderPass_BindVertexBufferDevice()

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 at line 292 of file render_pass.cc.

297 {
298 BindVertexBuffer(wrapper, device_buffer->GetBuffer(), offset_in_bytes,
299 length_in_bytes, vertex_count);
300}
static void BindVertexBuffer(flutter::gpu::RenderPass *wrapper, TBuffer buffer, int offset_in_bytes, int length_in_bytes, int vertex_count)
Definition: render_pass.cc:269

◆ InternalFlutterGpu_RenderPass_BindVertexBufferHost()

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 at line 302 of file render_pass.cc.

307 {
308 std::optional<impeller::BufferView> view =
309 host_buffer->GetBufferViewForOffset(offset_in_bytes);
310 if (!view.has_value()) {
312 << "Failed to bind vertex buffer due to invalid HostBuffer offset: "
313 << offset_in_bytes;
314 return;
315 }
316 BindVertexBuffer(wrapper, view->buffer, view->range.offset,
317 view->range.length, vertex_count);
318}

◆ InternalFlutterGpu_RenderPass_ClearBindings()

FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_ClearBindings ( flutter::gpu::RenderPass wrapper)

Definition at line 459 of file render_pass.cc.

460 {
461 auto& command = wrapper->GetCommand();
462 command.vertex_buffer = {};
463 command.vertex_bindings = {};
464 command.fragment_bindings = {};
465}

◆ InternalFlutterGpu_RenderPass_Draw()

FLUTTER_GPU_EXPORT bool InternalFlutterGpu_RenderPass_Draw ( flutter::gpu::RenderPass wrapper)

Definition at line 514 of file render_pass.cc.

514 {
515 return wrapper->Draw();
516}

◆ InternalFlutterGpu_RenderPass_Initialize()

FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_Initialize ( Dart_Handle  wrapper)

Exports

Definition at line 194 of file render_pass.cc.

194 {
195 auto res = fml::MakeRefCounted<flutter::gpu::RenderPass>();
196 res->AssociateWithDartWrapper(wrapper);
197}

◆ InternalFlutterGpu_RenderPass_SetColorAttachment()

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 at line 199 of file render_pass.cc.

206 {
208 desc.load_action = flutter::gpu::ToImpellerLoadAction(load_action);
209 desc.store_action = flutter::gpu::ToImpellerStoreAction(store_action);
210 desc.clear_color = ToImpellerColor(static_cast<uint32_t>(clear_color));
211 desc.texture = texture->GetTexture();
212 if (!Dart_IsNull(resolve_texture_wrapper)) {
213 flutter::gpu::Texture* resolve_texture =
215 resolve_texture_wrapper);
216 desc.resolve_texture = resolve_texture->GetTexture();
217 }
218 wrapper->GetRenderTarget().SetColorAttachment(desc, color_attachment_index);
219 return Dart_Null();
220}
impeller::RenderTarget & GetRenderTarget()
Definition: render_pass.cc:43
std::shared_ptr< impeller::Texture > GetTexture()
Definition: texture.cc:26
RenderTarget & SetColorAttachment(const ColorAttachment &attachment, size_t index)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
static impeller::Color ToImpellerColor(uint32_t argb)
Definition: render_pass.cc:183
constexpr impeller::LoadAction ToImpellerLoadAction(FlutterGPULoadAction value)
Definition: formats.h:247
constexpr impeller::StoreAction ToImpellerStoreAction(FlutterGPUStoreAction value)
Definition: formats.h:270

◆ InternalFlutterGpu_RenderPass_SetColorBlendEnable()

FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetColorBlendEnable ( flutter::gpu::RenderPass wrapper,
int  color_attachment_index,
bool  enable 
)

Definition at line 467 of file render_pass.cc.

470 {
471 auto& color = wrapper->GetColorAttachmentDescriptor(color_attachment_index);
472 color.blending_enabled = enable;
473}
impeller::ColorAttachmentDescriptor & GetColorAttachmentDescriptor(size_t color_attachment_index)
Definition: render_pass.cc:51
DlColor color

◆ InternalFlutterGpu_RenderPass_SetColorBlendEquation()

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 at line 475 of file render_pass.cc.

483 {
484 auto& color = wrapper->GetColorAttachmentDescriptor(color_attachment_index);
485 color.color_blend_op =
486 flutter::gpu::ToImpellerBlendOperation(color_blend_operation);
487 color.src_color_blend_factor =
488 flutter::gpu::ToImpellerBlendFactor(source_color_blend_factor);
489 color.dst_color_blend_factor =
490 flutter::gpu::ToImpellerBlendFactor(destination_color_blend_factor);
491 color.alpha_blend_op =
492 flutter::gpu::ToImpellerBlendOperation(alpha_blend_operation);
493 color.src_alpha_blend_factor =
494 flutter::gpu::ToImpellerBlendFactor(source_alpha_blend_factor);
495 color.dst_alpha_blend_factor =
496 flutter::gpu::ToImpellerBlendFactor(destination_alpha_blend_factor);
497}
constexpr impeller::BlendFactor ToImpellerBlendFactor(FlutterGPUBlendFactor value)
Definition: formats.h:179
constexpr impeller::BlendOperation ToImpellerBlendOperation(FlutterGPUBlendOperation value)
Definition: formats.h:225

◆ InternalFlutterGpu_RenderPass_SetDepthCompareOperation()

FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetDepthCompareOperation ( flutter::gpu::RenderPass wrapper,
int  compare_operation 
)

Definition at line 506 of file render_pass.cc.

508 {
509 auto& depth = wrapper->GetDepthAttachmentDescriptor();
510 depth.depth_compare =
512}
impeller::DepthAttachmentDescriptor & GetDepthAttachmentDescriptor()
Definition: render_pass.cc:61
constexpr impeller::CompareFunction ToImpellerCompareFunction(FlutterGPUCompareFunction value)
Definition: formats.h:439

◆ InternalFlutterGpu_RenderPass_SetDepthStencilAttachment()

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 at line 222 of file render_pass.cc.

230 {
231 {
233 desc.load_action = flutter::gpu::ToImpellerLoadAction(depth_load_action);
234 desc.store_action = flutter::gpu::ToImpellerStoreAction(depth_store_action);
235 desc.clear_depth = depth_clear_value;
236 desc.texture = texture->GetTexture();
238 }
239 {
241 desc.load_action = flutter::gpu::ToImpellerLoadAction(stencil_load_action);
242 desc.store_action =
243 flutter::gpu::ToImpellerStoreAction(stencil_store_action);
244 desc.clear_stencil = stencil_clear_value;
245 desc.texture = texture->GetTexture();
247 }
248
249 return Dart_Null();
250}
RenderTarget & SetDepthAttachment(std::optional< DepthAttachment > attachment)
RenderTarget & SetStencilAttachment(std::optional< StencilAttachment > attachment)

◆ InternalFlutterGpu_RenderPass_SetDepthWriteEnable()

FLUTTER_GPU_EXPORT void InternalFlutterGpu_RenderPass_SetDepthWriteEnable ( flutter::gpu::RenderPass wrapper,
bool  enable 
)

Definition at line 499 of file render_pass.cc.

501 {
502 auto& depth = wrapper->GetDepthAttachmentDescriptor();
503 depth.depth_write_enabled = true;
504}