summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ã…dahl <jadahl@gmail.com>2022-10-10 09:20:36 +0200
committerMarge Bot <marge-bot@gnome.org>2022-12-17 23:12:34 +0000
commit8d179c078de6de97681224aea82d7de6a1563f2a (patch)
tree07406d1b2387a820f6231fda4c29cdb420f5290c
parent9e8d32980a17e6bb1a1995cf2436e3d099ad07f1 (diff)
downloadmutter-8d179c078de6de97681224aea82d7de6a1563f2a.tar.gz
cogl/driver/gles: Fix RGB10 GL formats
COGL_PIXEL_FORMAT_ABGR_2101010 is defined to mean the 2 A bits are placed in a 32 bit unsigned integer on the bits with highest significance, followed by B on the following 10 bits, and so on, until R on the 10 least significant bits. UNSIGNED_INT_2_10_10_10_REV_EXT is defined to represent color channels as ``` 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------- | a | b | g | r | ------------------------------------------------------------------------------------- ``` As can be seen, this matches COGL_PIXEL_FORMAT_ABGR_2101010, meaning that's the format we can directly read and write. In Cogl, when finding the GL formats, we get the tuple with the GL format given the format we pass, but we also get returned "required format" (CoglPixelFormat). This required format represents the format that is required when reading actual pixels from GLES. In GLES, the above mentioned format is the only one supported by the EXT_texture_type_2_10_10_10_REV extension, thus for other types, we need to do the CPU side conversion ourselves. To achieve this, correctly return COGL_PIXEL_FORMAT_ABGR_2101010 as the required format. The internal format should also be GL_RGB10_A2, not GL_RGBA. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2461>
-rw-r--r--cogl/cogl/driver/gl/gles/cogl-driver-gles.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index 0904f5a04..59cf0c07e 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -143,24 +143,24 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
required_format = COGL_PIXEL_FORMAT_RGB_888;
break;
- case COGL_PIXEL_FORMAT_RGBA_1010102:
- case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
+ case COGL_PIXEL_FORMAT_ABGR_2101010:
+ case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
if (_cogl_has_private_feature
(context, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_RGBA1010102))
{
- glintformat = GL_RGBA;
+ glintformat = GL_RGB10_A2_EXT;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_INT_2_10_10_10_REV_EXT;
break;
}
G_GNUC_FALLTHROUGH;
#endif
+ case COGL_PIXEL_FORMAT_RGBA_1010102:
+ case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
case COGL_PIXEL_FORMAT_BGRA_1010102:
case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
case COGL_PIXEL_FORMAT_XBGR_2101010:
- case COGL_PIXEL_FORMAT_ABGR_2101010:
- case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
case COGL_PIXEL_FORMAT_XRGB_2101010:
case COGL_PIXEL_FORMAT_ARGB_2101010:
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
@@ -168,10 +168,10 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
if (_cogl_has_private_feature
(context, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_RGBA1010102))
{
- glintformat = GL_RGBA;
+ glintformat = GL_RGB10_A2_EXT;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_INT_2_10_10_10_REV_EXT;
- required_format = COGL_PIXEL_FORMAT_RGBA_1010102;
+ required_format = COGL_PIXEL_FORMAT_ABGR_2101010;
required_format |= (format & COGL_PREMULT_BIT);
break;
}