| Flutter Impeller |

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
impeller::RenderPass Class Referenceabstract

Render passes encode render commands directed as one specific render target into an underlying command buffer. More...

`#include <render_pass.h>`

Inheritance diagram for impeller::RenderPass:

## Public Member Functions
virtual | ~RenderPass ()
const RenderTarget & | GetRenderTarget () const
ISize | GetRenderTargetSize () const
virtual bool | IsValid () const =0
void | SetLabel (std::string label)
HostBuffer & | GetTransientsBuffer ()
bool | AddCommand (Command &&command)
| Record a command for subsequent encoding to the underlying command buffer. No work is encoded into the command buffer at this time. More...
bool | EncodeCommands () const
| Encode the recorded commands to the underlying command buffer. More...
const std::vector< Command > & | GetCommands () const
| Accessor for the current Commands. More...

## Protected Member Functions
| RenderPass (std::weak_ptr< const Context > context, const RenderTarget &target)
const std::weak_ptr< const Context > & | GetContext () const
virtual void | OnSetLabel (std::string label)=0
virtual bool | OnEncodeCommands (const Context &context) const =0

## Protected Attributes
const std::weak_ptr< const Context > | context_
const RenderTarget | render_target_
std::shared_ptr< HostBuffer > | transients_buffer_
std::vector< Command > | commands_

## Detailed Description

Render passes encode render commands directed as one specific render target into an underlying command buffer.

Render passes can be obtained from the command buffer in which the pass is meant to encode commands into.

See also
  `CommandBuffer`

Definition at line 27 of file render_pass.h.

## Constructor & Destructor Documentation

## ◆ ~RenderPass()

impeller::RenderPass::~RenderPass | ( |  | ) |
| virtual

Definition at line 19 of file render_pass.cc.

19 {
20 auto strong_context = context_.lock();
21 if (strong_context) {
22 strong_context->GetHostBufferPool().Recycle(transients_buffer_);
23 }
24 }

References context_, and transients_buffer_.

## ◆ RenderPass()

impeller::RenderPass::RenderPass | ( | std::weak_ptr< const Context > | context,
|  | const RenderTarget & | target
| ) |  |
| protected

Definition at line 9 of file render_pass.cc.

11 : context_(std::move(context)),
12 render_target_(target),
13 transients_buffer_() {
14 auto strong_context = context_.lock();
15 FML_DCHECK(strong_context);
16 transients_buffer_ = strong_context->GetHostBufferPool().Grab();
17 }

References context_, and transients_buffer_.

## Member Function Documentation

## ◆ AddCommand()

bool impeller::RenderPass::AddCommand | ( | Command && | command | ) |

Record a command for subsequent encoding to the underlying command buffer. No work is encoded into the command buffer at this time.

Parameters

  [in] | command | The command

Returns
  If the command was valid for subsequent commitment.

Definition at line 46 of file render_pass.cc.

46 {
47 if (!command) {
48 VALIDATION_LOG << "Attempted to add an invalid command to the render pass.";
49 return false;
50 }
51
52 if (command.scissor.has_value()) {
53 auto target_rect = IRect({}, render_target_.GetRenderTargetSize());
54 if (!target_rect.Contains(command.scissor.value())) {
55 VALIDATION_LOG << "Cannot apply a scissor that lies outside the bounds "
56 "of the render target.";
57 return false;
58 }
59 }
60
61 if (command.vertex_count == 0u) {
62 // Essentially a no-op. Don't record the command but this is not necessary
63 // an error either.
64 return true;
65 }
66
67 if (command.instance_count == 0u) {
68 // Essentially a no-op. Don't record the command but this is not necessary
69 // an error either.
70 return true;
71 }
72
73 commands_.emplace_back(std::move(command));
74 return true;
75 }

References commands_, impeller::RenderTarget::GetRenderTargetSize(), render_target_, and VALIDATION_LOG.

Referenced by impeller::scene::EncodeCommand(), ImGui_ImplImpeller_RenderDrawData(), impeller::CheckerboardContents::Render(), impeller::TiledTextureContents::Render(), impeller::RuntimeEffectContents::Render(), impeller::ClipContents::Render(), impeller::SolidRRectBlurContents::Render(), impeller::SolidColorContents::Render(), impeller::TextContents::Render(), impeller::TextureContents::Render(), impeller::VerticesColorContents::Render(), impeller::AtlasContents::Render(), impeller::ClipRestoreContents::Render(), impeller::VerticesUVContents::Render(), impeller::AtlasTextureContents::Render(), impeller::AtlasColorContents::Render(), and impeller::testing::TEST_P().

## ◆ EncodeCommands()

bool impeller::RenderPass::EncodeCommands | ( |  | ) | const

Encode the recorded commands to the underlying command buffer.

Returns
  If the commands were encoded to the underlying command buffer.

Definition at line 77 of file render_pass.cc.

77 {
78 auto context = context_.lock();
79 // The context could have been collected in the meantime.
80 if (!context) {
81 return false;
82 }
83 return OnEncodeCommands(*context);
84 }

References context_, and OnEncodeCommands().

## ◆ GetCommands()

const std::vector<Command>& impeller::RenderPass::GetCommands | ( |  | ) | const
| inline

Accessor for the current Commands.

Visible for testing.

Definition at line 65 of file render_pass.h.

65 { return commands_; }

References commands_.

## ◆ GetContext()

const std::weak_ptr< const Context > & impeller::RenderPass::GetContext | ( |  | ) | const
| protected

Definition at line 86 of file render_pass.cc.

