Skip to content

Commit 01a8151

Browse files
committed
Move comparator_lt_t to binops.hlsl and create gt, gte, lte
1 parent 7978b9a commit 01a8151

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

include/nbl/builtin/hlsl/algorithm.hlsl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef _NBL_BUILTIN_HLSL_ALGORITHM_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_ALGORITHM_INCLUDED_
66

7+
#include "binops.hlsl"
8+
79
namespace nbl
810
{
911
namespace hlsl
@@ -109,27 +111,18 @@ uint upper_bound(inout Accessor accessor, const uint begin, const uint end, cons
109111
namespace impl
110112
{
111113

112-
template<typename T>
113-
struct comparator_lt_t
114-
{
115-
bool operator()(const T lhs, const T rhs)
116-
{
117-
return lhs<rhs;
118-
}
119-
};
120-
121114
// extra indirection due to https://github.com/microsoft/DirectXShaderCompiler/issues/4771
122115
template<class Accessor, typename T>
123116
uint lower_bound(inout Accessor accessor, const uint begin, const uint end, const T value)
124117
{
125-
using Comparator = impl::comparator_lt_t<T>;
118+
using Comparator = binops::comparator_lt_t<T>;
126119
Comparator comp;
127120
return nbl::hlsl::lower_bound<Accessor,Comparator>(accessor,begin,end,value,comp);
128121
}
129122
template<class Accessor, typename T>
130123
uint upper_bound(inout Accessor accessor, const uint begin, const uint end, const T value)
131124
{
132-
using Comparator = impl::comparator_lt_t<T>;
125+
using Comparator = binops::comparator_lt_t<T>;
133126
Comparator comp;
134127
return nbl::hlsl::upper_bound<Accessor,Comparator>(accessor,begin,end,value,comp);
135128
}

include/nbl/builtin/hlsl/binops.hlsl

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
// For conditions of distribution and use, see copyright notice in nabla.h
44
#ifndef _NBL_BUILTIN_HLSL_BINOPS_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_BINOPS_INCLUDED_
6-
// TODO (PentaKon): Should this file be renamed to binops.hlsl ?
76
// TODO (PentaKon): Should we move isNPoT from algorithm.hlsl to this file ?
87
namespace nbl
98
{
109
namespace hlsl
1110
{
12-
// TODO (PentaKon): NBL_GLSL_EVAL? Keep as macro or don't use at all?
1311
namespace binops
1412
{
1513
template<typename T>
@@ -66,6 +64,42 @@ struct max
6664
}
6765
};
6866

67+
template<typename T>
68+
struct comparator_lt_t
69+
{
70+
bool operator()(const T lhs, const T rhs)
71+
{
72+
return lhs<rhs;
73+
}
74+
};
75+
76+
template<typename T>
77+
struct comparator_gt_t
78+
{
79+
bool operator()(const T lhs, const T rhs)
80+
{
81+
return lhs>rhs;
82+
}
83+
};
84+
85+
template<typename T>
86+
struct comparator_lte_t
87+
{
88+
bool operator()(const T lhs, const T rhs)
89+
{
90+
return lhs<=rhs;
91+
}
92+
};
93+
94+
template<typename T>
95+
struct comparator_gte_t
96+
{
97+
bool operator()(const T lhs, const T rhs)
98+
{
99+
return lhs>=rhs;
100+
}
101+
};
102+
69103
}
70104
}
71105
}

0 commit comments

Comments
 (0)