| Flutter Impeller |

Public Member Functions | Protected Member Functions | Static 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 std::shared_ptr< const Context > & | GetContext () const
const RenderTarget & | GetRenderTarget () const
ISize | GetRenderTargetSize () const
const Matrix & | GetOrthographicTransform () const
virtual bool | IsValid () const =0
void | SetLabel (std::string_view label)
virtual void | SetPipeline (PipelineRef pipeline)
| The pipeline to use for this command. More...
void | SetPipeline (const std::shared_ptr< Pipeline< PipelineDescriptor >> &pipeline)
| The pipeline to use for this command. More...
virtual void | SetCommandLabel (std::string_view label)
| The debugging label to use for the command. More...
virtual void | SetStencilReference (uint32_t value)
virtual void | SetBaseVertex (uint64_t value)
virtual void | SetViewport (Viewport viewport)
virtual void | SetScissor (IRect32 scissor)
virtual void | SetElementCount (size_t count)
virtual void | SetInstanceCount (size_t count)
virtual bool | SetVertexBuffer (VertexBuffer buffer)
| Specify the vertex and index buffer to use for this command. More...
bool | SetVertexBuffer (BufferView vertex_buffer)
| Specify a vertex buffer to use for this command. More...
bool | SetVertexBuffer (std::vector< BufferView > vertex_buffers)
| Specify a set of vertex buffers to use for this command. More...
virtual bool | SetVertexBuffer (BufferView vertex_buffers[], size_t vertex_buffer_count)
| Specify a set of vertex buffers to use for this command. More...
virtual bool | SetIndexBuffer (BufferView index_buffer, IndexType index_type)
| Specify an index buffer to use for this command. To unset the index buffer, pass IndexType::kNone to index_type. More...
virtual fml::Status | Draw ()
| Record the currently pending command. More...
virtual bool | BindResource (ShaderStage stage, DescriptorType type, const ShaderUniformSlot &slot, const ShaderMetadata *metadata, BufferView view) override
virtual bool | BindResource (ShaderStage stage, DescriptorType type, const SampledImageSlot &slot, const ShaderMetadata *metadata, std::shared_ptr< const Texture > texture, raw_ptr< const Sampler >) override
virtual bool | BindDynamicResource (ShaderStage stage, DescriptorType type, const SampledImageSlot &slot, std::unique_ptr< ShaderMetadata > metadata, std::shared_ptr< const Texture > texture, raw_ptr< const Sampler >)
| Bind with dynamically generated shader metadata. More...
virtual bool | BindDynamicResource (ShaderStage stage, DescriptorType type, const ShaderUniformSlot &slot, std::unique_ptr< ShaderMetadata > metadata, BufferView view)
| Bind with dynamically generated shader metadata. More...
bool | EncodeCommands () const
| Encode the recorded commands to the underlying command buffer. More...
virtual const std::vector< Command > & | GetCommands () const
| Accessor for the current Commands. More...
SampleCount | GetSampleCount () const
| The sample count of the attached render target. More...
PixelFormat | GetRenderTargetPixelFormat () const
| The pixel format of the attached render target. More...
bool | HasDepthAttachment () const
| Whether the render target has a depth attachment. More...
bool | HasStencilAttachment () const
| Whether the render target has an stencil attachment. More...
Public Member Functions inherited from impeller::ResourceBinder
virtual | ~ResourceBinder ()=default

## Protected Member Functions
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...
| RenderPass (std::shared_ptr< const Context > context, const RenderTarget &target)
virtual void | OnSetLabel (std::string_view label)=0
virtual bool | OnEncodeCommands (const Context &context) const =0

## Static Protected Member Functions
static bool | ValidateVertexBuffers (const BufferView vertex_buffers[], size_t vertex_buffer_count)
static bool | ValidateIndexBuffer (const BufferView &index_buffer, IndexType index_type)

## Protected Attributes
const std::shared_ptr< const Context > | context_
const SampleCount | sample_count_
const PixelFormat | pixel_format_
const bool | has_depth_attachment_
const bool | has_stencil_attachment_
const ISize | render_target_size_
const RenderTarget | render_target_
std::vector< Command > | commands_
std::vector< BufferView > | vertex_buffers_
std::vector< BufferResource > | bound_buffers_
std::vector< TextureAndSampler > | bound_textures_
const Matrix | orthographic_

