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