Bug 1486055 - Revendor ANGLE with popcnt on Windows+ARM fix.
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 28 Sep 2018 13:23:24 -0700
changeset 494570 8a7d0b7ce84eb68f2d9832d1bdd0d73103ff8aa9
parent 494569 909adfe5eaa7c22edbfd0d887349c42cd3943601
child 494571 4fb20c215e9c3ea771d8709c5912610d626edb3e
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1486055
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1486055 - Revendor ANGLE with popcnt on Windows+ARM fix.
gfx/angle/checkout/out/gen/angle/id/commit.h
gfx/angle/checkout/src/common/mathutil.cpp
gfx/angle/checkout/src/common/mathutil.h
gfx/angle/checkout/src/common/platform.h
gfx/angle/cherry_picks.txt
--- a/gfx/angle/checkout/out/gen/angle/id/commit.h
+++ b/gfx/angle/checkout/out/gen/angle/id/commit.h
@@ -1,3 +1,3 @@
-#define ANGLE_COMMIT_HASH "786e980807f1"
+#define ANGLE_COMMIT_HASH "4fb8d7f978ad"
 #define ANGLE_COMMIT_HASH_SIZE 12
-#define ANGLE_COMMIT_DATE "2018-09-25 17:58:13 -0700"
+#define ANGLE_COMMIT_DATE "2018-09-28 14:28:35 -0700"
--- a/gfx/angle/checkout/src/common/mathutil.cpp
+++ b/gfx/angle/checkout/src/common/mathutil.cpp
@@ -65,9 +65,20 @@ void convert999E5toRGBFloats(unsigned in
 {
     const RGB9E5Data *inputData = reinterpret_cast<const RGB9E5Data*>(&input);
 
     *red = inputData->R * pow(2.0f, (int)inputData->E - g_sharedexp_bias - g_sharedexp_mantissabits);
     *green = inputData->G * pow(2.0f, (int)inputData->E - g_sharedexp_bias - g_sharedexp_mantissabits);
     *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
--- a/gfx/angle/checkout/src/common/mathutil.h
+++ b/gfx/angle/checkout/src/common/mathutil.h
@@ -924,43 +924,65 @@ inline uint32_t BitfieldReverse(uint32_t
     for (size_t j = 0u; j < 32u; ++j)
     {
         result |= (((value >> j) & 1u) << (31u - j));
     }
     return result;
 }
 
 // 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);
 }
 #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));
 }
 
 inline int BitCount(uint16_t bits)
 {
     return BitCount(static_cast<uint32_t>(bits));
--- a/gfx/angle/checkout/src/common/platform.h
+++ b/gfx/angle/checkout/src/common/platform.h
@@ -4,17 +4,17 @@
 // found in the LICENSE file.
 //
 
 // platform.h: Operating system specific includes and defines.
 
 #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
 #   define ANGLE_PLATFORM_POSIX 1
 #elif defined(ANDROID)
 #   define ANGLE_PLATFORM_ANDROID 1
 #   define ANGLE_PLATFORM_POSIX 1
 #elif defined(__linux__) || defined(EMSCRIPTEN)
--- a/gfx/angle/cherry_picks.txt
+++ b/gfx/angle/cherry_picks.txt
@@ -1,8 +1,19 @@
+commit 4fb8d7f978adda36086377ea7846951faa9f6bd3
+Author: Jeff Gilbert <jgilbert@mozilla.com>
+Date:   Wed Sep 26 18:04:05 2018 -0700
+
+    Polyfill BitCount for ARM/ARM64 on MSVC.
+    
+    Also _WIN64 implies _WIN32.
+    
+    Bug: angleproject:2858
+    Change-Id: I63e2ffd2e9e304171ea6adb99836733981cc1813
+
 commit 786e980807f104d35bf31a769d31699024b89c2f
 Author: Jeff Gilbert <jgilbert@mozilla.com>
 Date:   Tue Sep 25 14:18:35 2018 -0700
 
     Stream support for R16*_UNORM and P010/P016.
     
     Bug: angleproject:2850
     Change-Id: Ib23b3012b5244c8e3edbdfa05d9b4e4869bbfed8