Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::gpu::RenderPass Class Reference

#include <render_pass.h>

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

Public Member Functions

 RenderPass ()
 
 ~RenderPass () override
 
const std::shared_ptr< const impeller::Context > & GetContext () const
 
impeller::CommandGetCommand ()
 
const impeller::CommandGetCommand () const
 
impeller::RenderTargetGetRenderTarget ()
 
const impeller::RenderTargetGetRenderTarget () const
 
impeller::ColorAttachmentDescriptorGetColorAttachmentDescriptor (size_t color_attachment_index)
 
impeller::DepthAttachmentDescriptorGetDepthAttachmentDescriptor ()
 
impeller::VertexBufferGetVertexBuffer ()
 
bool Begin (flutter::gpu::CommandBuffer &command_buffer)
 
void SetPipeline (fml::RefPtr< RenderPipeline > pipeline)
 
std::shared_ptr< impeller::Pipeline< impeller::PipelineDescriptor > > GetOrCreatePipeline ()
 
impeller::Command ProvisionRasterCommand ()
 
bool Draw ()
 
- 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< RenderPass >
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
 
virtual void RetainDartWrappableReference () const =0
 
virtual void ReleaseDartWrappableReference () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields { kPeerIndex , kNumberOfNativeFields }
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< RenderPass >
 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 27 of file render_pass.h.

Constructor & Destructor Documentation

◆ RenderPass()

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

Definition at line 25 of file render_pass.cc.

