Fix Cycles build in VS2022, use explicit two's complement in find_first_set()

Compiling Cycles in Visual Studio 2022 yields the error:
C4146: unary minus operator applied to unsigned type, result still unsigned

Replacing it with explicit two's complement achieves the same result as signed
negation but avoids the error.

Differential Revision: https://developer.blender.org/D16616
This commit is contained in:
Leszek Godlewski 2022-11-28 19:39:49 +01:00 committed by Brecht Van Lommel
parent 937130a294
commit 07d3a3962a
1 changed files with 1 additions and 1 deletions

View File

@ -860,7 +860,7 @@ ccl_device_inline uint find_first_set(uint x)
return (x != 0) ? ctz(x) + 1 : 0;
#else
# ifdef _MSC_VER
return (x != 0) ? (32 - count_leading_zeros(x & (-x))) : 0;
return (x != 0) ? (32 - count_leading_zeros(x & (~x + 1))) : 0;
# else
return __builtin_ffs(x);
# endif