## 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 30 of file render_pass.h.

## Constructor & Destructor Documentation

## ◆ ~RenderPass()

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

Definition at line 25 of file render_pass.cc.

25 {}

## ◆ RenderPass()

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

Definition at line 14 of file render_pass.cc.

16 : context_(std::move(context)),
17 sample_count_(target.GetSampleCount()),
18 pixel_format_(target.GetRenderTargetPixelFormat()),
19 has_depth_attachment_(target.GetDepthAttachment().has_value()),
20 has_stencil_attachment_(target.GetStencilAttachment().has_value()),
21 render_target_size_(target.GetRenderTargetSize()),
22 render_target_(target),
23 orthographic_(Matrix::MakeOrthographic(render_target_size_)) {}
impeller::RenderPass::has_depth_attachment_
const bool has_depth_attachment_
Definition: render_pass.h:244
impeller::RenderPass::has_stencil_attachment_
const bool has_stencil_attachment_
Definition: render_pass.h:245
impeller::RenderPass::sample_count_
const SampleCount sample_count_
Definition: render_pass.h:242
impeller::RenderPass::context_
const std::shared_ptr< const Context > context_
Definition: render_pass.h:236
impeller::RenderPass::orthographic_
const Matrix orthographic_
Definition: render_pass.h:252
impeller::RenderPass::render_target_size_
const ISize render_target_size_
Definition: render_pass.h:246
impeller::RenderPass::render_target_
const RenderTarget render_target_
Definition: render_pass.h:247
impeller::RenderPass::pixel_format_
const PixelFormat pixel_format_
Definition: render_pass.h:243
impeller::Matrix::MakeOrthographic
static constexpr Matrix MakeOrthographic(TSize< T > size)
Definition: matrix.h:633

## Member Function Documentation

## ◆ AddCommand()

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

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

62 {
63 if (!command.IsValid()) {
64 VALIDATION_LOG << "Attempted to add an invalid command to the render pass.";
65 return false;
66 }
67
68 if (command.element_count == 0u || command.instance_count == 0u) {
69 // Essentially a no-op. Don't record the command but this is not necessary
70 // an error either.
71 return true;
72 }
73
74 commands_.emplace_back(std::move(command));
75 return true;
76 }
impeller::RenderPass::commands_
std::vector< Command > commands_
Definition: render_pass.h:248
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91

References commands_, and VALIDATION_LOG.

Referenced by Draw().

## ◆ BindDynamicResource() [1/2]

bool impeller::RenderPass::BindDynamicResource | ( | ShaderStage | stage,
|  | DescriptorType | type,
|  | const SampledImageSlot & | slot,
|  | std::unique_ptr< ShaderMetadata > | metadata,
|  | std::shared_ptr< const Texture > | texture,
|  | raw_ptr< const Sampler > | sampler
| ) |  |
| virtual

Bind with dynamically generated shader metadata.

Definition at line 270 of file render_pass.cc.

278 {
279 if (!sampler) {
280 return false;
281 }
282 if (!texture || !texture->IsValid()) {
283 return false;
284 }
285 TextureResource resource =
286 TextureResource::MakeDynamic(std::move(metadata), std::move(texture));
287 return BindTexture(stage, slot, std::move(resource), sampler);
288 }
impeller::Resource< std::shared_ptr< const Texture > >::MakeDynamic
static Resource MakeDynamic(std::unique_ptr< ShaderMetadata > metadata, ResourceType p_resource)
Definition: command.h:38
impeller::TextureResource
Resource< std::shared_ptr< const Texture > > TextureResource
Definition: command.h:55

References impeller::Resource< std::shared_ptr< const Texture > >::MakeDynamic().

Referenced by impeller::RuntimeEffectContents::Render().

## ◆ BindDynamicResource() [2/2]

bool impeller::RenderPass::BindDynamicResource | ( | ShaderStage | stage,
|  | DescriptorType | type,
|  | const ShaderUniformSlot & | slot,
|  | std::unique_ptr< ShaderMetadata > | metadata,
|  | BufferView | view
| ) |  |
| virtual

Bind with dynamically generated shader metadata.

Definition at line 255 of file render_pass.cc.

259 {
260 FML_DCHECK(slot.ext_res_0 != VertexDescriptor::kReservedVertexBufferIndex);
261 if (!view) {
262 return false;
263 }
264 BufferResource resouce =
265 BufferResource::MakeDynamic(std::move(metadata), std::move(view));
266
267 return BindBuffer(stage, slot, std::move(resouce));
268 }
impeller::VertexDescriptor::kReservedVertexBufferIndex
static constexpr size_t kReservedVertexBufferIndex
Definition: vertex_descriptor.h:25
impeller::BufferResource
Resource< BufferView > BufferResource
Definition: command.h:54

References impeller::ShaderUniformSlot::ext_res_0, impeller::VertexDescriptor::kReservedVertexBufferIndex, and impeller::Resource< T >::MakeDynamic().

## ◆ BindResource() [1/2]

bool impeller::RenderPass::BindResource | ( | ShaderStage | stage,
|  | DescriptorType | type,
|  | const SampledImageSlot & | slot,
|  | const ShaderMetadata * | metadata,
|  | std::shared_ptr< const Texture > | texture,
|  | raw_ptr< const Sampler > | sampler
| ) |  |
| overridevirtual

Implements impeller::ResourceBinder.

Definition at line 239 of file render_pass.cc.

244 {
245 if (!sampler) {
246 return false;
247 }
248 if (!texture || !texture->IsValid()) {
249 return false;
250 }
251 TextureResource resource = TextureResource(metadata, std::move(texture));
252 return BindTexture(stage, slot, std::move(resource), sampler);
253 }

## ◆ BindResource() [2/2]

bool impeller::RenderPass::BindResource | ( | ShaderStage | stage,
|  | DescriptorType | type,
|  | const ShaderUniformSlot & | slot,
|  | const ShaderMetadata * | metadata,
|  | BufferView | view
| ) |  |
| overridevirtual

Implements impeller::ResourceBinder.

Definition at line 225 of file render_pass.cc.

229 {
230 FML_DCHECK(slot.ext_res_0 != VertexDescriptor::kReservedVertexBufferIndex);
231 if (!view) {
232 return false;
233 }
234 BufferResource resouce = BufferResource(metadata, std::move(view));
235 return BindBuffer(stage, slot, std::move(resouce));
236 }

References impeller::ShaderUniformSlot::ext_res_0, and impeller::VertexDescriptor::kReservedVertexBufferIndex.

Referenced by impeller::RuntimeEffectContents::Render().

## ◆ Draw()

fml::Status impeller::RenderPass::Draw | ( |  | ) |
| virtual

Record the currently pending command.

Definition at line 208 of file render_pass.cc.

208 {
209 pending_.bound_buffers.offset = bound_buffers_start_.value_or(0u);
210 pending_.bound_textures.offset = bound_textures_start_.value_or(0u);
211 pending_.vertex_buffers.offset = vertex_buffers_start_.value_or(0u);
212 auto result = AddCommand(std::move(pending_));
213 pending_ = Command{};
214 bound_textures_start_ = std::nullopt;
215 bound_buffers_start_ = std::nullopt;
216 vertex_buffers_start_ = std::nullopt;
217 if (result) {
218 return fml::Status();
219 }
220 return fml::Status(fml::StatusCode::kInvalidArgument,
221 "Failed to encode command");
222 }
impeller::RenderPass::AddCommand
bool AddCommand(Command &&command)
Record a command for subsequent encoding to the underlying command buffer. No work is encoded into th...
Definition: render_pass.cc:62
impeller::Command::bound_textures
Range bound_textures
Definition: command.h:92
impeller::Command::vertex_buffers
Range vertex_buffers
Definition: command.h:98
impeller::Command::bound_buffers
Range bound_buffers
Definition: command.h:91
impeller::Range::offset
size_t offset
Definition: range.h:14

