Flutter Engine
The Flutter Engine
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
13
14namespace impeller {
15
16class RenderPassMTL final : public RenderPass {
17 public:
18 // |RenderPass|
19 ~RenderPassMTL() override;
20
21 private:
22 friend class CommandBufferMTL;
23
24 id<MTLCommandBuffer> buffer_ = nil;
25 id<MTLRenderCommandEncoder> encoder_ = nil;
26 MTLRenderPassDescriptor* desc_ = nil;
27 std::string label_;
28 bool is_metal_trace_active_ = false;
29 bool is_valid_ = false;
30 // Many parts of the codebase will start writing to a render pass but
31 // never submit them. This boolean is used to track if a submit happened
32 // so that in the dtor we can always ensure the render pass is finished.
33 mutable bool did_finish_encoding_ = false;
34
35 PassBindingsCacheMTL pass_bindings_;
36
37 // Per-command state
38 size_t instance_count_ = 1u;
39 size_t base_vertex_ = 0u;
40 size_t vertex_count_ = 0u;
41 bool has_valid_pipeline_ = false;
42 bool has_label_ = false;
43 BufferView index_buffer_ = {};
44 PrimitiveType primitive_type_ = {};
45 MTLIndexType index_type_ = {};
46
47 RenderPassMTL(std::shared_ptr<const Context> context,
48 const RenderTarget& target,
49 id<MTLCommandBuffer> buffer);
50
51 // |RenderPass|
52 void ReserveCommands(size_t command_count) override {}
53
54 // |RenderPass|
55 bool IsValid() const override;
56
57 // |RenderPass|
58 void OnSetLabel(std::string label) override;
59
60 // |RenderPass|
61 bool OnEncodeCommands(const Context& context) const override;
62
63 // |RenderPass|
64 void SetPipeline(
65 const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) override;
66
67 // |RenderPass|
68 void SetCommandLabel(std::string_view label) override;
69
70 // |RenderPass|
71 void SetStencilReference(uint32_t value) override;
72
73 // |RenderPass|
74 void SetBaseVertex(uint64_t value) override;
75
76 // |RenderPass|
77 void SetViewport(Viewport viewport) override;
78
79 // |RenderPass|
80 void SetScissor(IRect scissor) override;
81
82 // |RenderPass|
83 void SetInstanceCount(size_t count) override;
84
85 // |RenderPass|
86 bool SetVertexBuffer(VertexBuffer buffer) override;
87
88 // |RenderPass|
89 fml::Status Draw() override;
90
91 // |RenderPass|
92 bool BindResource(ShaderStage stage,
94 const ShaderUniformSlot& slot,
95 const ShaderMetadata& metadata,
96 BufferView view) override;
97
98 // |RenderPass|
99 bool BindResource(ShaderStage stage,
101 const ShaderUniformSlot& slot,
102 const std::shared_ptr<const ShaderMetadata>& metadata,
103 BufferView view) override;
104
105 // |RenderPass|
106 bool BindResource(ShaderStage stage,
108 const SampledImageSlot& slot,
109 const ShaderMetadata& metadata,
110 std::shared_ptr<const Texture> texture,
111 const std::unique_ptr<const Sampler>& sampler) override;
112
113 RenderPassMTL(const RenderPassMTL&) = delete;
114
115 RenderPassMTL& operator=(const RenderPassMTL&) = delete;
116};
117
118} // namespace impeller
119
120#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_RENDER_PASS_MTL_H_
int count
Definition: FontMgrTest.cpp:50
GLenum type
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
static void Draw(SkCanvas *canvas, const SkRect &rect)
uint8_t value
uint32_t * target
FlTexture * texture
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition: formats.h:352
IRect64 IRect
Definition: rect.h:772
Ensures that bindings on the pass are not redundantly set or updated. Avoids making the driver do add...