glgsg: Fixes to format selection in OpenGL renderbuffers

Fixes #1137
This commit is contained in:
rdb 2021-04-07 00:20:38 +02:00
parent bcb61fec09
commit ab4367ee7b

View File

@ -964,8 +964,26 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
} else { } else {
gl_format = GL_R16F; gl_format = GL_R16F;
} }
} else if (_fb_properties.get_color_bits() > 8 * 3) { } else if (_fb_properties.get_color_bits() > 10 * 3 ||
gl_format = GL_RGB16_EXT; _fb_properties.get_red_bits() > 10 ||
_fb_properties.get_green_bits() > 10 ||
_fb_properties.get_blue_bits() > 10) {
// 16-bit normalized.
if (_fb_properties.get_blue_bits() > 0 ||
_fb_properties.get_color_bits() == 1 ||
_fb_properties.get_color_bits() > 16 * 2) {
gl_format = GL_RGBA16;
} else if (_fb_properties.get_green_bits() > 0 ||
_fb_properties.get_color_bits() > 16) {
gl_format = GL_RG16;
} else {
gl_format = GL_R16;
}
} else if (_fb_properties.get_color_bits() > 8 * 3 ||
_fb_properties.get_red_bits() > 8 ||
_fb_properties.get_green_bits() > 8 ||
_fb_properties.get_blue_bits() > 8) {
gl_format = GL_RGB10_A2;
} else { } else {
gl_format = GL_RGB; gl_format = GL_RGB;
} }
@ -982,7 +1000,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
if (_fb_properties.get_color_bits() > 16 * 3) { if (_fb_properties.get_color_bits() > 16 * 3) {
gl_format = GL_RGBA32F_ARB; gl_format = GL_RGBA32F_ARB;
} else if (_fb_properties.get_color_bits() > 8 * 3) { } else if (_fb_properties.get_color_bits() > 8 * 3) {
gl_format = GL_RGBA16_EXT; gl_format = GL_RGBA16;
} else { } else {
gl_format = GL_RGBA; gl_format = GL_RGBA;
} }