Skip to content

Commit f278259

Browse files
committed
Resolved conflicts, merged cpp_compat_intrinsics_refactor
2 parents 39f5c4b + e0e1b8c commit f278259

File tree

7 files changed

+27
-101
lines changed

7 files changed

+27
-101
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <nbl/builtin/hlsl/vector_utils/vector_traits.hlsl>
77
#include <nbl/builtin/hlsl/array_accessors.hlsl>
88
#include <nbl/builtin/hlsl/spirv_intrinsics/core.hlsl>
9-
#include <nbl/builtin/hlsl/spirv_intrinsics/GLSL.std.450.hlsl>
9+
#include <nbl/builtin/hlsl/spirv_intrinsics/glsl.std.450.hlsl>
1010

1111
#ifndef __HLSL_VERSION
1212
#include <algorithm>
@@ -190,21 +190,21 @@ inline T floor(NBL_CONST_REF_ARG(T) val)
190190

191191
}
192192

193+
// TODO: for clearer error messages, use concepts to ensure that input type is a square matrix
193194
// inverse not defined cause its implemented via hidden friend
194-
template<typename T, uint16_t N, uint16_t M>
195-
inline matrix<T, N, M> inverse(NBL_CONST_REF_ARG(matrix<T, N, M>) m)
195+
template<typename T, uint16_t N>
196+
inline matrix<T, N, N> inverse(NBL_CONST_REF_ARG(matrix<T, N, N>) m)
196197
{
197198
#ifdef __HLSL_VERSION
198199
return spirv::matrixInverse(m);
199200
#else
200-
return reinterpret_cast<matrix<T, N, M>&>(glm::inverse(reinterpret_cast<typename matrix<T, N, M>::Base const&>(m)));
201+
return reinterpret_cast<matrix<T, N, N>&>(glm::inverse(reinterpret_cast<typename matrix<T, N, N>::Base const&>(m)));
201202
#endif
202203
}
203204

