 |
Flutter Impeller
|
|
Go to the documentation of this file.
6 #include "fml/status.h"
12 : context_(
std::move(context)),
13 sample_count_(target.GetSampleCount()),
14 pixel_format_(target.GetRenderTargetPixelFormat()),
15 has_depth_attachment_(target.GetDepthAttachment().has_value()),
16 has_stencil_attachment_(target.GetStencilAttachment().has_value()),
17 render_target_size_(target.GetRenderTargetSize()),
18 render_target_(target),
19 orthographic_(
Matrix::MakeOrthographic(render_target_size_)) {}
59 if (!command.IsValid()) {
60 VALIDATION_LOG <<
"Attempted to add an invalid command to the render pass.";
64 if (command.scissor.has_value()) {
66 if (!target_rect.Contains(command.scissor.value())) {
67 VALIDATION_LOG <<
"Cannot apply a scissor that lies outside the bounds "
68 "of the render target.";
73 if (command.vertex_buffer.vertex_count == 0u ||
74 command.instance_count == 0u) {
80 commands_.emplace_back(std::move(command));
99 pending_.label = std::string(label);
100 #endif // IMPELLER_DEBUG
128 auto result =
AddCommand(std::move(pending_));
131 return fml::Status();
133 return fml::Status(fml::StatusCode::kInvalidArgument,
134 "Failed to encode command");
143 return pending_.
BindResource(stage, type, slot, metadata, view);
150 const std::shared_ptr<const ShaderMetadata>& metadata,
152 return pending_.
BindResource(stage, type, slot, metadata, std::move(view));
160 std::shared_ptr<const Texture> texture,
161 const std::unique_ptr<const Sampler>& sampler) {
162 return pending_.
BindResource(stage, type, slot, metadata, std::move(texture),
An object used to specify work to the GPU along with references to resources the GPU will used when d...
const RenderTarget & GetRenderTarget() const
std::optional< IRect > scissor
RenderPass(std::shared_ptr< const Context > context, const RenderTarget &target)
std::optional< Viewport > viewport
virtual bool SetVertexBuffer(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
const bool has_depth_attachment_
virtual void SetCommandLabel(std::string_view label)
The debugging label to use for the command.
const Matrix & GetOrthographicTransform() const
const PixelFormat pixel_format_
virtual bool BindResource(ShaderStage stage, DescriptorType type, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, BufferView view) override
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
virtual fml::Status Draw()
Record the currently pending command.
virtual void SetInstanceCount(size_t count)
bool EncodeCommands() const
Encode the recorded commands to the underlying command buffer.
ISize GetRenderTargetSize() const
virtual void SetViewport(Viewport viewport)
virtual bool OnEncodeCommands(const Context &context) const =0
Metadata required to bind a combined texture and sampler.
bool BindVertices(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
SampleCount GetSampleCount() const
The sample count of the attached render target.
bool HasDepthAttachment() const
Whether the render target has a depth attachment.
const RenderTarget render_target_
virtual void SetStencilReference(uint32_t value)
virtual void SetScissor(IRect scissor)
std::vector< Command > commands_
const ISize render_target_size_
ISize GetRenderTargetSize() const
bool BindResource(ShaderStage stage, DescriptorType type, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, BufferView view) override
uint32_t stencil_reference
void SetLabel(std::string label)
constexpr static TRect MakeSize(const TSize< U > &size)
bool HasStencilAttachment() const
Whether the render target has an stencil attachment.
virtual void OnSetLabel(std::string label)=0
const std::shared_ptr< const Context > context_
virtual void SetPipeline(const std::shared_ptr< Pipeline< PipelineDescriptor >> &pipeline)
The pipeline to use for this command.
std::shared_ptr< Pipeline< PipelineDescriptor > > pipeline
const bool has_stencil_attachment_
const Matrix orthographic_
bool AddCommand(Command &&command)
Record a command for subsequent encoding to the underlying command buffer. No work is encoded into th...
const std::shared_ptr< const Context > & GetContext() const
virtual void SetBaseVertex(uint64_t value)
A 4x4 matrix using column-major storage.
PixelFormat GetRenderTargetPixelFormat() const
The pixel format of the attached render target.
const SampleCount sample_count_