References AddCommand(), impeller::Command::bound_buffers, impeller::Command::bound_textures, impeller::Range::offset, and impeller::Command::vertex_buffers.

Referenced by impeller::ColorSourceContents::DrawGeometry(), ImGui_ImplImpeller_RenderDrawData(), impeller::AtlasContents::Render(), impeller::ColorFilterAtlasContents::Render(), impeller::SolidRRectLikeBlurContents::Render(), impeller::TextContents::Render(), impeller::TextureContents::Render(), impeller::VerticesSimpleBlendContents::Render(), impeller::ClipContents::Render(), impeller::RenderClipRestore(), 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 78 of file render_pass.cc.

78 {
79 return OnEncodeCommands(*context_);
80 }
impeller::RenderPass::OnEncodeCommands
virtual bool OnEncodeCommands(const Context &context) const =0

References context_, and OnEncodeCommands().

## ◆ GetCommands()

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

Accessor for the current Commands.

Visible for testing.

Definition at line 217 of file render_pass.h.

217 { return commands_; }

References commands_.

## ◆ GetContext()

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

Definition at line 82 of file render_pass.cc.

82 {
83 return context_;
84 }

References context_.

## ◆ GetOrthographicTransform()

const Matrix & impeller::RenderPass::GetOrthographicTransform | ( |  | ) | const

Definition at line 51 of file render_pass.cc.

51 {
52 return orthographic_;
53 }

References orthographic_.

Referenced by impeller::Entity::GetShaderTransform(), impeller::ClipContents::Render(), impeller::RenderClipRestore(), and impeller::testing::TEST_P().

## ◆ GetRenderTarget()

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

Definition at line 43 of file render_pass.cc.

43 {
44 return render_target_;
45 }

References render_target_.

## ◆ GetRenderTargetPixelFormat()

PixelFormat impeller::RenderPass::GetRenderTargetPixelFormat | ( |  | ) | const

The pixel format of the attached render target.

Definition at line 31 of file render_pass.cc.

31 {
32 return pixel_format_;
33 }

References pixel_format_.

Referenced by impeller::OptionsFromPass().

## ◆ GetRenderTargetSize()

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

Definition at line 47 of file render_pass.cc.

47 {
48 return render_target_size_;
49 }

References render_target_size_.

Referenced by ImGui_ImplImpeller_RenderDrawData(), impeller::Entity::Render(), impeller::ClipContents::Render(), impeller::RenderClipRestore(), and impeller::testing::TEST_P().

## ◆ GetSampleCount()

SampleCount impeller::RenderPass::GetSampleCount | ( |  | ) | const

The sample count of the attached render target.

Definition at line 27 of file render_pass.cc.

27 {
28 return sample_count_;
29 }

References sample_count_.

Referenced by impeller::OptionsFromPass().

## ◆ HasDepthAttachment()

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

Whether the render target has a depth attachment.

Definition at line 35 of file render_pass.cc.

35 {
36 return has_depth_attachment_;
37 }

References has_depth_attachment_.

Referenced by impeller::OptionsFromPass().

## ◆ HasStencilAttachment()

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

Whether the render target has an stencil attachment.

Definition at line 39 of file render_pass.cc.

39 {
40 return has_stencil_attachment_;
41 }

References has_stencil_attachment_.

Referenced by impeller::OptionsFromPass().

## ◆ IsValid()

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

## ◆ OnEncodeCommands()

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

Referenced by EncodeCommands().

## ◆ OnSetLabel()

virtual void impeller::RenderPass::OnSetLabel | ( | std::string_view | label | ) |
| protectedpure virtual

Referenced by SetLabel().

## ◆ SetBaseVertex()

void impeller::RenderPass::SetBaseVertex | ( | uint64_t | value | ) |
| virtual

Definition at line 107 of file render_pass.cc.

107 {
108 pending_.base_vertex = value;
109 }
value
int32_t value
Definition: dl_golden_unittests.cc:459
impeller::Command::base_vertex
uint64_t base_vertex
Definition: command.h:125

References impeller::Command::base_vertex, and value.

