mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
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>
This commit is contained in:
parent
9e8d32980a
commit
8d179c078d
@ -143,24 +143,24 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
|||||||
required_format = COGL_PIXEL_FORMAT_RGB_888;
|
required_format = COGL_PIXEL_FORMAT_RGB_888;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COGL_PIXEL_FORMAT_RGBA_1010102:
|
case COGL_PIXEL_FORMAT_ABGR_2101010:
|
||||||
case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
|
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
if (_cogl_has_private_feature
|
if (_cogl_has_private_feature
|
||||||
(context, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_RGBA1010102))
|
(context, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_RGBA1010102))
|
||||||
{
|
{
|
||||||
glintformat = GL_RGBA;
|
glintformat = GL_RGB10_A2_EXT;
|
||||||
glformat = GL_RGBA;
|
glformat = GL_RGBA;
|
||||||
gltype = GL_UNSIGNED_INT_2_10_10_10_REV_EXT;
|
gltype = GL_UNSIGNED_INT_2_10_10_10_REV_EXT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
G_GNUC_FALLTHROUGH;
|
G_GNUC_FALLTHROUGH;
|
||||||
#endif
|
#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:
|
||||||
case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
|
case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
|
||||||
case COGL_PIXEL_FORMAT_XBGR_2101010:
|
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_XRGB_2101010:
|
||||||
case COGL_PIXEL_FORMAT_ARGB_2101010:
|
case COGL_PIXEL_FORMAT_ARGB_2101010:
|
||||||
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||||
@ -168,10 +168,10 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
|||||||
if (_cogl_has_private_feature
|
if (_cogl_has_private_feature
|
||||||
(context, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_RGBA1010102))
|
(context, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_RGBA1010102))
|
||||||
{
|
{
|
||||||
glintformat = GL_RGBA;
|
glintformat = GL_RGB10_A2_EXT;
|
||||||
glformat = GL_RGBA;
|
glformat = GL_RGBA;
|
||||||
gltype = GL_UNSIGNED_INT_2_10_10_10_REV_EXT;
|
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);
|
required_format |= (format & COGL_PREMULT_BIT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user