Allow to use texture compression with GLES when extension is available
This commit is contained in:
parent
fab05a54e8
commit
765d4019b7
@ -216,12 +216,12 @@ if (BUILD_RECORDER)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SERVER_ONLY AND NOT USE_GLES2)
|
||||
if(NOT SERVER_ONLY)
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/graphics_utils")
|
||||
include_directories("${PROJECT_SOURCE_DIR}/lib/graphics_utils")
|
||||
endif()
|
||||
|
||||
if(NOT SERVER_ONLY AND NOT USE_GLES2)
|
||||
if(NOT SERVER_ONLY)
|
||||
find_library(SQUISH_LIBRARY NAMES squish libsquish)
|
||||
find_path(SQUISH_INCLUDEDIR NAMES squish.h PATHS)
|
||||
if (NOT SQUISH_LIBRARY OR NOT SQUISH_INCLUDEDIR)
|
||||
@ -479,14 +479,12 @@ target_link_libraries(supertuxkart
|
||||
|
||||
if(NOT SERVER_ONLY)
|
||||
if(NOT USE_GLES2)
|
||||
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARIES} graphics_utils)
|
||||
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(supertuxkart GLESv2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SERVER_ONLY AND NOT USE_GLES2)
|
||||
target_link_libraries(supertuxkart ${SQUISH_LIBRARY})
|
||||
target_link_libraries(supertuxkart ${SQUISH_LIBRARY} graphics_utils)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
|
@ -33,6 +33,7 @@
|
||||
<card contains="ATI" os="windows" version="<=3.1.8787" disable="ForceLegacyDevice"/>
|
||||
<card os="android" disable="TextureFormatBGRA8888"/>
|
||||
<card os="android" disable="ColorBufferFloat"/>
|
||||
<card os="android" disable="TextureCompressionS3TC"/>
|
||||
<card contains="Adreno" os="android" version="<=19" disable="VertexIdWorking"/>
|
||||
<card contains="Android Emulator" os="android" disable="ForceLegacyDevice"/>
|
||||
<card contains="Android Emulator" os="android" disable="NpotTextures"/>
|
||||
|
@ -232,6 +232,13 @@ void CentralVideoSettings::init()
|
||||
hasColorBufferFloat = true;
|
||||
Log::info("GLDriver", "EXT Color Buffer Float Present");
|
||||
}
|
||||
|
||||
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_EXT_TEXTURE_COMPRESSION_S3TC) &&
|
||||
hasGLExtension("GL_EXT_texture_compression_s3tc"))
|
||||
{
|
||||
hasTextureCompression = true;
|
||||
Log::info("GLDriver", "EXT Texture Compression S3TC Present");
|
||||
}
|
||||
|
||||
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_VERTEX_ID_WORKING))
|
||||
{
|
||||
|
@ -29,14 +29,14 @@
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||
#if !(defined(SERVER_ONLY) || defined(ANDROID))
|
||||
#include <squish.h>
|
||||
static_assert(squish::kColourClusterFit == (1 << 5), "Wrong header");
|
||||
static_assert(squish::kColourRangeFit == (1 << 6), "Wrong header");
|
||||
static_assert(squish::kColourIterativeClusterFit == (1 << 8), "Wrong header");
|
||||
#endif
|
||||
|
||||
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||
#if !(defined(SERVER_ONLY) || defined(ANDROID))
|
||||
extern "C"
|
||||
{
|
||||
#include <mipmap/img.h>
|
||||
@ -46,7 +46,7 @@ extern "C"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
#if !defined(ANDROID)
|
||||
static const uint8_t CACHE_VERSION = 1;
|
||||
#endif
|
||||
|
||||
@ -221,7 +221,7 @@ bool SPTexture::compressedTexImage2d(std::shared_ptr<video::IImage> texture,
|
||||
<core::dimension2du, unsigned> >&
|
||||
mipmap_sizes)
|
||||
{
|
||||
#if !defined(SERVER_ONLY) && !defined(USE_GLES2)
|
||||
#if !defined(SERVER_ONLY) && !defined(ANDROID)
|
||||
unsigned format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
if (m_undo_srgb)
|
||||
{
|
||||
@ -319,7 +319,7 @@ bool SPTexture::saveCompressedTexture(std::shared_ptr<video::IImage> texture,
|
||||
<core::dimension2du, unsigned> >& sizes,
|
||||
const std::string& cache_location)
|
||||
{
|
||||
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||
#if !defined(SERVER_ONLY) && !defined(ANDROID)
|
||||
const unsigned total_size = std::accumulate(sizes.begin(), sizes.end(), 0,
|
||||
[] (const unsigned int previous, const std::pair
|
||||
<core::dimension2du, unsigned>& cur_sizes)
|
||||
@ -384,7 +384,7 @@ std::shared_ptr<video::IImage> SPTexture::getTextureCache(const std::string& p,
|
||||
std::vector<std::pair<core::dimension2du, unsigned> >* sizes)
|
||||
{
|
||||
std::shared_ptr<video::IImage> cache;
|
||||
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||
#if !(defined(SERVER_ONLY) || defined(ANDROID))
|
||||
io::IReadFile* file = irr::io::createReadFile(p.c_str());
|
||||
if (file == NULL)
|
||||
{
|
||||
@ -474,7 +474,7 @@ bool SPTexture::threadedLoad()
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef USE_GLES2
|
||||
#ifndef ANDROID
|
||||
if (UserConfigParams::m_hq_mipmap && image->getDimension().Width > 1 &&
|
||||
image->getDimension().Height > 1)
|
||||
{
|
||||
@ -672,7 +672,7 @@ void SPTexture::generateHQMipmap(void* in,
|
||||
<core::dimension2du, unsigned> >& mms,
|
||||
uint8_t* out)
|
||||
{
|
||||
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||
#if !(defined(SERVER_ONLY) || defined(ANDROID))
|
||||
imMipmapCascade cascade;
|
||||
imReduceOptions options;
|
||||
imReduceSetOptions(&options,
|
||||
@ -704,7 +704,7 @@ void SPTexture::generateHQMipmap(void* in,
|
||||
void SPTexture::squishCompressImage(uint8_t* rgba, int width, int height,
|
||||
int pitch, void* blocks, unsigned flags)
|
||||
{
|
||||
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||
#if !(defined(SERVER_ONLY) || defined(ANDROID))
|
||||
// This function is copied from CompressImage in libsquish to avoid omp
|
||||
// if enabled by shared libsquish, because we are already using
|
||||
// multiple thread
|
||||
@ -754,7 +754,7 @@ std::vector<std::pair<core::dimension2du, unsigned> >
|
||||
{
|
||||
std::vector<std::pair<core::dimension2du, unsigned> > mipmap_sizes;
|
||||
|
||||
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||
#if !(defined(SERVER_ONLY) || defined(ANDROID))
|
||||
unsigned width = image->getDimension().Width;
|
||||
unsigned height = image->getDimension().Height;
|
||||
mipmap_sizes.emplace_back(core::dimension2du(width, height), 0);
|
||||
|
Loading…
Reference in New Issue
Block a user