cogl/gles: Use unsized internal formats for RGB8, RGBA8 in GLES 2.0
GLES 2.0 does not have RGB8 and RGBA8 as sized internal formats. There
is OES_rgb8_rgba8 which adds RGB8 and RGBA8 but only for
RenderbufferStorageOES and not for TexImage2D which I wrongly assumed.
It seems like there is currently no GLES2 extension which adds RGB8 and
RGBA8 to TexImage2D so we have no choice but to fall back to unsized
internal formats in those cases as long as we don't want to drop GLES2
support.
This should be fine in practice and we should get our 8bpc textures.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3680
Fixes: 7f943613a8
("cogl: Use sized internal renderable formats")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4036>
This commit is contained in:
parent
846fc458d3
commit
2ce64ac0c3
2 changed files with 20 additions and 15 deletions
|
@ -46,6 +46,7 @@ typedef enum
|
|||
COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL,
|
||||
COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_BGRA8888,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_SIZED_RGBA,
|
||||
COGL_PRIVATE_FEATURE_UNPACK_SUBIMAGE,
|
||||
COGL_PRIVATE_FEATURE_SAMPLER_OBJECTS,
|
||||
COGL_PRIVATE_FEATURE_READ_PIXELS_ANY_STRIDE,
|
||||
|
|
|
@ -134,10 +134,7 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
|||
* Sized formats from table 4.5:
|
||||
* RGBA4, RGB5_A1, RGB565
|
||||
*
|
||||
* More color-renderable formats from extensions:
|
||||
*
|
||||
* OES_rgb8_rgba8
|
||||
* adds RGB8, RGBA8 as color-renderable internal formats
|
||||
* More color-renderable formats for glTexImage2D from extensions:
|
||||
*
|
||||
* EXT_texture_format_BGRA8888
|
||||
* adds BGRA_EXT as internal and external color-renderable format
|
||||
|
@ -146,8 +143,9 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
|||
* adds R16F, RG16F (required EXT_texture_rg) and RGB16F, RGBA16F
|
||||
* as internal color-renderable formats
|
||||
*
|
||||
* => We require GLES 2 + OES_rgb8_rgba8 or GLES 3 which gives us at least:
|
||||
* RGB8, RGBA8, RGBA4, RGB5_A1, RGB565
|
||||
* This means we have no way to get sized internal formats for RGB8 and RGBA8
|
||||
* in GLES 2.0 and we have to fall back to non-sized internal formats but in
|
||||
* practice this should be fine.
|
||||
*/
|
||||
|
||||
/* For GLES 2 (not GLES 3) the glintformat and glformat have to match:
|
||||
|
@ -204,7 +202,12 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
|||
break;
|
||||
|
||||
case COGL_PIXEL_FORMAT_RGB_888:
|
||||
glintformat = GL_RGB8;
|
||||
if (_cogl_has_private_feature
|
||||
(context, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_SIZED_RGBA))
|
||||
glintformat = GL_RGB8;
|
||||
else
|
||||
glintformat = GL_RGB;
|
||||
|
||||
glformat = GL_RGB;
|
||||
gltype = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
@ -315,7 +318,11 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
|||
|
||||
case COGL_PIXEL_FORMAT_RGBA_8888:
|
||||
case COGL_PIXEL_FORMAT_RGBA_8888_PRE:
|
||||
glintformat = GL_RGBA8;
|
||||
if (_cogl_has_private_feature
|
||||
(context, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_SIZED_RGBA))
|
||||
glintformat = GL_RGBA8;
|
||||
else
|
||||
glintformat = GL_RGBA;
|
||||
glformat = GL_RGBA;
|
||||
gltype = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
@ -727,14 +734,11 @@ _cogl_driver_update_features (CoglContext *context,
|
|||
gl_minor,
|
||||
gl_extensions);
|
||||
|
||||
if (!_cogl_check_extension ("GL_OES_rgb8_rgba8", gl_extensions) &&
|
||||
!COGL_CHECK_GL_VERSION (gl_major, gl_minor, 3, 0))
|
||||
if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 3, 0))
|
||||
{
|
||||
g_set_error (error,
|
||||
COGL_DRIVER_ERROR,
|
||||
COGL_DRIVER_ERROR_INVALID_VERSION,
|
||||
"GL_OES_rgb8_rgba8 is required for GLES 2");
|
||||
return FALSE;
|
||||
/* unfortunately there is no GLES 2 ext which adds the equivalent */
|
||||
COGL_FLAGS_SET (private_features,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_SIZED_RGBA, TRUE);
|
||||
}
|
||||
|
||||
if (_cogl_check_extension ("GL_ANGLE_pack_reverse_row_order", gl_extensions))
|
||||
|
|
Loading…
Reference in a new issue