Skip to content

Commit f827f83

Browse files
author
rt
committed
remove ETC recompression
1 parent 31954d2 commit f827f83

File tree

4 files changed

+8
-48
lines changed

4 files changed

+8
-48
lines changed

rts/Map/SMF/SMFGroundTextures.cpp

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
#include <cmath>
55
#include <cstdlib>
66
#include <cstdio>
7-
#if defined(USE_LIBSQUISH) && !defined(HEADLESS)
8-
#include "lib/squish/squish.h"
9-
#include "lib/rg-etc1/rg_etc1.h"
10-
#endif
117

128
#include "SMFGroundTextures.h"
139
#include "SMFFormat.h"
@@ -167,16 +163,11 @@ void CSMFGroundTextures::LoadTiles(CSMFMapFile& file)
167163
swabDWordInPlace(tileMap[i]);
168164
}
169165

170-
#if defined(USE_LIBSQUISH) && !defined(HEADLESS) && defined(GLEW_ARB_ES3_compatibility)
171-
if (RecompressTilesIfNeeded()) {
172-
// Not all FOSS drivers support S3TC, use ETC1 for those if possible
173-
// ETC2 is backward compatible with ETC1! GLEW doesn't have the ETC1 extension :<
174-
tileTexFormat = GL_COMPRESSED_RGB8_ETC2;
175-
} else
176-
#endif
177-
{
178-
tileTexFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
179-
}
166+
// ETCx is nicer than S3TC (when in hardware) although it lacks alpha support,
167+
// but recompressing the DXT tiles has little benefit since FOSS drivers also
168+
// implement S3TC now
169+
// (recompression quality would have to be low anyway for performance reasons)
170+
tileTexFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
180171
}
181172

182173
void CSMFGroundTextures::LoadSquareTextures(const int mipLevel)
@@ -258,38 +249,6 @@ void CSMFGroundTextures::ConvolveHeightMap(const int mapWidth, const int mipLeve
258249
}
259250
}
260251

261-
#if defined(USE_LIBSQUISH) && !defined(HEADLESS) && defined(GLEW_ARB_ES3_compatibility)
262-
// Not all FOSS drivers support S3TC, use ETC1 for those if possible
263-
bool CSMFGroundTextures::RecompressTilesIfNeeded()
264-
{
265-
// if DXT1 is supported, we don't need to recompress
266-
if (GLEW_EXT_texture_compression_s3tc || GLEW_EXT_texture_compression_dxt1)
267-
return false;
268-
269-
// check if ETC1/2 is supported
270-
if (!GLEW_ARB_ES3_compatibility)
271-
return false;
272-
273-
// note 1: Mesa should support this
274-
// note 2: Nvidia supports ETC but preprocesses the texture (on the CPU) each upload = slow -> makes no sense to add it as another map compression format
275-
// note 3: for both DXT1 & ETC1/2 blocksize is 8 bytes per 4x4 pixel block -> perfect for us :)
276-
277-
loadscreen->SetLoadMessage("Recompressing Map Tiles with ETC1");
278-
Watchdog::ClearTimer(WDT_MAIN);
279-
280-
rg_etc1::pack_etc1_block_init();
281-
rg_etc1::etc1_pack_params pack_params;
282-
pack_params.m_quality = rg_etc1::cLowQuality; // must be low, all others take _ages_ to process
283-
284-
for_mt(0, tiles.size() / 8, [&](const int i) {
285-
squish::u8 rgba[64]; // 4x4 pixels * 4 * 1byte channels = 64byte
286-
squish::Decompress(rgba, &tiles[i * 8], squish::kDxt1);
287-
rg_etc1::pack_etc1_block(&tiles[i * 8], (const unsigned int*)rgba, pack_params);
288-
});
289-
290-
return true;
291-
}
292-
#endif
293252

294253
inline bool CSMFGroundTextures::TexSquareInView(int btx, int bty) const
295254
{

rts/Map/SMF/SMFGroundTextures.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class CSMFGroundTextures: public CBaseGroundTextures
2525
void LoadTiles(CSMFMapFile& file);
2626
void LoadSquareTextures(const int mipLevel);
2727
void ConvolveHeightMap(const int mapWidth, const int mipLevel);
28-
bool RecompressTilesIfNeeded();
2928
void ExtractSquareTiles(const int texSquareX, const int texSquareY, const int mipLevel, GLint* tileBuf) const;
3029
void LoadSquareTexture(int x, int y, int level);
3130

rts/Rendering/GlobalRendering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ void CGlobalRendering::CheckGLExtensions() const
555555
CHECK_EXT(GLEW_ARB_get_program_binary); // 4.1
556556

557557
CHECK_EXT(GLEW_ARB_texture_compression);
558+
CHECK_EXT(GLEW_EXT_texture_compression_s3tc);
559+
CHECK_EXT(GLEW_EXT_texture_compression_dxt1);
558560
CHECK_EXT(GLEW_ARB_texture_float); // 3.0 (FP{16,32} textures)
559561
CHECK_EXT(GLEW_ARB_texture_non_power_of_two); // 2.0 (NPOT textures)
560562
CHECK_EXT(GLEW_ARB_texture_rectangle); // 3.0 (rectangular textures)

rts/Rendering/Models/IModelParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ S3DModel* CModelLoader::CreateModel(
268268

269269
models.emplace_back();
270270
models.back() = std::move(model);
271-
return &models[model.id];
271+
return &(models.back());
272272
}
273273

274274

0 commit comments

Comments
 (0)