Skip to content

Commit 7528d4e

Browse files
committed
Another fix
1 parent 46ff7c8 commit 7528d4e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,20 @@ struct find_msb_helper<uint64_t>
106106
static int32_t findMSB(NBL_CONST_REF_ARG(uint64_t) val)
107107
{
108108
#ifdef __HLSL_VERSION
109-
const uint32_t lowBits = uint32_t(val);
110109
const uint32_t highBits = uint32_t(val >> 32);
110+
const int32_t highMsb = find_msb_helper<uint32_t>::findMSB(highBits);
111111

112-
const int32_t lowMsb = find_msb_helper<uint32_t>::findMSB(lowBits);
113-
if (lowMsb == -1)
112+
if (highMsb == -1)
114113
{
115-
const uint32_t highBits = uint32_t(val >> 32);
116-
const int32_t highMsb = find_msb_helper<uint32_t>::findMSB(highBits);
117-
if (highBits == -1)
114+
const uint32_t lowBits = uint32_t(val);
115+
const int32_t lowMsb = find_msb_helper<uint32_t>::findMSB(lowBits);
116+
if (lowMsb == -1)
118117
return -1;
119-
else
120-
return 32 + highMsb;
118+
119+
return lowMsb;
121120
}
122121

123-
return lowMsb;
122+
return highMsb + 32;
124123
#else
125124
return glm::findMSB(val);
126125
#endif
@@ -221,14 +220,13 @@ struct find_lsb_helper<uint64_t>
221220
{
222221
#ifdef __HLSL_VERSION
223222
const uint32_t lowBits = uint32_t(val);
224-
const uint32_t highBits = uint32_t(val >> 32);
225-
226223
const int32_t lowLsb = find_lsb_helper<uint32_t>::findLSB(lowBits);
224+
227225
if (lowLsb == -1)
228226
{
229227
const uint32_t highBits = uint32_t(val >> 32);
230228
const int32_t highLsb = find_lsb_helper<uint32_t>::findLSB(highBits);
231-
if (highBits == -1)
229+
if (highLsb == -1)
232230
return -1;
233231
else
234232
return 32 + highLsb;

0 commit comments

Comments
 (0)