Check if drivers support BGRA texture format and fallback to RGBA
This commit is contained in:
parent
fb1c049906
commit
b0c0af8c46
@ -50,6 +50,10 @@ void CentralVideoSettings::init()
|
|||||||
hasExplicitAttribLocation = false;
|
hasExplicitAttribLocation = false;
|
||||||
hasGS = false;
|
hasGS = false;
|
||||||
|
|
||||||
|
#if defined(USE_GLES2)
|
||||||
|
hasBGRA = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_GI_has_artifact = false;
|
m_GI_has_artifact = false;
|
||||||
m_need_rh_workaround = false;
|
m_need_rh_workaround = false;
|
||||||
m_need_srgb_workaround = false;
|
m_need_srgb_workaround = false;
|
||||||
@ -218,6 +222,15 @@ void CentralVideoSettings::init()
|
|||||||
hasAtomics = true;
|
hasAtomics = true;
|
||||||
hasSSBO = true;
|
hasSSBO = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_TEXTURE_FORMAT_BGRA8888) &&
|
||||||
|
(hasGLExtension("GL_IMG_texture_format_BGRA8888") ||
|
||||||
|
hasGLExtension("GL_EXT_texture_format_BGRA8888")))
|
||||||
|
{
|
||||||
|
hasBGRA = true;
|
||||||
|
Log::info("GLDriver", "EXT texture format BGRA8888 Present");
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,6 +350,13 @@ bool CentralVideoSettings::isARBMultiDrawIndirectUsable() const
|
|||||||
return hasMultiDrawIndirect;
|
return hasMultiDrawIndirect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_GLES2)
|
||||||
|
bool CentralVideoSettings::isEXTTextureFormatBGRA8888Usable() const
|
||||||
|
{
|
||||||
|
return hasBGRA;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool CentralVideoSettings::supportsShadows() const
|
bool CentralVideoSettings::supportsShadows() const
|
||||||
{
|
{
|
||||||
return isARBGeometryShadersUsable() && isARBUniformBufferObjectUsable() && isARBExplicitAttribLocationUsable();
|
return isARBGeometryShadersUsable() && isARBUniformBufferObjectUsable() && isARBExplicitAttribLocationUsable();
|
||||||
|
@ -43,6 +43,10 @@ private:
|
|||||||
bool hasImageLoadStore;
|
bool hasImageLoadStore;
|
||||||
bool hasMultiDrawIndirect;
|
bool hasMultiDrawIndirect;
|
||||||
|
|
||||||
|
#if defined(USE_GLES2)
|
||||||
|
bool hasBGRA;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool m_need_rh_workaround;
|
bool m_need_rh_workaround;
|
||||||
bool m_need_srgb_workaround;
|
bool m_need_srgb_workaround;
|
||||||
bool m_need_srgb_visual_workaround;
|
bool m_need_srgb_visual_workaround;
|
||||||
@ -76,6 +80,10 @@ public:
|
|||||||
bool isARBMultiDrawIndirectUsable() const;
|
bool isARBMultiDrawIndirectUsable() const;
|
||||||
bool isARBExplicitAttribLocationUsable() const;
|
bool isARBExplicitAttribLocationUsable() const;
|
||||||
|
|
||||||
|
#if defined(USE_GLES2)
|
||||||
|
bool isEXTTextureFormatBGRA8888Usable() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Are all required extensions available for feature support
|
// Are all required extensions available for feature support
|
||||||
bool supportsShadows() const;
|
bool supportsShadows() const;
|
||||||
|
@ -57,6 +57,9 @@ namespace GraphicsRestrictions
|
|||||||
"TextureCompressionS3TC",
|
"TextureCompressionS3TC",
|
||||||
"AMDVertexShaderLayer",
|
"AMDVertexShaderLayer",
|
||||||
"ExplicitAttribLocation",
|
"ExplicitAttribLocation",
|
||||||
|
#if defined(USE_GLES2)
|
||||||
|
"TextureFormatBGRA8888",
|
||||||
|
#endif
|
||||||
"DriverRecentEnough",
|
"DriverRecentEnough",
|
||||||
"HighDefinitionTextures",
|
"HighDefinitionTextures",
|
||||||
"AdvancedPipeline",
|
"AdvancedPipeline",
|
||||||
|
@ -51,6 +51,9 @@ namespace GraphicsRestrictions
|
|||||||
GR_EXT_TEXTURE_COMPRESSION_S3TC,
|
GR_EXT_TEXTURE_COMPRESSION_S3TC,
|
||||||
GR_AMD_VERTEX_SHADER_LAYER,
|
GR_AMD_VERTEX_SHADER_LAYER,
|
||||||
GR_EXPLICIT_ATTRIB_LOCATION,
|
GR_EXPLICIT_ATTRIB_LOCATION,
|
||||||
|
#if defined(USE_GLES2)
|
||||||
|
GR_TEXTURE_FORMAT_BGRA8888,
|
||||||
|
#endif
|
||||||
GR_DRIVER_RECENT_ENOUGH,
|
GR_DRIVER_RECENT_ENOUGH,
|
||||||
GR_HIGHDEFINITION_TEXTURES,
|
GR_HIGHDEFINITION_TEXTURES,
|
||||||
GR_ADVANCED_PIPELINE,
|
GR_ADVANCED_PIPELINE,
|
||||||
|
@ -87,10 +87,20 @@ void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha)
|
|||||||
memcpy(data, tex->lock(), w * h * 4);
|
memcpy(data, tex->lock(), w * h * 4);
|
||||||
tex->unlock();
|
tex->unlock();
|
||||||
unsigned internalFormat, Format;
|
unsigned internalFormat, Format;
|
||||||
if (tex->hasAlpha())
|
Format = tex->hasAlpha() ? GL_BGRA : GL_BGR;
|
||||||
Format = GL_BGRA;
|
#if defined(USE_GLES2)
|
||||||
else
|
if (!CVS->isEXTTextureFormatBGRA8888Usable())
|
||||||
Format = GL_BGR;
|
{
|
||||||
|
Format = tex->hasAlpha() ? GL_RGBA : GL_RGB;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < w * h; i++)
|
||||||
|
{
|
||||||
|
char tmp_val = data[i*4];
|
||||||
|
data[i*4] = data[i*4 + 2];
|
||||||
|
data[i*4 + 2] = tmp_val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (premul_alpha)
|
if (premul_alpha)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user