@@ -166,6 +166,19 @@ struct flipSign_helper<FloatingPoint, Bool NBL_PARTIAL_REQ_BOT(concepts::Floatin
166
166
}
167
167
};
168
168
169
+ template <typename FloatingPoint>
170
+ NBL_PARTIAL_REQ_TOP (concepts::FloatingPointLikeScalar<FloatingPoint>)
171
+ struct flipSign_helper<FloatingPoint, FloatingPoint NBL_PARTIAL_REQ_BOT (concepts::FloatingPointLikeScalar<FloatingPoint>) >
172
+ {
173
+ static FloatingPoint __call (FloatingPoint val, FloatingPoint flip)
174
+ {
175
+ using AsFloat = typename float_of_size<sizeof (FloatingPoint)>::type;
176
+ using AsUint = typename unsigned_integer_of_size<sizeof (FloatingPoint)>::type;
177
+ const AsUint asUint = ieee754::impl::bitCastToUintType (val);
178
+ return bit_cast<FloatingPoint>(asUint ^ (ieee754::traits<AsFloat>::signMask && flip));
179
+ }
180
+ };
181
+
169
182
template <typename Vectorial, typename Bool>
170
183
NBL_PARTIAL_REQ_TOP (concepts::FloatingPointLikeVectorial<Vectorial> && concepts::BooleanScalar<Bool>)
171
184
struct flipSign_helper<Vectorial, Bool NBL_PARTIAL_REQ_BOT (concepts::FloatingPointLikeVectorial<Vectorial> && concepts::BooleanScalar<Bool>) >
@@ -203,6 +216,24 @@ struct flipSign_helper<Vectorial, BoolVector NBL_PARTIAL_REQ_BOT(concepts::Float
203
216
return output;
204
217
}
205
218
};
219
+
220
+ template <typename Vectorial>
221
+ NBL_PARTIAL_REQ_TOP (concepts::FloatingPointLikeVectorial<Vectorial>)
222
+ struct flipSign_helper<Vectorial, Vectorial NBL_PARTIAL_REQ_BOT (concepts::FloatingPointLikeVectorial<Vectorial>) >
223
+ {
224
+ static Vectorial __call (Vectorial val, Vectorial flip)
225
+ {
226
+ using traits_v = hlsl::vector_traits<Vectorial>;
227
+ array_get<Vectorial, typename traits_v::scalar_type> getter_v;
228
+ array_set<Vectorial, typename traits_v::scalar_type> setter;
229
+
230
+ Vectorial output;
231
+ for (uint32_t i = 0 ; i < traits_v::Dimension; ++i)
232
+ setter (output, i, flipSign_helper<typename traits_v::scalar_type, typename traits_v::scalar_type>::__call (getter_v (val, i), getter_v (flip, i)));
233
+
234
+ return output;
235
+ }
236
+ };
206
237
}
207
238
208
239
template <typename T, typename U>
@@ -211,6 +242,12 @@ NBL_CONSTEXPR_INLINE_FUNC T flipSign(T val, U flip)
211
242
return impl::flipSign_helper<T, U>::__call (val, flip);
212
243
}
213
244
245
+ template <typename T>
246
+ NBL_CONSTEXPR_INLINE_FUNC T flipSignIfRHSNegative (T val, T flip)
247
+ {
248
+ return impl::flipSign_helper<T, T>::__call (val, flip);
249
+ }
250
+
214
251
}
215
252
}
216
253
}
0 commit comments