diff options
Diffstat (limited to 'thirdparty/etcpak/patches')
-rw-r--r-- | thirdparty/etcpak/patches/libpng-unbundle.patch | 13 | ||||
-rw-r--r-- | thirdparty/etcpak/patches/llvm-c++11-narrowing-errors.patch | 64 | ||||
-rw-r--r-- | thirdparty/etcpak/patches/pthread-setname.patch | 66 | ||||
-rw-r--r-- | thirdparty/etcpak/patches/windows-mingw-bswap.patch | 50 |
4 files changed, 193 insertions, 0 deletions
diff --git a/thirdparty/etcpak/patches/libpng-unbundle.patch b/thirdparty/etcpak/patches/libpng-unbundle.patch new file mode 100644 index 0000000000..e3c07412c6 --- /dev/null +++ b/thirdparty/etcpak/patches/libpng-unbundle.patch @@ -0,0 +1,13 @@ +diff --git a/thirdparty/etcpak/Bitmap.cpp b/thirdparty/etcpak/Bitmap.cpp +index 6aa36f5caa..ef318318ac 100644 +--- a/thirdparty/etcpak/Bitmap.cpp ++++ b/thirdparty/etcpak/Bitmap.cpp +@@ -3,7 +3,7 @@ + #include <string.h> + #include <assert.h> + +-#include "libpng/png.h" ++#include <png.h> + #include "lz4/lz4.h" + + #include "Bitmap.hpp" diff --git a/thirdparty/etcpak/patches/llvm-c++11-narrowing-errors.patch b/thirdparty/etcpak/patches/llvm-c++11-narrowing-errors.patch new file mode 100644 index 0000000000..ab0d1e63a2 --- /dev/null +++ b/thirdparty/etcpak/patches/llvm-c++11-narrowing-errors.patch @@ -0,0 +1,64 @@ +diff --git a/thirdparty/etcpak/BlockData.cpp b/thirdparty/etcpak/BlockData.cpp +index bd738085f3..395b55246b 100644 +--- a/thirdparty/etcpak/BlockData.cpp ++++ b/thirdparty/etcpak/BlockData.cpp +@@ -334,10 +334,10 @@ static etcpak_force_inline void DecodeT( uint64_t block, uint32_t* dst, uint32_t + const auto c3b = clampu8( cb1 - table59T58H[codeword] ); + + const uint32_t col_tab[4] = { +- cr0 | ( cg0 << 8 ) | ( cb0 << 16 ) | 0xFF000000, +- c2r | ( c2g << 8 ) | ( c2b << 16 ) | 0xFF000000, +- cr1 | ( cg1 << 8 ) | ( cb1 << 16 ) | 0xFF000000, +- c3r | ( c3g << 8 ) | ( c3b << 16 ) | 0xFF000000 ++ uint32_t(cr0 | ( cg0 << 8 ) | ( cb0 << 16 ) | 0xFF000000), ++ uint32_t(c2r | ( c2g << 8 ) | ( c2b << 16 ) | 0xFF000000), ++ uint32_t(cr1 | ( cg1 << 8 ) | ( cb1 << 16 ) | 0xFF000000), ++ uint32_t(c3r | ( c3g << 8 ) | ( c3b << 16 ) | 0xFF000000) + }; + + const uint32_t indexes = ( block >> 32 ) & 0xFFFFFFFF; +@@ -389,10 +389,10 @@ static etcpak_force_inline void DecodeTAlpha( uint64_t block, uint64_t alpha, ui + const auto c3b = clampu8( cb1 - table59T58H[codeword] ); + + const uint32_t col_tab[4] = { +- cr0 | ( cg0 << 8 ) | ( cb0 << 16 ), +- c2r | ( c2g << 8 ) | ( c2b << 16 ), +- cr1 | ( cg1 << 8 ) | ( cb1 << 16 ), +- c3r | ( c3g << 8 ) | ( c3b << 16 ) ++ uint32_t(cr0 | ( cg0 << 8 ) | ( cb0 << 16 )), ++ uint32_t(c2r | ( c2g << 8 ) | ( c2b << 16 )), ++ uint32_t(cr1 | ( cg1 << 8 ) | ( cb1 << 16 )), ++ uint32_t(c3r | ( c3g << 8 ) | ( c3b << 16 )) + }; + + const uint32_t indexes = ( block >> 32 ) & 0xFFFFFFFF; +@@ -436,10 +436,10 @@ static etcpak_force_inline void DecodeH( uint64_t block, uint32_t* dst, uint32_t + const auto codeword = codeword_hi | codeword_lo; + + const uint32_t col_tab[] = { +- clampu8( r0 + table59T58H[codeword] ) | ( clampu8( g0 + table59T58H[codeword] ) << 8 ) | ( clampu8( b0 + table59T58H[codeword] ) << 16 ), +- clampu8( r0 - table59T58H[codeword] ) | ( clampu8( g0 - table59T58H[codeword] ) << 8 ) | ( clampu8( b0 - table59T58H[codeword] ) << 16 ), +- clampu8( r1 + table59T58H[codeword] ) | ( clampu8( g1 + table59T58H[codeword] ) << 8 ) | ( clampu8( b1 + table59T58H[codeword] ) << 16 ), +- clampu8( r1 - table59T58H[codeword] ) | ( clampu8( g1 - table59T58H[codeword] ) << 8 ) | ( clampu8( b1 - table59T58H[codeword] ) << 16 ) ++ uint32_t(clampu8( r0 + table59T58H[codeword] ) | ( clampu8( g0 + table59T58H[codeword] ) << 8 ) | ( clampu8( b0 + table59T58H[codeword] ) << 16 )), ++ uint32_t(clampu8( r0 - table59T58H[codeword] ) | ( clampu8( g0 - table59T58H[codeword] ) << 8 ) | ( clampu8( b0 - table59T58H[codeword] ) << 16 )), ++ uint32_t(clampu8( r1 + table59T58H[codeword] ) | ( clampu8( g1 + table59T58H[codeword] ) << 8 ) | ( clampu8( b1 + table59T58H[codeword] ) << 16 )), ++ uint32_t(clampu8( r1 - table59T58H[codeword] ) | ( clampu8( g1 - table59T58H[codeword] ) << 8 ) | ( clampu8( b1 - table59T58H[codeword] ) << 16 )) + }; + + for( uint8_t j = 0; j < 4; j++ ) +@@ -483,10 +483,10 @@ static etcpak_force_inline void DecodeHAlpha( uint64_t block, uint64_t alpha, ui + const auto tbl = g_alpha[(alpha >> 48) & 0xF]; + + const uint32_t col_tab[] = { +- clampu8( r0 + table59T58H[codeword] ) | ( clampu8( g0 + table59T58H[codeword] ) << 8 ) | ( clampu8( b0 + table59T58H[codeword] ) << 16 ), +- clampu8( r0 - table59T58H[codeword] ) | ( clampu8( g0 - table59T58H[codeword] ) << 8 ) | ( clampu8( b0 - table59T58H[codeword] ) << 16 ), +- clampu8( r1 + table59T58H[codeword] ) | ( clampu8( g1 + table59T58H[codeword] ) << 8 ) | ( clampu8( b1 + table59T58H[codeword] ) << 16 ), +- clampu8( r1 - table59T58H[codeword] ) | ( clampu8( g1 - table59T58H[codeword] ) << 8 ) | ( clampu8( b1 - table59T58H[codeword] ) << 16 ) ++ uint32_t(clampu8( r0 + table59T58H[codeword] ) | ( clampu8( g0 + table59T58H[codeword] ) << 8 ) | ( clampu8( b0 + table59T58H[codeword] ) << 16 )), ++ uint32_t(clampu8( r0 - table59T58H[codeword] ) | ( clampu8( g0 - table59T58H[codeword] ) << 8 ) | ( clampu8( b0 - table59T58H[codeword] ) << 16 )), ++ uint32_t(clampu8( r1 + table59T58H[codeword] ) | ( clampu8( g1 + table59T58H[codeword] ) << 8 ) | ( clampu8( b1 + table59T58H[codeword] ) << 16 )), ++ uint32_t(clampu8( r1 - table59T58H[codeword] ) | ( clampu8( g1 - table59T58H[codeword] ) << 8 ) | ( clampu8( b1 - table59T58H[codeword] ) << 16 )) + }; + + for( uint8_t j = 0; j < 4; j++ ) diff --git a/thirdparty/etcpak/patches/pthread-setname.patch b/thirdparty/etcpak/patches/pthread-setname.patch new file mode 100644 index 0000000000..e2b009a1b3 --- /dev/null +++ b/thirdparty/etcpak/patches/pthread-setname.patch @@ -0,0 +1,66 @@ +diff --git a/thirdparty/etcpak/System.cpp b/thirdparty/etcpak/System.cpp +index 1383d0ecd0..041f2676e8 100644 +--- a/thirdparty/etcpak/System.cpp ++++ b/thirdparty/etcpak/System.cpp +@@ -2,7 +2,6 @@ + #ifdef _WIN32 + # include <windows.h> + #else +-# include <pthread.h> + # include <unistd.h> + #endif + +@@ -35,7 +34,7 @@ unsigned int System::CPUCores() + + void System::SetThreadName( std::thread& thread, const char* name ) + { +-#ifdef _WIN32 ++#ifdef _MSC_VER + const DWORD MS_VC_EXCEPTION=0x406D1388; + + # pragma pack( push, 8 ) +@@ -62,7 +61,5 @@ void System::SetThreadName( std::thread& thread, const char* name ) + __except(EXCEPTION_EXECUTE_HANDLER) + { + } +-#elif !defined(__APPLE__) +- pthread_setname_np( thread.native_handle(), name ); + #endif + } +diff --git a/thirdparty/etcpak/TaskDispatch.cpp b/thirdparty/etcpak/TaskDispatch.cpp +index 7287da4de2..b1ba17953b 100644 +--- a/thirdparty/etcpak/TaskDispatch.cpp ++++ b/thirdparty/etcpak/TaskDispatch.cpp +@@ -1,5 +1,8 @@ + #include <assert.h> + #include <stdio.h> ++#ifndef _MSC_VER ++#include <pthread.h> ++#endif + + #include "Debug.hpp" + #include "System.hpp" +@@ -22,15 +25,19 @@ TaskDispatch::TaskDispatch( size_t workers ) + { + char tmp[16]; + sprintf( tmp, "Worker %zu", i ); +-#ifdef __APPLE__ ++#ifdef _MSC_VER ++ auto worker = std::thread( [this]{ Worker(); } ); ++ System::SetThreadName( worker, tmp ); ++#else // Using pthread. + auto worker = std::thread( [this, tmp]{ ++#ifdef __APPLE__ + pthread_setname_np( tmp ); ++#else // Linux or MinGW. ++ pthread_setname_np( pthread_self(), tmp ); ++#endif + Worker(); + } ); +-#else +- auto worker = std::thread( [this]{ Worker(); } ); + #endif +- System::SetThreadName( worker, tmp ); + m_workers.emplace_back( std::move( worker ) ); + } + diff --git a/thirdparty/etcpak/patches/windows-mingw-bswap.patch b/thirdparty/etcpak/patches/windows-mingw-bswap.patch new file mode 100644 index 0000000000..c09192f573 --- /dev/null +++ b/thirdparty/etcpak/patches/windows-mingw-bswap.patch @@ -0,0 +1,50 @@ +diff --git a/thirdparty/etcpak/BlockData.cpp b/thirdparty/etcpak/BlockData.cpp +index a2cd032c5b..bd738085f3 100644 +--- a/thirdparty/etcpak/BlockData.cpp ++++ b/thirdparty/etcpak/BlockData.cpp +@@ -15,7 +15,7 @@ + # include <arm_neon.h> + #endif + +-#ifdef __SSE4_1__ ++#if defined __SSE4_1__ || defined __AVX2__ || defined _MSC_VER + # ifdef _MSC_VER + # include <intrin.h> + # include <Windows.h> +@@ -24,12 +24,6 @@ + # else + # include <x86intrin.h> + # endif +-#else +-# ifndef _MSC_VER +-# include <byteswap.h> +-# define _bswap(x) bswap_32(x) +-# define _bswap64(x) bswap_64(x) +-# endif + #endif + + #ifndef _bswap +diff --git a/thirdparty/etcpak/ProcessRGB.cpp b/thirdparty/etcpak/ProcessRGB.cpp +index 220d5c55e2..9dc5a78b67 100644 +--- a/thirdparty/etcpak/ProcessRGB.cpp ++++ b/thirdparty/etcpak/ProcessRGB.cpp +@@ -1,5 +1,6 @@ + #include <array> + #include <string.h> ++#include <limits> + + #ifdef __ARM_NEON + # include <arm_neon.h> +@@ -21,12 +22,6 @@ + # else + # include <x86intrin.h> + # endif +-#else +-# ifndef _MSC_VER +-# include <byteswap.h> +-# define _bswap(x) bswap_32(x) +-# define _bswap64(x) bswap_64(x) +-# endif + #endif + + #ifndef _bswap |