cogl/pixel-format: Add G16 and RG1616 pixel formats

They are needed as "subformats" for higher bit YCbCr formats, such as
P010, and we don't plan to use or expose them otherwise. Thus don't
implement any conversion or packing features.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3244>
This commit is contained in:
Robert Mader 2023-09-04 21:27:03 +02:00
parent 4c5b2e0e48
commit 15320b5a66
9 changed files with 36 additions and 1 deletions

View File

@ -316,6 +316,8 @@ _cogl_bitmap_needs_short_temp_buffer (CoglPixelFormat format)
floats */ floats */
switch (format) switch (format)
{ {
case COGL_PIXEL_FORMAT_G_16:
case COGL_PIXEL_FORMAT_RG_1616:
case COGL_PIXEL_FORMAT_DEPTH_16: case COGL_PIXEL_FORMAT_DEPTH_16:
case COGL_PIXEL_FORMAT_DEPTH_32: case COGL_PIXEL_FORMAT_DEPTH_32:
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:

View File

@ -536,6 +536,8 @@ G_PASTE (_cogl_unpack_, component_size) (CoglPixelFormat format,
case COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE: case COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE:
G_PASTE (_cogl_unpack_argb_fp_16161616_, component_size) (src, dst, width); G_PASTE (_cogl_unpack_argb_fp_16161616_, component_size) (src, dst, width);
break; break;
case COGL_PIXEL_FORMAT_G_16:
case COGL_PIXEL_FORMAT_RG_1616:
case COGL_PIXEL_FORMAT_DEPTH_16: case COGL_PIXEL_FORMAT_DEPTH_16:
case COGL_PIXEL_FORMAT_DEPTH_32: case COGL_PIXEL_FORMAT_DEPTH_32:
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:
@ -1037,6 +1039,8 @@ G_PASTE (_cogl_pack_, component_size) (CoglPixelFormat format,
case COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE: case COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE:
G_PASTE (_cogl_pack_argb_fp_16161616_, component_size) (src, dst, width); G_PASTE (_cogl_pack_argb_fp_16161616_, component_size) (src, dst, width);
break; break;
case COGL_PIXEL_FORMAT_G_16:
case COGL_PIXEL_FORMAT_RG_1616:
case COGL_PIXEL_FORMAT_DEPTH_16: case COGL_PIXEL_FORMAT_DEPTH_16:
case COGL_PIXEL_FORMAT_DEPTH_32: case COGL_PIXEL_FORMAT_DEPTH_32:
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:

View File

@ -98,6 +98,13 @@ static const CoglPixelFormatInfo format_info_table[] = {
.aligned = 1, .aligned = 1,
.bpp = { 1 }, .bpp = { 1 },
}, },
{
.cogl_format = COGL_PIXEL_FORMAT_G_16,
.format_str = "G_16",
.n_planes = 1,
.aligned = 1,
.bpp = { 2 },
},
{ {
.cogl_format = COGL_PIXEL_FORMAT_RG_88, .cogl_format = COGL_PIXEL_FORMAT_RG_88,
.format_str = "RG_88", .format_str = "RG_88",
@ -105,6 +112,13 @@ static const CoglPixelFormatInfo format_info_table[] = {
.aligned = 1, .aligned = 1,
.bpp = { 2 }, .bpp = { 2 },
}, },
{
.cogl_format = COGL_PIXEL_FORMAT_RG_1616,
.format_str = "RG_1616",
.n_planes = 1,
.aligned = 1,
.bpp = { 4 },
},
{ {
.cogl_format = COGL_PIXEL_FORMAT_RGB_888, .cogl_format = COGL_PIXEL_FORMAT_RGB_888,
.format_str = "RGB_888", .format_str = "RGB_888",

View File

@ -105,7 +105,8 @@ G_BEGIN_DECLS
* 11 = 8 bpp fp16 * 11 = 8 bpp fp16
* 12 = 3 bpp, not aligned * 12 = 3 bpp, not aligned
* 13 = 4 bpp, not aligned (e.g. 2101010) * 13 = 4 bpp, not aligned (e.g. 2101010)
* 14-15 = undefined * 14 = 2 bpp, aligned (e.g. G_16)
* 15 = 4 bpp, aligned (e.g. RG_1616)
* *
* Note: the gap at 10-11 is just because we wanted to maintain that * Note: the gap at 10-11 is just because we wanted to maintain that
* all non-aligned formats have the third bit set in case that's * all non-aligned formats have the third bit set in case that's
@ -142,11 +143,13 @@ G_BEGIN_DECLS
* @COGL_PIXEL_FORMAT_RG_88: RG, 16 bits. Note that red-green textures * @COGL_PIXEL_FORMAT_RG_88: RG, 16 bits. Note that red-green textures
* are only available if %COGL_FEATURE_ID_TEXTURE_RG is advertised. * are only available if %COGL_FEATURE_ID_TEXTURE_RG is advertised.
* See cogl_texture_set_components() for details. * See cogl_texture_set_components() for details.
* @COGL_PIXEL_FORMAT_RG_1616: RG, 32 bits
* @COGL_PIXEL_FORMAT_RGB_565: RGB, 16 bits * @COGL_PIXEL_FORMAT_RGB_565: RGB, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_4444: RGBA, 16 bits * @COGL_PIXEL_FORMAT_RGBA_4444: RGBA, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_5551: RGBA, 16 bits * @COGL_PIXEL_FORMAT_RGBA_5551: RGBA, 16 bits
* @COGL_PIXEL_FORMAT_YUV: Not currently supported * @COGL_PIXEL_FORMAT_YUV: Not currently supported
* @COGL_PIXEL_FORMAT_G_8: Single luminance component * @COGL_PIXEL_FORMAT_G_8: Single luminance component
* @COGL_PIXEL_FORMAT_G_16: Single luminance component, 16 bits
* @COGL_PIXEL_FORMAT_RGB_888: RGB, 24 bits * @COGL_PIXEL_FORMAT_RGB_888: RGB, 24 bits
* @COGL_PIXEL_FORMAT_BGR_888: BGR, 24 bits * @COGL_PIXEL_FORMAT_BGR_888: BGR, 24 bits
* @COGL_PIXEL_FORMAT_RGBX_8888: RGBX, 32 bits * @COGL_PIXEL_FORMAT_RGBX_8888: RGBX, 32 bits
@ -213,8 +216,10 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT, COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT,
COGL_PIXEL_FORMAT_YUV = 7, COGL_PIXEL_FORMAT_YUV = 7,
COGL_PIXEL_FORMAT_G_8 = 8, COGL_PIXEL_FORMAT_G_8 = 8,
COGL_PIXEL_FORMAT_G_16 = 14,
COGL_PIXEL_FORMAT_RG_88 = 9, COGL_PIXEL_FORMAT_RG_88 = 9,
COGL_PIXEL_FORMAT_RG_1616 = 15,
COGL_PIXEL_FORMAT_RGB_888 = 2, COGL_PIXEL_FORMAT_RGB_888 = 2,
COGL_PIXEL_FORMAT_BGR_888 = (2 | COGL_BGR_BIT), COGL_PIXEL_FORMAT_BGR_888 = (2 | COGL_BGR_BIT),

View File

@ -377,6 +377,8 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
gltype = GL_UNSIGNED_INT_24_8; gltype = GL_UNSIGNED_INT_24_8;
break; break;
case COGL_PIXEL_FORMAT_G_16:
case COGL_PIXEL_FORMAT_RG_1616:
case COGL_PIXEL_FORMAT_ANY: case COGL_PIXEL_FORMAT_ANY:
case COGL_PIXEL_FORMAT_YUV: case COGL_PIXEL_FORMAT_YUV:
g_assert_not_reached (); g_assert_not_reached ();

View File

@ -452,6 +452,8 @@ _cogl_texture_driver_upload_supported (CoglContext *ctx,
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
case COGL_PIXEL_FORMAT_G_16:
case COGL_PIXEL_FORMAT_RG_1616:
case COGL_PIXEL_FORMAT_DEPTH_16: case COGL_PIXEL_FORMAT_DEPTH_16:
case COGL_PIXEL_FORMAT_DEPTH_32: case COGL_PIXEL_FORMAT_DEPTH_32:
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:

View File

@ -264,6 +264,8 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
gltype = GL_UNSIGNED_INT_24_8; gltype = GL_UNSIGNED_INT_24_8;
break; break;
case COGL_PIXEL_FORMAT_G_16:
case COGL_PIXEL_FORMAT_RG_1616:
case COGL_PIXEL_FORMAT_ANY: case COGL_PIXEL_FORMAT_ANY:
case COGL_PIXEL_FORMAT_YUV: case COGL_PIXEL_FORMAT_YUV:
g_assert_not_reached (); g_assert_not_reached ();

View File

@ -506,6 +506,8 @@ _cogl_texture_driver_upload_supported (CoglContext *ctx,
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
case COGL_PIXEL_FORMAT_G_16:
case COGL_PIXEL_FORMAT_RG_1616:
case COGL_PIXEL_FORMAT_DEPTH_16: case COGL_PIXEL_FORMAT_DEPTH_16:
case COGL_PIXEL_FORMAT_DEPTH_32: case COGL_PIXEL_FORMAT_DEPTH_32:
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:

View File

@ -40,7 +40,9 @@ static const CoglDrmFormatMap meta_cogl_drm_format_map[] = {
/* DRM formats are defined as little-endian, not machine endian. */ /* DRM formats are defined as little-endian, not machine endian. */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN #if G_BYTE_ORDER == G_LITTLE_ENDIAN
{ DRM_FORMAT_R8, COGL_PIXEL_FORMAT_G_8, META_MULTI_TEXTURE_FORMAT_INVALID }, { DRM_FORMAT_R8, COGL_PIXEL_FORMAT_G_8, META_MULTI_TEXTURE_FORMAT_INVALID },
{ DRM_FORMAT_R16, COGL_PIXEL_FORMAT_G_16, META_MULTI_TEXTURE_FORMAT_INVALID },
{ DRM_FORMAT_GR88, COGL_PIXEL_FORMAT_RG_88, META_MULTI_TEXTURE_FORMAT_INVALID }, { DRM_FORMAT_GR88, COGL_PIXEL_FORMAT_RG_88, META_MULTI_TEXTURE_FORMAT_INVALID },
{ DRM_FORMAT_GR1616, COGL_PIXEL_FORMAT_RG_1616, META_MULTI_TEXTURE_FORMAT_INVALID },
{ DRM_FORMAT_RGB565, COGL_PIXEL_FORMAT_RGB_565, META_MULTI_TEXTURE_FORMAT_SIMPLE }, { DRM_FORMAT_RGB565, COGL_PIXEL_FORMAT_RGB_565, META_MULTI_TEXTURE_FORMAT_SIMPLE },
{ DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_XBGR_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, { DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_XBGR_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE },
{ DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, { DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE },