| 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 #pragma once
6
7 #include <vector>
8
9 #include "flutter/fml/macros.h"
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 template <size_t Size>
42 void RegisterDescriptorSetLayouts(
43 const std::array<DescriptorSetLayout, Size>& inputs) {
44 return RegisterDescriptorSetLayouts(inputs.data(), inputs.size());
45 }
46
47 void SetStageInputs(const ShaderStageIOSlot* const stage_inputs[],
48 size_t count,
49 const ShaderStageBufferLayout* const stage_layout[],
50 size_t layout_count);
51
52 void RegisterDescriptorSetLayouts(const DescriptorSetLayout desc_set_layout[],
53 size_t count);
54
55 const std::vector<ShaderStageIOSlot>& GetStageInputs() const;
56
57 const std::vector<ShaderStageBufferLayout>& GetStageLayouts() const;
58
59 const std::vector<DescriptorSetLayout>& GetDescriptorSetLayouts() const;
60
61 // |Comparable<VertexDescriptor>|
62 std::size_t GetHash() const override;
63
64 // |Comparable<VertexDescriptor>|
65 bool IsEqual(const VertexDescriptor& other) const override;
66
67 private:
68 std::vector<ShaderStageIOSlot> inputs_;
69 std::vector<ShaderStageBufferLayout> layouts_;
70 std::vector<DescriptorSetLayout> desc_set_layouts_;
71
72 FML_DISALLOW_COPY_AND_ASSIGN(VertexDescriptor);
73 };
74
75 } // namespace impeller
impeller::ShaderStageIOSlot
Definition: shader_types.h:88
impeller::DescriptorSetLayout
Definition: shader_types.h:149
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:117
impeller::VertexDescriptor::IsEqual
bool IsEqual(const VertexDescriptor &other) const override
Definition: vertex_descriptor.cc:50
impeller::VertexDescriptor::VertexDescriptor
VertexDescriptor()
impeller::VertexDescriptor::~VertexDescriptor
virtual ~VertexDescriptor()
impeller::VertexDescriptor::GetDescriptorSetLayouts
const std::vector< DescriptorSetLayout > & GetDescriptorSetLayouts() const
Definition: vertex_descriptor.cc:64
impeller::Comparable
Definition: comparable.h:32
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:42
impeller::VertexDescriptor::GetStageLayouts
const std::vector< ShaderStageBufferLayout > & GetStageLayouts() const
Definition: vertex_descriptor.cc:58
impeller::VertexDescriptor::GetStageInputs
const std::vector< ShaderStageIOSlot > & GetStageInputs() const
Definition: vertex_descriptor.cc:54
impeller::VertexDescriptor::GetHash
std::size_t GetHash() const override
Definition: vertex_descriptor.cc:38
shader_types.h
impeller
Definition: aiks_context.cc:10