| 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 desc_set_layouts_.emplace_back(desc_set_layout[i]);
41 }
42 }
43
44 // |Comparable<VertexDescriptor>|
45 size_t VertexDescriptor::GetHash() const {
46 auto seed = fml::HashCombine();
47 for (const auto& input : inputs_) {
48 fml::HashCombineSeed(seed, input.GetHash());
49 }
50 for (const auto& layout : layouts_) {
51 fml::HashCombineSeed(seed, layout.GetHash());
52 }
53 return seed;
54 }
55
56 // |Comparable<VertexDescriptor>|
57 bool VertexDescriptor::IsEqual(const VertexDescriptor& other) const {
58 return inputs_ == other.inputs_ && layouts_ == other.layouts_;
59 }
60
61 const std::vector<ShaderStageIOSlot>& VertexDescriptor::GetStageInputs() const {
62 return inputs_;
63 }
64
65 const std::vector<ShaderStageBufferLayout>& VertexDescriptor::GetStageLayouts()
66 const {
67 return layouts_;
68 }
69
70 const std::vector<DescriptorSetLayout>&
71 VertexDescriptor::GetDescriptorSetLayouts() const {
72 return desc_set_layouts_;
73 }
74
75 } // namespace impeller
impeller::ShaderStageIOSlot
Definition: shader_types.h:112
impeller::DescriptorSetLayout
Definition: shader_types.h:162
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::ShaderStageBufferLayout
Definition: shader_types.h:141
impeller::VertexDescriptor::IsEqual
bool IsEqual(const VertexDescriptor &other) const override
Definition: vertex_descriptor.cc:57
vertex_descriptor.h
impeller::VertexDescriptor::VertexDescriptor
VertexDescriptor()
impeller::VertexDescriptor::~VertexDescriptor
virtual ~VertexDescriptor()
impeller::VertexDescriptor::GetDescriptorSetLayouts
const std::vector< DescriptorSetLayout > & GetDescriptorSetLayouts() const
Definition: vertex_descriptor.cc:71
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::RegisterDescriptorSetLayouts
void RegisterDescriptorSetLayouts(const std::array< DescriptorSetLayout, Size > &inputs)
Definition: vertex_descriptor.h:45
impeller::VertexDescriptor::GetStageLayouts
const std::vector< ShaderStageBufferLayout > & GetStageLayouts() const
Definition: vertex_descriptor.cc:65
impeller::VertexDescriptor::GetStageInputs
const std::vector< ShaderStageIOSlot > & GetStageInputs() const
Definition: vertex_descriptor.cc:61
impeller::VertexDescriptor::GetHash
std::size_t GetHash() const override
Definition: vertex_descriptor.cc:45
impeller
Definition: aiks_context.cc:10