Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
12
13namespace 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///
23class 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
29
30 // |Comparable<PipelineVertexDescriptor>|
32
33 template <size_t Size, size_t LayoutSize>
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>
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_
int count
Describes the format and layout of vertices expected by the pipeline. While it is possible to constru...
const std::vector< ShaderStageIOSlot > & GetStageInputs() const
void RegisterDescriptorSetLayouts(const std::array< DescriptorSetLayout, Size > &inputs)
bool IsEqual(const VertexDescriptor &other) const override
static constexpr size_t kReservedVertexBufferIndex
const std::vector< DescriptorSetLayout > & GetDescriptorSetLayouts() const
const std::vector< ShaderStageBufferLayout > & GetStageLayouts() const
std::size_t GetHash() const override
void SetStageInputs(const std::array< const ShaderStageIOSlot *, Size > &inputs, const std::array< const ShaderStageBufferLayout *, LayoutSize > &layout)