| 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
5 #include "impeller/renderer/compute_pipeline_descriptor.h"
6
7 #include "impeller/core/formats.h"
8 #include "impeller/renderer/shader_function.h"
9 #include "impeller/renderer/shader_library.h"
10 #include "impeller/renderer/vertex_descriptor.h"
11
12 namespace impeller {
13
14 ComputePipelineDescriptor::ComputePipelineDescriptor() = default;
15
16 ComputePipelineDescriptor::~ComputePipelineDescriptor() = default;
17
18 // Comparable<ComputePipelineDescriptor>
19 std::size_t ComputePipelineDescriptor::GetHash() const {
20 auto seed = fml::HashCombine();
21 fml::HashCombineSeed(seed, label_);
22 if (entrypoint_) {
23 fml::HashCombineSeed(seed, entrypoint_->GetHash());
24 }
25 return seed;
26 }
27
28 // Comparable<ComputePipelineDescriptor>
29 bool ComputePipelineDescriptor::IsEqual(
30 const ComputePipelineDescriptor& other) const {
31 return label_ == other.label_ &&
32 DeepComparePointer(entrypoint_, other.entrypoint_);
33 }
34
35 ComputePipelineDescriptor& ComputePipelineDescriptor::SetLabel(
36 std::string_view label) {
37 label_ = label;
38 return *this;
39 }
40
41 ComputePipelineDescriptor& ComputePipelineDescriptor::SetStageEntrypoint(
42 std::shared_ptr<const ShaderFunction> function) {
43 FML_DCHECK(!function || function->GetStage() == ShaderStage::kCompute);
44 if (!function || function->GetStage() != ShaderStage::kCompute) {
45 return *this;
46 }
47
48 if (function->GetStage() == ShaderStage::kUnknown) {
49 return *this;
50 }
51
52 entrypoint_ = std::move(function);
53
54 return *this;
55 }
56
57 std::shared_ptr<const ShaderFunction>
58 ComputePipelineDescriptor::GetStageEntrypoint() const {
59 return entrypoint_;
60 }
61
62 const std::string& ComputePipelineDescriptor::GetLabel() const {
63 return label_;
64 }
65
66 bool ComputePipelineDescriptor::RegisterDescriptorSetLayouts(
67 const DescriptorSetLayout desc_set_layout[],
68 size_t count) {
69 descriptor_set_layouts_.reserve(descriptor_set_layouts_.size() + count);
70 for (size_t i = 0; i < count; i++) {
71 descriptor_set_layouts_.emplace_back(desc_set_layout[i]);
72 }
73 return true;
74 }
75
76 const std::vector<DescriptorSetLayout>&
77 ComputePipelineDescriptor::GetDescriptorSetLayouts() const {
78 return descriptor_set_layouts_;
79 }
80
81 } // namespace impeller
impeller::ComputePipelineDescriptor
Definition: compute_pipeline_descriptor.h:21
impeller::ComputePipelineDescriptor::GetDescriptorSetLayouts
const std::vector< DescriptorSetLayout > & GetDescriptorSetLayouts() const
Definition: compute_pipeline_descriptor.cc:77
impeller::ComputePipelineDescriptor::SetLabel
ComputePipelineDescriptor & SetLabel(std::string_view label)
Definition: compute_pipeline_descriptor.cc:35
impeller::ComputePipelineDescriptor::GetStageEntrypoint
std::shared_ptr< const ShaderFunction > GetStageEntrypoint() const
Definition: compute_pipeline_descriptor.cc:58
impeller::ComputePipelineDescriptor::IsEqual
bool IsEqual(const ComputePipelineDescriptor &other) const override
Definition: compute_pipeline_descriptor.cc:29
impeller::ComputePipelineDescriptor::GetHash
std::size_t GetHash() const override
Definition: compute_pipeline_descriptor.cc:19
impeller::ComputePipelineDescriptor::~ComputePipelineDescriptor
~ComputePipelineDescriptor()
impeller::ComputePipelineDescriptor::SetStageEntrypoint
ComputePipelineDescriptor & SetStageEntrypoint(std::shared_ptr< const ShaderFunction > function)
Definition: compute_pipeline_descriptor.cc:41
impeller::ComputePipelineDescriptor::ComputePipelineDescriptor
ComputePipelineDescriptor()
impeller::ComputePipelineDescriptor::GetLabel
const std::string & GetLabel() const
Definition: compute_pipeline_descriptor.cc:62
impeller::ComputePipelineDescriptor::RegisterDescriptorSetLayouts
bool RegisterDescriptorSetLayouts(const std::array< DescriptorSetLayout, Size > &inputs)
Definition: compute_pipeline_descriptor.h:43
compute_pipeline_descriptor.h
formats.h
impeller
Definition: allocation.cc:12
impeller::ShaderStage::kUnknown
@ kUnknown
impeller::ShaderStage::kCompute
@ kCompute
impeller::DeepComparePointer
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition: comparable.h:57
shader_function.h
shader_library.h
impeller::DescriptorSetLayout
Definition: shader_types.h:167
vertex_descriptor.h