Skip to content

Commit cb8c98b

Browse files
committed
Fixes
1 parent eccc6e9 commit cb8c98b

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

include/nbl/builtin/hlsl/impl/tgmath_impl.hlsl

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ struct HELPER_NAME<T NBL_PARTIAL_REQ_BOT(always_true<decltype(spirv::SPIRV_FUNCT
7979
}\
8080
};
8181

82-
AUTO_SPECIALIZE_TRIVIAL_CASE_HELPER(cos_helper, cos, T)
8382
AUTO_SPECIALIZE_TRIVIAL_CASE_HELPER(sin_helper, sin, T)
83+
AUTO_SPECIALIZE_TRIVIAL_CASE_HELPER(cos_helper, cos, T)
84+
AUTO_SPECIALIZE_TRIVIAL_CASE_HELPER(acos_helper, acos, T)
8485
AUTO_SPECIALIZE_TRIVIAL_CASE_HELPER(abs_helper, sAbs, T)
8586
AUTO_SPECIALIZE_TRIVIAL_CASE_HELPER(abs_helper, fAbs, T)
8687
AUTO_SPECIALIZE_TRIVIAL_CASE_HELPER(sqrt_helper, sqrt, T)
@@ -94,13 +95,13 @@ AUTO_SPECIALIZE_TRIVIAL_CASE_HELPER(isnan_helper, isNan, ISINF_AND_ISNAN_RETURN_
9495
#undef ISINF_AND_ISNAN_RETURN_TYPE
9596
#undef AUTO_SPECIALIZE_TRIVIAL_CASE_HELPER
9697

97-
template<typename T, typename U> NBL_PARTIAL_REQ_TOP(always_true<decltype(spirv::pow<T>(experimental::declval<T>(), experimental::declval<T>()))>)
98-
struct pow_helper<T, U NBL_PARTIAL_REQ_BOT(always_true<decltype(spirv::pow<T>(experimental::declval<T>(), experimental::declval<T>()))>) >
98+
template<typename T> NBL_PARTIAL_REQ_TOP(always_true<decltype(spirv::pow<T>(experimental::declval<T>(), experimental::declval<T>()))>)
99+
struct pow_helper<T NBL_PARTIAL_REQ_BOT(always_true<decltype(spirv::pow<T>(experimental::declval<T>(), experimental::declval<T>()))>) >
99100
{
100101
using return_t = T;
101102
static inline return_t __call(const T x, const T y)
102103
{
103-
return spirv::pow<T>(x, y, a);
104+
return spirv::pow<T>(x, y);
104105
}
105106
};
106107

@@ -266,10 +267,17 @@ struct erfInv_helper<FloatingPoint NBL_PARTIAL_REQ_BOT(concepts::FloatingPointSc
266267
}
267268
};
268269

270+
#ifdef __HLSL_VERSION
271+
// SPIR-V already defines specializations for builtin vector types
272+
#define VECTOR_SPECIALIZATION_CONCEPT concepts::Vectorial<T> && !is_vector_v<T>
273+
#else
274+
#define VECTOR_SPECIALIZATION_CONCEPT concepts::Vectorial<T>
275+
#endif
276+
269277
#define AUTO_SPECIALIZE_HELPER_FOR_VECTOR(HELPER_NAME, RETURN_TYPE)\
270278
template<typename T>\
271-
NBL_PARTIAL_REQ_TOP(concepts::Vectorial<T>)\
272-
struct HELPER_NAME<T NBL_PARTIAL_REQ_BOT(concepts::Vectorial<T>) >\
279+
NBL_PARTIAL_REQ_TOP(VECTOR_SPECIALIZATION_CONCEPT)\
280+
struct HELPER_NAME<T NBL_PARTIAL_REQ_BOT(VECTOR_SPECIALIZATION_CONCEPT) >\
273281
{\
274282
using return_t = RETURN_TYPE;\
275283
static return_t __call(NBL_CONST_REF_ARG(T) vec)\
@@ -287,9 +295,6 @@ struct HELPER_NAME<T NBL_PARTIAL_REQ_BOT(concepts::Vectorial<T>) >\
287295
}\
288296
};
289297

290-
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(cos_helper, T)
291-
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(sin_helper, T)
292-
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(acos_helper, T)
293298
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(sqrt_helper, T)
294299
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(abs_helper, T)
295300
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(log_helper, T)
@@ -299,12 +304,16 @@ AUTO_SPECIALIZE_HELPER_FOR_VECTOR(floor_helper, T)
299304
#define INT_VECTOR_RETURN_TYPE vector<int32_t, vector_traits<T>::Dimension>
300305
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(isinf_helper, INT_VECTOR_RETURN_TYPE)
301306
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(isnan_helper, INT_VECTOR_RETURN_TYPE)
307+
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(cos_helper, T)
308+
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(sin_helper, T)
309+
AUTO_SPECIALIZE_HELPER_FOR_VECTOR(acos_helper, T)
310+
302311
#undef INT_VECTOR_RETURN_TYPE
303312
#undef AUTO_SPECIALIZE_HELPER_FOR_VECTOR
304313

305314
template<typename T>
306-
NBL_PARTIAL_REQ_TOP(concepts::Vectorial<T>)
307-
struct pow_helper<T NBL_PARTIAL_REQ_BOT(concepts::Vectorial<T>) >
315+
NBL_PARTIAL_REQ_TOP(VECTOR_SPECIALIZATION_CONCEPT)
316+
struct pow_helper<T NBL_PARTIAL_REQ_BOT(VECTOR_SPECIALIZATION_CONCEPT) >
308317
{
309318
using return_t = T;
310319
static return_t __call(NBL_CONST_REF_ARG(T) x, NBL_CONST_REF_ARG(T) y)
@@ -320,6 +329,7 @@ struct pow_helper<T NBL_PARTIAL_REQ_BOT(concepts::Vectorial<T>) >
320329
return output;
321330
}
322331
};
332+
#undef VECTOR_SPECIALIZATION_CONCEPT
323333

324334
}
325335
}

include/nbl/builtin/hlsl/spirv_intrinsics/glsl.std.450.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ enable_if_t<is_integral_v<Integer> && is_signed_v<Integer>, Integer> sAbs(Intege
142142

143143
template<typename FloatingPoint>
144144
[[vk::ext_instruction(GLSLstd450Sin, "GLSL.std.450")]]
145-
enable_if_t<is_floating_point_v<FloatingPoint> && (sizeof(FloatingPoint) <= 4), FloatingPoint> sin(FloatingPoint val);
145+
enable_if_t<is_floating_point_v<FloatingPoint>, FloatingPoint> sin(FloatingPoint val);
146146

147147
template<typename FloatingPoint>
148148
[[vk::ext_instruction(GLSLstd450Cos, "GLSL.std.450")]]
149-
enable_if_t<is_floating_point_v<FloatingPoint> && (sizeof(FloatingPoint) <= 4), FloatingPoint> cos(FloatingPoint val);
149+
enable_if_t<is_floating_point_v<FloatingPoint>, FloatingPoint> cos(FloatingPoint val);
150150

151151
template<typename FloatingPoint>
152152
[[vk::ext_instruction(GLSLstd450Acos, "GLSL.std.450")]]
153-
enable_if_t<is_floating_point_v<FloatingPoint> && (sizeof(FloatingPoint) <= 4), FloatingPoint> acos(FloatingPoint val);
153+
enable_if_t<is_floating_point_v<FloatingPoint>, FloatingPoint> acos(FloatingPoint val);
154154

155155
}
156156
}

0 commit comments

Comments
 (0)