Flutter Impeller
compute_pipeline_descriptor.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_PIPELINE_DESCRIPTOR_H_
6 #define FLUTTER_IMPELLER_RENDERER_COMPUTE_PIPELINE_DESCRIPTOR_H_
7 
8 #include <array>
9 #include <cstdint>
10 #include <memory>
11 #include <string>
12 
15 
16 namespace impeller {
17 
18 class ShaderFunction;
19 template <typename T>
20 class Pipeline;
21 
23  : public Comparable<ComputePipelineDescriptor> {
24  public:
26 
28 
29  ComputePipelineDescriptor& SetLabel(std::string_view label);
30 
31  const std::string& GetLabel() const;
32 
34  std::shared_ptr<const ShaderFunction> function);
35 
36  std::shared_ptr<const ShaderFunction> GetStageEntrypoint() const;
37 
38  //----------------------------------------------------------------------------
39  /// @brief Set the workgroup (threadgroup) size declared by the shader.
40  ///
41  /// A dimension of 0 is sized by a specialization constant and
42  /// resolved by the backend at dispatch (for example, to the
43  /// device maximum).
44  ///
45  ComputePipelineDescriptor& SetWorkgroupSize(std::array<uint32_t, 3> size);
46 
47  std::array<uint32_t, 3> GetWorkgroupSize() const;
48 
49  // Comparable<ComputePipelineDescriptor>
50  std::size_t GetHash() const override;
51 
52  // Comparable<PipelineDescriptor>
53  bool IsEqual(const ComputePipelineDescriptor& other) const override;
54 
55  template <size_t Size>
57  const std::array<DescriptorSetLayout, Size>& inputs) {
58  return RegisterDescriptorSetLayouts(inputs.data(), inputs.size());
59  }
60 
61  bool RegisterDescriptorSetLayouts(const DescriptorSetLayout desc_set_layout[],
62  size_t count);
63 
64  const std::vector<DescriptorSetLayout>& GetDescriptorSetLayouts() const;
65 
66  private:
67  std::string label_;
68  std::shared_ptr<const ShaderFunction> entrypoint_;
69  std::array<uint32_t, 3> workgroup_size_ = {0u, 0u, 0u};
70  std::vector<DescriptorSetLayout> descriptor_set_layouts_;
71 };
72 
73 } // namespace impeller
74 
75 #endif // FLUTTER_IMPELLER_RENDERER_COMPUTE_PIPELINE_DESCRIPTOR_H_
const std::vector< DescriptorSetLayout > & GetDescriptorSetLayouts() const
ComputePipelineDescriptor & SetLabel(std::string_view label)
std::shared_ptr< const ShaderFunction > GetStageEntrypoint() const
bool IsEqual(const ComputePipelineDescriptor &other) const override
std::array< uint32_t, 3 > GetWorkgroupSize() const
ComputePipelineDescriptor & SetStageEntrypoint(std::shared_ptr< const ShaderFunction > function)
ComputePipelineDescriptor & SetWorkgroupSize(std::array< uint32_t, 3 > size)
Set the workgroup (threadgroup) size declared by the shader.
bool RegisterDescriptorSetLayouts(const std::array< DescriptorSetLayout, Size > &inputs)