mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Expand workarounds for format inconsistency with BGRA8888 extension on GLES
fixes #16011
This commit is contained in:
parent
37d2bc8a5f
commit
cf07b56235
2 changed files with 17 additions and 9 deletions
|
@ -165,9 +165,8 @@ public:
|
|||
}
|
||||
|
||||
#ifndef IRR_COMPILE_GL_COMMON
|
||||
// On GLES 3.0 we must use sized internal formats for textures in certain
|
||||
// cases (e.g. with ETT_2D_MS). However ECF_A8R8G8B8 is mapped to GL_BGRA
|
||||
// (an unsized format).
|
||||
// On GLES 3.0 we must use sized internal formats for textures when calling
|
||||
// glTexStorage. But ECF_A8R8G8B8 might be mapped to GL_BGRA (an unsized format).
|
||||
// Since we don't upload to RTT we can safely pick a different combo that works.
|
||||
if (InternalFormat == GL_BGRA && Driver->Version.Major >= 3) {
|
||||
InternalFormat = GL_RGBA8;
|
||||
|
@ -271,7 +270,7 @@ public:
|
|||
// For OpenGL an array texture is basically just a 3D texture internally.
|
||||
// So if we call glGetTexImage() we would download the entire array,
|
||||
// except the caller only wants a single layer.
|
||||
// To do this properly we could have to use glGetTextureSubImage() [4.5]
|
||||
// To do this properly we could use glGetTextureSubImage() [4.5]
|
||||
// or some trickery with glTextureView() [4.3].
|
||||
// Also neither of those will work on GLES.
|
||||
|
||||
|
@ -522,10 +521,18 @@ protected:
|
|||
}
|
||||
|
||||
// reference: <https://www.khronos.org/opengl/wiki/Texture_Storage>
|
||||
bool use_tex_storage = Driver->getFeature().TexStorage;
|
||||
|
||||
#ifndef IRR_COMPILE_GL_COMMON
|
||||
// On GLES 3.0 if we don't have a sized format suitable for glTexStorage,
|
||||
// just avoid using it. Only affects the extension that provides BGRA.
|
||||
if (InternalFormat == GL_BGRA && Driver->Version.Major >= 3)
|
||||
use_tex_storage = false;
|
||||
#endif
|
||||
|
||||
switch (Type) {
|
||||
case ETT_2D:
|
||||
if (Driver->getFeature().TexStorage) {
|
||||
if (use_tex_storage) {
|
||||
GL.TexStorage2D(TextureType, levels, InternalFormat,
|
||||
Size.Width, Size.Height);
|
||||
} else {
|
||||
|
@ -541,6 +548,7 @@ protected:
|
|||
|
||||
// glTexImage2DMultisample is supported by OpenGL 3.2+
|
||||
// glTexStorage2DMultisample is supported by OpenGL 4.3+ and OpenGL ES 3.1+
|
||||
// so pick the most compatible one
|
||||
#ifdef IRR_COMPILE_GL_COMMON // legacy driver
|
||||
constexpr bool use_gl_impl = true;
|
||||
#else
|
||||
|
@ -557,7 +565,7 @@ protected:
|
|||
case ETT_CUBEMAP:
|
||||
for (u32 i = 0; i < 6; i++) {
|
||||
GLenum target = getTextureTarget(i);
|
||||
if (Driver->getFeature().TexStorage) {
|
||||
if (use_tex_storage) {
|
||||
GL.TexStorage2D(target, levels, InternalFormat,
|
||||
Size.Width, Size.Height);
|
||||
} else {
|
||||
|
@ -568,7 +576,7 @@ protected:
|
|||
}
|
||||
break;
|
||||
case ETT_2D_ARRAY:
|
||||
if (Driver->getFeature().TexStorage) {
|
||||
if (use_tex_storage) {
|
||||
GL.TexStorage3D(TextureType, levels, InternalFormat,
|
||||
Size.Width, Size.Height, layers);
|
||||
} else {
|
||||
|
|
|
@ -63,8 +63,8 @@ void COpenGLES2Driver::initFeatures()
|
|||
TextureFormats[ECF_D24S8] = {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8};
|
||||
|
||||
// NOTE a recent (2024) revision of EXT_texture_format_BGRA8888 also
|
||||
// adds a sized format GL_BGRA8_EXT. We have a workaround in place to
|
||||
// fix up the InternalFormat in case of render targets.
|
||||
// adds a sized format GL_BGRA8_EXT. Because we can't rely on that we
|
||||
// have stupid workarounds in place on texture creation...
|
||||
if (FeatureAvailable[IRR_GL_EXT_texture_format_BGRA8888] || FeatureAvailable[IRR_GL_APPLE_texture_format_BGRA8888])
|
||||
TextureFormats[ECF_A8R8G8B8] = {GL_BGRA, GL_BGRA, GL_UNSIGNED_BYTE};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue