| Flutter Impeller |

vertex_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/vertex_descriptor.h"
6
7 namespace impeller {
8
9 VertexDescriptor::VertexDescriptor() = default;
10
11 VertexDescriptor::~VertexDescriptor() = default;
12
13 void VertexDescriptor::SetStageInputs(
14 const ShaderStageIOSlot* const stage_inputs[],
15 size_t count,
16 const ShaderStageBufferLayout* const stage_layout[],
17 size_t layout_count) {
18 inputs_.reserve(inputs_.size() + count);
19 layouts_.reserve(layouts_.size() + layout_count);
20 for (size_t i = 0; i < count; i++) {
21 inputs_.emplace_back(*stage_inputs[i]);
22 }
23 for (size_t i = 0; i < layout_count; i++) {
24 layouts_.emplace_back(*stage_layout[i]);
25 }
26 }
27
28 void VertexDescriptor::SetStageInputs(
29 const std::vector<ShaderStageIOSlot>& inputs,
30 const std::vector<ShaderStageBufferLayout>& layout) {
31 inputs_.insert(inputs_.end(), inputs.begin(), inputs.end());
32 layouts_.insert(layouts_.end(), layout.begin(), layout.end());
33 }
34
35 void VertexDescriptor::RegisterDescriptorSetLayouts(
36 const DescriptorSetLayout desc_set_layout[],
37 size_t count) {
38 desc_set_layouts_.reserve(desc_set_layouts_.size() + count);
39 for (size_t i = 0; i < count; i++) {
40 uses_input_attachments_ |=
41 desc_set_layout[i].descriptor_type == DescriptorType::kInputAttachment;
42 desc_set_layouts_.emplace_back(desc_set_layout[i]);
43 }
44 }
45
46 // |Comparable<VertexDescriptor>|
47 size_t VertexDescriptor::GetHash() const {
48 auto seed = fml::HashCombine();
49 for (const auto& input : inputs_) {
50 fml::HashCombineSeed(seed, input.GetHash());
51 }
52 for (const auto& layout : layouts_) {
53 fml::HashCombineSeed(seed, layout.GetHash());
54 }
55 return seed;
56 }
57
58 // |Comparable<VertexDescriptor>|
59 bool VertexDescriptor::IsEqual(const VertexDescriptor& other) const {
60 return inputs_ == other.inputs_ && layouts_ == other.layouts_;
61 }
62
63 const std::vector<ShaderStageIOSlot>& VertexDescriptor::GetStageInputs() const {
64 return inputs_;
65 }
66
67 const std::vector<ShaderStageBufferLayout>& VertexDescriptor::GetStageLayouts()
68 const {
69 return layouts_;
70 }
71
72 const std::vector<DescriptorSetLayout>&
73 VertexDescriptor::GetDescriptorSetLayouts() const {
74 return desc_set_layouts_;
75 }
76
77 bool VertexDescriptor::UsesInputAttacments() const {
78 return uses_input_attachments_;
79 }
80
81 } // namespace impeller
impeller::VertexDescriptor
Describes the format and layout of vertices expected by the pipeline. While it is possible to constru...
Definition: vertex_descriptor.h:23
impeller::VertexDescriptor::GetStageInputs
const std::vector< ShaderStageIOSlot > & GetStageInputs() const
Definition: vertex_descriptor.cc:63
impeller::VertexDescriptor::RegisterDescriptorSetLayouts
void RegisterDescriptorSetLayouts(const std::array< DescriptorSetLayout, Size > &inputs)
Definition: vertex_descriptor.h:45
impeller::VertexDescriptor::IsEqual
bool IsEqual(const VertexDescriptor &other) const override
Definition: vertex_descriptor.cc:59
impeller::VertexDescriptor::VertexDescriptor
VertexDescriptor()
impeller::VertexDescriptor::~VertexDescriptor
virtual ~VertexDescriptor()
impeller::VertexDescriptor::GetDescriptorSetLayouts
const std::vector< DescriptorSetLayout > & GetDescriptorSetLayouts() const
Definition: vertex_descriptor.cc:73
impeller::VertexDescriptor::GetStageLayouts
const std::vector< ShaderStageBufferLayout > & GetStageLayouts() const
Definition: vertex_descriptor.cc:67
impeller::VertexDescriptor::GetHash
std::size_t GetHash() const override
Definition: vertex_descriptor.cc:47
impeller::VertexDescriptor::SetStageInputs
void SetStageInputs(const std::array< const ShaderStageIOSlot *, Size > &inputs, const std::array< const ShaderStageBufferLayout *, LayoutSize > &layout)
Definition: vertex_descriptor.h:34
impeller::VertexDescriptor::UsesInputAttacments
bool UsesInputAttacments() const
Definition: vertex_descriptor.cc:77
impeller
Definition: allocation.cc:12
impeller::DescriptorType::kInputAttachment
@ kInputAttachment
impeller::DescriptorSetLayout
Definition: shader_types.h:167
impeller::DescriptorSetLayout::descriptor_type
DescriptorType descriptor_type
Definition: shader_types.h:169
impeller::ShaderStageBufferLayout
Definition: shader_types.h:144
impeller::ShaderStageIOSlot
Definition: shader_types.h:112
vertex_descriptor.h