зеркало из https://github.com/AvaloniaUI/angle.git
Polyfill BitCount for ARM/ARM64 on MSVC.
Also _WIN64 implies _WIN32. Bug: angleproject:2858 Change-Id: I63e2ffd2e9e304171ea6adb99836733981cc1813 Reviewed-on: https://chromium-review.googlesource.com/1248441 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Родитель
e8dd079698
Коммит
c0b82333ab
|
@ -70,4 +70,15 @@ void convert999E5toRGBFloats(unsigned int input, float *red, float *green, float
|
|||
*blue = inputData->B * pow(2.0f, (int)inputData->E - g_sharedexp_bias - g_sharedexp_mantissabits);
|
||||
}
|
||||
|
||||
int BitCountPolyfill(uint32_t bits)
|
||||
{
|
||||
int ones = 0;
|
||||
while (bits)
|
||||
{
|
||||
ones += bool(bits & 1);
|
||||
bits >>= 1;
|
||||
}
|
||||
return ones;
|
||||
}
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
@ -929,26 +929,30 @@ inline uint32_t BitfieldReverse(uint32_t value)
|
|||
}
|
||||
|
||||
// Count the 1 bits.
|
||||
#if defined(ANGLE_PLATFORM_WINDOWS)
|
||||
#if defined(_M_IX86) || defined(_M_X64)
|
||||
#define ANGLE_HAS_BITCOUNT_32
|
||||
inline int BitCount(uint32_t bits)
|
||||
{
|
||||
return static_cast<int>(__popcnt(bits));
|
||||
}
|
||||
#if defined(ANGLE_IS_64_BIT_CPU)
|
||||
#if defined(_M_X64)
|
||||
#define ANGLE_HAS_BITCOUNT_64
|
||||
inline int BitCount(uint64_t bits)
|
||||
{
|
||||
return static_cast<int>(__popcnt64(bits));
|
||||
}
|
||||
#endif // defined(ANGLE_IS_64_BIT_CPU)
|
||||
#endif // defined(ANGLE_PLATFORM_WINDOWS)
|
||||
#endif // defined(_M_X64)
|
||||
#endif // defined(_M_IX86) || defined(_M_X64)
|
||||
|
||||
#if defined(ANGLE_PLATFORM_POSIX)
|
||||
#define ANGLE_HAS_BITCOUNT_32
|
||||
inline int BitCount(uint32_t bits)
|
||||
{
|
||||
return __builtin_popcount(bits);
|
||||
}
|
||||
|
||||
#if defined(ANGLE_IS_64_BIT_CPU)
|
||||
#define ANGLE_HAS_BITCOUNT_64
|
||||
inline int BitCount(uint64_t bits)
|
||||
{
|
||||
return __builtin_popcountll(bits);
|
||||
|
@ -956,6 +960,24 @@ inline int BitCount(uint64_t bits)
|
|||
#endif // defined(ANGLE_IS_64_BIT_CPU)
|
||||
#endif // defined(ANGLE_PLATFORM_POSIX)
|
||||
|
||||
int BitCountPolyfill(uint32_t bits);
|
||||
|
||||
#if !defined(ANGLE_HAS_BITCOUNT_32)
|
||||
inline int BitCount(const uint32_t bits)
|
||||
{
|
||||
return BitCountPolyfill(bits);
|
||||
}
|
||||
#endif // !defined(ANGLE_HAS_BITCOUNT_32)
|
||||
|
||||
#if !defined(ANGLE_HAS_BITCOUNT_64)
|
||||
inline int BitCount(const uint64_t bits)
|
||||
{
|
||||
return BitCount(static_cast<uint32_t>(bits >> 32)) + BitCount(static_cast<uint32_t>(bits));
|
||||
}
|
||||
#endif // !defined(ANGLE_HAS_BITCOUNT_64)
|
||||
#undef ANGLE_HAS_BITCOUNT_32
|
||||
#undef ANGLE_HAS_BITCOUNT_64
|
||||
|
||||
inline int BitCount(uint8_t bits)
|
||||
{
|
||||
return BitCount(static_cast<uint32_t>(bits));
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef COMMON_PLATFORM_H_
|
||||
#define COMMON_PLATFORM_H_
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#if defined(_WIN32)
|
||||
# define ANGLE_PLATFORM_WINDOWS 1
|
||||
#elif defined(__APPLE__)
|
||||
# define ANGLE_PLATFORM_APPLE 1
|
||||
|
|
Загрузка…
Ссылка в новой задаче