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 76 of file render_pass.cc.

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

References command_buffer.

Referenced by InternalFlutterGpu_RenderPass_Begin().

◆ ClearBindings()

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

Definition at line 92 of file render_pass.cc.

92 {
97 for (auto& buffer : vertex_buffers) {
98 buffer = {};
99 }
101 index_buffer = {};
103}
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 185 of file render_pass.cc.

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

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

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 36 of file render_pass.cc.

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

Referenced by InternalFlutterGpu_RenderPass_BindTexture().

◆ GetDepthAttachmentDescriptor()

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

Definition at line 58 of file render_pass.cc.

58 {
59 return depth_desc_;
60}

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 40 of file render_pass.cc.

40 {
41 return render_target_;
42}

Referenced by InternalFlutterGpu_RenderPass_SetColorAttachment(), and InternalFlutterGpu_RenderPass_SetDepthStencilAttachment().

◆ GetRenderTarget() [2/2]

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

Definition at line 44 of file render_pass.cc.

44 {
45 return render_target_;
46}

◆ GetStencilBackAttachmentDescriptor()

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

Definition at line 68 of file render_pass.cc.

68 {
69 return stencil_back_desc_;
70}

Referenced by InternalFlutterGpu_RenderPass_SetStencilConfig().

◆ GetStencilFrontAttachmentDescriptor()

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

Definition at line 63 of file render_pass.cc.

63 {
64 return stencil_front_desc_;
65}

Referenced by InternalFlutterGpu_RenderPass_SetStencilConfig().

◆ SetPipeline()

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

Definition at line 86 of file render_pass.cc.

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