Delete unused support for ETC1 texture compression

This commit is contained in:
Henrik Rydgård 2020-02-29 17:45:58 +01:00
parent b4111a9628
commit d35fd5040d
17 changed files with 18 additions and 2646 deletions

View File

@ -485,12 +485,6 @@ add_library(gason STATIC
ext/native/ext/gason/gason.h
)
add_library(rg_etc1 STATIC
ext/native/ext/rg_etc1/rg_etc1.cpp
ext/native/ext/rg_etc1/rg_etc1.h
)
include_directories(ext/native/ext/rg_etc1)
if(USE_FFMPEG)
if(NOT FFMPEG_DIR)
if(NOT USE_SYSTEM_FFMPEG)
@ -1082,7 +1076,7 @@ if(ANDROID)
set(ATOMIC_LIB atomic)
endif()
target_link_libraries(native ${LIBZIP_LIBRARY} ${PNG_LIBRARY} ${ZLIB_LIBRARY} rg_etc1 gason udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB})
target_link_libraries(native ${LIBZIP_LIBRARY} ${PNG_LIBRARY} ${ZLIB_LIBRARY} gason udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB})
if(TARGET Ext::GLEW)
target_link_libraries(native Ext::GLEW)
endif()

View File

@ -18,9 +18,7 @@
static Draw::DataFormat ZimToT3DFormat(int zim) {
switch (zim) {
case ZIM_ETC1: return Draw::DataFormat::ETC1;
case ZIM_RGBA8888: return Draw::DataFormat::R8G8B8A8_UNORM;
case ZIM_LUMINANCE: return Draw::DataFormat::R8_UNORM;
default: return Draw::DataFormat::R8G8B8A8_UNORM;
}
}

View File

@ -409,7 +409,6 @@
<ClInclude Include="..\..\ext\native\ext\libzip\config.h" />
<ClInclude Include="..\..\ext\native\ext\libzip\zip.h" />
<ClInclude Include="..\..\ext\native\ext\libzip\zipint.h" />
<ClInclude Include="..\..\ext\native\ext\rg_etc1\rg_etc1.h" />
<ClInclude Include="..\..\ext\native\ext\sha1\sha1.h" />
<ClInclude Include="..\..\ext\native\file\chunk_file.h" />
<ClInclude Include="..\..\ext\native\file\fd_util.h" />
@ -1454,7 +1453,6 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='UWP Gold|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\ext\native\ext\rg_etc1\rg_etc1.cpp" />
<ClCompile Include="..\..\ext\native\ext\sha1\sha1.cpp" />
<ClCompile Include="..\..\ext\native\file\chunk_file.cpp" />
<ClCompile Include="..\..\ext\native\file\fd_util.cpp" />
@ -1644,4 +1642,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -58,9 +58,6 @@
<Filter Include="ext\gason">
<UniqueIdentifier>{fb517d8e-e6c4-4eaf-a579-9970daa96541}</UniqueIdentifier>
</Filter>
<Filter Include="ext\rg_etc1">
<UniqueIdentifier>{6c81d960-607b-4da7-b114-a6c57dff4360}</UniqueIdentifier>
</Filter>
<Filter Include="ext\sha1">
<UniqueIdentifier>{b68fe6a0-b55f-4411-91f4-63ab1eaf47a3}</UniqueIdentifier>
</Filter>
@ -462,9 +459,6 @@
<ClCompile Include="..\..\ext\native\ext\gason\gason.cpp">
<Filter>ext\gason</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\ext\rg_etc1\rg_etc1.cpp">
<Filter>ext\rg_etc1</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\ext\sha1\sha1.cpp">
<Filter>ext\sha1</Filter>
</ClCompile>
@ -732,9 +726,6 @@
<ClInclude Include="..\..\ext\native\ext\gason\gason.h">
<Filter>ext\gason</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\ext\rg_etc1\rg_etc1.h">
<Filter>ext\rg_etc1</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\ext\sha1\sha1.h">
<Filter>ext\sha1</Filter>
</ClInclude>
@ -748,4 +739,4 @@
<Filter>gfx</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>

View File

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1022
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PPSSPPWindows", "PPSSPP.vcxproj", "{567AF8DB-42C1-4D08-96CD-D70A2DFEFC6B}"
ProjectSection(ProjectDependencies) = postProject
@ -329,16 +329,14 @@ Global
{FBE46262-7C2C-400C-92F9-F8A9E72594DD}.Release|Win32.ActiveCfg = Release|x64
{FBE46262-7C2C-400C-92F9-F8A9E72594DD}.Release|x64.ActiveCfg = Release|x64
{FBE46262-7C2C-400C-92F9-F8A9E72594DD}.Release|x64.Build.0 = Release|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Debug|ARM.ActiveCfg = Debug|Win32
{B7DED405-40A2-48F8-9382-538F10D442F1}.Debug|ARM64.ActiveCfg = Debug|Win32
{B7DED405-40A2-48F8-9382-538F10D442F1}.Debug|Win32.ActiveCfg = Debug|Win32
{B7DED405-40A2-48F8-9382-538F10D442F1}.Debug|Win32.Build.0 = Debug|Win32
{B7DED405-40A2-48F8-9382-538F10D442F1}.Debug|ARM.ActiveCfg = Debug|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Debug|ARM64.ActiveCfg = Debug|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Debug|Win32.ActiveCfg = Debug|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Debug|x64.ActiveCfg = Debug|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Debug|x64.Build.0 = Debug|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Release|ARM.ActiveCfg = Release|Win32
{B7DED405-40A2-48F8-9382-538F10D442F1}.Release|ARM64.ActiveCfg = Release|Win32
{B7DED405-40A2-48F8-9382-538F10D442F1}.Release|Win32.ActiveCfg = Release|Win32
{B7DED405-40A2-48F8-9382-538F10D442F1}.Release|Win32.Build.0 = Release|Win32
{B7DED405-40A2-48F8-9382-538F10D442F1}.Release|ARM.ActiveCfg = Release|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Release|ARM64.ActiveCfg = Release|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Release|Win32.ActiveCfg = Release|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Release|x64.ActiveCfg = Release|x64
{B7DED405-40A2-48F8-9382-538F10D442F1}.Release|x64.Build.0 = Release|x64
EndGlobalSection

View File

@ -15,7 +15,6 @@ LOCAL_SRC_FILES :=\
base/stringutil.cpp \
data/base64.cpp \
data/compression.cpp \
ext/rg_etc1/rg_etc1.cpp \
ext/cityhash/city.cpp \
ext/libpng17/png.c \
ext/libpng17/pngerror.c \

View File

@ -1,3 +0,0 @@
cmake_minimum_required(VERSION 2.6)
add_library(rg_etc1 rg_etc1.cpp)

File diff suppressed because it is too large Load Diff

View File

@ -1,76 +0,0 @@
// File: rg_etc1.h - Fast, high quality ETC1 block packer/unpacker - Rich Geldreich <richgel99@gmail.com>
// Please see ZLIB license at the end of this file.
#pragma once
namespace rg_etc1
{
// Unpacks an 8-byte ETC1 compressed block to a block of 4x4 32bpp RGBA pixels.
// Returns false if the block is invalid. Invalid blocks will still be unpacked with clamping.
// This function is thread safe, and does not dynamically allocate any memory.
// If preserve_alpha is true, the alpha channel of the destination pixels will not be overwritten. Otherwise, alpha will be set to 255.
bool unpack_etc1_block(const void *pETC1_block, unsigned int* pDst_pixels_rgba, int stride, bool preserve_alpha = false);
// Quality setting = the higher the quality, the slower.
// To pack large textures, it is highly recommended to call pack_etc1_block() in parallel, on different blocks, from multiple threads (particularly when using cHighQuality).
enum etc1_quality
{
cLowQuality,
cMediumQuality,
cHighQuality,
};
struct etc1_pack_params
{
etc1_quality m_quality;
bool m_dithering;
inline etc1_pack_params()
{
clear();
}
void clear()
{
m_quality = cHighQuality;
m_dithering = false;
}
};
// Important: pack_etc1_block_init() must be called before calling pack_etc1_block().
void pack_etc1_block_init();
// Packs a 4x4 block of 32bpp RGBA pixels to an 8-byte ETC1 block.
// 32-bit RGBA pixels must always be arranged as (R,G,B,A) (R first, A last) in memory, independent of platform endianness. A should always be 255.
// Returns squared error of result.
// This function is thread safe, and does not dynamically allocate any memory.
// pack_etc1_block() does not currently support "perceptual" colorspace metrics - it primarily optimizes for RGB RMSE.
unsigned int pack_etc1_block(void* pETC1_block, const unsigned int* pSrc_pixels_rgba, etc1_pack_params& pack_params);
} // namespace rg_etc1
//------------------------------------------------------------------------------
//
// rg_etc1 uses the ZLIB license:
// http://opensource.org/licenses/Zlib
//
// Copyright (c) 2012 Rich Geldreich
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
//------------------------------------------------------------------------------

