summaryrefslogtreecommitdiff
path: root/thirdparty/etcpak/patches
diff options
context:
space:
mode:
authorK. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>2021-04-06 22:05:56 -0700
committerRémi Verschelde <rverschelde@gmail.com>2021-04-13 00:12:12 +0200
commitd840165a324b5c218ca3a4882f030986855c8383 (patch)
tree7c5f4b091ecc647f2b6ed48135945f84c6dc2de9 /thirdparty/etcpak/patches
parentb895071895cffcbcda7f4156d7175ba5b8068852 (diff)
Add `etcpak` library for faster ETC/ETC2/S3TC imports.
- `etc` module was renamed to `etcpak` and modified to use the new library. - PKM importer is removed in the process, it's obsolete. - Old library `etc2comp` is removed. - S3TC compression no longer done via `squish` (but decompression still is). - Slight modifications to etcpak sources for MinGW compatibility, to fix LLVM `-Wc++11-narrowing` errors, and to allow using vendored or system libpng. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'thirdparty/etcpak/patches')
-rw-r--r--thirdparty/etcpak/patches/libpng-unbundle.patch13
-rw-r--r--thirdparty/etcpak/patches/llvm-c++11-narrowing-errors.patch64
-rw-r--r--thirdparty/etcpak/patches/windows-mingw-fixes.patch63
3 files changed, 140 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/windows-mingw-fixes.patch b/thirdparty/etcpak/patches/windows-mingw-fixes.patch
new file mode 100644
index 0000000000..1da60e4a4f
--- /dev/null
+++ b/thirdparty/etcpak/patches/windows-mingw-fixes.patch
@@ -0,0 +1,63 @@
+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
+diff --git a/thirdparty/etcpak/System.cpp b/thirdparty/etcpak/System.cpp
+index 1383d0ecd0..a09b289cb2 100644
+--- a/thirdparty/etcpak/System.cpp
++++ b/thirdparty/etcpak/System.cpp
+@@ -35,7 +35,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 )