| Flutter Impeller |

compute_pass.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_COMPUTE_PASS_H_
6 #define FLUTTER_IMPELLER_RENDERER_COMPUTE_PASS_H_
7
8 #include <string>
9
10 #include "fml/status.h"
11 #include "impeller/core/resource_binder.h"
12 #include "impeller/renderer/compute_pipeline_descriptor.h"
13 #include "impeller/renderer/pipeline_descriptor.h"
14
15 namespace impeller {
16
17 //------------------------------------------------------------------------------
18 /// @brief Compute passes encode compute shader into the underlying command
19 /// buffer.
20 ///
21 /// @see `CommandBuffer`
22 ///
23 class ComputePass : public ResourceBinder {
24 public:
25 virtual ~ComputePass();
26
27 virtual bool IsValid() const = 0;
28
29 void SetLabel(const std::string& label);
30
31 virtual void SetCommandLabel(std::string_view label) = 0;
32
33 virtual void SetPipeline(
34 const std::shared_ptr<Pipeline<ComputePipelineDescriptor>>& pipeline) = 0;
35
36 virtual fml::Status Compute(const ISize& grid_size) = 0;
37
38 /// @brief Ensures all previously encoded compute command's buffer writes are
39 /// visible to any subsequent compute commands.
40 ///
41 /// On Vulkan, it does not matter if the compute command is in a
42 /// different command buffer, only that it is executed later in queue
43 /// order.
44 virtual void AddBufferMemoryBarrier() = 0;
45
46 /// @brief Ensures all previously encoded compute command's texture writes are
47 /// visible to any subsequent compute commands.
48 ///
49 /// On Vulkan, it does not matter if the compute command is in a
50 /// different command buffer, only that it is executed later in queue
51 /// order.
52 virtual void AddTextureMemoryBarrier() = 0;
53
54 //----------------------------------------------------------------------------
55 /// @brief Encode the recorded commands to the underlying command buffer.
56 ///
57 /// @return If the commands were encoded to the underlying command
58 /// buffer.
59 ///
60 virtual bool EncodeCommands() const = 0;
61
62 const Context& GetContext() const { return *context_; }
63
64 protected:
65 const std::shared_ptr<const Context> context_;
66
67 explicit ComputePass(std::shared_ptr<const Context> context);
68
69 virtual void OnSetLabel(const std::string& label) = 0;
70
71 private:
72 ComputePass(const ComputePass&) = delete;
73
74 ComputePass& operator=(const ComputePass&) = delete;
75 };
76
77 } // namespace impeller
78
79 #endif // FLUTTER_IMPELLER_RENDERER_COMPUTE_PASS_H_
impeller::Pipeline< ComputePipelineDescriptor >
impeller::ComputePass::AddTextureMemoryBarrier
virtual void AddTextureMemoryBarrier()=0
Ensures all previously encoded compute command's texture writes are visible to any subsequent compute...
impeller::ComputePass::Compute
virtual fml::Status Compute(const ISize &grid_size)=0
impeller::ComputePass::SetPipeline
virtual void SetPipeline(const std::shared_ptr< Pipeline< ComputePipelineDescriptor >> &pipeline)=0
impeller::ComputePass::IsValid
virtual bool IsValid() const =0
impeller::ComputePass::ComputePass
ComputePass(std::shared_ptr< const Context > context)
Definition: compute_pass.cc:9
impeller::TSize< int64_t >
impeller::ComputePass::EncodeCommands
virtual bool EncodeCommands() const =0
Encode the recorded commands to the underlying command buffer.
resource_binder.h
impeller::ResourceBinder
An interface for binding resources. This is implemented by |Command| and |ComputeCommand| to make GPU...
Definition: resource_binder.h:23
impeller::ComputePass::context_
const std::shared_ptr< const Context > context_
Definition: compute_pass.h:65
compute_pipeline_descriptor.h
impeller::ComputePass::SetCommandLabel
virtual void SetCommandLabel(std::string_view label)=0
impeller::ComputePass::GetContext
const Context & GetContext() const
Definition: compute_pass.h:62
impeller::ComputePass::AddBufferMemoryBarrier
virtual void AddBufferMemoryBarrier()=0
Ensures all previously encoded compute command's buffer writes are visible to any subsequent compute ...
impeller::ComputePass::OnSetLabel
virtual void OnSetLabel(const std::string &label)=0
impeller::ComputePass::SetLabel
void SetLabel(const std::string &label)
Definition: compute_pass.cc:14
impeller::Context
To do anything rendering related with Impeller, you need a context.
Definition: context.h:46
impeller::ComputePass::~ComputePass
virtual ~ComputePass()
pipeline_descriptor.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