Skip to content

Commit 2f38f2a

Browse files
committed
Refactor
1 parent 5fd3934 commit 2f38f2a

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct dot_helper
2020
{
2121
using scalar_type = typename vector_traits<T>::scalar_type;
2222

23-
static inline scalar_type dot_product(NBL_CONST_REF_ARG(T) lhs, NBL_CONST_REF_ARG(T) rhs)
23+
static inline scalar_type __call(NBL_CONST_REF_ARG(T) lhs, NBL_CONST_REF_ARG(T) rhs)
2424
{
2525
static array_get<T, scalar_type> getter;
2626
scalar_type retval = getter(lhs, 0) * getter(rhs, 0);
@@ -40,7 +40,7 @@ struct dot_helper<vector<FLOAT_TYPE, N> >\
4040
using VectorType = vector<FLOAT_TYPE, N>;\
4141
using ScalarType = typename vector_traits<VectorType>::scalar_type;\
4242
\
43-
static inline ScalarType dot_product(NBL_CONST_REF_ARG(VectorType) lhs, NBL_CONST_REF_ARG(VectorType) rhs)\
43+
static inline ScalarType __call(NBL_CONST_REF_ARG(VectorType) lhs, NBL_CONST_REF_ARG(VectorType) rhs)\
4444
{\
4545
return RETURN_VALUE;\
4646
}\
@@ -65,7 +65,7 @@ struct find_msb_helper;
6565
template<>
6666
struct find_msb_helper<uint32_t>
6767
{
68-
static int32_t findMSB(NBL_CONST_REF_ARG(uint32_t) val)
68+
static int32_t __call(NBL_CONST_REF_ARG(uint32_t) val)
6969
{
7070
#ifdef __HLSL_VERSION
7171
return spirv::findUMsb(val);
@@ -78,7 +78,7 @@ struct find_msb_helper<uint32_t>
7878
template<>
7979
struct find_msb_helper<int32_t>
8080
{
81-
static int32_t findMSB(NBL_CONST_REF_ARG(int32_t) val)
81+
static int32_t __call(NBL_CONST_REF_ARG(int32_t) val)
8282
{
8383
#ifdef __HLSL_VERSION
8484
return spirv::findSMsb(val);
@@ -92,9 +92,9 @@ struct find_msb_helper<int32_t>
9292
template<>\
9393
struct find_msb_helper<INPUT_INTEGER_TYPE>\
9494
{\
95-
static int32_t findMSB(NBL_CONST_REF_ARG(INPUT_INTEGER_TYPE) val)\
95+
static int32_t __call(NBL_CONST_REF_ARG(INPUT_INTEGER_TYPE) val)\
9696
{\
97-
return find_msb_helper<INTEGER_TYPE>::findMSB(val);\
97+
return find_msb_helper<INTEGER_TYPE>::__call(val);\
9898
}\
9999
};\
100100

@@ -108,16 +108,16 @@ DEFINE_FIND_MSB_COMMON_SPECIALIZATION(uint8_t, uint32_t)
108108
template<>
109109
struct find_msb_helper<uint64_t>
110110
{
111-
static int32_t findMSB(NBL_CONST_REF_ARG(uint64_t) val)
111+
static int32_t __call(NBL_CONST_REF_ARG(uint64_t) val)
112112
{
113113
#ifdef __HLSL_VERSION
114114
const uint32_t highBits = uint32_t(val >> 32);
115-
const int32_t highMsb = find_msb_helper<uint32_t>::findMSB(highBits);
115+
const int32_t highMsb = find_msb_helper<uint32_t>::__call(highBits);
116116

117117
if (highMsb == -1)
118118
{
119119
const uint32_t lowBits = uint32_t(val);
120-
const int32_t lowMsb = find_msb_helper<uint32_t>::findMSB(lowBits);
120+
const int32_t lowMsb = find_msb_helper<uint32_t>::__call(lowBits);
121121
if (lowMsb == -1)
122122
return -1;
123123

@@ -134,7 +134,7 @@ struct find_msb_helper<uint64_t>
134134
template<int N>
135135
struct find_msb_helper<vector<uint32_t, N> >
136136
{
137-
static vector<int32_t, N> findMSB(NBL_CONST_REF_ARG(vector<uint32_t, N>) val)
137+
static vector<int32_t, N> __call(NBL_CONST_REF_ARG(vector<uint32_t, N>) val)
138138
{
139139
#ifdef __HLSL_VERSION
140140
return spirv::findUMsb(val);
@@ -147,7 +147,7 @@ struct find_msb_helper<vector<uint32_t, N> >
147147
template<int N>
148148
struct find_msb_helper<vector<int32_t, N> >
149149
{
150-
static vector<int32_t, N> findMSB(NBL_CONST_REF_ARG(vector<int32_t, N>) val)
150+
static vector<int32_t, N> __call(NBL_CONST_REF_ARG(vector<int32_t, N>) val)
151151
{
152152
#ifdef __HLSL_VERSION
153153
return spirv::findSMsb(val);
@@ -163,10 +163,10 @@ template<typename EnumType>
163163
requires std::is_enum_v<EnumType>
164164
struct find_msb_helper<EnumType>
165165
{
166-
static int32_t findMSB(NBL_CONST_REF_ARG(EnumType) val)
166+
static int32_t __call(NBL_CONST_REF_ARG(EnumType) val)
167167
{
168168
using underlying_t = std::underlying_type_t<EnumType>;
169-
return find_msb_helper<underlying_t>::findMSB(static_cast<underlying_t>(val));
169+
return find_msb_helper<underlying_t>::__call(static_cast<underlying_t>(val));
170170
}
171171
};
172172

@@ -178,7 +178,7 @@ struct find_lsb_helper;
178178
template<>
179179
struct find_lsb_helper<int32_t>
180180
{
181-
static int32_t findLSB(NBL_CONST_REF_ARG(int32_t) val)
181+
static int32_t __call(NBL_CONST_REF_ARG(int32_t) val)
182182
{
183183
#ifdef __HLSL_VERSION
184184
return spirv::findILsb(val);
@@ -191,7 +191,7 @@ struct find_lsb_helper<int32_t>
191191
template<>
192192
struct find_lsb_helper<uint32_t>
193193
{
194-
static int32_t findLSB(NBL_CONST_REF_ARG(uint32_t) val)
194+
static int32_t __call(NBL_CONST_REF_ARG(uint32_t) val)
195195
{
196196
#ifdef __HLSL_VERSION
197197
return spirv::findILsb(val);
@@ -205,9 +205,9 @@ struct find_lsb_helper<uint32_t>
205205
template<>\
206206
struct find_lsb_helper<INPUT_INTEGER_TYPE>\
207207
{\
208-
static int32_t findLSB(NBL_CONST_REF_ARG(INPUT_INTEGER_TYPE) val)\
208+
static int32_t __call(NBL_CONST_REF_ARG(INPUT_INTEGER_TYPE) val)\
209209
{\
210-
return find_lsb_helper<INTEGER_TYPE>::findLSB(val);\
210+
return find_lsb_helper<INTEGER_TYPE>::__call(val);\
211211
}\
212212
};\
213213

@@ -221,16 +221,16 @@ DEFINE_FIND_LSB_COMMON_SPECIALIZATION(uint8_t, uint32_t)
221221
template<>
222222
struct find_lsb_helper<uint64_t>
223223
{
224-
static int32_t findLSB(NBL_CONST_REF_ARG(uint64_t) val)
224+
static int32_t __call(NBL_CONST_REF_ARG(uint64_t) val)
225225
{
226226
#ifdef __HLSL_VERSION
227227
const uint32_t lowBits = uint32_t(val);
228-
const int32_t lowLsb = find_lsb_helper<uint32_t>::findLSB(lowBits);
228+
const int32_t lowLsb = find_lsb_helper<uint32_t>::__call(lowBits);
229229

230230
if (lowLsb == -1)
231231
{
232232
const uint32_t highBits = uint32_t(val >> 32);
233-
const int32_t highLsb = find_lsb_helper<uint32_t>::findLSB(highBits);
233+
const int32_t highLsb = find_lsb_helper<uint32_t>::__call(highBits);
234234
if (highLsb == -1)
235235
return -1;
236236
else
@@ -247,7 +247,7 @@ struct find_lsb_helper<uint64_t>
247247
template<int N>
248248
struct find_lsb_helper<vector<int32_t, N> >
249249
{
250-
static vector<int32_t, N> findLSB(NBL_CONST_REF_ARG(vector<int32_t, N>) val)
250+
static vector<int32_t, N> __call(NBL_CONST_REF_ARG(vector<int32_t, N>) val)
251251
{
252252
#ifdef __HLSL_VERSION
253253
return spirv::findILsb(val);
@@ -260,7 +260,7 @@ struct find_lsb_helper<vector<int32_t, N> >
260260
template<int N>
261261
struct find_lsb_helper<vector<uint32_t, N> >
262262
{
263-
static vector<int32_t, N> findLSB(NBL_CONST_REF_ARG(vector<uint32_t, N>) val)
263+
static vector<int32_t, N> __call(NBL_CONST_REF_ARG(vector<uint32_t, N>) val)
264264
{
265265
#ifdef __HLSL_VERSION
266266
return spirv::findILsb(val);
@@ -276,10 +276,10 @@ template<typename EnumType>
276276
requires std::is_enum_v<EnumType>
277277
struct find_lsb_helper<EnumType>
278278
{
279-
static int32_t findLSB(NBL_CONST_REF_ARG(EnumType) val)
279+
static int32_t __call(NBL_CONST_REF_ARG(EnumType) val)
280280
{
281281
using underlying_t = std::underlying_type_t<EnumType>;
282-
return find_lsb_helper<underlying_t>::findLSB(static_cast<underlying_t>(val));
282+
return find_lsb_helper<underlying_t>::__call(static_cast<underlying_t>(val));
283283
}
284284
};
285285

@@ -306,7 +306,7 @@ struct transpose_helper<matrix<T, N, M> >
306306
{
307307
using transposed_t = typename matrix_traits<matrix<T, N, M> >::transposed_type;
308308

309-
static transposed_t transpose(NBL_CONST_REF_ARG(matrix<T, N, M>) m)
309+
static transposed_t __call(NBL_CONST_REF_ARG(matrix<T, N, M>) m)
310310
{
311311
#ifdef __HLSL_VERSION
312312
return spirv::transpose(m);
@@ -319,7 +319,7 @@ struct transpose_helper<matrix<T, N, M> >
319319
template<typename LhsT, typename RhsT>
320320
struct mul_helper
321321
{
322-
static inline mul_output_t<LhsT, RhsT> multiply(LhsT lhs, RhsT rhs)
322+
static inline mul_output_t<LhsT, RhsT> __call(LhsT lhs, RhsT rhs)
323323
{
324324
return mul(lhs, rhs);
325325
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ T clamp(NBL_CONST_REF_ARG(T) val, NBL_CONST_REF_ARG(T) min, NBL_CONST_REF_ARG(T)
6161
template<typename T>
6262
typename vector_traits<T>::scalar_type dot(NBL_CONST_REF_ARG(T) lhs, NBL_CONST_REF_ARG(T) rhs)
6363
{
64-
return cpp_compat_intrinsics_impl::dot_helper<T>::dot_product(lhs, rhs);
64+
return cpp_compat_intrinsics_impl::dot_helper<T>::__call(lhs, rhs);
6565
}
6666

6767
// TODO: for clearer error messages, use concepts to ensure that input type is a square matrix
@@ -80,13 +80,13 @@ inline T determinant(NBL_CONST_REF_ARG(matrix<T, N, N>) m)
8080
template<typename Integer>
8181
inline typename cpp_compat_intrinsics_impl::find_lsb_return_type<Integer>::type findLSB(NBL_CONST_REF_ARG(Integer) val)
8282
{
83-
return cpp_compat_intrinsics_impl::find_lsb_helper<Integer>::findLSB(val);
83+
return cpp_compat_intrinsics_impl::find_lsb_helper<Integer>::__call(val);
8484
}
8585

8686
template<typename Integer>
8787
inline typename cpp_compat_intrinsics_impl::find_msb_return_type<Integer>::type findMSB(NBL_CONST_REF_ARG(Integer) val)
8888
{
89-
return cpp_compat_intrinsics_impl::find_msb_helper<Integer>::findMSB(val);
89+
return cpp_compat_intrinsics_impl::find_msb_helper<Integer>::__call(val);
9090
}
9191

9292
// TODO: for clearer error messages, use concepts to ensure that input type is a square matrix
@@ -105,14 +105,14 @@ inline matrix<T, N, N> inverse(NBL_CONST_REF_ARG(matrix<T, N, N>) m)
105105
template<typename Matrix>
106106
inline typename matrix_traits<Matrix>::transposed_type transpose(NBL_CONST_REF_ARG(Matrix) m)
107107
{
108-
return cpp_compat_intrinsics_impl::transpose_helper<Matrix>::transpose(m);
108+
return cpp_compat_intrinsics_impl::transpose_helper<Matrix>::__call(m);
109109
}
110110

111111
// TODO: concepts, to ensure that MatT is a matrix and VecT is a vector type
112112
template<typename LhsT, typename RhsT>
113113
mul_output_t<LhsT, RhsT> mul(LhsT mat, RhsT vec)
114114
{
115-
return cpp_compat_intrinsics_impl::mul_helper<LhsT, RhsT>::multiply(mat, vec);
115+
return cpp_compat_intrinsics_impl::mul_helper<LhsT, RhsT>::__call(mat, vec);
116116
}
117117

118118
template<typename T>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct lerp_helper;
2727
template<>\
2828
struct lerp_helper<TYPE, TYPE>\
2929
{\
30-
static inline TYPE lerp(NBL_CONST_REF_ARG(TYPE) x, NBL_CONST_REF_ARG(TYPE) y, NBL_CONST_REF_ARG(TYPE) a)\
30+
static inline TYPE __call(NBL_CONST_REF_ARG(TYPE) x, NBL_CONST_REF_ARG(TYPE) y, NBL_CONST_REF_ARG(TYPE) a)\
3131
{\
3232
return MIX_FUNCTION(x, y, a);\
3333
}\
@@ -36,7 +36,7 @@ struct lerp_helper<TYPE, TYPE>\
3636
template<int N>\
3737
struct lerp_helper<vector<TYPE, N>, vector<TYPE, N> >\
3838
{\
39-
static inline vector<TYPE, N> lerp(NBL_CONST_REF_ARG(vector<TYPE, N>) x, NBL_CONST_REF_ARG(vector<TYPE, N>) y, NBL_CONST_REF_ARG(vector<TYPE, N>) a)\
39+
static inline vector<TYPE, N> __call(NBL_CONST_REF_ARG(vector<TYPE, N>) x, NBL_CONST_REF_ARG(vector<TYPE, N>) y, NBL_CONST_REF_ARG(vector<TYPE, N>) a)\
4040
{\
4141
return MIX_FUNCTION(x, y, a);\
4242
}\
@@ -45,7 +45,7 @@ struct lerp_helper<vector<TYPE, N>, vector<TYPE, N> >\
4545
template<int N>\
4646
struct lerp_helper<vector<TYPE, N>, TYPE>\
4747
{\
48-
static inline vector<TYPE, N> lerp(NBL_CONST_REF_ARG(vector<TYPE, N>) x, NBL_CONST_REF_ARG(vector<TYPE, N>) y, NBL_CONST_REF_ARG(TYPE) a)\
48+
static inline vector<TYPE, N> __call(NBL_CONST_REF_ARG(vector<TYPE, N>) x, NBL_CONST_REF_ARG(vector<TYPE, N>) y, NBL_CONST_REF_ARG(TYPE) a)\
4949
{\
5050
return MIX_FUNCTION(x, y, a);\
5151
}\
@@ -60,7 +60,7 @@ DEFINE_LERP_HELPER_COMMON_SPECIALIZATION(float64_t)
6060
template<typename T>
6161
struct lerp_helper<T, bool>
6262
{
63-
static inline T lerp(NBL_CONST_REF_ARG(T) x, NBL_CONST_REF_ARG(T) y, NBL_CONST_REF_ARG(bool) a)
63+
static inline T __call(NBL_CONST_REF_ARG(T) x, NBL_CONST_REF_ARG(T) y, NBL_CONST_REF_ARG(bool) a)
6464
{
6565
if (a)
6666
return y;
@@ -74,7 +74,7 @@ struct lerp_helper<vector<T, N>, vector<bool, N> >
7474
{
7575
using output_vec_t = vector<T, N>;
7676

77-
static inline output_vec_t lerp(NBL_CONST_REF_ARG(output_vec_t) x, NBL_CONST_REF_ARG(output_vec_t) y, NBL_CONST_REF_ARG(vector<bool, N>) a)
77+
static inline output_vec_t __call(NBL_CONST_REF_ARG(output_vec_t) x, NBL_CONST_REF_ARG(output_vec_t) y, NBL_CONST_REF_ARG(vector<bool, N>) a)
7878
{
7979
output_vec_t retval;
8080
for (uint32_t i = 0; i < vector_traits<output_vec_t>::Dimension; i++)

include/nbl/builtin/hlsl/tgmath.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ inline Vector floor(NBL_CONST_REF_ARG(Vector) vec)
113113
template<typename T, typename U>
114114
inline T lerp(NBL_CONST_REF_ARG(T) x, NBL_CONST_REF_ARG(T) y, NBL_CONST_REF_ARG(U) a)
115115
{
116-
return tgmath_impl::lerp_helper<T, U>::lerp(x, y, a);
116+
return tgmath_impl::lerp_helper<T, U>::__call(x, y, a);
117117
}
118118

119119
template<typename FloatingPoint NBL_FUNC_REQUIRES(hlsl::is_floating_point_v<FloatingPoint>)

include/nbl/core/util/bitflag.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,18 @@ namespace nbl::hlsl::cpp_compat_intrinsics_impl
5959
template<typename ENUM_TYPE>
6060
struct find_lsb_helper<core::bitflag<ENUM_TYPE>>
6161
{
62-
static int32_t findLSB(NBL_CONST_REF_ARG(core::bitflag<ENUM_TYPE>) val)
62+
static int32_t __call(NBL_CONST_REF_ARG(core::bitflag<ENUM_TYPE>) val)
6363
{
64-
return find_lsb_helper<ENUM_TYPE>::findLSB(val.value);
64+
return find_lsb_helper<ENUM_TYPE>::__call(val.value);
6565
}
6666
};
6767

6868
template<typename ENUM_TYPE>
6969
struct find_msb_helper<core::bitflag<ENUM_TYPE>>
7070
{
71-
static int32_t findMSB(NBL_CONST_REF_ARG(core::bitflag<ENUM_TYPE>) val)
71+
static int32_t __call(NBL_CONST_REF_ARG(core::bitflag<ENUM_TYPE>) val)
7272
{
73-
return find_msb_helper<ENUM_TYPE>::findMSB(val.value);
73+
return find_msb_helper<ENUM_TYPE>::__call(val.value);
7474
}
7575
};
7676
}

0 commit comments

Comments
 (0)