File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
include/nbl/builtin/hlsl/cpp_compat Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ int findLSB(NBL_CONST_REF_ARG(Integer) val)
149
149
}
150
150
151
151
template<typename Integer>
152
- int findMSB (NBL_CONST_REF_ARG (Integer) val)
152
+ inline int findMSB (NBL_CONST_REF_ARG (Integer) val)
153
153
{
154
154
#ifdef __HLSL_VERSION
155
155
if (is_signed_v<Integer>)
@@ -178,6 +178,40 @@ int findMSB(NBL_CONST_REF_ARG(Integer) val)
178
178
#endif
179
179
}
180
180
181
+ template<>
182
+ inline int findMSB<uint64_t>(NBL_CONST_REF_ARG (uint64_t) val)
183
+ {
184
+ #ifdef __HLSL_VERSION
185
+ uint32_t highBits = uint32_t (val >> 32 );
186
+ uint32_t lowBits = uint32_t (val);
187
+
188
+ int highBitsMSB = spirv::findUMsb (highBits);
189
+ if (highBitsMSB == -1 )
190
+ return spirv::findUMsb (lowBits);
191
+
192
+ return highBitsMSB;
193
+ #else
194
+ return glm::findMSB (val);
195
+ #endif
196
+ }
197
+
198
+ template<>
199
+ inline int findMSB<int64_t>(NBL_CONST_REF_ARG (int64_t) val)
200
+ {
201
+ #ifdef __HLSL_VERSION
202
+ int32_t highBits = int32_t (val >> 32 );
203
+ int32_t lowBits = int32_t (val);
204
+
205
+ int highBitsMSB = spirv::findSMsb (highBits);
206
+ if (highBitsMSB == -1 )
207
+ return spirv::findSMsb (lowBits);
208
+
209
+ return highBitsMSB;
210
+ #else
211
+ return glm::findMSB (val);
212
+ #endif
213
+ }
214
+
181
215
// TODO: some of the functions in this header should move to `tgmath`
182
216
template<typename T>
183
217
inline T floor (NBL_CONST_REF_ARG (T) val)
You can’t perform that action at this time.
0 commit comments