From ac483345c427069a033feeb0f9b0302d04787e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 12 Mar 2019 00:32:08 +0100 Subject: [PATCH] GLES2: Convert unsupported float texture types to 8-bit types --- drivers/gles2/rasterizer_storage_gles2.cpp | 75 ++++++++++++++-------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index afdb45d28ee..206679dda34 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -120,9 +120,13 @@ Ref RasterizerStorageGLES2::_get_gl_image_and_format(const Ref &p_ } break; case Image::FORMAT_RG8: { - - ERR_EXPLAIN("RG texture not supported"); - ERR_FAIL_V(image); + ERR_PRINT("RG texture not supported, converting to RGB8."); + if (image.is_valid()) + image->convert(Image::FORMAT_RGB8); + r_real_format = Image::FORMAT_RGB8; + r_gl_internal_format = GL_RGB; + r_gl_format = GL_RGB; + r_gl_type = GL_UNSIGNED_BYTE; } break; case Image::FORMAT_RGB8: { @@ -155,42 +159,57 @@ Ref RasterizerStorageGLES2::_get_gl_image_and_format(const Ref &p_ } break; case Image::FORMAT_RF: { if (!config.float_texture_supported) { - ERR_EXPLAIN("R float texture not supported"); - ERR_FAIL_V(image); + ERR_PRINT("R float texture not supported, converting to RGB8."); + if (image.is_valid()) + image->convert(Image::FORMAT_RGB8); + r_real_format = Image::FORMAT_RGB8; + r_gl_internal_format = GL_RGB; + r_gl_format = GL_RGB; + r_gl_type = GL_UNSIGNED_BYTE; + } else { + r_gl_internal_format = GL_ALPHA; + r_gl_format = GL_ALPHA; + r_gl_type = GL_FLOAT; } - - r_gl_internal_format = GL_ALPHA; - r_gl_format = GL_ALPHA; - r_gl_type = GL_FLOAT; } break; case Image::FORMAT_RGF: { - ERR_EXPLAIN("RG float texture not supported"); - ERR_FAIL_V(image); - + ERR_PRINT("RG float texture not supported, converting to RGB8."); + if (image.is_valid()) + image->convert(Image::FORMAT_RGB8); + r_real_format = Image::FORMAT_RGB8; + r_gl_internal_format = GL_RGB; + r_gl_format = GL_RGB; + r_gl_type = GL_UNSIGNED_BYTE; } break; case Image::FORMAT_RGBF: { if (!config.float_texture_supported) { - - ERR_EXPLAIN("RGB float texture not supported"); - ERR_FAIL_V(image); + ERR_PRINT("RGB float texture not supported, converting to RGB8."); + if (image.is_valid()) + image->convert(Image::FORMAT_RGB8); + r_real_format = Image::FORMAT_RGB8; + r_gl_internal_format = GL_RGB; + r_gl_format = GL_RGB; + r_gl_type = GL_UNSIGNED_BYTE; + } else { + r_gl_internal_format = GL_RGB; + r_gl_format = GL_RGB; + r_gl_type = GL_FLOAT; } - - r_gl_internal_format = GL_RGB; - r_gl_format = GL_RGB; - r_gl_type = GL_FLOAT; - } break; case Image::FORMAT_RGBAF: { if (!config.float_texture_supported) { - - ERR_EXPLAIN("RGBA float texture not supported"); - ERR_FAIL_V(image); + ERR_PRINT("RGBA float texture not supported, converting to RGBA8."); + if (image.is_valid()) + image->convert(Image::FORMAT_RGBA8); + r_real_format = Image::FORMAT_RGBA8; + r_gl_internal_format = GL_RGBA; + r_gl_format = GL_RGBA; + r_gl_type = GL_UNSIGNED_BYTE; + } else { + r_gl_internal_format = GL_RGBA; + r_gl_format = GL_RGBA; + r_gl_type = GL_FLOAT; } - - r_gl_internal_format = GL_RGBA; - r_gl_format = GL_RGBA; - r_gl_type = GL_FLOAT; - } break; case Image::FORMAT_RH: { need_decompress = true;