View File

@ -75,15 +75,6 @@ int LoadZIMPtr(const uint8_t *zim, size_t datasize, int *width, int *height, int
case ZIM_RGB565:
image_data_size[i] = width[i] * height[i] * 2;
break;
case ZIM_ETC1:
{
int data_width = width[i];
int data_height = height[i];
if (data_width < 4) data_width = 4;
if (data_height < 4) data_height = 4;
image_data_size[i] = data_width * data_height / 2;
break;
}
default:
ELOG("Invalid ZIM format %i", *flags & ZIM_FORMAT_MASK);
return 0;

View File

@ -21,11 +21,6 @@ enum {
ZIM_RGBA8888 = 0, // Assumed format if no other format is set
ZIM_RGBA4444 = 1, // GL_UNSIGNED_SHORT_4_4_4_4
ZIM_RGB565 = 2, // GL_UNSIGNED_SHORT_5_6_5
ZIM_ETC1 = 3,
ZIM_RGB888 = 4,
ZIM_LUMINANCE_ALPHA = 5,
ZIM_LUMINANCE = 6,
ZIM_ALPHA = 7,
// There's space for plenty more formats.
ZIM_FORMAT_MASK = 15,
ZIM_HAS_MIPS = 16, // If set, assumes that a full mip chain is present. Mips are zlib-compressed individually and stored in sequence. Always half sized.
@ -48,4 +43,4 @@ enum {
// Watch out! If the image has mipmaps, multiple values will be written
// to width, height, and image, as if they were arrays, up to 12 (max texture size is 4096 which is 2^12).
int LoadZIM(const char *filename, int *width, int *height, int *flags, uint8_t **image);
int LoadZIMPtr(const uint8_t *zim, size_t datasize, int *width, int *height, int *flags, uint8_t **image);
int LoadZIMPtr(const uint8_t *zim, size_t datasize, int *width, int *height, int *flags, uint8_t **image);

View File

@ -2,7 +2,6 @@
#include <string.h>
#include <math.h>
#include "base/logging.h"
#include "ext/rg_etc1/rg_etc1.h"
#include "image/zim_save.h"
#include "zlib.h"
@ -100,43 +99,6 @@ void Convert(const uint8_t *image_data, int width, int height, int pitch, int fl
}
break;
}
case ZIM_ETC1: {
rg_etc1::pack_etc1_block_init();
rg_etc1::etc1_pack_params params;
params.m_dithering = false; //(flags & ZIM_ETC1_DITHER) != 0;
if (flags & ZIM_ETC1_LOW) {
params.m_quality = rg_etc1::cLowQuality;
} else if (flags & ZIM_ETC1_MEDIUM) {
params.m_quality = rg_etc1::cMediumQuality;
} else {
params.m_quality = rg_etc1::cHighQuality;
}
// Check for power of 2
if (!ispowerof2(width) || !ispowerof2(height)) {
FLOG("Image must have power of 2 dimensions, %ix%i just isn't that.", width, height);
}
// Convert RGBX to ETC1 before saving.
int blockw = width/4;
int blockh = height/4;
*data_size = blockw * blockh * 8;
*data = new uint8_t[*data_size];
#ifndef __ANDROID__
#pragma omp parallel for
#endif
for (int y = 0; y < blockh; y++) {
for (int x = 0; x < blockw; x++) {
uint32_t block[16];
for (int iy = 0; iy < 4; iy++) {
memcpy(block + 4 * iy, image_data + ((y * 4 + iy) * (pitch/4) + x * 4) * 4, 16);
}
rg_etc1::pack_etc1_block((*data) + (blockw * y + x) * 8, block, params);
}
}
width = blockw * 4;
height = blockh * 4;
break;
}
case ZIM_RGBA4444:
{
*data_size = width * height * 2;
@ -251,10 +213,6 @@ void SaveZIM(FILE *f, int width, int height, int pitch, int flags, const uint8_t
image_data = smaller;
width /= 2;
height /= 2;
if ((flags & ZIM_FORMAT_MASK) == ZIM_ETC1) {
if (width < 4) width = 4;
if (height < 4) height = 4;
}
pitch = width * 4;
}
}

View File

@ -410,7 +410,6 @@
<ClInclude Include="ext\libzip\config.h" />
<ClInclude Include="ext\libzip\zip.h" />
<ClInclude Include="ext\libzip\zipint.h" />
<ClInclude Include="ext\rg_etc1\rg_etc1.h" />
<ClInclude Include="ext\sha1\sha1.h" />
<ClInclude Include="file\chunk_file.h" />
<ClInclude Include="file\fd_util.h" />
@ -1122,7 +1121,6 @@
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="ext\rg_etc1\rg_etc1.cpp" />
<ClCompile Include="ext\sha1\sha1.cpp" />
<ClCompile Include="file\chunk_file.cpp" />
<ClCompile Include="file\fd_util.cpp" />

View File

@ -161,9 +161,6 @@
<ClInclude Include="ext\cityhash\citycrc.h">
<Filter>ext</Filter>
</ClInclude>
<ClInclude Include="ext\rg_etc1\rg_etc1.h">
<Filter>ext</Filter>
</ClInclude>
<ClInclude Include="thread\prioritizedworkqueue.h">
<Filter>thread</Filter>
</ClInclude>
@ -460,9 +457,6 @@
<ClCompile Include="ext\cityhash\city.cpp">
<Filter>ext</Filter>
</ClCompile>
<ClCompile Include="ext\rg_etc1\rg_etc1.cpp">
<Filter>ext</Filter>
</ClCompile>
<ClCompile Include="thread\prioritizedworkqueue.cpp">
<Filter>thread</Filter>
</ClCompile>

View File

@ -27,7 +27,6 @@ include_directories(..)
include_directories(../ext)
include_directories(../math/lin)
include_directories(../image)
include_directories(../ext/rg_etc1)
include_directories(/usr/local/include)
link_directories(/opt/local/lib)
@ -44,12 +43,11 @@ add_subdirectory(../file file)
add_subdirectory(../image image)
add_subdirectory(../math math)
add_subdirectory(../util util)
add_subdirectory(../ext/rg_etc1 rg_etc1)
add_subdirectory(../ext/libpng17 png17)
add_executable(atlastool atlastool.cpp)
target_link_libraries(atlastool freetype util image png17 z rg_etc1 file base)
target_link_libraries(atlastool freetype util image png17 z file base)
add_executable(zimtool zimtool.cpp)
target_link_libraries(zimtool freetype image png17 z rg_etc1 file base)
target_link_libraries(zimtool freetype image png17 z file base)

View File

@ -50,8 +50,7 @@
using namespace std;
static int global_id;
static bool etc1 = false;
static bool highcolor = false;
static bool highcolor = false; // Low color mode is used by PPGE, can't delete.
typedef unsigned short u16;
@ -786,10 +785,7 @@ int main(int argc, char **argv) {
}
CHECK(argc >= 3);
if (argc > 3) {
if (!strcmp(argv[3], "etc1")) {
printf("ETC1 enabled!\n");
etc1 = true;
} else if (!strcmp(argv[3], "8888")) {
if (!strcmp(argv[3], "8888")) {
highcolor = true;
printf("RGBA8888 enabled!\n");
}
@ -885,10 +881,7 @@ int main(int argc, char **argv) {
printf("Resolving...\n");
vector<Data> results = bucket.Resolve(image_width, dest);
if (etc1) {
printf("Writing .ZIM %ix%i ETC1...\n", dest.width(), dest.height());
dest.SaveZIM(image_name.c_str(), ZIM_ETC1 | ZIM_ZLIB_COMPRESSED);
} else if (highcolor) {
if (highcolor) {
printf("Writing .ZIM %ix%i RGBA8888...\n", dest.width(), dest.height());
dest.SaveZIM(image_name.c_str(), ZIM_RGBA8888 | ZIM_ZLIB_COMPRESSED);
} else {

View File

@ -11,7 +11,7 @@ char magic[5] = "ZIMG";
bool FLAGS_flip = false;
const char *format_strings[4] = { "8888", "4444", "565", "ETC1" };
int formats[4] = { ZIM_RGBA8888, ZIM_RGBA4444, ZIM_RGB565, ZIM_ETC1 };
int formats[3] = { ZIM_RGBA8888, ZIM_RGBA4444, ZIM_RGB565 };
void printusage() {
fprintf(stderr, "Usage: zimtool infile.png outfile.zim [-f=FORMAT] [-m] [-g]\n");
@ -72,12 +72,6 @@ int main(int argc, char **argv) {
}
// TODO: make setting?
flags |= ZIM_ETC1_MEDIUM;
if ((flags & ZIM_FORMAT_MASK) == ZIM_ETC1) {
if (flags & ZIM_GEN_MIPS) {
fprintf(stderr, "WARNING: Cannot generate ETC1 mips at runtime\n");
flags &= ~ZIM_GEN_MIPS;
}
}
if (!format_set) {
fprintf(stderr, "Must set format\n");
printusage();