Referenced by ImGui_ImplImpeller_RenderDrawData().

## ◆ SetCommandLabel()

void impeller::RenderPass::SetCommandLabel | ( | std::string_view | label | ) |
| virtual

The debugging label to use for the command.

Definition at line 97 of file render_pass.cc.

97 {
98 #ifdef IMPELLER_DEBUG
99 pending_.label = std::string(label);
100 #endif // IMPELLER_DEBUG
101 }

Referenced by impeller::ColorSourceContents::DrawGeometry(), ImGui_ImplImpeller_RenderDrawData(), impeller::AtlasContents::Render(), impeller::ColorFilterAtlasContents::Render(), impeller::SolidColorContents::Render(), impeller::TextContents::Render(), impeller::TextureContents::Render(), impeller::TiledTextureContents::Render(), impeller::VerticesSimpleBlendContents::Render(), impeller::ClipContents::Render(), impeller::RenderClipRestore(), impeller::SolidRRectBlurContents::SetPassInfo(), and impeller::testing::TEST_P().

## ◆ SetElementCount()

void impeller::RenderPass::SetElementCount | ( | size_t | count | ) |
| virtual

The number of elements to draw. When only a vertex buffer is set, this is the vertex count. When an index buffer is set, this is the index count.

Definition at line 119 of file render_pass.cc.

119 {
120 pending_.element_count = count;
121 }
impeller::Command::element_count
uint32_t element_count
Definition: command.h:130

References impeller::Command::element_count.

Referenced by impeller::TextContents::Render(), and SetVertexBuffer().

## ◆ SetIndexBuffer()

bool impeller::RenderPass::SetIndexBuffer | ( | BufferView | index_buffer,
|  | IndexType | index_type
| ) |  |
| virtual

Specify an index buffer to use for this command. To unset the index buffer, pass IndexType::kNone to index_type.

Parameters

  [in] | index_buffer | The buffer view to use for sourcing indices. When an index buffer is bound, the `vertex_count` set via `SetVertexBuffer` is used as the number of indices to draw.
  [in] | index_type | The size of each index in the index buffer. Pass IndexType::kNone to unset the index buffer.

Returns
  Returns false if the index buffer view is invalid.

Definition at line 164 of file render_pass.cc.

164 {
165 if (!ValidateIndexBuffer(index_buffer, index_type)) {
166 return false;
167 }
168
169 pending_.index_buffer = std::move(index_buffer);
170 pending_.index_type = index_type;
171 return true;
172 }
impeller::RenderPass::ValidateIndexBuffer
static bool ValidateIndexBuffer(const BufferView &index_buffer, IndexType index_type)
Definition: render_pass.cc:193
impeller::Command::index_buffer
BufferView index_buffer
The index buffer binding used by the vertex shader stage.
Definition: command.h:87
impeller::Command::index_type
IndexType index_type
Definition: command.h:153

References impeller::Command::index_buffer, impeller::Command::index_type, and ValidateIndexBuffer().

Referenced by impeller::TextContents::Render(), and SetVertexBuffer().

## ◆ SetInstanceCount()

void impeller::RenderPass::SetInstanceCount | ( | size_t | count | ) |
| virtual

The number of instances of the given set of vertices to render. Not all backends support rendering more than one instance at a time.

Warning
  Setting this to more than one will limit the availability of backends to use with this command.

Definition at line 123 of file render_pass.cc.

123 {
124 pending_.instance_count = count;
125 }
impeller::Command::instance_count
uint32_t instance_count
Definition: command.h:139

References impeller::Command::instance_count.

Referenced by impeller::testing::TEST_P().

## ◆ SetLabel()

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

Definition at line 55 of file render_pass.cc.

55 {
56 if (label.empty()) {
57 return;
58 }
59 OnSetLabel(label);
60 }
impeller::RenderPass::OnSetLabel
virtual void OnSetLabel(std::string_view label)=0

References OnSetLabel().

## ◆ SetPipeline() [1/2]

void impeller::RenderPass::SetPipeline | ( | const std::shared_ptr< Pipeline< PipelineDescriptor >> & | pipeline | ) |

