Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::gpu::RenderPass Class Reference

#include <render_pass.h>

Inheritance diagram for flutter::gpu::RenderPass:
flutter::RefCountedDartWrappable< RenderPass > fml::RefCountedThreadSafe< T > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Classes

struct  BufferAndUniformSlot
 

Public Types

using BufferUniformMap = std::unordered_map< const flutter::gpu::Shader::UniformBinding *, BufferAndUniformSlot >
 
using TextureUniformMap = std::unordered_map< const flutter::gpu::Shader::TextureBinding *, impeller::TextureAndSampler >
 
- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex ,
  kNumberOfNativeFields
}
 

Public Member Functions

 RenderPass ()
 
 ~RenderPass () override
 
const std::shared_ptr< const impeller::Context > & GetContext () const
 
impeller::RenderTargetGetRenderTarget ()
 
const impeller::RenderTargetGetRenderTarget () const
 
impeller::ColorAttachmentDescriptorGetColorAttachmentDescriptor (size_t color_attachment_index)
 
impeller::DepthAttachmentDescriptorGetDepthAttachmentDescriptor ()
 
impeller::StencilAttachmentDescriptorGetStencilFrontAttachmentDescriptor ()
 
impeller::StencilAttachmentDescriptorGetStencilBackAttachmentDescriptor ()
 
impeller::PipelineDescriptorGetPipelineDescriptor ()
 
bool Begin (flutter::gpu::CommandBuffer &command_buffer)
 
void SetPipeline (fml::RefPtr< RenderPipeline > pipeline)
 
void ClearBindings ()
 
bool Draw (size_t element_count, size_t instance_count, bool indexed)
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< RenderPass >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< T >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Public Attributes

BufferUniformMap vertex_uniform_bindings
 
TextureUniformMap vertex_texture_bindings
 
BufferUniformMap fragment_uniform_bindings
 
TextureUniformMap fragment_texture_bindings
 
std::array< impeller::BufferView, kMaxVertexBufferSlotsvertex_buffers
 
size_t vertex_buffer_count = 0
 
impeller::BufferView index_buffer
 
impeller::IndexType index_buffer_type = impeller::IndexType::kNone
 
uint32_t stencil_reference = 0
 
std::optional< impeller::IRect32scissor
 
std::optional< impeller::Viewportviewport
 

Static Public Attributes

static constexpr size_t kMaxVertexBufferSlots = 16
 

Additional Inherited Members

- Protected Member Functions inherited from fml::RefCountedThreadSafe< T >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 28 of file render_pass.h.

Member Typedef Documentation

◆ BufferUniformMap

◆ TextureUniformMap

Constructor & Destructor Documentation

◆ RenderPass()

flutter::gpu::RenderPass::RenderPass ( )
default

◆ ~RenderPass()

flutter::gpu::RenderPass::~RenderPass ( )
overridedefault

Member Function Documentation

◆ Begin()

bool flutter::gpu::RenderPass::Begin ( flutter::gpu::CommandBuffer command_buffer)

Definition at line 77 of file render_pass.cc.

77 {
78 render_pass_ =
79 command_buffer.GetCommandBuffer()->CreateRenderPass(render_target_);
80 if (!render_pass_) {
81 return false;
82 }
83 command_buffer.AddRenderPass(render_pass_);
84 return true;
85}
std::shared_ptr< CommandBuffer > command_buffer

References command_buffer.

Referenced by InternalFlutterGpu_RenderPass_Begin().

◆ ClearBindings()

void flutter::gpu::RenderPass::ClearBindings ( )

Definition at line 93 of file render_pass.cc.

93 {
98 for (auto& buffer : vertex_buffers) {
99 buffer = {};
100 }
102 index_buffer = {};
104}
TextureUniformMap fragment_texture_bindings
Definition render_pass.h:79
BufferUniformMap fragment_uniform_bindings
Definition render_pass.h:78
TextureUniformMap vertex_texture_bindings
Definition render_pass.h:77
BufferUniformMap vertex_uniform_bindings
Definition render_pass.h:76
impeller::IndexType index_buffer_type
Definition render_pass.h:92
std::array< impeller::BufferView, kMaxVertexBufferSlots > vertex_buffers
Definition render_pass.h:88
impeller::BufferView index_buffer
Definition render_pass.h:91
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98
@ kNone
Does not use the index buffer.

References flutter::buffer, fragment_texture_bindings, fragment_uniform_bindings, index_buffer, index_buffer_type, impeller::kNone, vertex_buffer_count, vertex_buffers, vertex_texture_bindings, and vertex_uniform_bindings.

Referenced by InternalFlutterGpu_RenderPass_ClearBindings().

◆ Draw()

bool flutter::gpu::RenderPass::Draw ( size_t  element_count,
size_t  instance_count,
bool  indexed 
)

