More work on gles + texture compression.
Now it's usable with mesa, nvidia blob and in theory nvidia tegra too.
This commit is contained in:
@@ -44,6 +44,7 @@ void CentralVideoSettings::init()
|
||||
hasSSBO = false;
|
||||
hasImageLoadStore = false;
|
||||
hasTextureCompression = false;
|
||||
hasTextureCompressionSRGB = false;
|
||||
hasUBO = false;
|
||||
hasExplicitAttribLocation = false;
|
||||
hasGS = false;
|
||||
@@ -53,19 +54,12 @@ void CentralVideoSettings::init()
|
||||
hasSamplerObjects = false;
|
||||
hasVertexType2101010Rev = false;
|
||||
hasInstancedArrays = false;
|
||||
|
||||
#if defined(USE_GLES2)
|
||||
hasBGRA = false;
|
||||
hasColorBufferFloat = false;
|
||||
#endif
|
||||
m_need_vertex_id_workaround = false;
|
||||
|
||||
// Call to glGetIntegerv should not be made if --no-graphics is used
|
||||
if (!ProfileWorld::isNoGraphics())
|
||||
{
|
||||
|
||||
}
|
||||
if (!ProfileWorld::isNoGraphics())
|
||||
{
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &m_gl_major_version);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &m_gl_minor_version);
|
||||
@@ -193,6 +187,10 @@ void CentralVideoSettings::init()
|
||||
m_supports_sp = isARBInstancedArraysUsable() &&
|
||||
isARBVertexType2101010RevUsable() && isARBSamplerObjectsUsable() &&
|
||||
isARBExplicitAttribLocationUsable();
|
||||
|
||||
hasTextureCompressionSRGB = true;
|
||||
hasBGRA = true;
|
||||
hasColorBufferFloat = true;
|
||||
|
||||
#else
|
||||
if (m_glsl == true)
|
||||
@@ -234,11 +232,20 @@ void CentralVideoSettings::init()
|
||||
}
|
||||
|
||||
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_EXT_TEXTURE_COMPRESSION_S3TC) &&
|
||||
hasGLExtension("GL_EXT_texture_compression_s3tc"))
|
||||
(hasGLExtension("GL_EXT_texture_compression_s3tc") ||
|
||||
hasGLExtension("GL_ANGLE_texture_compression_dxt5")))
|
||||
{
|
||||
hasTextureCompression = true;
|
||||
Log::info("GLDriver", "EXT Texture Compression S3TC Present");
|
||||
}
|
||||
|
||||
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_EXT_TEXTURE_COMPRESSION_S3TC) &&
|
||||
(hasGLExtension("GL_EXT_texture_compression_s3tc_srgb") ||
|
||||
hasGLExtension("GL_NV_sRGB_formats")))
|
||||
{
|
||||
hasTextureCompressionSRGB = true;
|
||||
Log::info("GLDriver", "EXT Texture Compression S3TC sRGB Present");
|
||||
}
|
||||
|
||||
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_VERTEX_ID_WORKING))
|
||||
{
|
||||
@@ -322,6 +329,11 @@ bool CentralVideoSettings::isEXTTextureCompressionS3TCUsable() const
|
||||
return hasTextureCompression;
|
||||
}
|
||||
|
||||
bool CentralVideoSettings::isEXTTextureCompressionS3TCSRGBUsable() const
|
||||
{
|
||||
return hasTextureCompression && hasTextureCompressionSRGB;
|
||||
}
|
||||
|
||||
|
||||
bool CentralVideoSettings::isARBBufferStorageUsable() const
|
||||
{
|
||||
@@ -368,7 +380,6 @@ bool CentralVideoSettings::isEXTTextureFilterAnisotropicUsable() const
|
||||
return hasTextureFilterAnisotropic;
|
||||
}
|
||||
|
||||
#if defined(USE_GLES2)
|
||||
bool CentralVideoSettings::isEXTTextureFormatBGRA8888Usable() const
|
||||
{
|
||||
return hasBGRA;
|
||||
@@ -378,7 +389,6 @@ bool CentralVideoSettings::isEXTColorBufferFloatUsable() const
|
||||
{
|
||||
return hasColorBufferFloat;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CentralVideoSettings::supportsComputeShadersFiltering() const
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ private:
|
||||
bool hasExplicitAttribLocation;
|
||||
bool hasGS;
|
||||
bool hasTextureCompression;
|
||||
bool hasTextureCompressionSRGB;
|
||||
bool hasAtomics;
|
||||
bool hasSSBO;
|
||||
bool hasImageLoadStore;
|
||||
@@ -45,12 +46,8 @@ private:
|
||||
bool hasSamplerObjects;
|
||||
bool hasVertexType2101010Rev;
|
||||
bool hasInstancedArrays;
|
||||
|
||||
#if defined(USE_GLES2)
|
||||
bool hasBGRA;
|
||||
bool hasColorBufferFloat;
|
||||
#endif
|
||||
|
||||
bool m_need_vertex_id_workaround;
|
||||
public:
|
||||
static bool m_supports_sp;
|
||||
@@ -65,6 +62,7 @@ public:
|
||||
// Extension is available and safe to use
|
||||
bool isARBUniformBufferObjectUsable() const;
|
||||
bool isEXTTextureCompressionS3TCUsable() const;
|
||||
bool isEXTTextureCompressionS3TCSRGBUsable() const;
|
||||
bool isARBTextureViewUsable() const;
|
||||
bool isARBGeometryShadersUsable() const;
|
||||
bool isARBTextureStorageUsable() const;
|
||||
@@ -81,11 +79,8 @@ public:
|
||||
bool isARBSamplerObjectsUsable() const;
|
||||
bool isARBVertexType2101010RevUsable() const;
|
||||
bool isARBInstancedArraysUsable() const;
|
||||
|
||||
#if defined(USE_GLES2)
|
||||
bool isEXTTextureFormatBGRA8888Usable() const;
|
||||
bool isEXTColorBufferFloatUsable() const;
|
||||
#endif
|
||||
|
||||
// Are all required extensions available for feature support
|
||||
bool supportsComputeShadersFiltering() const;
|
||||
|
||||
@@ -92,7 +92,6 @@ RTT::RTT(unsigned int width, unsigned int height, float rtt_scale,
|
||||
GLint diffuse_specular_internal_format = GL_R11F_G11F_B10F;
|
||||
GLint type = GL_FLOAT;
|
||||
|
||||
#if defined(USE_GLES2)
|
||||
if (!CVS->isEXTColorBufferFloatUsable())
|
||||
{
|
||||
rgba_internal_format = GL_RGBA8;
|
||||
@@ -104,7 +103,7 @@ RTT::RTT(unsigned int width, unsigned int height, float rtt_scale,
|
||||
diffuse_specular_internal_format = GL_RGBA8;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!CVS->isDeferredEnabled())
|
||||
{
|
||||
// RTT is used in only deferred shading which need hdr framebuffer
|
||||
|
||||
@@ -123,10 +123,8 @@ void ShaderBasedRenderer::renderSkybox(const scene::ICameraSceneNode *camera) co
|
||||
// ----------------------------------------------------------------------------
|
||||
void ShaderBasedRenderer::renderSSAO() const
|
||||
{
|
||||
#if defined(USE_GLES2)
|
||||
if (!CVS->isEXTColorBufferFloatUsable())
|
||||
return;
|
||||
#endif
|
||||
|
||||
m_rtts->getFBO(FBO_SSAO).bind();
|
||||
glClearColor(1., 1., 1., 1.);
|
||||
|
||||
@@ -68,18 +68,26 @@ SPTexture::SPTexture(const std::string& path, Material* m, bool undo_srgb,
|
||||
return;
|
||||
}
|
||||
|
||||
std::string cache_subdir = "hd/";
|
||||
std::string cache_subdir = "hd";
|
||||
if ((UserConfigParams::m_high_definition_textures & 0x01) == 0x01)
|
||||
{
|
||||
cache_subdir = "hd/";
|
||||
cache_subdir = "hd";
|
||||
}
|
||||
else
|
||||
{
|
||||
cache_subdir = StringUtils::insertValues("resized_%i/",
|
||||
cache_subdir = StringUtils::insertValues("resized_%i",
|
||||
(int)UserConfigParams::m_max_texture_size);
|
||||
}
|
||||
|
||||
#ifdef USE_GLES2
|
||||
if (m_undo_srgb && !CVS->isEXTTextureCompressionS3TCSRGBUsable())
|
||||
{
|
||||
cache_subdir += "-linear";
|
||||
}
|
||||
#endif
|
||||
|
||||
m_cache_directory = file_manager->getCachedTexturesDir() +
|
||||
cache_subdir + container_id;
|
||||
cache_subdir + "/" + container_id;
|
||||
file_manager->checkAndCreateDirectoryP(m_cache_directory);
|
||||
|
||||
#endif
|
||||
@@ -204,7 +212,11 @@ std::shared_ptr<video::IImage> SPTexture::getTextureImage() const
|
||||
#ifndef USE_GLES2
|
||||
}
|
||||
#endif
|
||||
if (m_undo_srgb && !use_tex_compress)
|
||||
|
||||
bool force_undo_srgb = use_tex_compress &&
|
||||
!CVS->isEXTTextureCompressionS3TCSRGBUsable();
|
||||
|
||||
if (m_undo_srgb && (!use_tex_compress || force_undo_srgb))
|
||||
{
|
||||
data[i * 4] = srgb255ToLinear(data[i * 4]);
|
||||
data[i * 4 + 1] = srgb255ToLinear(data[i * 4 + 1]);
|
||||
@@ -223,7 +235,7 @@ bool SPTexture::compressedTexImage2d(std::shared_ptr<video::IImage> texture,
|
||||
{
|
||||
#if !defined(SERVER_ONLY) && !defined(ANDROID)
|
||||
unsigned format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
if (m_undo_srgb)
|
||||
if (m_undo_srgb && CVS->isEXTTextureCompressionS3TCSRGBUsable())
|
||||
{
|
||||
format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user