Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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 <array>
9#include <cstdint>
10#include <string>
11
12#include "fml/status.h"
16
17namespace impeller {
18
19//------------------------------------------------------------------------------
20/// @brief Compute passes encode compute shader into the underlying command
21/// buffer.
22///
23/// @see `CommandBuffer`
24///
26 public:
27 virtual ~ComputePass();
28
29 virtual bool IsValid() const = 0;
30
31 void SetLabel(const std::string& label);
32
33 virtual void SetCommandLabel(std::string_view label) = 0;
34
35 virtual void SetPipeline(
36 const std::shared_ptr<Pipeline<ComputePipelineDescriptor>>& pipeline) = 0;
37
38 //----------------------------------------------------------------------------
39 /// @brief Dispatch a grid of compute workgroups.
40 ///
41 /// The components of `workgroup_count` are workgroup
42 /// (threadgroup) counts, not invocation counts. The number of
43 /// invocations per workgroup (the local size) is declared by the
44 /// shader. The total invocations along an axis is therefore the
45 /// workgroup count times the shader's local size.
46 ///
47 /// @return A cancelled status if any dimension is zero.
48 ///
49 virtual fml::Status Compute(std::array<uint32_t, 3> workgroup_count) = 0;
50
51 /// @brief Ensures all previously encoded compute command's buffer writes are
52 /// visible to any subsequent compute commands.
53 ///
54 /// On Vulkan, it does not matter if the compute command is in a
55 /// different command buffer, only that it is executed later in queue
56 /// order.
57 virtual void AddBufferMemoryBarrier() = 0;
58
59 /// @brief Ensures all previously encoded compute command's texture writes are
60 /// visible to any subsequent compute commands.
61 ///
62 /// On Vulkan, it does not matter if the compute command is in a
63 /// different command buffer, only that it is executed later in queue
64 /// order.
65 virtual void AddTextureMemoryBarrier() = 0;
66
67 //----------------------------------------------------------------------------
68 /// @brief Encode the recorded commands to the underlying command buffer.
69 ///
70 /// @return If the commands were encoded to the underlying command
71 /// buffer.
72 ///
73 virtual bool EncodeCommands() const = 0;
74
75 const Context& GetContext() const { return *context_; }
76
77 protected:
78 const std::shared_ptr<const Context> context_;
79
80 explicit ComputePass(std::shared_ptr<const Context> context);
81
82 virtual void OnSetLabel(const std::string& label) = 0;
83
84 private:
85 ComputePass(const ComputePass&) = delete;
86
87 ComputePass& operator=(const ComputePass&) = delete;
88};
89
90} // namespace impeller
91
92#endif // FLUTTER_IMPELLER_RENDERER_COMPUTE_PASS_H_
Compute passes encode compute shader into the underlying command buffer.
const std::shared_ptr< const Context > context_
virtual void OnSetLabel(const std::string &label)=0
virtual void AddBufferMemoryBarrier()=0
Ensures all previously encoded compute command's buffer writes are visible to any subsequent compute ...
virtual void SetCommandLabel(std::string_view label)=0
virtual void SetPipeline(const std::shared_ptr< Pipeline< ComputePipelineDescriptor > > &pipeline)=0
virtual fml::Status Compute(std::array< uint32_t, 3 > workgroup_count)=0
Dispatch a grid of compute workgroups.
void SetLabel(const std::string &label)
const Context & GetContext() const
virtual bool EncodeCommands() const =0
Encode the recorded commands to the underlying command buffer.
virtual bool IsValid() const =0
virtual void AddTextureMemoryBarrier()=0
Ensures all previously encoded compute command's texture writes are visible to any subsequent compute...
To do anything rendering related with Impeller, you need a context.
Definition context.h:69
Describes the fixed function and programmable aspects of rendering and compute operations performed b...
Definition pipeline.h:53
std::shared_ptr< ContextGLES > context
std::shared_ptr< PipelineGLES > pipeline
An interface for binding resources. This is implemented by |Command| and |ComputeCommand| to make GPU...