| Flutter Impeller |

vertex_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_VERTEX_DESCRIPTOR_H_
6 #define FLUTTER_IMPELLER_RENDERER_VERTEX_DESCRIPTOR_H_
7
8 #include <vector>
9
10 #include "impeller/base/comparable.h"
11 #include "impeller/core/shader_types.h"
12
13 namespace impeller {
14
15 //------------------------------------------------------------------------------
16 /// @brief Describes the format and layout of vertices expected by the
17 /// pipeline. While it is possible to construct these descriptors
18 /// manually, it would be tedious to do so. These are usually
19 /// constructed using shader information reflected using
20 /// `impellerc`. The usage of this class is indirectly via
21 /// `PipelineBuilder<VS, FS>`.
22 ///
23 class VertexDescriptor final : public Comparable<VertexDescriptor> {
24 public:
25 static constexpr size_t kReservedVertexBufferIndex =
26 30u; // The final slot available. Regular buffer indices go up from 0.
27
28 VertexDescriptor();
29
30 // |Comparable<PipelineVertexDescriptor>|
31 virtual ~VertexDescriptor();
32
33 template <size_t Size, size_t LayoutSize>
34 void SetStageInputs(
35 const std::array<const ShaderStageIOSlot*, Size>& inputs,
36 const std::array<const ShaderStageBufferLayout*, LayoutSize>& layout) {
37 return SetStageInputs(inputs.data(), inputs.size(), layout.data(),
38 layout.size());
39 }
40
41 void SetStageInputs(const std::vector<ShaderStageIOSlot>& inputs,
42 const std::vector<ShaderStageBufferLayout>& layout);
43
44 template <size_t Size>
45 void RegisterDescriptorSetLayouts(
46 const std::array<DescriptorSetLayout, Size>& inputs) {
47 return RegisterDescriptorSetLayouts(inputs.data(), inputs.size());
48 }
49
50 void SetStageInputs(const ShaderStageIOSlot* const stage_inputs[],
51 size_t count,
52 const ShaderStageBufferLayout* const stage_layout[],
53 size_t layout_count);
54
55 void RegisterDescriptorSetLayouts(const DescriptorSetLayout desc_set_layout[],
56 size_t count);
57
58 const std::vector<ShaderStageIOSlot>& GetStageInputs() const;
59
60 const std::vector<ShaderStageBufferLayout>& GetStageLayouts() const;
61
62 const std::vector<DescriptorSetLayout>& GetDescriptorSetLayouts() const;
63
64 // |Comparable<VertexDescriptor>|
65 std::size_t GetHash() const override;
66
67 // |Comparable<VertexDescriptor>|
68 bool IsEqual(const VertexDescriptor& other) const override;
69
70 bool UsesInputAttacments() const;
71
72 private:
73 std::vector<ShaderStageIOSlot> inputs_;
74 std::vector<ShaderStageBufferLayout> layouts_;
75 std::vector<DescriptorSetLayout> desc_set_layouts_;
76 bool uses_input_attachments_ = false;
77
78 VertexDescriptor(const VertexDescriptor&) = delete;
79
80 VertexDescriptor& operator=(const VertexDescriptor&) = delete;
81 };
82
83 } // namespace impeller
84
85 #endif // FLUTTER_IMPELLER_RENDERER_VERTEX_DESCRIPTOR_H_
impeller::ShaderStageIOSlot
Definition: shader_types.h:112
impeller::DescriptorSetLayout
Definition: shader_types.h:165
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:144
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::Comparable
Definition: comparable.h:29
comparable.h
impeller::VertexDescriptor::kReservedVertexBufferIndex
static constexpr size_t kReservedVertexBufferIndex
Definition: vertex_descriptor.h:25
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:67
impeller::VertexDescriptor::GetStageInputs
const std::vector< ShaderStageIOSlot > & GetStageInputs() const
Definition: vertex_descriptor.cc:63
impeller::VertexDescriptor::UsesInputAttacments
bool UsesInputAttacments() const
Definition: vertex_descriptor.cc:77
impeller::VertexDescriptor::GetHash
std::size_t GetHash() const override
Definition: vertex_descriptor.cc:47
shader_types.h
impeller
Definition: allocation.cc:12