Skip to content

Commit 563be55

Browse files
committed
Added requirements to projection matrix creation functions
1 parent edee654 commit 563be55

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,6 @@ MatT identity()
4040
return diagonal<MatT>(1);
4141
}
4242

43-
// TODO: this is temporary function, delete when removing vectorSIMD
44-
#ifndef __HLSL_VERSION
45-
template<typename T>
46-
inline core::vectorSIMDf transformVector(NBL_CONST_REF_ARG(matrix<T, 4, 4>) mat, NBL_CONST_REF_ARG(core::vectorSIMDf) vec)
47-
{
48-
core::vectorSIMDf output;
49-
float32_t4 tmp;
50-
for (int i = 0; i < 4; ++i) // rather do that that reinterpret_cast for safety
51-
tmp[i] = output[i];
52-
53-
for (int i = 0; i < 4; ++i)
54-
output[i] = hlsl::dot<float32_t4>(mat[i], tmp);
55-
56-
return output;
57-
}
58-
#endif
5943
template<typename T>
6044
inline matrix<T, 4, 4> getMatrix3x4As4x4(NBL_CONST_REF_ARG(matrix<T, 3, 4>) mat)
6145
{

include/nbl/builtin/hlsl/projection/projection.hlsl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
#define _NBL_BUILTIN_HLSL_PROJECTION_PROJECTION_INCLUDED_
33

44
#include <nbl/builtin/hlsl/cpp_compat.hlsl>
5+
#include <nbl/builtin/hlsl/concepts.hlsl>
56

67
namespace nbl
78
{
89
namespace hlsl
910
{
1011
// TODO: use glm instead for c++
11-
template<typename FloatingPoint>
12+
template<typename FloatingPoint NBL_FUNC_REQUIRES(concepts::FloatingPoint<FloatingPoint>)
1213
inline matrix<FloatingPoint, 4, 4> buildProjectionMatrixPerspectiveFovRH(FloatingPoint fieldOfViewRadians, FloatingPoint aspectRatio, FloatingPoint zNear, FloatingPoint zFar)
1314
{
1415
const FloatingPoint h = core::reciprocal<FloatingPoint>(tan(fieldOfViewRadians * 0.5f));
@@ -25,7 +26,7 @@ inline matrix<FloatingPoint, 4, 4> buildProjectionMatrixPerspectiveFovRH(Floatin
2526

2627
return m;
2728
}
28-
template<typename FloatingPoint>
29+
template<typename FloatingPoint NBL_FUNC_REQUIRES(concepts::FloatingPoint<FloatingPoint>)
2930
inline matrix<FloatingPoint, 4, 4> buildProjectionMatrixPerspectiveFovLH(FloatingPoint fieldOfViewRadians, FloatingPoint aspectRatio, FloatingPoint zNear, FloatingPoint zFar)
3031
{
3132
const FloatingPoint h = core::reciprocal<FloatingPoint>(tan(fieldOfViewRadians * 0.5f));
@@ -43,7 +44,7 @@ inline matrix<FloatingPoint, 4, 4> buildProjectionMatrixPerspectiveFovLH(Floatin
4344
return m;
4445
}
4546

46-
template<typename FloatingPoint>
47+
template<typename FloatingPoint NBL_FUNC_REQUIRES(concepts::FloatingPoint<FloatingPoint>)
4748
inline matrix<FloatingPoint, 4, 4> buildProjectionMatrixOrthoRH(FloatingPoint widthOfViewVolume, FloatingPoint heightOfViewVolume, FloatingPoint zNear, FloatingPoint zFar)
4849
{
4950
_NBL_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); //division by zero
@@ -59,7 +60,7 @@ inline matrix<FloatingPoint, 4, 4> buildProjectionMatrixOrthoRH(FloatingPoint wi
5960
return m;
6061
}
6162

62-
template<typename FloatingPoint>
63+
template<typename FloatingPoint NBL_FUNC_REQUIRES(concepts::FloatingPoint<FloatingPoint>)
6364
inline matrix<FloatingPoint, 4, 4> buildProjectionMatrixOrthoLH(FloatingPoint widthOfViewVolume, FloatingPoint heightOfViewVolume, FloatingPoint zNear, FloatingPoint zFar)
6465
{
6566
_NBL_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); //division by zero

0 commit comments

Comments
 (0)