26 : vertex_buffer_(
@ kNone
Does not use the index buffer.

◆ ~RenderPass()

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

Member Function Documentation

◆ Begin()

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

Definition at line 69 of file render_pass.cc.

69 {
70 render_pass_ =
71 command_buffer.GetCommandBuffer()->CreateRenderPass(render_target_);
72 if (!render_pass_) {
73 return false;
74 }
75 command_buffer.AddRenderPass(render_pass_);
76 return true;
77}
std::shared_ptr< impeller::CommandBuffer > GetCommandBuffer()
void AddRenderPass(std::shared_ptr< impeller::RenderPass > render_pass)

◆ Draw()

bool flutter::gpu::RenderPass::Draw ( )

Definition at line 138 of file render_pass.cc.

138 {
140#ifdef IMPELLER_DEBUG
141 render_pass_->SetCommandLabel(result.label);
142#endif // IMPELLER_DEBUG
143 render_pass_->SetPipeline(result.pipeline);
144 render_pass_->SetStencilReference(result.stencil_reference);
145 render_pass_->SetBaseVertex(result.base_vertex);
146 if (result.viewport.has_value()) {
147 render_pass_->SetViewport(result.viewport.value());
148 }
149 if (result.scissor.has_value()) {
150 render_pass_->SetScissor(result.scissor.value());
151 }
152 render_pass_->SetVertexBuffer(result.vertex_buffer);
153 for (const auto& buffer : result.vertex_bindings.buffers) {
154 render_pass_->BindResource(impeller::ShaderStage::kVertex,
156 buffer.slot, *buffer.view.GetMetadata(),
157 buffer.view.resource);
158 }
159 for (const auto& texture : result.vertex_bindings.sampled_images) {
160 render_pass_->BindResource(impeller::ShaderStage::kVertex,
162 texture.slot, *texture.texture.GetMetadata(),
163 texture.texture.resource, texture.sampler);
164 }
165 for (const auto& buffer : result.fragment_bindings.buffers) {
166 render_pass_->BindResource(impeller::ShaderStage::kFragment,
168 buffer.slot, *buffer.view.GetMetadata(),
169 buffer.view.resource);
170 }
171 for (const auto& texture : result.fragment_bindings.sampled_images) {
172 render_pass_->BindResource(impeller::ShaderStage::kFragment,
174 texture.slot, *texture.texture.GetMetadata(),
175 texture.texture.resource, texture.sampler);
176 }
177 return render_pass_->Draw().ok();
178}
impeller::Command ProvisionRasterCommand()
Definition: render_pass.cc:129
GAsyncResult * result
FlTexture * texture
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 vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
An object used to specify work to the GPU along with references to resources the GPU will used when d...
Definition: command.h:92

◆ GetColorAttachmentDescriptor()

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

Definition at line 51 of file render_pass.cc.

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

◆ GetCommand() [1/2]

impeller::Command & flutter::gpu::RenderPass::GetCommand ( )

Definition at line 35 of file render_pass.cc.

35 {
36 return command_;
37}

◆ GetCommand() [2/2]

const impeller::Command & flutter::gpu::RenderPass::GetCommand ( ) const

Definition at line 39 of file render_pass.cc.

39 {
40 return command_;
41}

◆ GetContext()

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

Definition at line 31 of file render_pass.cc.

31 {
32 return render_pass_->GetContext();
33}

◆ GetDepthAttachmentDescriptor()

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

Definition at line 61 of file render_pass.cc.

61 {
62 return depth_desc_;
63}

◆ GetOrCreatePipeline()

std::shared_ptr< impeller::Pipeline< impeller::PipelineDescriptor > > flutter::gpu::RenderPass::GetOrCreatePipeline ( )

Lookup an Impeller pipeline by building a descriptor based on the current command state.

Definition at line 84 of file render_pass.cc.

84 {
85 // Infer the pipeline layout based on the shape of the RenderTarget.
86 auto pipeline_desc = pipeline_descriptor_;
87 for (const auto& it : render_target_.GetColorAttachments()) {
88 auto& color = GetColorAttachmentDescriptor(it.first);
89 color.format = render_target_.GetRenderTargetPixelFormat();
90 }
91 pipeline_desc.SetColorAttachmentDescriptors(color_descriptors_);
92
93 {
94 auto stencil = render_target_.GetStencilAttachment();
95 if (stencil && impeller::IsStencilWritable(
96 stencil->texture->GetTextureDescriptor().format)) {
97 pipeline_desc.SetStencilPixelFormat(
98 stencil->texture->GetTextureDescriptor().format);
99 pipeline_desc.SetStencilAttachmentDescriptors(stencil_front_desc_,
100 stencil_back_desc_);
101 } else {
102 pipeline_desc.ClearStencilAttachments();
103 }
104 }
105
106 {
107 auto depth = render_target_.GetDepthAttachment();
108 if (depth && impeller::IsDepthWritable(
109 depth->texture->GetTextureDescriptor().format)) {
110 pipeline_desc.SetDepthPixelFormat(
111 depth->texture->GetTextureDescriptor().format);
112 pipeline_desc.SetDepthStencilAttachmentDescriptor(depth_desc_);
113 } else {
114 pipeline_desc.ClearDepthAttachment();
115 }
116 }
117
118 auto& context = *GetContext();
119
120 render_pipeline_->BindToPipelineDescriptor(*context.GetShaderLibrary(),
121 pipeline_desc);
122
123 auto pipeline =
124 context.GetPipelineLibrary()->GetPipeline(pipeline_desc).Get();
125 FML_DCHECK(pipeline) << "Couldn't resolve render pipeline";
126 return pipeline;
127}
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
const std::map< size_t, ColorAttachment > & GetColorAttachments() const
PixelFormat GetRenderTargetPixelFormat() const
const std::optional< DepthAttachment > & GetDepthAttachment() const
const std::optional< StencilAttachment > & GetStencilAttachment() const
#define FML_DCHECK(condition)
Definition: logging.h:103
constexpr bool IsDepthWritable(PixelFormat format)
Definition: formats.h:119
constexpr bool IsStencilWritable(PixelFormat format)
Definition: formats.h:129

◆ GetRenderTarget() [1/2]

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

Definition at line 43 of file render_pass.cc.

43 {
44 return render_target_;
45}

◆ GetRenderTarget() [2/2]

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

Definition at line 47 of file render_pass.cc.

47 {
48 return render_target_;
49}

◆ GetVertexBuffer()

impeller::VertexBuffer & flutter::gpu::RenderPass::GetVertexBuffer ( )

Definition at line 65 of file render_pass.cc.

65 {
66 return vertex_buffer_;
67}

◆ ProvisionRasterCommand()

impeller::Command flutter::gpu::RenderPass::ProvisionRasterCommand ( )

Definition at line 129 of file render_pass.cc.

129 {
130 impeller::Command result = command_;
131
132 result.pipeline = GetOrCreatePipeline();
133 result.BindVertices(vertex_buffer_);
134
135 return result;
136}
std::shared_ptr< impeller::Pipeline< impeller::PipelineDescriptor > > GetOrCreatePipeline()
Definition: render_pass.cc:84

◆ SetPipeline()

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

Definition at line 79 of file render_pass.cc.

79 {
80 render_pipeline_ = std::move(pipeline);
81}

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