-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRate.hpp
128 lines (102 loc) · 5.27 KB
/
Rate.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
///
/// Langulus::Flow
/// Copyright (c) 2017 Dimo Markov <[email protected]>
/// Part of the Langulus framework, see https://langulus.com
///
/// SPDX-License-Identifier: GPL-3.0-or-later
///
#pragma once
#include "Common.hpp"
namespace Langulus::Flow
{
///
/// Refresh rates
///
/// Represents the frequency at which data is recomputed
/// Many of these rates map onto shader stages
///
struct RefreshRate {
LANGULUS(POD) true;
LANGULUS(NULLIFIABLE) true;
LANGULUS(NAME) "Rate";
LANGULUS(INFO) "Refresh rate";
using Type = uint8_t;
enum Enum : Type {
Auto = 0, // Automatically determined refresh rate,
// based on traits and context
None, // No refresh rate (a constant, that never
// refreshes)
Tick, // Refresh once per tick (when temporal flow
// moves forward in time)
Pass, // Updated once per a render pass
Camera, // Updated for each camera
Level, // Updated for each level
Renderable, // Updated for each renderable
Instance, // Updated for each instance
// The following are mapped to ShaderStage::Enum
Vertex, // Refresh once per vertex (by vertex shader)
Primitive, // Refresh once per geometric primitive
// (by geometry shader)
TessCtrl, // Refresh once per tesselation control unit
// (by tesselation control shader)
TessEval, // Refresh once per tesselation evaluation
// unit (by tesselation evaluation shader)
Pixel, // Refresh once per pixel (by fragment
// shader)
Counter,
};
Type mMode = Auto;
LANGULUS_NAMED_VALUES(
Auto,
None,
Tick,
Pass,
Camera,
Level,
Renderable,
Instance,
Vertex,
Primitive,
TessCtrl,
TessEval,
Pixel
);
// Rates that are considered shader stages, mapped to ShaderStage
static constexpr Offset StagesBegin = Enum::Vertex;
static constexpr Offset StagesEnd = Enum::Counter;
static constexpr Count StagesCount = StagesEnd - StagesBegin;
// Rates that are considered uniforms
static constexpr Offset UniformBegin = Enum::Tick;
static constexpr Offset UniformEnd = StagesBegin;
static constexpr Count UniformCount = UniformEnd - UniformBegin;
// Rates that are considered inputs
static constexpr Offset InputBegin = UniformBegin;
static constexpr Offset InputEnd = StagesEnd;
static constexpr Count InputCount = InputEnd - InputBegin;
// Rates that are considered static
static constexpr Offset StaticUniformBegin = UniformBegin;
static constexpr Offset StaticUniformEnd = Enum::Camera;
static constexpr Count StaticUniformCount = StaticUniformEnd - StaticUniformBegin;
// Rates that are considered dynamic
static constexpr Offset DynamicUniformBegin = StaticUniformEnd;
static constexpr Offset DynamicUniformEnd = UniformEnd;
static constexpr Count DynamicUniformCount = DynamicUniformEnd - DynamicUniformBegin;
public:
constexpr RefreshRate() noexcept = default;
constexpr RefreshRate(const CT::Number auto&) noexcept;
constexpr RefreshRate(const Enum&) noexcept;
NOD() constexpr bool IsUniform() const noexcept;
NOD() constexpr bool IsStaticUniform() const noexcept;
NOD() constexpr bool IsDynamicUniform() const noexcept;
NOD() constexpr bool IsAttribute() const noexcept;
NOD() constexpr bool IsInput() const noexcept;
NOD() constexpr bool IsShaderStage() const noexcept;
NOD() constexpr Offset GetInputIndex() const;
NOD() constexpr Offset GetStaticUniformIndex() const;
NOD() constexpr Offset GetDynamicUniformIndex() const;
NOD() constexpr Offset GetStageIndex() const;
constexpr operator Enum () const noexcept {
return static_cast<Enum>(mMode);
}
};
} // namespace Langulus::Flow