tess
1.0.0
Performance-first tile and path simulation substrate
Toggle main menu visibility
Loading...
Searching...
No Matches
metadata_types.h
1
#pragma once
2
3
#include <tess/core/fail_fast.h>
4
5
#include <cstdint>
6
#include <limits>
7
#include <type_traits>
8
9
namespace
tess {
10
12
struct
DirtyMask
{
13
std::uint32_t value = 0;
14
15
[[nodiscard]]
constexpr
bool
empty()
const
noexcept
{
return
value == 0; }
16
[[nodiscard]]
constexpr
explicit
operator
bool()
const
noexcept
{
17
return
!empty();
18
}
19
20
friend
constexpr
bool
operator==(
DirtyMask
lhs,
21
DirtyMask
rhs)
noexcept
=
default
;
22
};
23
24
[[nodiscard]]
constexpr
DirtyMask
operator|(
DirtyMask
lhs,
25
DirtyMask
rhs)
noexcept
{
26
return
DirtyMask
{lhs.value | rhs.value};
27
}
28
29
[[nodiscard]]
constexpr
DirtyMask
operator&(
DirtyMask
lhs,
30
DirtyMask
rhs)
noexcept
{
31
return
DirtyMask
{lhs.value & rhs.value};
32
}
33
34
[[nodiscard]]
constexpr
DirtyMask
operator~(
DirtyMask
mask)
noexcept
{
35
return
DirtyMask
{~mask.value};
36
}
37
38
constexpr
DirtyMask
& operator|=(
DirtyMask
& lhs,
DirtyMask
rhs)
noexcept
{
39
lhs = lhs | rhs;
40
return
lhs;
41
}
42
43
constexpr
DirtyMask
& operator&=(
DirtyMask
& lhs,
DirtyMask
rhs)
noexcept
{
44
lhs = lhs & rhs;
45
return
lhs;
46
}
47
49
struct
ActiveMask
{
50
std::uint32_t value = 0;
51
52
[[nodiscard]]
constexpr
bool
empty()
const
noexcept
{
return
value == 0; }
53
[[nodiscard]]
constexpr
explicit
operator
bool()
const
noexcept
{
54
return
!empty();
55
}
56
57
friend
constexpr
bool
operator==(
ActiveMask
lhs,
58
ActiveMask
rhs)
noexcept
=
default
;
59
};
60
61
[[nodiscard]]
constexpr
ActiveMask
operator|(
ActiveMask
lhs,
62
ActiveMask
rhs)
noexcept
{
63
return
ActiveMask
{lhs.value | rhs.value};
64
}
65
66
[[nodiscard]]
constexpr
ActiveMask
operator&(
ActiveMask
lhs,
67
ActiveMask
rhs)
noexcept
{
68
return
ActiveMask
{lhs.value & rhs.value};
69
}
70
71
[[nodiscard]]
constexpr
ActiveMask
operator~(
ActiveMask
mask)
noexcept
{
72
return
ActiveMask
{~mask.value};
73
}
74
75
constexpr
ActiveMask
& operator|=(
ActiveMask
& lhs,
ActiveMask
rhs)
noexcept
{
76
lhs = lhs | rhs;
77
return
lhs;
78
}
79
80
constexpr
ActiveMask
& operator&=(
ActiveMask
& lhs,
ActiveMask
rhs)
noexcept
{
81
lhs = lhs & rhs;
82
return
lhs;
83
}
84
86
struct
ContentVersion
{
87
std::uint64_t value = 0;
88
89
friend
constexpr
bool
operator==(
ContentVersion
lhs,
90
ContentVersion
rhs)
noexcept
=
default
;
91
};
92
93
inline
ContentVersion
& operator++(
ContentVersion
&
version
)
noexcept
{
94
if
(
version
.value == std::numeric_limits<std::uint64_t>::max()) {
95
detail::fail_fast(
"ContentVersion exhausted"
);
96
}
97
++version.value;
98
return
version;
99
}
100
102
struct
TopologyVersion
{
103
std::uint64_t value = 0;
104
105
friend
constexpr
bool
operator==(
TopologyVersion
lhs,
106
TopologyVersion
rhs)
noexcept
=
default
;
107
};
108
109
inline
TopologyVersion
& operator++(
TopologyVersion
&
version
)
noexcept
{
110
if
(
version
.value == std::numeric_limits<std::uint64_t>::max()) {
111
detail::fail_fast(
"TopologyVersion exhausted"
);
112
}
113
++version.value;
114
return
version;
115
}
116
118
struct
ResidencyGeneration
{
119
std::uint64_t value = 0;
120
121
[[nodiscard]]
constexpr
bool
valid()
const
noexcept
{
return
value != 0; }
122
123
friend
constexpr
bool
operator==(
ResidencyGeneration
lhs,
124
ResidencyGeneration
rhs)
noexcept
=
default
;
125
};
126
127
inline
ResidencyGeneration
& operator++(
128
ResidencyGeneration
& generation)
noexcept
{
129
if
(generation.value == std::numeric_limits<std::uint64_t>::max()) {
130
detail::fail_fast(
"ResidencyGeneration exhausted"
);
131
}
132
++generation.value;
133
return
generation;
134
}
135
136
static_assert
(std::is_standard_layout_v<DirtyMask>);
137
static_assert
(std::is_trivially_copyable_v<DirtyMask>);
138
static_assert
(
sizeof
(
DirtyMask
) ==
sizeof
(std::uint32_t));
139
static_assert
(
alignof
(
DirtyMask
) ==
alignof
(std::uint32_t));
140
static_assert
(std::is_standard_layout_v<ActiveMask>);
141
static_assert
(std::is_trivially_copyable_v<ActiveMask>);
142
static_assert
(
sizeof
(
ActiveMask
) ==
sizeof
(std::uint32_t));
143
static_assert
(
alignof
(
ActiveMask
) ==
alignof
(std::uint32_t));
144
static_assert
(std::is_standard_layout_v<ContentVersion>);
145
static_assert
(std::is_trivially_copyable_v<ContentVersion>);
146
static_assert
(
sizeof
(
ContentVersion
) ==
sizeof
(std::uint64_t));
147
static_assert
(
alignof
(
ContentVersion
) ==
alignof
(std::uint64_t));
148
static_assert
(std::is_standard_layout_v<TopologyVersion>);
149
static_assert
(std::is_trivially_copyable_v<TopologyVersion>);
150
static_assert
(
sizeof
(
TopologyVersion
) ==
sizeof
(std::uint64_t));
151
static_assert
(
alignof
(
TopologyVersion
) ==
alignof
(std::uint64_t));
152
static_assert
(std::is_standard_layout_v<ResidencyGeneration>);
153
static_assert
(std::is_trivially_copyable_v<ResidencyGeneration>);
154
static_assert
(
sizeof
(
ResidencyGeneration
) ==
sizeof
(std::uint64_t));
155
static_assert
(
alignof
(
ResidencyGeneration
) ==
alignof
(std::uint64_t));
156
157
}
// namespace tess
tess::ActiveMask
Definition
metadata_types.h:49
tess::ContentVersion
Definition
metadata_types.h:86
tess::DirtyMask
Definition
metadata_types.h:12
tess::ResidencyGeneration
Definition
metadata_types.h:118
tess::TopologyVersion
Definition
metadata_types.h:102
tess::version
Definition
version.h:21
include
tess
storage
metadata_types.h
Generated by
1.17.0