Append a draw to the underlying render pass. [element_count] is the vertex count for a non-indexed draw, or the index count when [indexed] is true. [instance_count] is the number of instances to draw.

Definition at line 186 of file render_pass.cc.

188 {
189 if (element_count == 0u || instance_count == 0u) {
190 return true;
191 }
192
194 // drawIndexed was called without an index buffer bound.
195 return false;
196 }
197
198 render_pass_->SetPipeline(impeller::PipelineRef(GetOrCreatePipeline()));
199
200 for (const auto& [_, buffer] : vertex_uniform_bindings) {
201 render_pass_->BindDynamicResource(
204 std::make_unique<impeller::ShaderMetadata>(*buffer.view.GetMetadata()),
205 buffer.view.resource);
206 }
207 for (const auto& [_, texture] : vertex_texture_bindings) {
208 render_pass_->BindDynamicResource(
210 texture.slot,
211 std::make_unique<impeller::ShaderMetadata>(
212 *texture.texture.GetMetadata()),
213 texture.texture.resource, texture.sampler);
214 }
215 for (const auto& [_, buffer] : fragment_uniform_bindings) {
216 render_pass_->BindDynamicResource(
219 std::make_unique<impeller::ShaderMetadata>(*buffer.view.GetMetadata()),
220 buffer.view.resource);
221 }
222 for (const auto& [_, texture] : fragment_texture_bindings) {
223 render_pass_->BindDynamicResource(
226 std::make_unique<impeller::ShaderMetadata>(
227 *texture.texture.GetMetadata()),
228 texture.texture.resource, texture.sampler);
229 }
230
231 render_pass_->SetVertexBuffer(vertex_buffers.data(), vertex_buffer_count);
232 if (indexed) {
233 render_pass_->SetIndexBuffer(index_buffer, index_buffer_type);
234 } else {
235 render_pass_->SetIndexBuffer(impeller::BufferView{},
237 }
238 render_pass_->SetElementCount(element_count);
239 render_pass_->SetInstanceCount(instance_count);
240
241 render_pass_->SetStencilReference(stencil_reference);
242
243 if (viewport.has_value()) {
244 render_pass_->SetViewport(viewport.value());
245 }
246
247 if (scissor.has_value()) {
248 render_pass_->SetScissor(scissor.value());
249 }
250
251 bool result = render_pass_->Draw().ok();
252
253 return result;
254}
std::optional< impeller::Viewport > viewport
Definition render_pass.h:96
std::optional< impeller::IRect32 > scissor
Definition render_pass.h:95
FlTexture * texture

References flutter::buffer, fragment_texture_bindings, fragment_uniform_bindings, index_buffer, index_buffer_type, impeller::kFragment, impeller::kNone, impeller::kSampledImage, impeller::kUniformBuffer, impeller::kVertex, scissor, stencil_reference, texture, vertex_buffer_count, vertex_buffers, vertex_texture_bindings, vertex_uniform_bindings, and viewport.

Referenced by InternalFlutterGpu_RenderPass_Draw(), and InternalFlutterGpu_RenderPass_DrawIndexed().

◆ GetColorAttachmentDescriptor()

impeller::ColorAttachmentDescriptor & flutter::gpu::RenderPass::GetColorAttachmentDescriptor ( size_t  color_attachment_index)

Definition at line 49 of file render_pass.cc.

50 {
51 auto color = color_descriptors_.find(color_attachment_index);
52 if (color == color_descriptors_.end()) {
53 return color_descriptors_[color_attachment_index] = {};
54 }
55 return color->second;
56}

Referenced by InternalFlutterGpu_RenderPass_SetColorBlendEnable(), and InternalFlutterGpu_RenderPass_SetColorBlendEquation().

◆ GetContext()

const std::shared_ptr< const impeller::Context > & flutter::gpu::RenderPass::GetContext ( ) const

Definition at line 37 of file render_pass.cc.

37 {
38 return render_pass_->GetContext();
39}

Referenced by InternalFlutterGpu_RenderPass_BindTexture().

◆ GetDepthAttachmentDescriptor()

impeller::DepthAttachmentDescriptor & flutter::gpu::RenderPass::GetDepthAttachmentDescriptor ( )

Definition at line 59 of file render_pass.cc.

59 {
60 return depth_desc_;
61}

Referenced by InternalFlutterGpu_RenderPass_SetDepthCompareOperation(), and InternalFlutterGpu_RenderPass_SetDepthWriteEnable().

◆ GetPipelineDescriptor()

impeller::PipelineDescriptor & flutter::gpu::RenderPass::GetPipelineDescriptor ( )

◆ GetRenderTarget() [1/2]

impeller::RenderTarget & flutter::gpu::RenderPass::GetRenderTarget ( )

