| Flutter Impeller |

compute_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_COMPUTE_PASS_MTL_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_COMPUTE_PASS_MTL_H_
7
8 #include <Metal/Metal.h>
9
10 #include "impeller/renderer/backend/metal/compute_pass_bindings_cache_mtl.h"
11 #include "impeller/renderer/compute_pass.h"
12 #include "impeller/renderer/pipeline_descriptor.h"
13
14 namespace impeller {
15
16 class ComputePassMTL final : public ComputePass {
17 public:
18 // |RenderPass|
19 ~ComputePassMTL() override;
20
21 private:
22 friend class CommandBufferMTL;
23
24 id<MTLCommandBuffer> buffer_ = nil;
25 id<MTLComputeCommandEncoder> encoder_ = nil;
26 ComputePassBindingsCacheMTL pass_bindings_cache_ =
27 ComputePassBindingsCacheMTL();
28 bool is_valid_ = false;
29 bool has_label_ = false;
30
31 ComputePassMTL(std::shared_ptr<const Context> context,
32 id<MTLCommandBuffer> buffer);
33
34 // |ComputePass|
35 bool IsValid() const override;
36
37 // |ComputePass|
38 fml::Status Compute(const ISize& grid_size) override;
39
40 // |ComputePass|
41 void SetCommandLabel(std::string_view label) override;
42
43 // |ComputePass|
44 void OnSetLabel(const std::string& label) override;
45
46 // |ComputePass|
47 void SetPipeline(const std::shared_ptr<Pipeline<ComputePipelineDescriptor>>&
48 pipeline) override;
49
50 // |ComputePass|
51 bool BindResource(ShaderStage stage,
52 DescriptorType type,
53 const ShaderUniformSlot& slot,
54 const ShaderMetadata* metadata,
55 BufferView view) override;
56
57 // |ComputePass|
58 bool BindResource(ShaderStage stage,
59 DescriptorType type,
60 const SampledImageSlot& slot,
61 const ShaderMetadata* metadata,
62 std::shared_ptr<const Texture> texture,
63 raw_ptr<const Sampler> sampler) override;
64
65 // |ComputePass|
66 bool EncodeCommands() const override;
67
68 // |ComputePass|
69 void AddBufferMemoryBarrier() override;
70
71 // |ComputePass|
72 void AddTextureMemoryBarrier() override;
73
74 ComputePassMTL(const ComputePassMTL&) = delete;
75
76 ComputePassMTL& operator=(const ComputePassMTL&) = delete;
77 };
78
79 } // namespace impeller
80
81 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_COMPUTE_PASS_MTL_H_
type
GLenum type
Definition: blit_command_gles.cc:153
impeller::CommandBufferMTL
Definition: command_buffer_mtl.h:15
impeller::ComputePass
Compute passes encode compute shader into the underlying command buffer.
Definition: compute_pass.h:23
impeller::ComputePassMTL
Definition: compute_pass_mtl.h:16
impeller::ComputePassMTL::~ComputePassMTL
~ComputePassMTL() override
impeller::Pipeline< ComputePipelineDescriptor >
impeller::raw_ptr
A wrapper around a raw ptr that adds additional unopt mode only checks.
Definition: raw_ptr.h:15
compute_pass.h
compute_pass_bindings_cache_mtl.h
impeller
Definition: allocation.cc:12
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::DescriptorType
DescriptorType
Definition: shader_types.h:158
pipeline_descriptor.h
impeller::BufferView
Definition: buffer_view.h:19
impeller::ComputePassBindingsCacheMTL
Ensures that bindings on the pass are not redundantly set or updated. Avoids making the driver do add...
Definition: compute_pass_bindings_cache_mtl.h:24
impeller::SampledImageSlot
Metadata required to bind a combined texture and sampler.
Definition: shader_types.h:98
impeller::ShaderMetadata
Definition: shader_types.h:72
impeller::ShaderUniformSlot
Metadata required to bind a buffer.
Definition: shader_types.h:81
impeller::TSize
Definition: size.h:25