Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
render_pass_mtl.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_RENDER_PASS_MTL_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_RENDER_PASS_MTL_H_
7
8#include <Metal/Metal.h>
9
10#include "flutter/fml/macros.h"
14
15namespace impeller {
16
17class RenderPassMTL final : public RenderPass {
18 public:
19 // |RenderPass|
20 ~RenderPassMTL() override;
21
22 private:
23 friend class CommandBufferMTL;
24
25 id<MTLCommandBuffer> buffer_ = nil;
26 id<MTLRenderCommandEncoder> encoder_ = nil;
27 MTLRenderPassDescriptor* desc_ = nil;
28 std::string label_;
29 bool is_metal_trace_active_ = false;
30 bool is_valid_ = false;
31 // Many parts of the codebase will start writing to a render pass but
32 // never submit them. This boolean is used to track if a submit happened
33 // so that in the dtor we can always ensure the render pass is finished.
34 mutable bool did_finish_encoding_ = false;
35
36 PassBindingsCacheMTL pass_bindings_;
37
38 // Per-command state
39 size_t instance_count_ = 1u;
40 size_t base_vertex_ = 0u;
41 size_t vertex_count_ = 0u;
42 bool has_valid_pipeline_ = false;
43 bool has_label_ = false;
44 BufferView index_buffer_ = {};
45 PrimitiveType primitive_type_ = {};
46 MTLIndexType index_type_ = {};
47
48 RenderPassMTL(std::shared_ptr<const Context> context,
49 const RenderTarget& target,
50 id<MTLCommandBuffer> buffer);
51
52 // |RenderPass|
53 void ReserveCommands(size_t command_count) override {}
54
55 // |RenderPass|
56 bool IsValid() const override;
57
58 // |RenderPass|
59 void OnSetLabel(std::string label) override;
60
61 // |RenderPass|
62 bool OnEncodeCommands(const Context& context) const override;
63
64 // |RenderPass|
65 void SetPipeline(
66 const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) override;
67
68 // |RenderPass|
69 void SetCommandLabel(std::string_view label) override;
70
71 // |RenderPass|
72 void SetStencilReference(uint32_t value) override;
73
74 // |RenderPass|
75 void SetBaseVertex(uint64_t value) override;
76
77 // |RenderPass|
78 void SetViewport(Viewport viewport) override;
79
80 // |RenderPass|
81 void SetScissor(IRect scissor) override;
82
83 // |RenderPass|
84 void SetInstanceCount(size_t count) override;
85
86 // |RenderPass|
87 bool SetVertexBuffer(VertexBuffer buffer) override;
88
89 // |RenderPass|
90 fml::Status Draw() override;
91
92 // |RenderPass|
93 bool BindResource(ShaderStage stage,
95 const ShaderUniformSlot& slot,
96 const ShaderMetadata& metadata,
97 BufferView view) override;
98
99 // |RenderPass|
100 bool BindResource(ShaderStage stage,
102 const ShaderUniformSlot& slot,
103 const std::shared_ptr<const ShaderMetadata>& metadata,
104 BufferView view) override;
105
106 // |RenderPass|
107 bool BindResource(ShaderStage stage,
109 const SampledImageSlot& slot,
110 const ShaderMetadata& metadata,
111 std::shared_ptr<const Texture> texture,
112 const std::unique_ptr<const Sampler>& sampler) override;
113
114 RenderPassMTL(const RenderPassMTL&) = delete;
115
116 RenderPassMTL& operator=(const RenderPassMTL&) = delete;
117};
118
119} // namespace impeller
120
121#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_RENDER_PASS_MTL_H_
int count
To do anything rendering related with Impeller, you need a context.
Definition context.h:46
Describes the fixed function and programmable aspects of rendering and compute operations performed b...
Definition pipeline.h:49
void SetPipeline(const std::shared_ptr< Pipeline< PipelineDescriptor > > &pipeline) override
The pipeline to use for this command.
void SetCommandLabel(std::string_view label) override
The debugging label to use for the command.
void OnSetLabel(std::string label) override
void ReserveCommands(size_t command_count) override
Reserve [command_count] commands in the HAL command buffer.
void SetViewport(Viewport viewport) override
void SetScissor(IRect scissor) override
bool BindResource(ShaderStage stage, DescriptorType type, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, BufferView view) override
bool OnEncodeCommands(const Context &context) const override
bool SetVertexBuffer(VertexBuffer buffer) override
Specify the vertex and index buffer to use for this command.
void SetBaseVertex(uint64_t value) override
void SetStencilReference(uint32_t value) override
fml::Status Draw() override
Record the currently pending command.
void SetInstanceCount(size_t count) override
bool IsValid() const override
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:33
static const uint8_t buffer[]
uint32_t * target
FlTexture * texture
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition formats.h:353
Ensures that bindings on the pass are not redundantly set or updated. Avoids making the driver do add...
Metadata required to bind a combined texture and sampler.
Metadata required to bind a buffer.