mirror of
https://github.com/brl/mutter.git
synced 2024-11-09 15:37:00 -05:00
cogl: Add 64 bit half-point pixel RGBA formats
In order to support the DRM formats DRM_FORMAT_ABGR16161616F and friends, as well as the wl_shm formats WL_SHM_FORMAT_ABGR16161616F and friends, cogl needs to have knowledge about said formats too. We don't have a software implementation of the half point data types however, so the pack/unpack methods remain unimplemented. We don't need them for now, so it's not crucial that we add them. For the GLES2 driver, currently only two formats are supported, and since we don't currently have pack/unpack implementations, the other formats will for now remain unsupported, until we have a half float implementation. https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
This commit is contained in:
parent
b191f89305
commit
6777a547ca
@ -351,6 +351,14 @@ _cogl_bitmap_needs_short_temp_buffer (CoglPixelFormat format)
|
||||
case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -323,6 +323,14 @@ G_PASTE (_cogl_unpack_abgr_2101010_, component_size) (const uint8_t *src,
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
G_PASTE (_cogl_unpack_argb_fp_16161616_, component_size) (const uint8_t *src,
|
||||
component_type *dst,
|
||||
int width)
|
||||
{
|
||||
g_warning ("Not implemented");
|
||||
}
|
||||
|
||||
#undef UNPACK_1
|
||||
#undef UNPACK_2
|
||||
#undef UNPACK_4
|
||||
@ -396,6 +404,16 @@ G_PASTE (_cogl_unpack_, component_size) (CoglPixelFormat format,
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||
G_PASTE (_cogl_unpack_abgr_2101010_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE:
|
||||
G_PASTE (_cogl_unpack_argb_fp_16161616_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_DEPTH_16:
|
||||
case COGL_PIXEL_FORMAT_DEPTH_32:
|
||||
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:
|
||||
@ -683,6 +701,14 @@ G_PASTE (_cogl_pack_abgr_2101010_, component_size) (const component_type *src,
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
G_PASTE (_cogl_pack_argb_fp_16161616_, component_size) (const component_type *src,
|
||||
uint8_t *dst,
|
||||
int width)
|
||||
{
|
||||
g_warning ("Not implemented");
|
||||
}
|
||||
|
||||
#undef PACK_SIZE
|
||||
#undef PACK_1
|
||||
#undef PACK_2
|
||||
@ -757,6 +783,16 @@ G_PASTE (_cogl_pack_, component_size) (CoglPixelFormat format,
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||
G_PASTE (_cogl_pack_abgr_2101010_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE:
|
||||
G_PASTE (_cogl_pack_argb_fp_16161616_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_DEPTH_16:
|
||||
case COGL_PIXEL_FORMAT_DEPTH_32:
|
||||
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:
|
||||
|
@ -245,6 +245,62 @@ static const CoglPixelFormatInfo format_info_table[] = {
|
||||
.aligned = 0,
|
||||
.bpp = { 4 },
|
||||
},
|
||||
{
|
||||
.cogl_format = COGL_PIXEL_FORMAT_RGBA_FP_16161616,
|
||||
.format_str = "RGBA_FP_16161616",
|
||||
.n_planes = 1,
|
||||
.bpp = { 8 },
|
||||
.aligned = 1
|
||||
},
|
||||
{
|
||||
.cogl_format = COGL_PIXEL_FORMAT_BGRA_FP_16161616,
|
||||
.format_str = "BGRA_FP_16161616",
|
||||
.n_planes = 1,
|
||||
.bpp = { 8 },
|
||||
.aligned = 1
|
||||
},
|
||||
{
|
||||
.cogl_format = COGL_PIXEL_FORMAT_ARGB_FP_16161616,
|
||||
.format_str = "ARGB_FP_16161616",
|
||||
.n_planes = 1,
|
||||
.bpp = { 8 },
|
||||
.aligned = 1
|
||||
},
|
||||
{
|
||||
.cogl_format = COGL_PIXEL_FORMAT_ABGR_FP_16161616,
|
||||
.format_str = "ABGR_FP_16161616",
|
||||
.n_planes = 1,
|
||||
.bpp = { 8 },
|
||||
.aligned = 1
|
||||
},
|
||||
{
|
||||
.cogl_format = COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE,
|
||||
.format_str = "RGBA_FP_16161616_PRE",
|
||||
.n_planes = 1,
|
||||
.bpp = { 8 },
|
||||
.aligned = 1
|
||||
},
|
||||
{
|
||||
.cogl_format = COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE,
|
||||
.format_str = "BGRA_FP_16161616_PRE",
|
||||
.n_planes = 1,
|
||||
.bpp = { 8 },
|
||||
.aligned = 1
|
||||
},
|
||||
{
|
||||
.cogl_format = COGL_PIXEL_FORMAT_ARGB_FP_16161616_PRE,
|
||||
.format_str = "ARGB_FP_16161616_PRE",
|
||||
.n_planes = 1,
|
||||
.bpp = { 8 },
|
||||
.aligned = 1
|
||||
},
|
||||
{
|
||||
.cogl_format = COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE,
|
||||
.format_str = "ABGR_FP_16161616_PRE",
|
||||
.n_planes = 1,
|
||||
.bpp = { 8 },
|
||||
.aligned = 1
|
||||
},
|
||||
{
|
||||
.cogl_format = COGL_PIXEL_FORMAT_DEPTH_16,
|
||||
.format_str = "DEPTH_16",
|
||||
|
@ -103,7 +103,7 @@ G_BEGIN_DECLS
|
||||
* 7 = YUV: undefined bpp, undefined alignment
|
||||
* 9 = 2 bpp, aligned
|
||||
* 10 = depth, aligned (8, 16, 24, 32, 32f)
|
||||
* 11 = undefined
|
||||
* 11 = 8 bpp fp16
|
||||
* 12 = 3 bpp, not aligned
|
||||
* 13 = 4 bpp, not aligned (e.g. 2101010)
|
||||
* 14-15 = undefined
|
||||
@ -168,6 +168,14 @@ G_BEGIN_DECLS
|
||||
* @COGL_PIXEL_FORMAT_BGRA_1010102_PRE: Premultiplied BGRA, 32 bits, 10 bpc
|
||||
* @COGL_PIXEL_FORMAT_ARGB_2101010_PRE: Premultiplied ARGB, 32 bits, 10 bpc
|
||||
* @COGL_PIXEL_FORMAT_ABGR_2101010_PRE: Premultiplied ABGR, 32 bits, 10 bpc
|
||||
* @COGL_PIXEL_FORMAT_RGBA_FP_16161616: RGBA half floating point, 64 bit
|
||||
* @COGL_PIXEL_FORMAT_BGRA_FP_16161616: BGRA half floating point, 64 bit
|
||||
* @COGL_PIXEL_FORMAT_ARGB_FP_16161616: ARGB half floating point, 64 bit
|
||||
* @COGL_PIXEL_FORMAT_ABGR_FP_16161616: ABGR half floating point, 64 bit
|
||||
* @COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE: Premultiplied RGBA half floating point, 64 bit
|
||||
* @COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE: Premultiplied BGRA half floating point, 64 bit
|
||||
* @COGL_PIXEL_FORMAT_ARGB_FP_16161616_PRE: Premultiplied ARGB half floating point, 64 bit
|
||||
* @COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE: Premultiplied ABGR half floating point, 64 bit
|
||||
*
|
||||
* Pixel formats used by Cogl. For the formats with a byte per
|
||||
* component, the order of the components specify the order in
|
||||
@ -216,6 +224,11 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
|
||||
COGL_PIXEL_FORMAT_ARGB_2101010 = (13 | COGL_A_BIT | COGL_AFIRST_BIT),
|
||||
COGL_PIXEL_FORMAT_ABGR_2101010 = (13 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
|
||||
|
||||
COGL_PIXEL_FORMAT_RGBA_FP_16161616 = (11 | COGL_A_BIT),
|
||||
COGL_PIXEL_FORMAT_BGRA_FP_16161616 = (11 | COGL_A_BIT | COGL_BGR_BIT),
|
||||
COGL_PIXEL_FORMAT_ARGB_FP_16161616 = (11 | COGL_A_BIT | COGL_AFIRST_BIT),
|
||||
COGL_PIXEL_FORMAT_ABGR_FP_16161616 = (11 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
|
||||
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT),
|
||||
COGL_PIXEL_FORMAT_BGRA_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT),
|
||||
COGL_PIXEL_FORMAT_ARGB_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_AFIRST_BIT),
|
||||
@ -228,6 +241,11 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
|
||||
COGL_PIXEL_FORMAT_ARGB_2101010_PRE = (COGL_PIXEL_FORMAT_ARGB_2101010 | COGL_PREMULT_BIT),
|
||||
COGL_PIXEL_FORMAT_ABGR_2101010_PRE = (COGL_PIXEL_FORMAT_ABGR_2101010 | COGL_PREMULT_BIT),
|
||||
|
||||
COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE = (11 | COGL_A_BIT | COGL_PREMULT_BIT),
|
||||
COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE = (11 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT),
|
||||
COGL_PIXEL_FORMAT_ARGB_FP_16161616_PRE = (11 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_AFIRST_BIT),
|
||||
COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE = (11 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
|
||||
|
||||
COGL_PIXEL_FORMAT_DEPTH_16 = (9 | COGL_DEPTH_BIT),
|
||||
COGL_PIXEL_FORMAT_DEPTH_32 = (3 | COGL_DEPTH_BIT),
|
||||
|
||||
|
@ -288,6 +288,31 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
||||
gltype = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
break;
|
||||
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE:
|
||||
glintformat = GL_RGBA;
|
||||
glformat = GL_RGBA;
|
||||
gltype = GL_HALF_FLOAT;
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE:
|
||||
glintformat = GL_RGBA;
|
||||
glformat = GL_BGRA;
|
||||
gltype = GL_HALF_FLOAT;
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616_PRE:
|
||||
glintformat = GL_RGBA;
|
||||
glformat = GL_BGRA;
|
||||
gltype = GL_HALF_FLOAT;
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE:
|
||||
glintformat = GL_RGBA;
|
||||
glformat = GL_RGBA;
|
||||
gltype = GL_HALF_FLOAT;
|
||||
break;
|
||||
|
||||
case COGL_PIXEL_FORMAT_DEPTH_16:
|
||||
glintformat = GL_DEPTH_COMPONENT16;
|
||||
glformat = GL_DEPTH_COMPONENT;
|
||||
|
@ -59,6 +59,9 @@
|
||||
#ifndef GL_UNSIGNED_INT_2_10_10_10_REV_EXT
|
||||
#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
|
||||
#endif
|
||||
#ifndef GL_HALF_FLOAT_OES
|
||||
#define GL_HALF_FLOAT_OES 0x8D61
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
_cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
|
||||
@ -207,6 +210,26 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
||||
gltype = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
break;
|
||||
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_ARGB_FP_16161616_PRE:
|
||||
case COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE:
|
||||
g_warning ("Unhandled 16 bpc pixel format used");
|
||||
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616:
|
||||
case COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE:
|
||||
if (!_cogl_has_private_feature
|
||||
(context, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_HALF_FLOAT))
|
||||
g_warning ("Missing 16 bpc half float extension");
|
||||
|
||||
glintformat = GL_RGBA;
|
||||
glformat = GL_RGBA;
|
||||
gltype = GL_HALF_FLOAT_OES;
|
||||
break;
|
||||
|
||||
case COGL_PIXEL_FORMAT_DEPTH_16:
|
||||
glintformat = GL_DEPTH_COMPONENT;
|
||||
glformat = GL_DEPTH_COMPONENT;
|
||||
|
Loading…
Reference in New Issue
Block a user