@@ -53,11 +53,8 @@ struct emulated_int64_t
5353 constexpr explicit emulated_int64_t (const emulated_uint64_t& other);
5454 #endif
5555
56- NBL_CONSTEXPR_FUNC this_t operator-() NBL_CONST_MEMBER_FUNC
57- {
58- storage_t inverted = ~data;
59- return create (_static_cast<storage_t>(inverted)) + _static_cast<this_t>(1 );
60- }
56+ NBL_CONSTEXPR_FUNC emulated_int64_t operator-() NBL_CONST_MEMBER_FUNC;
57+
6158};
6259
6360// ------------------------------------------------ TYPE TRAITS SATISFIED -----------------------------------------------------
@@ -196,24 +193,25 @@ constexpr emulated_uint64_t::operator I() const noexcept
196193template<typename T> NBL_PARTIAL_REQ_TOP (concepts::ImitationIntegral64Scalar<T>)
197194struct left_shift_operator<T NBL_PARTIAL_REQ_BOT (concepts::ImitationIntegral64Scalar<T>) >
198195{
196+ using type_t = T;
199197 NBL_CONSTEXPR_STATIC uint32_t ComponentBitWidth = uint32_t (8 * sizeof (uint32_t));
200198
201199 // Can't do generic templated definition, see:
202200 //https://github.com/microsoft/DirectXShaderCompiler/issues/7325
203201
204202 // If `_bits > 63` or `_bits < 0` the result is undefined
205- NBL_CONSTEXPR_FUNC T operator ()(NBL_CONST_REF_ARG (T ) operand, uint32_t bits)
203+ NBL_CONSTEXPR_FUNC type_t operator ()(NBL_CONST_REF_ARG (type_t ) operand, uint32_t bits)
206204 {
207205 const bool bigShift = bits >= ComponentBitWidth; // Shift that completely rewrites LSB
208206 const uint32_t shift = bigShift ? bits - ComponentBitWidth : ComponentBitWidth - bits;
209- const T shifted = T ::create (bigShift ? vector <uint32_t, 2 >(0 , operand.__getLSB () << shift)
207+ const type_t shifted = type_t ::create (bigShift ? vector <uint32_t, 2 >(0 , operand.__getLSB () << shift)
210208 : vector <uint32_t, 2 >(operand.__getLSB () << bits, (operand.__getMSB () << bits) | (operand.__getLSB () >> shift)));
211- ternary_operator<T > ternary;
209+ ternary_operator<type_t > ternary;
212210 return ternary (bool (bits), shifted, operand);
213211 }
214212
215213 // If `_bits > 63` or `_bits < 0` the result is undefined
216- NBL_CONSTEXPR_FUNC T operator ()(NBL_CONST_REF_ARG (T ) operand, T bits)
214+ NBL_CONSTEXPR_FUNC type_t operator ()(NBL_CONST_REF_ARG (type_t ) operand, type_t bits)
217215 {
218216 return operator ()(operand, _static_cast<uint32_t>(bits));
219217 }
@@ -381,6 +379,26 @@ NBL_CONSTEXPR_INLINE_VAR emulated_uint64_t minus_assign<emulated_uint64_t>::iden
381379template<>
382380NBL_CONSTEXPR_INLINE_VAR emulated_int64_t minus_assign<emulated_int64_t>::identity = minus<emulated_int64_t>::identity;
383381
382+ // --------------------------------- Unary operators ------------------------------------------
383+ // Specializations of the structs found in functional.hlsl
384+ template<>
385+ struct unary_minus_operator<emulated_int64_t>
386+ {
387+ using type_t = emulated_int64_t;
388+
389+ NBL_CONSTEXPR_FUNC type_t operator ()(NBL_CONST_REF_ARG (type_t) operand)
390+ {
391+ using storage_t = type_t::storage_t;
392+ storage_t inverted = ~operand.data;
393+ return type_t::create (_static_cast<storage_t>(inverted)) + _static_cast<type_t>(1 );
394+ }
395+ };
396+
397+ NBL_CONSTEXPR_INLINE_FUNC emulated_int64_t emulated_int64_t::operator-() NBL_CONST_MEMBER_FUNC
398+ {
399+ unary_minus_operator<emulated_int64_t> unaryMinus;
400+ return unaryMinus (NBL_DEREF_THIS);
401+ }
384402
385403} //namespace nbl
386404} //namespace hlsl
0 commit comments