Skip to content

Commit 59e388a

Browse files
committed
Fix
1 parent 8c94b0c commit 59e388a

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

include/nbl/builtin/hlsl/cpp_compat/intrinsics.hlsl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <nbl/builtin/hlsl/type_traits.hlsl>
66
#include <nbl/builtin/hlsl/vector_utils/vector_traits.hlsl>
77
#include <nbl/builtin/hlsl/array_accessors.hlsl>
8+
#include <nbl/builtin/hlsl/spirv_intrinsics/core.hlsl>
89
#include <nbl/builtin/hlsl/spirv_intrinsics/GLSL.std.450.hlsl>
910

1011
#ifndef __HLSL_VERSION
@@ -271,6 +272,25 @@ inline T exp2(NBL_CONST_REF_ARG(T) val)
271272
#endif
272273
}
273274

275+
#ifdef __HLSL_VERSION
276+
#define EXP2_SPECIALIZATION_RETUR_VAL spirv::Exp2(float(val))
277+
#else
278+
#define EXP2_SPECIALIZATION_RETUR_VAL std::exp2(val)
279+
#endif
280+
#define DEFINE_EXP2_SPECIALIZATION(TYPE)\
281+
template<>\
282+
inline TYPE exp2(NBL_CONST_REF_ARG(TYPE) val)\
283+
{\
284+
return EXP2_SPECIALIZATION_RETUR_VAL;\
285+
}\
286+
287+
DEFINE_EXP2_SPECIALIZATION(int16_t)
288+
DEFINE_EXP2_SPECIALIZATION(int32_t)
289+
DEFINE_EXP2_SPECIALIZATION(int64_t)
290+
DEFINE_EXP2_SPECIALIZATION(uint16_t)
291+
DEFINE_EXP2_SPECIALIZATION(uint32_t)
292+
DEFINE_EXP2_SPECIALIZATION(uint64_t)
293+
274294
template<typename FloatingPoint>
275295
inline FloatingPoint rsqrt(FloatingPoint x)
276296
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ template<typename Integral>
2626
[[vk::ext_instruction(GLSLstd450::GLSLstd450FindUMsb, "GLSL.std.450")]]
2727
enable_if_t<is_integral_v<Integral> && (sizeof(scalar_type_t<Integral>) == 4), Integral> findUMsb(Integral value);
2828

29-
template<typename T>
29+
template<typename FloatingPoint>
3030
[[vk::ext_instruction(GLSLstd450::GLSLstd450Exp2, "GLSL.std.450")]]
31-
enable_if_t<is_fundamental<T>::value, T> Exp2(T val);
31+
enable_if_t<is_floating_point<FloatingPoint>::value, FloatingPoint> Exp2(FloatingPoint val);
3232

3333
template<typename FloatingPoint>
3434
[[vk::ext_instruction(GLSLstd450::GLSLstd450InverseSqrt, "GLSL.std.450")]]

src/nbl/builtin/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/ext/DepthPyramidGenerator/vir
210210

211211
# HLSL
212212
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/macros.h")
213+
214+
# utility
215+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/array_accessors.hlsl")
216+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/vector_utils/vector_traits.hlsl")
217+
213218
#spirv intrinsics
214219
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/core.hlsl")
215220
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/fragment_shader_pixel_interlock.hlsl")
@@ -219,10 +224,11 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_bal
219224
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_basic.hlsl")
220225
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_shuffle.hlsl")
221226
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_vote.hlsl")
227+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/GLSL.std.450.hlsl")
222228
#C++ compatibility
223229
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat.hlsl")
224230
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/basic.h")
225-
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/intrinsics.h")
231+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/intrinsics.hlsl")
226232
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/matrix.hlsl")
227233
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/promote.hlsl")
228234
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/vector.hlsl")

0 commit comments

Comments
 (0)