summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-12-24 17:11:08 -0300
committerGravatar ReinUsesLisp2019-12-24 18:24:08 -0300
commitb9e3f5eb36318f269257ab60f446b72a63aecc3c (patch)
tree9fe62261d7be8240b51ce16abf8315416f9b226f /src
parentfixed_pipeline_state: Define structure and loaders (diff)
downloadyuzu-b9e3f5eb36318f269257ab60f446b72a63aecc3c.tar.gz
yuzu-b9e3f5eb36318f269257ab60f446b72a63aecc3c.tar.xz
yuzu-b9e3f5eb36318f269257ab60f446b72a63aecc3c.zip
fixed_pipeline_state: Define symetric operator!= and mark as noexcept
Marks as noexcept Hash, operator== and operator!= for consistency.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_vulkan/fixed_pipeline_state.cpp41
-rw-r--r--src/video_core/renderer_vulkan/fixed_pipeline_state.h91
2 files changed, 92 insertions, 40 deletions
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
index f75c348fe..5a490f6ef 100644
--- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
+++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
@@ -125,39 +125,39 @@ constexpr FixedPipelineState::Rasterizer GetRasterizerState(const Maxwell& regs)
125 125
126} // Anonymous namespace 126} // Anonymous namespace
127 127
128std::size_t FixedPipelineState::VertexBinding::Hash() const { 128std::size_t FixedPipelineState::VertexBinding::Hash() const noexcept {
129 return (index << stride) ^ divisor; 129 return (index << stride) ^ divisor;
130} 130}
131 131
132bool FixedPipelineState::VertexBinding::operator==(const VertexBinding& rhs) const { 132bool FixedPipelineState::VertexBinding::operator==(const VertexBinding& rhs) const noexcept {
133 return std::tie(index, stride, divisor) == std::tie(rhs.index, rhs.stride, rhs.divisor); 133 return std::tie(index, stride, divisor) == std::tie(rhs.index, rhs.stride, rhs.divisor);
134} 134}
135 135
136std::size_t FixedPipelineState::VertexAttribute::Hash() const { 136std::size_t FixedPipelineState::VertexAttribute::Hash() const noexcept {
137 return static_cast<std::size_t>(index) ^ (static_cast<std::size_t>(buffer) << 13) ^ 137 return static_cast<std::size_t>(index) ^ (static_cast<std::size_t>(buffer) << 13) ^
138 (static_cast<std::size_t>(type) << 22) ^ (static_cast<std::size_t>(size) << 31) ^ 138 (static_cast<std::size_t>(type) << 22) ^ (static_cast<std::size_t>(size) << 31) ^
139 (static_cast<std::size_t>(offset) << 36); 139 (static_cast<std::size_t>(offset) << 36);
140} 140}
141 141
142bool FixedPipelineState::VertexAttribute::operator==(const VertexAttribute& rhs) const { 142bool FixedPipelineState::VertexAttribute::operator==(const VertexAttribute& rhs) const noexcept {
143 return std::tie(index, buffer, type, size, offset) == 143 return std::tie(index, buffer, type, size, offset) ==
144 std::tie(rhs.index, rhs.buffer, rhs.type, rhs.size, rhs.offset); 144 std::tie(rhs.index, rhs.buffer, rhs.type, rhs.size, rhs.offset);
145} 145}
146 146
147std::size_t FixedPipelineState::StencilFace::Hash() const { 147std::size_t FixedPipelineState::StencilFace::Hash() const noexcept {
148 return static_cast<std::size_t>(action_stencil_fail) ^ 148 return static_cast<std::size_t>(action_stencil_fail) ^
149 (static_cast<std::size_t>(action_depth_fail) << 4) ^ 149 (static_cast<std::size_t>(action_depth_fail) << 4) ^
150 (static_cast<std::size_t>(action_depth_fail) << 20) ^ 150 (static_cast<std::size_t>(action_depth_fail) << 20) ^
151 (static_cast<std::size_t>(action_depth_pass) << 36); 151 (static_cast<std::size_t>(action_depth_pass) << 36);
152} 152}
153 153
154bool FixedPipelineState::StencilFace::operator==(const StencilFace& rhs) const { 154bool FixedPipelineState::StencilFace::operator==(const StencilFace& rhs) const noexcept {
155 return std::tie(action_stencil_fail, action_depth_fail, action_depth_pass, test_func) == 155 return std::tie(action_stencil_fail, action_depth_fail, action_depth_pass, test_func) ==
156 std::tie(rhs.action_stencil_fail, rhs.action_depth_fail, rhs.action_depth_pass, 156 std::tie(rhs.action_stencil_fail, rhs.action_depth_fail, rhs.action_depth_pass,
157 rhs.test_func); 157 rhs.test_func);
158} 158}
159 159
160std::size_t FixedPipelineState::BlendingAttachment::Hash() const { 160std::size_t FixedPipelineState::BlendingAttachment::Hash() const noexcept {
161 return static_cast<std::size_t>(enable) ^ (static_cast<std::size_t>(rgb_equation) << 5) ^ 161 return static_cast<std::size_t>(enable) ^ (static_cast<std::size_t>(rgb_equation) << 5) ^
162 (static_cast<std::size_t>(src_rgb_func) << 10) ^ 162 (static_cast<std::size_t>(src_rgb_func) << 10) ^
163 (static_cast<std::size_t>(dst_rgb_func) << 15) ^ 163 (static_cast<std::size_t>(dst_rgb_func) << 15) ^
@@ -170,14 +170,15 @@ std::size_t FixedPipelineState::BlendingAttachment::Hash() const {
170 (static_cast<std::size_t>(components[3]) << 38); 170 (static_cast<std::size_t>(components[3]) << 38);
171} 171}
172 172
173bool FixedPipelineState::BlendingAttachment::operator==(const BlendingAttachment& rhs) const { 173bool FixedPipelineState::BlendingAttachment::operator==(const BlendingAttachment& rhs) const
174 noexcept {
174 return std::tie(enable, rgb_equation, src_rgb_func, dst_rgb_func, a_equation, src_a_func, 175 return std::tie(enable, rgb_equation, src_rgb_func, dst_rgb_func, a_equation, src_a_func,
175 dst_a_func, components) == 176 dst_a_func, components) ==
176 std::tie(rhs.enable, rhs.rgb_equation, rhs.src_rgb_func, rhs.dst_rgb_func, 177 std::tie(rhs.enable, rhs.rgb_equation, rhs.src_rgb_func, rhs.dst_rgb_func,
177 rhs.a_equation, rhs.src_a_func, rhs.dst_a_func, rhs.components); 178 rhs.a_equation, rhs.src_a_func, rhs.dst_a_func, rhs.components);
178} 179}
179 180
180std::size_t FixedPipelineState::VertexInput::Hash() const { 181std::size_t FixedPipelineState::VertexInput::Hash() const noexcept {
181 std::size_t hash = num_bindings ^ (num_attributes << 32); 182 std::size_t hash = num_bindings ^ (num_attributes << 32);
182 for (std::size_t i = 0; i < num_bindings; ++i) { 183 for (std::size_t i = 0; i < num_bindings; ++i) {
183 boost::hash_combine(hash, bindings[i].Hash()); 184 boost::hash_combine(hash, bindings[i].Hash());
@@ -188,37 +189,37 @@ std::size_t FixedPipelineState::VertexInput::Hash() const {
188 return hash; 189 return hash;
189} 190}
190 191
191bool FixedPipelineState::VertexInput::operator==(const VertexInput& rhs) const { 192bool FixedPipelineState::VertexInput::operator==(const VertexInput& rhs) const noexcept {
192 return std::equal(bindings.begin(), bindings.begin() + num_bindings, rhs.bindings.begin(), 193 return std::equal(bindings.begin(), bindings.begin() + num_bindings, rhs.bindings.begin(),
193 rhs.bindings.begin() + rhs.num_bindings) && 194 rhs.bindings.begin() + rhs.num_bindings) &&
194 std::equal(attributes.begin(), attributes.begin() + num_attributes, 195 std::equal(attributes.begin(), attributes.begin() + num_attributes,
195 rhs.attributes.begin(), rhs.attributes.begin() + rhs.num_attributes); 196 rhs.attributes.begin(), rhs.attributes.begin() + rhs.num_attributes);
196} 197}
197 198
198std::size_t FixedPipelineState::InputAssembly::Hash() const { 199std::size_t FixedPipelineState::InputAssembly::Hash() const noexcept {
199 std::size_t point_size_int = 0; 200 std::size_t point_size_int = 0;
200 std::memcpy(&point_size_int, &point_size, sizeof(point_size)); 201 std::memcpy(&point_size_int, &point_size, sizeof(point_size));
201 return (static_cast<std::size_t>(topology) << 24) ^ (point_size_int << 32) ^ 202 return (static_cast<std::size_t>(topology) << 24) ^ (point_size_int << 32) ^
202 static_cast<std::size_t>(primitive_restart_enable); 203 static_cast<std::size_t>(primitive_restart_enable);
203} 204}
204 205
205bool FixedPipelineState::InputAssembly::operator==(const InputAssembly& rhs) const { 206bool FixedPipelineState::InputAssembly::operator==(const InputAssembly& rhs) const noexcept {
206 return std::tie(topology, primitive_restart_enable, point_size) == 207 return std::tie(topology, primitive_restart_enable, point_size) ==
207 std::tie(rhs.topology, rhs.primitive_restart_enable, rhs.point_size); 208 std::tie(rhs.topology, rhs.primitive_restart_enable, rhs.point_size);
208} 209}
209 210
210std::size_t FixedPipelineState::Tessellation::Hash() const { 211std::size_t FixedPipelineState::Tessellation::Hash() const noexcept {
211 return static_cast<std::size_t>(patch_control_points) ^ 212 return static_cast<std::size_t>(patch_control_points) ^
212 (static_cast<std::size_t>(primitive) << 6) ^ (static_cast<std::size_t>(spacing) << 8) ^ 213 (static_cast<std::size_t>(primitive) << 6) ^ (static_cast<std::size_t>(spacing) << 8) ^
213 (static_cast<std::size_t>(clockwise) << 10); 214 (static_cast<std::size_t>(clockwise) << 10);
214} 215}
215 216
216bool FixedPipelineState::Tessellation::operator==(const Tessellation& rhs) const { 217bool FixedPipelineState::Tessellation::operator==(const Tessellation& rhs) const noexcept {
217 return std::tie(patch_control_points, primitive, spacing, clockwise) == 218 return std::tie(patch_control_points, primitive, spacing, clockwise) ==
218 std::tie(rhs.patch_control_points, rhs.primitive, rhs.spacing, rhs.clockwise); 219 std::tie(rhs.patch_control_points, rhs.primitive, rhs.spacing, rhs.clockwise);
219} 220}
220 221
221std::size_t FixedPipelineState::Rasterizer::Hash() const { 222std::size_t FixedPipelineState::Rasterizer::Hash() const noexcept {
222 return static_cast<std::size_t>(cull_enable) ^ 223 return static_cast<std::size_t>(cull_enable) ^
223 (static_cast<std::size_t>(depth_bias_enable) << 1) ^ 224 (static_cast<std::size_t>(depth_bias_enable) << 1) ^
224 (static_cast<std::size_t>(ndc_minus_one_to_one) << 2) ^ 225 (static_cast<std::size_t>(ndc_minus_one_to_one) << 2) ^
@@ -226,13 +227,13 @@ std::size_t FixedPipelineState::Rasterizer::Hash() const {
226 (static_cast<std::size_t>(front_face) << 48); 227 (static_cast<std::size_t>(front_face) << 48);
227} 228}
228 229
229bool FixedPipelineState::Rasterizer::operator==(const Rasterizer& rhs) const { 230bool FixedPipelineState::Rasterizer::operator==(const Rasterizer& rhs) const noexcept {
230 return std::tie(cull_enable, depth_bias_enable, ndc_minus_one_to_one, cull_face, front_face) == 231 return std::tie(cull_enable, depth_bias_enable, ndc_minus_one_to_one, cull_face, front_face) ==
231 std::tie(rhs.cull_enable, rhs.depth_bias_enable, rhs.ndc_minus_one_to_one, rhs.cull_face, 232 std::tie(rhs.cull_enable, rhs.depth_bias_enable, rhs.ndc_minus_one_to_one, rhs.cull_face,
232 rhs.front_face); 233 rhs.front_face);
233} 234}
234 235
235std::size_t FixedPipelineState::DepthStencil::Hash() const { 236std::size_t FixedPipelineState::DepthStencil::Hash() const noexcept {
236 std::size_t hash = static_cast<std::size_t>(depth_test_enable) ^ 237 std::size_t hash = static_cast<std::size_t>(depth_test_enable) ^
237 (static_cast<std::size_t>(depth_write_enable) << 1) ^ 238 (static_cast<std::size_t>(depth_write_enable) << 1) ^
238 (static_cast<std::size_t>(depth_bounds_enable) << 2) ^ 239 (static_cast<std::size_t>(depth_bounds_enable) << 2) ^
@@ -243,7 +244,7 @@ std::size_t FixedPipelineState::DepthStencil::Hash() const {
243 return hash; 244 return hash;
244} 245}
245 246
246bool FixedPipelineState::DepthStencil::operator==(const DepthStencil& rhs) const { 247bool FixedPipelineState::DepthStencil::operator==(const DepthStencil& rhs) const noexcept {
247 return std::tie(depth_test_enable, depth_write_enable, depth_bounds_enable, depth_test_function, 248 return std::tie(depth_test_enable, depth_write_enable, depth_bounds_enable, depth_test_function,
248 stencil_enable, front_stencil, back_stencil) == 249 stencil_enable, front_stencil, back_stencil) ==
249 std::tie(rhs.depth_test_enable, rhs.depth_write_enable, rhs.depth_bounds_enable, 250 std::tie(rhs.depth_test_enable, rhs.depth_write_enable, rhs.depth_bounds_enable,
@@ -251,7 +252,7 @@ bool FixedPipelineState::DepthStencil::operator==(const DepthStencil& rhs) const
251 rhs.back_stencil); 252 rhs.back_stencil);
252} 253}
253 254
254std::size_t FixedPipelineState::ColorBlending::Hash() const { 255std::size_t FixedPipelineState::ColorBlending::Hash() const noexcept {
255 std::size_t hash = attachments_count << 13; 256 std::size_t hash = attachments_count << 13;
256 for (std::size_t rt = 0; rt < static_cast<std::size_t>(attachments_count); ++rt) { 257 for (std::size_t rt = 0; rt < static_cast<std::size_t>(attachments_count); ++rt) {
257 boost::hash_combine(hash, attachments[rt].Hash()); 258 boost::hash_combine(hash, attachments[rt].Hash());
@@ -259,7 +260,7 @@ std::size_t FixedPipelineState::ColorBlending::Hash() const {
259 return hash; 260 return hash;
260} 261}
261 262
262bool FixedPipelineState::ColorBlending::operator==(const ColorBlending& rhs) const { 263bool FixedPipelineState::ColorBlending::operator==(const ColorBlending& rhs) const noexcept {
263 return std::equal(attachments.begin(), attachments.begin() + attachments_count, 264 return std::equal(attachments.begin(), attachments.begin() + attachments_count,
264 rhs.attachments.begin(), rhs.attachments.begin() + rhs.attachments_count); 265 rhs.attachments.begin(), rhs.attachments.begin() + rhs.attachments_count);
265} 266}
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h
index 01f82be68..04152c0d4 100644
--- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h
+++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h
@@ -30,8 +30,13 @@ struct FixedPipelineState {
30 u32 stride; 30 u32 stride;
31 u32 divisor; 31 u32 divisor;
32 32
33 std::size_t Hash() const; 33 std::size_t Hash() const noexcept;
34 bool operator==(const VertexBinding& rhs) const; 34
35 bool operator==(const VertexBinding& rhs) const noexcept;
36
37 bool operator!=(const VertexBinding& rhs) const noexcept {
38 return !operator==(rhs);
39 }
35 }; 40 };
36 41
37 struct VertexAttribute { 42 struct VertexAttribute {
@@ -46,8 +51,13 @@ struct FixedPipelineState {
46 Maxwell::VertexAttribute::Size size; 51 Maxwell::VertexAttribute::Size size;
47 u32 offset; 52 u32 offset;
48 53
49 std::size_t Hash() const; 54 std::size_t Hash() const noexcept;
50 bool operator==(const VertexAttribute& rhs) const; 55
56 bool operator==(const VertexAttribute& rhs) const noexcept;
57
58 bool operator!=(const VertexAttribute& rhs) const noexcept {
59 return !operator==(rhs);
60 }
51 }; 61 };
52 62
53 struct StencilFace { 63 struct StencilFace {
@@ -63,8 +73,13 @@ struct FixedPipelineState {
63 Maxwell::StencilOp action_depth_pass; 73 Maxwell::StencilOp action_depth_pass;
64 Maxwell::ComparisonOp test_func; 74 Maxwell::ComparisonOp test_func;
65 75
66 std::size_t Hash() const; 76 std::size_t Hash() const noexcept;
67 bool operator==(const StencilFace& rhs) const; 77
78 bool operator==(const StencilFace& rhs) const noexcept;
79
80 bool operator!=(const StencilFace& rhs) const noexcept {
81 return !operator==(rhs);
82 }
68 }; 83 };
69 84
70 struct BlendingAttachment { 85 struct BlendingAttachment {
@@ -89,8 +104,13 @@ struct FixedPipelineState {
89 Maxwell::Blend::Factor dst_a_func; 104 Maxwell::Blend::Factor dst_a_func;
90 std::array<bool, 4> components; 105 std::array<bool, 4> components;
91 106
92 std::size_t Hash() const; 107 std::size_t Hash() const noexcept;
93 bool operator==(const BlendingAttachment& rhs) const; 108
109 bool operator==(const BlendingAttachment& rhs) const noexcept;
110
111 bool operator!=(const BlendingAttachment& rhs) const noexcept {
112 return !operator==(rhs);
113 }
94 }; 114 };
95 115
96 struct VertexInput { 116 struct VertexInput {
@@ -99,8 +119,13 @@ struct FixedPipelineState {
99 std::array<VertexBinding, Maxwell::NumVertexArrays> bindings; 119 std::array<VertexBinding, Maxwell::NumVertexArrays> bindings;
100 std::array<VertexAttribute, Maxwell::NumVertexAttributes> attributes; 120 std::array<VertexAttribute, Maxwell::NumVertexAttributes> attributes;
101 121
102 std::size_t Hash() const; 122 std::size_t Hash() const noexcept;
103 bool operator==(const VertexInput& rhs) const; 123
124 bool operator==(const VertexInput& rhs) const noexcept;
125
126 bool operator!=(const VertexInput& rhs) const noexcept {
127 return !operator==(rhs);
128 }
104 }; 129 };
105 130
106 struct InputAssembly { 131 struct InputAssembly {
@@ -114,8 +139,13 @@ struct FixedPipelineState {
114 bool primitive_restart_enable; 139 bool primitive_restart_enable;
115 float point_size; 140 float point_size;
116 141
117 std::size_t Hash() const; 142 std::size_t Hash() const noexcept;
118 bool operator==(const InputAssembly& rhs) const; 143
144 bool operator==(const InputAssembly& rhs) const noexcept;
145
146 bool operator!=(const InputAssembly& rhs) const noexcept {
147 return !operator==(rhs);
148 }
119 }; 149 };
120 150
121 struct Tessellation { 151 struct Tessellation {
@@ -130,8 +160,13 @@ struct FixedPipelineState {
130 Maxwell::TessellationSpacing spacing; 160 Maxwell::TessellationSpacing spacing;
131 bool clockwise; 161 bool clockwise;
132 162
133 std::size_t Hash() const; 163 std::size_t Hash() const noexcept;
134 bool operator==(const Tessellation& rhs) const; 164
165 bool operator==(const Tessellation& rhs) const noexcept;
166
167 bool operator!=(const Tessellation& rhs) const noexcept {
168 return !operator==(rhs);
169 }
135 }; 170 };
136 171
137 struct Rasterizer { 172 struct Rasterizer {
@@ -148,8 +183,13 @@ struct FixedPipelineState {
148 Maxwell::Cull::CullFace cull_face; 183 Maxwell::Cull::CullFace cull_face;
149 Maxwell::Cull::FrontFace front_face; 184 Maxwell::Cull::FrontFace front_face;
150 185
151 std::size_t Hash() const; 186 std::size_t Hash() const noexcept;
152 bool operator==(const Rasterizer& rhs) const; 187
188 bool operator==(const Rasterizer& rhs) const noexcept;
189
190 bool operator!=(const Rasterizer& rhs) const noexcept {
191 return !operator==(rhs);
192 }
153 }; 193 };
154 194
155 struct DepthStencil { 195 struct DepthStencil {
@@ -171,8 +211,13 @@ struct FixedPipelineState {
171 StencilFace front_stencil; 211 StencilFace front_stencil;
172 StencilFace back_stencil; 212 StencilFace back_stencil;
173 213
174 std::size_t Hash() const; 214 std::size_t Hash() const noexcept;
175 bool operator==(const DepthStencil& rhs) const; 215
216 bool operator==(const DepthStencil& rhs) const noexcept;
217
218 bool operator!=(const DepthStencil& rhs) const noexcept {
219 return !operator==(rhs);
220 }
176 }; 221 };
177 222
178 struct ColorBlending { 223 struct ColorBlending {
@@ -185,11 +230,17 @@ struct FixedPipelineState {
185 std::size_t attachments_count; 230 std::size_t attachments_count;
186 std::array<BlendingAttachment, Maxwell::NumRenderTargets> attachments; 231 std::array<BlendingAttachment, Maxwell::NumRenderTargets> attachments;
187 232
188 std::size_t Hash() const; 233 std::size_t Hash() const noexcept;
189 bool operator==(const ColorBlending& rhs) const; 234
235 bool operator==(const ColorBlending& rhs) const noexcept;
236
237 bool operator!=(const ColorBlending& rhs) const noexcept {
238 return !operator==(rhs);
239 }
190 }; 240 };
191 241
192 std::size_t Hash() const noexcept; 242 std::size_t Hash() const noexcept;
243
193 bool operator==(const FixedPipelineState& rhs) const noexcept; 244 bool operator==(const FixedPipelineState& rhs) const noexcept;
194 245
195 bool operator!=(const FixedPipelineState& rhs) const noexcept { 246 bool operator!=(const FixedPipelineState& rhs) const noexcept {