Windows/MSVC build failure: __builtin_clzll is not available
Summary
RasterizeToPixelsFromWorld3DGS.cu uses __builtin_clzll inside ceil_log2_u64, but this builtin is not available when compiling with MSVC on Windows. This causes Windows builds to fail.
Relevant code
uint32_t ceil_log2_u64(uint64_t x) {
if (x <= 1) {
return 0;
}
return 64u - static_cast<uint32_t>(__builtin_clzll(x - 1));
}
Problem
__builtin_clzll is a GCC/Clang-specific builtin. On MSVC, the equivalent operation should use _BitScanReverse64 from <intrin.h>, or the code should use std::countl_zero when C++20 is available.
Suggested fix
One possible MSVC-compatible implementation is:
#if defined(_MSC_VER)
#include <intrin.h>
#endif
namespace {
uint32_t ceil_log2_u64(uint64_t x) {
if (x <= 1) {
return 0;
}
#if defined(_MSC_VER)
unsigned long index;
_BitScanReverse64(&index, x - 1);
return static_cast<uint32_t>(index) + 1u;
#else
return 64u - static_cast<uint32_t>(__builtin_clzll(x - 1));
#endif
}
} // namespace
This is equivalent because _BitScanReverse64 returns the zero-based index of the most significant set bit, while 64 - __builtin_clzll(v) returns the bit width of v.
Notes
The zero case is already handled by the x <= 1 guard, so _BitScanReverse64 is only called with a nonzero value.
Windows/MSVC build failure:
__builtin_clzllis not availableSummary
RasterizeToPixelsFromWorld3DGS.cuuses__builtin_clzllinsideceil_log2_u64, but this builtin is not available when compiling with MSVC on Windows. This causes Windows builds to fail.Relevant code
Problem
__builtin_clzllis a GCC/Clang-specific builtin. On MSVC, the equivalent operation should use_BitScanReverse64from<intrin.h>, or the code should usestd::countl_zerowhen C++20 is available.Suggested fix
One possible MSVC-compatible implementation is:
This is equivalent because
_BitScanReverse64returns the zero-based index of the most significant set bit, while64 - __builtin_clzll(v)returns the bit width ofv.Notes
The zero case is already handled by the
x <= 1guard, so_BitScanReverse64is only called with a nonzero value.