The pipeline to use for this command.

Definition at line 92 of file render_pass.cc.

93 {
94 SetPipeline(PipelineRef(pipeline));
95 }
impeller::RenderPass::SetPipeline
virtual void SetPipeline(PipelineRef pipeline)
The pipeline to use for this command.
Definition: render_pass.cc:86
impeller::PipelineRef
raw_ptr< Pipeline< PipelineDescriptor > > PipelineRef
A raw ptr to a pipeline object.
Definition: pipeline.h:88

References SetPipeline().

## ◆ SetPipeline() [2/2]

void impeller::RenderPass::SetPipeline | ( | PipelineRef | pipeline | ) |
| virtual

The pipeline to use for this command.

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 pending_.pipeline = std::move(pipeline);
90 }
impeller::Command::pipeline
PipelineRef pipeline
Definition: command.h:83

References impeller::Command::pipeline.

Referenced by impeller::ColorSourceContents::DrawGeometry(), ImGui_ImplImpeller_RenderDrawData(), impeller::AtlasContents::Render(), impeller::ColorFilterAtlasContents::Render(), impeller::TextContents::Render(), impeller::TextureContents::Render(), impeller::VerticesSimpleBlendContents::Render(), impeller::ClipContents::Render(), impeller::RenderClipRestore(), impeller::SolidRRectBlurContents::SetPassInfo(), SetPipeline(), and impeller::testing::TEST_P().

## ◆ SetScissor()

void impeller::RenderPass::SetScissor | ( | IRect32 | scissor | ) |
| virtual

The scissor rect to use for clipping writes to the render target. The scissor rect must lie entirely within the render target. If unset, no scissor is applied.

Definition at line 115 of file render_pass.cc.

115 {
116 pending_.scissor = scissor;
117 }
impeller::Command::scissor
std::optional< IRect32 > scissor
Definition: command.h:113

References impeller::Command::scissor.

Referenced by ImGui_ImplImpeller_RenderDrawData().

## ◆ SetStencilReference()

void impeller::RenderPass::SetStencilReference | ( | uint32_t | value | ) |
| virtual

The reference value to use in stenciling operations. Stencil configuration is part of pipeline setup and can be read from the pipelines descriptor.

See also
  `Pipeline`
  `PipelineDescriptor`

Definition at line 103 of file render_pass.cc.

103 {
104 pending_.stencil_reference = value;
105 }
impeller::Command::stencil_reference
uint32_t stencil_reference
Definition: command.h:148

References impeller::Command::stencil_reference, and value.

Referenced by impeller::ColorSourceContents::DrawGeometry(), impeller::ClipContents::Render(), and impeller::RenderClipRestore().

## ◆ SetVertexBuffer() [1/4]

bool impeller::RenderPass::SetVertexBuffer | ( | BufferView | vertex_buffer | ) |

Specify a vertex buffer to use for this command.

Parameters

  [in] | vertex_buffer | The buffer view to use for sourcing vertices.

Returns
  Returns false if the given buffer view is invalid.

Definition at line 139 of file render_pass.cc.