86 {
87 return context_;
88 }

References context_.

## ◆ GetRenderTarget()

const RenderTarget & impeller::RenderPass::GetRenderTarget | ( |  | ) | const

Definition at line 26 of file render_pass.cc.

26 {
27 return render_target_;
28 }

References render_target_.

Referenced by impeller::EncodeCommandsInReactor(), impeller::scene::Material::GetContextOptions(), and impeller::OptionsFromPass().

## ◆ GetRenderTargetSize()

ISize impeller::RenderPass::GetRenderTargetSize | ( |  | ) | const

Definition at line 30 of file render_pass.cc.

30 {
31 return render_target_.GetRenderTargetSize();
32 }

References impeller::RenderTarget::GetRenderTargetSize(), and render_target_.

Referenced by impeller::ComputeUVGeometryForRect(), impeller::EncodeCommandsInReactor(), impeller::VerticesGeometry::GetPositionBuffer(), impeller::VerticesGeometry::GetPositionColorBuffer(), impeller::VerticesGeometry::GetPositionUVBuffer(), ImGui_ImplImpeller_RenderDrawData(), impeller::SceneContents::Render(), impeller::ClipContents::Render(), impeller::SolidRRectBlurContents::Render(), impeller::TextContents::Render(), impeller::TextureContents::Render(), impeller::AtlasContents::Render(), impeller::ClipRestoreContents::Render(), impeller::Entity::Render(), impeller::AtlasTextureContents::Render(), impeller::AtlasColorContents::Render(), and impeller::testing::TEST_P().

## ◆ GetTransientsBuffer()

HostBuffer & impeller::RenderPass::GetTransientsBuffer | ( |  | ) |

Definition at line 34 of file render_pass.cc.

34 {
35 return *transients_buffer_;
36 }

References transients_buffer_.

Referenced by impeller::ComputeUVGeometryForRect(), impeller::scene::EncodeCommand(), ImGui_ImplImpeller_RenderDrawData(), impeller::CheckerboardContents::Render(), impeller::TiledTextureContents::Render(), impeller::RuntimeEffectContents::Render(), impeller::ClipContents::Render(), impeller::SolidRRectBlurContents::Render(), impeller::SolidColorContents::Render(), impeller::TextContents::Render(), impeller::TextureContents::Render(), impeller::VerticesColorContents::Render(), impeller::AtlasContents::Render(), impeller::ClipRestoreContents::Render(), impeller::VerticesUVContents::Render(), impeller::AtlasTextureContents::Render(), impeller::AtlasColorContents::Render(), and impeller::testing::TEST_P().

## ◆ IsValid()

virtual bool impeller::RenderPass::IsValid | ( |  | ) | const
| pure virtual

## ◆ OnEncodeCommands()

virtual bool impeller::RenderPass::OnEncodeCommands | ( | const Context & | context | ) | const
| protected pure virtual

Referenced by EncodeCommands().

## ◆ OnSetLabel()

virtual void impeller::RenderPass::OnSetLabel | ( | std::string | label | ) |
| protected pure virtual

Referenced by SetLabel().

## ◆ SetLabel()

void impeller::RenderPass::SetLabel | ( | std::string | label | ) |

Definition at line 38 of file render_pass.cc.

38 {
39 if (label.empty()) {
40 return;
41 }
42 transients_buffer_->SetLabel(SPrintF("%s Transients", label.c_str()));
43 OnSetLabel(std::move(label));
44 }

References OnSetLabel(), impeller::SPrintF(), and transients_buffer_.

## Member Data Documentation

## ◆ commands_

std::vector<Command> impeller::RenderPass::commands_
| protected

Definition at line 71 of file render_pass.h.

Referenced by AddCommand(), impeller::EncodeCommandsInReactor(), and GetCommands().

## ◆ context_

const std::weak_ptr<const Context> impeller::RenderPass::context_
| protected

Definition at line 68 of file render_pass.h.

Referenced by EncodeCommands(), GetContext(), RenderPass(), and ~RenderPass().

## ◆ render_target_

const RenderTarget impeller::RenderPass::render_target_
| protected

Definition at line 69 of file render_pass.h.

Referenced by AddCommand(), GetRenderTarget(), and GetRenderTargetSize().

## ◆ transients_buffer_

std::shared_ptr<HostBuffer> impeller::RenderPass::transients_buffer_
| protected

Definition at line 70 of file render_pass.h.

Referenced by GetTransientsBuffer(), RenderPass(), SetLabel(), and ~RenderPass().

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

- impeller/renderer/render_pass.h
- impeller/renderer/render_pass.cc

impeller::SPrintF
std::string SPrintF(const char *format,...)
Definition: strings.cc:12
impeller::RenderPass::OnEncodeCommands
virtual bool OnEncodeCommands(const Context &context) const =0
impeller::RenderPass::render_target_
const RenderTarget render_target_
Definition: render_pass.h:69
impeller::IRect
TRect< int64_t > IRect
Definition: rect.h:307
impeller::RenderPass::commands_
std::vector< Command > commands_
Definition: render_pass.h:71
impeller::RenderTarget::GetRenderTargetSize
ISize GetRenderTargetSize() const
Definition: render_target.cc:150
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::RenderPass::OnSetLabel
virtual void OnSetLabel(std::string label)=0
impeller::RenderPass::context_
const std::weak_ptr< const Context > context_
Definition: render_pass.h:68
impeller::RenderPass::transients_buffer_
std::shared_ptr< HostBuffer > transients_buffer_
Definition: render_pass.h:70