Skip to content

Commit 4d0d477

Browse files
committed
Resolved conflicts, merged master
2 parents 0276f8e + dbbe7c6 commit 4d0d477

File tree

5 files changed

+51
-9
lines changed

5 files changed

+51
-9
lines changed

include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,41 @@ struct find_msb_return_type<vector<Integer, N> >
298298
template<typename Integer>
299299
using find_lsb_return_type = find_msb_return_type<Integer>;
300300

301+
template<typename T NBL_STRUCT_CONSTRAINABLE>
302+
struct bitReverse_helper;
303+
304+
template<typename Integer>
305+
NBL_PARTIAL_REQ_TOP(hlsl::is_integral_v<Integer> && hlsl::is_scalar_v<Integer>)
306+
struct bitReverse_helper<Integer NBL_PARTIAL_REQ_BOT(hlsl::is_integral_v<Integer>&& hlsl::is_scalar_v<Integer>) >
307+
{
308+
static inline Integer __call(NBL_CONST_REF_ARG(Integer) val)
309+
{
310+
#ifdef __HLSL_VERSION
311+
return spirv::bitReverse(val);
312+
#else
313+
return glm::bitfieldReverse(val);
314+
#endif
315+
}
316+
};
317+
318+
template<typename Vector>
319+
NBL_PARTIAL_REQ_TOP(hlsl::is_vector_v<Vector>)
320+
struct bitReverse_helper<Vector NBL_PARTIAL_REQ_BOT(hlsl::is_integral_v<Vector> && hlsl::is_vector_v<Vector>) >
321+
{
322+
static Vector __call(NBL_CONST_REF_ARG(Vector) vec)
323+
{
324+
#ifdef __HLSL_VERSION
325+
return spirv::bitReverse(vec);
326+
#else
327+
Vector output;
328+
using traits = hlsl::vector_traits<Vector>;
329+
for (uint32_t i = 0; i < traits::Dimension; ++i)
330+
output[i] = bitReverse_helper<scalar_type_t<Vector> >::__call(vec[i]);
331+
return output;
332+
#endif
333+
}
334+
};
335+
301336
template<typename Matrix>
302337
struct transpose_helper;
303338

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ inline FloatingPoint rsqrt(FloatingPoint x)
146146
#endif
147147
}
148148

149+
template<typename Integer>
150+
inline Integer bitReverse(Integer val)
151+
{
152+
return cpp_compat_intrinsics_impl::bitReverse_helper<Integer>::__call(val);
153+
}
154+
155+
149156
}
150157
}
151158

include/nbl/builtin/hlsl/glsl_compat/core.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ T bitfieldInsert(T base, T insert, uint32_t offset, uint32_t bits)
223223
template<typename T>
224224
T bitfieldReverse(T value)
225225
{
226-
return spirv::bitFieldReverse<T>(value);
226+
return spirv::bitReverse<T>(value);
227227
}
228228

229229
#endif

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ template<typename V NBL_STRUCT_CONSTRAINABLE>
101101
struct floor_helper;
102102

103103
template<typename FloatingPoint>
104-
NBL_PARTIAL_REQ_TOP(hlsl::is_floating_point_v<FloatingPoint>&& hlsl::is_scalar_v<FloatingPoint>)
105-
struct floor_helper<FloatingPoint NBL_PARTIAL_REQ_BOT(hlsl::is_vector_v<FloatingPoint>) >
104+
NBL_PARTIAL_REQ_TOP(hlsl::is_floating_point_v<FloatingPoint> && hlsl::is_scalar_v<FloatingPoint>)
105+
struct floor_helper<FloatingPoint NBL_PARTIAL_REQ_BOT(hlsl::is_floating_point_v<FloatingPoint>&& hlsl::is_scalar_v<FloatingPoint>) >
106106
{
107107
static FloatingPoint __call(NBL_CONST_REF_ARG(FloatingPoint) val)
108108
{
@@ -115,18 +115,18 @@ struct floor_helper<FloatingPoint NBL_PARTIAL_REQ_BOT(hlsl::is_vector_v<Floating
115115
};
116116

117117
template<typename Vector>
118-
NBL_PARTIAL_REQ_TOP(hlsl::is_vector_v<Vector>)
119-
struct floor_helper<Vector NBL_PARTIAL_REQ_BOT(hlsl::is_vector_v<Vector>) >
118+
NBL_PARTIAL_REQ_TOP(hlsl::is_floating_point_v<Vector> && hlsl::is_vector_v<Vector>)
119+
struct floor_helper<Vector NBL_PARTIAL_REQ_BOT(hlsl::is_floating_point_v<Vector> && hlsl::is_vector_v<Vector>) >
120120
{
121121
static Vector __call(NBL_CONST_REF_ARG(Vector) vec)
122122
{
123123
using traits = hlsl::vector_traits<Vector>;
124-
array_get<Vector, traits::scalar_type> getter;
125-
array_set<Vector, traits::scalar_type> setter;
124+
array_get<Vector, typename traits::scalar_type> getter;
125+
array_set<Vector, typename traits::scalar_type> setter;
126126

127127
Vector output;
128128
for (uint32_t i = 0; i < traits::Dimension; ++i)
129-
setter(output, i, floor_helper<traits::scalar_type>::__call(getter(vec, i)));
129+
setter(output, i, floor_helper<typename traits::scalar_type>::__call(getter(vec, i)));
130130

131131
return output;
132132
}

include/nbl/builtin/hlsl/spirv_intrinsics/core.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ enable_if_t<is_integral_v<Integral>, Integral> bitFieldInsert( Integral base, In
232232

233233
template<typename Integral>
234234
[[vk::ext_instruction( spv::OpBitReverse )]]
235-
enable_if_t<is_integral_v<Integral>, Integral> bitFieldReverse( Integral base );
235+
enable_if_t<is_integral_v<Integral>, Integral> bitReverse( Integral base );
236236

237237
template<typename FloatingPoint>
238238
[[vk::ext_instruction( spv::OpIsNan )]]

0 commit comments

Comments
 (0)