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