204205
namespace cpp_compat_intrinsics_impl
205206
{
206-
207-
// TODO: concept requiring T to be a float
207+
// TODO: concept requiring T to be a float when U is not bool
208208
template<typename T, typename U>
209209
struct lerp_helper
210210
{

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

Lines changed: 0 additions & 70 deletions
This file was deleted.

include/nbl/builtin/hlsl/emulated/vector_t.hlsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <nbl/builtin/hlsl/functional.hlsl>
66
#include <nbl/builtin/hlsl/array_accessors.hlsl>
77
#include <nbl/builtin/hlsl/vector_utils/vector_traits.hlsl>
8-
#include <nbl/builtin/hlsl/cpp_compat/intrinsics/dot_product.hlsl>
98

109
namespace nbl
1110
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "nbl/builtin/hlsl/cpp_compat.hlsl"
88
#include "nbl/builtin/hlsl/spirv_intrinsics/core.hlsl"
99
#include "nbl/builtin/hlsl/type_traits.hlsl"
10-
#include "nbl/builtin/hlsl/spirv_intrinsics/GLSL.std.450.hlsl"
10+
#include "nbl/builtin/hlsl/spirv_intrinsics/glsl.std.450.hlsl"
1111

1212
namespace nbl
1313
{

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#ifdef __HLSL_VERSION // TODO: AnastZIuk fix public search paths so we don't choke
99
#include "spirv/unified1/spirv.hpp"
10-
#include "spirv/unified1/GLSL.std.450.h"
1110
#endif
1211

1312
#include "nbl/builtin/hlsl/type_traits.hlsl"
@@ -188,21 +187,6 @@ template<typename T, typename P>
188187
[[vk::ext_instruction(spv::OpStore)]]
189188
enable_if_t<is_spirv_type_v<P>,void> store(P pointer, T obj);
190189

191-
//! Std 450 Extended set operations
192-
193-
template<typename SquareMatrix>
194-
[[vk::ext_instruction(GLSLstd450MatrixInverse, "GLSL.std.450")]]
195-
SquareMatrix matrixInverse(NBL_CONST_REF_ARG(SquareMatrix) mat);
196-
197-
[[vk::ext_instruction(GLSLstd450UnpackSnorm2x16, "GLSL.std.450")]]
198-
float32_t2 unpackSnorm2x16(uint32_t p);
199-
200-
[[vk::ext_instruction(GLSLstd450UnpackSnorm4x8, "GLSL.std.450")]]
201-
float32_t4 unpackSnorm4x8(uint32_t p);
202-
203-
[[vk::ext_instruction(GLSLstd450UnpackUnorm4x8, "GLSL.std.450")]]
204-
float32_t4 unpackUnorm4x8(uint32_t p);
205-
206190
// Memory Semantics link here: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Memory_Semantics_-id-
207191

208192
// https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_memory_semantics_id

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ namespace hlsl
1212
namespace spirv
1313
{
1414
// Find MSB and LSB restricted to 32-bit width component types https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html
15-
1615
template<typename Integral>
1716
[[vk::ext_instruction(GLSLstd450::GLSLstd450FindILsb, "GLSL.std.450")]]
18-
enable_if_t<is_integral_v<Integral> && (sizeof(scalar_type_t<Integral>) == 4), Integral> findILsb(Integral value);
17+
enable_if_t<is_integral_v<Integral> && (sizeof(scalar_type_t<Integral>) == 4 && !is_matrix_v<Integral>), Integral> findILsb(Integral value);
1918

2019
[[vk::ext_instruction(GLSLstd450::GLSLstd450FindSMsb, "GLSL.std.450")]]
2120
int32_t findSMsb(int32_t value);
@@ -25,27 +24,41 @@ uint32_t findUMsb(uint32_t value);
2524

2625
template<typename FloatingPoint>
2726
[[vk::ext_instruction(GLSLstd450::GLSLstd450Exp2, "GLSL.std.450")]]
28-
enable_if_t<is_floating_point<FloatingPoint>::value, FloatingPoint> exp2(FloatingPoint val);
27+
enable_if_t<is_floating_point<FloatingPoint>::value && !is_matrix_v<FloatingPoint>, FloatingPoint> exp2(FloatingPoint val);
2928

3029
template<typename FloatingPoint>
3130
[[vk::ext_instruction(GLSLstd450::GLSLstd450InverseSqrt, "GLSL.std.450")]]
32-
enable_if_t<is_floating_point_v<FloatingPoint>, FloatingPoint> inverseSqrt(FloatingPoint val);
31+
enable_if_t<is_floating_point_v<FloatingPoint> && !is_matrix_v<FloatingPoint>, FloatingPoint> inverseSqrt(FloatingPoint val);
3332

3433
template<typename FloatingPoint>
3534
[[vk::ext_instruction(GLSLstd450::GLSLstd450Floor, "GLSL.std.450")]]
36-
enable_if_t<is_floating_point_v<FloatingPoint>, FloatingPoint> floor(FloatingPoint val);
35+
enable_if_t<is_floating_point_v<FloatingPoint> && !is_matrix_v<FloatingPoint>, FloatingPoint> floor(FloatingPoint val);
3736

3837
template<typename FloatingPoint>
3938
[[vk::ext_instruction(GLSLstd450::GLSLstd450Cross, "GLSL.std.450")]]
4039
enable_if_t<is_floating_point_v<FloatingPoint>, vector<FloatingPoint, 3> > cross(in vector<FloatingPoint, 3> lhs, in vector<FloatingPoint, 3> rhs);
4140

4241
template<typename FloatingPoint>
4342
[[vk::ext_instruction(GLSLstd450::GLSLstd450FMix, "GLSL.std.450")]]
44-
enable_if_t<is_floating_point_v<FloatingPoint>, FloatingPoint> fMix(FloatingPoint val, FloatingPoint min, FloatingPoint max);
43+
enable_if_t<is_floating_point_v<FloatingPoint> && !is_matrix_v<FloatingPoint>, FloatingPoint> fMix(FloatingPoint val, FloatingPoint min, FloatingPoint max);
4544

4645
template<typename T, int N>
4746
[[vk::ext_instruction(GLSLstd450::GLSLstd450Determinant, "GLSL.std.450")]]
4847
T determinant(in matrix<T, N, N> mat);
48+
49+
template<typename T, int N>
50+
[[vk::ext_instruction(GLSLstd450MatrixInverse, "GLSL.std.450")]]
51+
matrix<T, N, N> matrixInverse(in matrix<T, N, N> mat);
52+
53+
[[vk::ext_instruction(GLSLstd450UnpackSnorm2x16, "GLSL.std.450")]]
54+
float32_t2 unpackSnorm2x16(uint32_t p);
55+
56+
[[vk::ext_instruction(GLSLstd450UnpackSnorm4x8, "GLSL.std.450")]]
57+
float32_t4 unpackSnorm4x8(uint32_t p);
58+
59+
[[vk::ext_instruction(GLSLstd450UnpackUnorm4x8, "GLSL.std.450")]]
60+
float32_t4 unpackUnorm4x8(uint32_t p);
61+
4962
}
5063
}
5164
}

src/nbl/builtin/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_bal
237237
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_basic.hlsl")
238238
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_shuffle.hlsl")
239239
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_vote.hlsl")
240-
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/GLSL.std.450.hlsl")
240+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/glsl.std.450.hlsl")
241241
#C++ compatibility
242242
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat.hlsl")
243243
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/basic.h")

0 commit comments

Comments
 (0)