Definition at line 41 of file render_pass.cc.

41 {
42 return render_target_;
43}

Referenced by InternalFlutterGpu_RenderPass_SetColorAttachment(), and InternalFlutterGpu_RenderPass_SetDepthStencilAttachment().

◆ GetRenderTarget() [2/2]

const impeller::RenderTarget & flutter::gpu::RenderPass::GetRenderTarget ( ) const

Definition at line 45 of file render_pass.cc.

45 {
46 return render_target_;
47}

◆ GetStencilBackAttachmentDescriptor()

impeller::StencilAttachmentDescriptor & flutter::gpu::RenderPass::GetStencilBackAttachmentDescriptor ( )

Definition at line 69 of file render_pass.cc.

69 {
70 return stencil_back_desc_;
71}

Referenced by InternalFlutterGpu_RenderPass_SetStencilConfig().

◆ GetStencilFrontAttachmentDescriptor()

impeller::StencilAttachmentDescriptor & flutter::gpu::RenderPass::GetStencilFrontAttachmentDescriptor ( )

Definition at line 64 of file render_pass.cc.

64 {
65 return stencil_front_desc_;
66}

Referenced by InternalFlutterGpu_RenderPass_SetStencilConfig().

◆ SetPipeline()

void flutter::gpu::RenderPass::SetPipeline ( fml::RefPtr< RenderPipeline pipeline)

Definition at line 87 of file render_pass.cc.

87 {
88 // On debug this makes a difference, but not on release builds.
89 // NOLINTNEXTLINE(performance-move-const-arg)
90 render_pipeline_ = std::move(pipeline);
91}
std::shared_ptr< PipelineGLES > pipeline

References pipeline.

Referenced by InternalFlutterGpu_RenderPass_BindPipeline().

Member Data Documentation

◆ fragment_texture_bindings

TextureUniformMap flutter::gpu::RenderPass::fragment_texture_bindings

Definition at line 79 of file render_pass.h.

Referenced by ClearBindings(), Draw(), and InternalFlutterGpu_RenderPass_BindTexture().

◆ fragment_uniform_bindings

BufferUniformMap flutter::gpu::RenderPass::fragment_uniform_bindings

Definition at line 78 of file render_pass.h.

Referenced by BindUniform(), ClearBindings(), and Draw().

◆ index_buffer

impeller::BufferView flutter::gpu::RenderPass::index_buffer

Definition at line 91 of file render_pass.h.

Referenced by BindIndexBuffer(), ClearBindings(), and Draw().

◆ index_buffer_type

impeller::IndexType flutter::gpu::RenderPass::index_buffer_type = impeller::IndexType::kNone

Definition at line 92 of file render_pass.h.

Referenced by BindIndexBuffer(), ClearBindings(), and Draw().

◆ kMaxVertexBufferSlots

constexpr size_t flutter::gpu::RenderPass::kMaxVertexBufferSlots = 16
staticconstexpr

Definition at line 87 of file render_pass.h.

Referenced by BindVertexBuffer().

◆ scissor

std::optional<impeller::IRect32> flutter::gpu::RenderPass::scissor

Definition at line 95 of file render_pass.h.

Referenced by Draw(), and InternalFlutterGpu_RenderPass_SetScissor().

◆ stencil_reference

uint32_t flutter::gpu::RenderPass::stencil_reference = 0

Definition at line 94 of file render_pass.h.

Referenced by Draw(), and InternalFlutterGpu_RenderPass_SetStencilReference().

◆ vertex_buffer_count

size_t flutter::gpu::RenderPass::vertex_buffer_count = 0

Definition at line 90 of file render_pass.h.

Referenced by BindVertexBuffer(), ClearBindings(), and Draw().

◆ vertex_buffers

std::array<impeller::BufferView, kMaxVertexBufferSlots> flutter::gpu::RenderPass::vertex_buffers

Definition at line 88 of file render_pass.h.

Referenced by BindVertexBuffer(), ClearBindings(), and Draw().

◆ vertex_texture_bindings

TextureUniformMap flutter::gpu::RenderPass::vertex_texture_bindings

Definition at line 77 of file render_pass.h.

Referenced by ClearBindings(), Draw(), and InternalFlutterGpu_RenderPass_BindTexture().

◆ vertex_uniform_bindings

BufferUniformMap flutter::gpu::RenderPass::vertex_uniform_bindings

Definition at line 76 of file render_pass.h.

Referenced by BindUniform(), ClearBindings(), and Draw().

◆ viewport

std::optional<impeller::Viewport> flutter::gpu::RenderPass::viewport

Definition at line 96 of file render_pass.h.

Referenced by Draw(), and InternalFlutterGpu_RenderPass_SetViewport().


The documentation for this class was generated from the following files: