Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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"
14
15namespace impeller {
16
17class 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_ =
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,
54 const ShaderUniformSlot& slot,
55 const ShaderMetadata& metadata,
56 BufferView view) override;
57
58 // |ComputePass|
59 bool BindResource(ShaderStage stage,
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_
bool IsValid() const override
void OnSetLabel(const std::string &label) override
void SetPipeline(const std::shared_ptr< Pipeline< ComputePipelineDescriptor > > &pipeline) override
fml::Status Compute(const ISize &grid_size) override
void SetCommandLabel(std::string_view label) override
void AddBufferMemoryBarrier() override
Ensures all previously encoded compute command's buffer writes are visible to any subsequent compute ...
void AddTextureMemoryBarrier() override
Ensures all previously encoded compute command's texture writes are visible to any subsequent compute...
bool BindResource(ShaderStage stage, DescriptorType type, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, BufferView view) override
bool EncodeCommands() const override
Encode the recorded commands to the underlying command buffer.
Compute passes encode compute shader into the underlying command buffer.
Describes the fixed function and programmable aspects of rendering and compute operations performed b...
Definition pipeline.h:49
static const uint8_t buffer[]
FlTexture * texture
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.