| Flutter Impeller |

Public Member Functions | List of all members
impeller::InlinePassContext Class Reference

`#include <inline_pass_context.h>`

## Public Member Functions
| InlinePassContext (const ContentContext &renderer, EntityPassTarget &pass_target)
| ~InlinePassContext ()
bool | IsValid () const
bool | IsActive () const
std::shared_ptr< Texture > | GetTexture ()
bool | EndPass (bool is_onscreen=false)
EntityPassTarget & | GetPassTarget () const
uint32_t | GetPassCount () const
const std::shared_ptr< RenderPass > & | GetRenderPass ()

## Detailed Description

Definition at line 17 of file inline_pass_context.h.

## Constructor & Destructor Documentation

## ◆ InlinePassContext()

impeller::InlinePassContext::InlinePassContext | ( | const ContentContext & | renderer,
|  | EntityPassTarget & | pass_target
| ) |  |

Definition at line 20 of file inline_pass_context.cc.

22 : renderer_(renderer), pass_target_(pass_target) {}

## ◆ ~InlinePassContext()

impeller::InlinePassContext::~InlinePassContext | ( |  | ) |

Definition at line 24 of file inline_pass_context.cc.

24 {
25 EndPass();
26 }
impeller::InlinePassContext::EndPass
bool EndPass(bool is_onscreen=false)
Definition: inline_pass_context.cc:43

References EndPass().

## Member Function Documentation

## ◆ EndPass()

bool impeller::InlinePassContext::EndPass | ( | bool | is_onscreen = `false` | ) |

Definition at line 43 of file inline_pass_context.cc.