139 {
140 return SetVertexBuffer(&vertex_buffer, 1);
141 }
impeller::RenderPass::SetVertexBuffer
virtual bool SetVertexBuffer(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
Definition: render_pass.cc:127

References SetVertexBuffer().

## ◆ SetVertexBuffer() [2/4]

bool impeller::RenderPass::SetVertexBuffer | ( | BufferView | vertex_buffers[],
|  | size_t | vertex_buffer_count
| ) |  |
| virtual

Specify a set of vertex buffers to use for this command.

Warning
  This method takes ownership of each buffer view in the vector. Attempting to use the given buffer views after this call is invalid.

Parameters

  [in] | vertex_buffers | Pointer to an array of vertex buffers to be copied. The maximum number of vertex buffers is 16.
  [in] | vertex_buffer_count | The number of vertex buffers to copy from the array (max 16).

Returns
  Returns false if any of the given buffer views are invalid.

Definition at line 147 of file render_pass.cc.

148 {
149 if (!ValidateVertexBuffers(vertex_buffers, vertex_buffer_count)) {
150 return false;
151 }
152
153 if (!vertex_buffers_start_.has_value()) {
154 vertex_buffers_start_ = vertex_buffers_.size();
155 }
156
157 pending_.vertex_buffers.length += vertex_buffer_count;
158 for (size_t i = 0; i < vertex_buffer_count; i++) {
159 vertex_buffers_.push_back(vertex_buffers[i]);
160 }
161 return true;
162 }
impeller::RenderPass::ValidateVertexBuffers
static bool ValidateVertexBuffers(const BufferView vertex_buffers[], size_t vertex_buffer_count)
Definition: render_pass.cc:174
impeller::RenderPass::vertex_buffers_
std::vector< BufferView > vertex_buffers_
Definition: render_pass.h:249
impeller::Range::length
size_t length
Definition: range.h:15

References impeller::Range::length, ValidateVertexBuffers(), impeller::Command::vertex_buffers, and vertex_buffers_.

## ◆ SetVertexBuffer() [3/4]

bool impeller::RenderPass::SetVertexBuffer | ( | std::vector< BufferView > | vertex_buffers | ) |

Specify a set of vertex buffers to use for this command.

Warning
  This method takes ownership of each buffer view in the vector. Attempting to use the given buffer views after this call is invalid.

Parameters

  [in] | vertex_buffers | The array of vertex buffer views to use. The maximum number of vertex buffers is 16.

Returns
  Returns false if any of the given buffer views are invalid.

Definition at line 143 of file render_pass.cc.

143 {
144 return SetVertexBuffer(vertex_buffers.data(), vertex_buffers.size());
145 }

References SetVertexBuffer().

## ◆ SetVertexBuffer() [4/4]

bool impeller::RenderPass::SetVertexBuffer | ( | VertexBuffer | buffer | ) |
| virtual

Specify the vertex and index buffer to use for this command.

Parameters

  [in] | buffer | The vertex and index buffer definition. If possible, this value should be moved and not copied.

Returns
  returns if the binding was updated.

Definition at line 127 of file render_pass.cc.

127 {
128 if (!SetVertexBuffer(&buffer.vertex_buffer, 1u)) {
129 return false;
130 }
131 if (!SetIndexBuffer(buffer.index_buffer, buffer.index_type)) {
132 return false;
133 }
134 SetElementCount(buffer.vertex_count);
135
136 return true;
137 }
impeller::RenderPass::SetIndexBuffer
virtual bool SetIndexBuffer(BufferView index_buffer, IndexType index_type)
Specify an index buffer to use for this command. To unset the index buffer, pass IndexType::kNone to ...
Definition: render_pass.cc:164
impeller::RenderPass::SetElementCount
virtual void SetElementCount(size_t count)
Definition: render_pass.cc:119

References impeller::VertexBuffer::index_buffer, impeller::VertexBuffer::index_type, SetElementCount(), SetIndexBuffer(), impeller::VertexBuffer::vertex_buffer, and impeller::VertexBuffer::vertex_count.

Referenced by impeller::ColorSourceContents::DrawGeometry(), ImGui_ImplImpeller_RenderDrawData(), impeller::AtlasContents::Render(), impeller::ColorFilterAtlasContents::Render(), impeller::SolidRRectLikeBlurContents::Render(), impeller::TextContents::Render(), impeller::TextureContents::Render(), impeller::VerticesSimpleBlendContents::Render(), impeller::ClipContents::Render(), impeller::RenderClipRestore(), SetVertexBuffer(), and impeller::testing::TEST_P().

## ◆ SetViewport()

void impeller::RenderPass::SetViewport | ( | Viewport | viewport | ) |
| virtual

The viewport coordinates that the rasterizer linearly maps normalized device coordinates to. If unset, the viewport is the size of the render target with a zero origin, znear=0, and zfar=1.

Definition at line 111 of file render_pass.cc.

111 {
112 pending_.viewport = viewport;
113 }
impeller::Command::viewport
std::optional< Viewport > viewport
Definition: command.h:106

References impeller::Command::viewport.

Referenced by ImGui_ImplImpeller_RenderDrawData().

## ◆ ValidateIndexBuffer()

bool impeller::RenderPass::ValidateIndexBuffer | ( | const BufferView & | index_buffer,
|  | IndexType | index_type
| ) |  |
| staticprotected

Definition at line 193 of file render_pass.cc.

194 {
195 if (index_type == IndexType::kUnknown) {
196 VALIDATION_LOG << "Cannot bind an index buffer with an unknown index type.";
197 return false;
198 }
199
200 if (index_type != IndexType::kNone && !index_buffer) {
201 VALIDATION_LOG << "Attempted to bind an invalid index buffer.";
202 return false;
203 }
204
205 return true;
206 }
impeller::IndexType::kUnknown
@ kUnknown
impeller::IndexType::kNone
@ kNone
Does not use the index buffer.

References impeller::kNone, impeller::kUnknown, and VALIDATION_LOG.

Referenced by SetIndexBuffer().

## ◆ ValidateVertexBuffers()

bool impeller::RenderPass::ValidateVertexBuffers | ( | const BufferView | vertex_buffers[],
|  | size_t | vertex_buffer_count
| ) |  |
| staticprotected

Definition at line 174 of file render_pass.cc.

175 {
176 if (vertex_buffer_count > kMaxVertexBuffers) {
177 VALIDATION_LOG << "Attempted to bind " << vertex_buffer_count
178 << " vertex buffers, but the maximum is "
179 << kMaxVertexBuffers << ".";
180 return false;
181 }
182
183 for (size_t i = 0; i < vertex_buffer_count; i++) {
184 if (!vertex_buffers[i]) {
185 VALIDATION_LOG << "Attempted to bind an invalid vertex buffer.";
186 return false;
187 }
188 }
189
190 return true;
191 }
impeller::kMaxVertexBuffers
constexpr size_t kMaxVertexBuffers
Definition: vertex_buffer.h:13

References impeller::kMaxVertexBuffers, and VALIDATION_LOG.

Referenced by SetVertexBuffer().

## Member Data Documentation

## ◆ bound_buffers_

std::vector<BufferResource> impeller::RenderPass::bound_buffers_
| protected

Definition at line 250 of file render_pass.h.

## ◆ bound_textures_

std::vector<TextureAndSampler> impeller::RenderPass::bound_textures_
| protected

Definition at line 251 of file render_pass.h.

## ◆ commands_

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

Definition at line 248 of file render_pass.h.

Referenced by AddCommand(), and GetCommands().

## ◆ context_

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

Definition at line 236 of file render_pass.h.

Referenced by EncodeCommands(), and GetContext().

## ◆ has_depth_attachment_

const bool impeller::RenderPass::has_depth_attachment_
| protected

Definition at line 244 of file render_pass.h.

Referenced by HasDepthAttachment().

## ◆ has_stencil_attachment_

const bool impeller::RenderPass::has_stencil_attachment_
| protected

Definition at line 245 of file render_pass.h.

Referenced by HasStencilAttachment().

## ◆ orthographic_

const Matrix impeller::RenderPass::orthographic_
| protected

Definition at line 252 of file render_pass.h.

Referenced by GetOrthographicTransform().

## ◆ pixel_format_

const PixelFormat impeller::RenderPass::pixel_format_
| protected

Definition at line 243 of file render_pass.h.

Referenced by GetRenderTargetPixelFormat().

## ◆ render_target_

const RenderTarget impeller::RenderPass::render_target_
| protected

Definition at line 247 of file render_pass.h.

Referenced by GetRenderTarget().

## ◆ render_target_size_

const ISize impeller::RenderPass::render_target_size_
| protected

Definition at line 246 of file render_pass.h.

Referenced by GetRenderTargetSize().

## ◆ sample_count_

const SampleCount impeller::RenderPass::sample_count_
| protected

Definition at line 242 of file render_pass.h.

Referenced by GetSampleCount().

## ◆ vertex_buffers_

std::vector<BufferView> impeller::RenderPass::vertex_buffers_
| protected

Definition at line 249 of file render_pass.h.

Referenced by SetVertexBuffer().

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

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