Flutter Impeller
compute_pipeline_descriptor.cc
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 
6 
11 
12 namespace impeller {
13 
15 
17 
18 // Comparable<ComputePipelineDescriptor>
20  auto seed = fml::HashCombine();
21  fml::HashCombineSeed(seed, label_);
22  if (entrypoint_) {
23  fml::HashCombineSeed(seed, entrypoint_->GetHash());
24  }
25  fml::HashCombineSeed(seed, workgroup_size_[0], workgroup_size_[1],
26  workgroup_size_[2]);
27  return seed;
28 }
29 
30 // Comparable<ComputePipelineDescriptor>
32  const ComputePipelineDescriptor& other) const {
33  return label_ == other.label_ &&
34  DeepComparePointer(entrypoint_, other.entrypoint_) &&
35  workgroup_size_ == other.workgroup_size_;
36 }
37 
39  std::string_view label) {
40  label_ = label;
41  return *this;
42 }
43 
45  std::shared_ptr<const ShaderFunction> function) {
46  FML_DCHECK(!function || function->GetStage() == ShaderStage::kCompute);
47  if (!function || function->GetStage() != ShaderStage::kCompute) {
48  return *this;
49  }
50 
51  if (function->GetStage() == ShaderStage::kUnknown) {
52  return *this;
53  }
54 
55  entrypoint_ = std::move(function);
56 
57  return *this;
58 }
59 
60 std::shared_ptr<const ShaderFunction>
62  return entrypoint_;
63 }
64 
66  std::array<uint32_t, 3> size) {
67  workgroup_size_ = size;
68  return *this;
69 }
70 
71 std::array<uint32_t, 3> ComputePipelineDescriptor::GetWorkgroupSize() const {
72  return workgroup_size_;
73 }
74 
75 const std::string& ComputePipelineDescriptor::GetLabel() const {
76  return label_;
77 }
78 
80  const DescriptorSetLayout desc_set_layout[],
81  size_t count) {
82  descriptor_set_layouts_.reserve(descriptor_set_layouts_.size() + count);
83  for (size_t i = 0; i < count; i++) {
84  descriptor_set_layouts_.emplace_back(desc_set_layout[i]);
85  }
86  return true;
87 }
88 
89 const std::vector<DescriptorSetLayout>&
91  return descriptor_set_layouts_;
92 }
93 
94 } // namespace impeller
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)
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition: comparable.h:55