43 {
44 if (!IsActive()) {
45 return true;
46 }
47 FML_DCHECK(command_buffer_);
48
49 if (!pass_->EncodeCommands()) {
50 VALIDATION_LOG << "Failed to encode and submit command buffer while ending "
51 "render pass.";
52 return false;
53 }
54
55 const std::shared_ptr<Texture>& target_texture =
56 GetPassTarget().GetRenderTarget().GetRenderTargetTexture();
57 if (target_texture->GetMipCount() > 1) {
58 fml::Status mip_status = AddMipmapGeneration(
59 command_buffer_, renderer_.GetContext(), target_texture);
60 if (!mip_status.ok()) {
61 return false;
62 }
63 }
64
65 pass_ = nullptr;
66 if (is_onscreen) {
67 return renderer_.GetContext()->SubmitOnscreen(std::move(command_buffer_));
68 } else {
69 return renderer_.GetContext()->EnqueueCommandBuffer(
70 std::move(command_buffer_));
71 }
72 }
impeller::ContentContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: content_context.cc:913
impeller::EntityPassTarget::GetRenderTarget
RenderTarget & GetRenderTarget()
Definition: entity_pass_target.cc:71
impeller::InlinePassContext::GetPassTarget
EntityPassTarget & GetPassTarget() const
Definition: inline_pass_context.cc:74
impeller::InlinePassContext::IsActive
bool IsActive() const
Definition: inline_pass_context.cc:32
impeller::RenderTarget::GetRenderTargetTexture
std::shared_ptr< Texture > GetRenderTargetTexture() const
Definition: render_target.cc:176
impeller::AddMipmapGeneration
fml::Status AddMipmapGeneration(const std::shared_ptr< CommandBuffer > &command_buffer, const std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
Adds a blit command to the render pass.
Definition: texture_util.cc:37
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::AddMipmapGeneration(), impeller::ContentContext::GetContext(), GetPassTarget(), impeller::EntityPassTarget::GetRenderTarget(), impeller::RenderTarget::GetRenderTargetTexture(), IsActive(), and VALIDATION_LOG.

Referenced by ~InlinePassContext().

## ◆ GetPassCount()

uint32_t impeller::InlinePassContext::GetPassCount | ( |  | ) | const

Definition at line 157 of file inline_pass_context.cc.

157 {
158 return pass_count_;
159 }

## ◆ GetPassTarget()

EntityPassTarget & impeller::InlinePassContext::GetPassTarget | ( |  | ) | const

Definition at line 74 of file inline_pass_context.cc.

74 {
75 return pass_target_;
76 }

Referenced by EndPass().

## ◆ GetRenderPass()

const std::shared_ptr< RenderPass > & impeller::InlinePassContext::GetRenderPass | ( |  | ) |

Create a new render pass if one isn't active. This path will run the first time this method is called, but it'll also run if the pass has been previously ended via `EndPass`.

Definition at line 78 of file inline_pass_context.cc.

78 {
79 if (IsActive()) {
80 return pass_;
81 }
82
83 /// Create a new render pass if one isn't active. This path will run the first
84 /// time this method is called, but it'll also run if the pass has been
85 /// previously ended via `EndPass`.
86
87 command_buffer_ = renderer_.GetContext()->CreateCommandBuffer();
88 if (!command_buffer_) {
89 VALIDATION_LOG << "Could not create command buffer.";
90 return pass_;
91 }
92
93 command_buffer_->SetLabel("EntityPass Command Buffer");
94
95 {
96 // If the pass target has a resolve texture, then we're using MSAA.
97 bool is_msaa =
98 pass_target_.GetRenderTarget().GetColorAttachment(0).resolve_texture !=
99 nullptr;
100 if (pass_count_ > 0 && is_msaa) {
101 pass_target_.Flip(renderer_);
102 }
103 }
104
105 // Find the color attachment a second time, since the target may have just
106 // flipped.
107 ColorAttachment color0 = pass_target_.GetRenderTarget().GetColorAttachment(0);
108 bool is_msaa = color0.resolve_texture != nullptr;
109
110 if (pass_count_ > 0) {
111 // When MSAA is being used, we end up overriding the entire backdrop by
112 // drawing the previous pass texture, and so we don't have to clear it and
113 // can use kDontCare.
114 color0.load_action = is_msaa ? LoadAction::kDontCare : LoadAction::kLoad;
115 } else {
116 color0.load_action = LoadAction::kClear;
117 }
118
119 color0.store_action =
120 is_msaa ? StoreAction::kMultisampleResolve : StoreAction::kStore;
121
122 auto depth = pass_target_.GetRenderTarget().GetDepthAttachment();
123 if (!depth.has_value()) {
124 VALIDATION_LOG << "Depth attachment unexpectedly missing from the "
125 "EntityPass render target.";
126 return pass_;
127 }
128 depth->load_action = LoadAction::kClear;
129 depth->store_action = StoreAction::kDontCare;
130 pass_target_.target_.SetDepthAttachment(depth.value());
131
132 auto stencil = pass_target_.GetRenderTarget().GetStencilAttachment();
133 if (!depth.has_value() || !stencil.has_value()) {
134 VALIDATION_LOG << "Stencil/Depth attachment unexpectedly missing from the "
135 "EntityPass render target.";
136 return pass_;
137 }
138 stencil->load_action = LoadAction::kClear;
139 stencil->store_action = StoreAction::kDontCare;
140 depth->load_action = LoadAction::kClear;
141 depth->store_action = StoreAction::kDontCare;
142 pass_target_.target_.SetDepthAttachment(depth);
143 pass_target_.target_.SetStencilAttachment(stencil.value());
144 pass_target_.target_.SetColorAttachment(color0, 0);
145
146 pass_ = command_buffer_->CreateRenderPass(pass_target_.GetRenderTarget());
147 if (!pass_) {
148 VALIDATION_LOG << "Could not create render pass.";
149 return pass_;
150 }
151 pass_->SetLabel("EntityPass Render Pass");
152
153 ++pass_count_;
154 return pass_;
155 }
impeller::EntityPassTarget::Flip
std::shared_ptr< Texture > Flip(const ContentContext &renderer)
Flips the backdrop and returns a readable texture that can be bound/sampled to restore the previous p...
Definition: entity_pass_target.cc:20
impeller::RenderTarget::GetColorAttachment
ColorAttachment GetColorAttachment(size_t index) const
Get the color attachment at [index].
Definition: render_target.cc:233
impeller::RenderTarget::SetColorAttachment
RenderTarget & SetColorAttachment(const ColorAttachment &attachment, size_t index)
Definition: render_target.cc:199
impeller::RenderTarget::SetDepthAttachment
RenderTarget & SetDepthAttachment(std::optional< DepthAttachment > attachment)
Definition: render_target.cc:213
impeller::RenderTarget::SetStencilAttachment
RenderTarget & SetStencilAttachment(std::optional< StencilAttachment > attachment)
Definition: render_target.cc:223
impeller::RenderTarget::GetDepthAttachment
const std::optional< DepthAttachment > & GetDepthAttachment() const
Definition: render_target.cc:247
impeller::RenderTarget::GetStencilAttachment
const std::optional< StencilAttachment > & GetStencilAttachment() const
Definition: render_target.cc:251
impeller::LoadAction::kDontCare
@ kDontCare
impeller::LoadAction::kLoad
@ kLoad
impeller::LoadAction::kClear
@ kClear
impeller::StoreAction::kStore
@ kStore
impeller::StoreAction::kDontCare
@ kDontCare
impeller::StoreAction::kMultisampleResolve
@ kMultisampleResolve
impeller::Attachment::resolve_texture
std::shared_ptr< Texture > resolve_texture
Definition: formats.h:658

References impeller::EntityPassTarget::Flip(), impeller::RenderTarget::GetColorAttachment(), impeller::ContentContext::GetContext(), impeller::RenderTarget::GetDepthAttachment(), impeller::EntityPassTarget::GetRenderTarget(), impeller::RenderTarget::GetStencilAttachment(), IsActive(), impeller::kClear, impeller::kDontCare, impeller::kLoad, impeller::kMultisampleResolve, impeller::kStore, impeller::Attachment::load_action, impeller::Attachment::resolve_texture, impeller::RenderTarget::SetColorAttachment(), impeller::RenderTarget::SetDepthAttachment(), impeller::RenderTarget::SetStencilAttachment(), impeller::Attachment::store_action, and VALIDATION_LOG.

## ◆ GetTexture()

std::shared_ptr< Texture > impeller::InlinePassContext::GetTexture | ( |  | ) |

Definition at line 36 of file inline_pass_context.cc.

36 {
37 if (!IsValid()) {
38 return nullptr;
39 }
40 return pass_target_.GetRenderTarget().GetRenderTargetTexture();
41 }
impeller::InlinePassContext::IsValid
bool IsValid() const
Definition: inline_pass_context.cc:28

References impeller::EntityPassTarget::GetRenderTarget(), impeller::RenderTarget::GetRenderTargetTexture(), and IsValid().

## ◆ IsActive()

bool impeller::InlinePassContext::IsActive | ( |  | ) | const

Definition at line 32 of file inline_pass_context.cc.

32 {
33 return pass_ != nullptr;
34 }

Referenced by EndPass(), and GetRenderPass().

## ◆ IsValid()

bool impeller::InlinePassContext::IsValid | ( |  | ) | const

Definition at line 28 of file inline_pass_context.cc.

28 {
29 return pass_target_.IsValid();
30 }
impeller::EntityPassTarget::IsValid
bool IsValid() const
Definition: entity_pass_target.cc:75

References impeller::EntityPassTarget::IsValid().

Referenced by GetTexture().

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

- impeller/entity/inline_pass_context.h
- impeller/entity/inline_pass_context.cc