Skip to content

Commit 18931dd

Browse files
committed
Roll back the GLSL bitreverse change, it was fine after all
1 parent 3359e34 commit 18931dd

File tree

1 file changed

+1
-8
lines changed
  • include/nbl/builtin/hlsl/glsl_compat

1 file changed

+1
-8
lines changed

include/nbl/builtin/hlsl/glsl_compat/core.hlsl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,10 @@ T bitfieldInsert(T base, T insert, uint32_t offset, uint32_t bits)
226226
return spirv::bitFieldInsert<T>(base, insert, offset, bits);
227227
}
228228

229-
// Spec requires this to return the bitreversal done with the amount of bits necessary to represent the number https://registry.khronos.org/OpenGL-Refpages/gl4/html/bitfieldReverse.xhtml
230229
template<typename T>
231230
T bitfieldReverse(T value)
232231
{
233-
using unsigned_t = typename make_unsigned<T>::type;
234-
// Bit-cast to uint to use the uint version of MSB
235-
unsigned_t unsignedCasted = spirv::bitcast<unsigned_t, T>(value);
236-
unsigned_t bits = findMSB(unsignedCasted);
237-
NBL_CONSTEXPR_STATIC_INLINE unsigned_t width = promote<unsigned_t, scalar_type_t<unsigned_t> >(scalar_type_t<unsigned_t>(sizeof(scalar_type_t<unsigned_t>)));
238-
// Do the shift in unsigned to ensure we do not get an arithmetic shift if signed, then cast back to original type
239-
return spirv::bitcast<T, unsigned_t>(spirv::bitReverse<unsigned_t>(unsignedCasted) >> (width - bits));
232+
return spirv::bitReverse(value);
240233
}
241234

242235
#endif

0 commit comments

Comments
 (0)