cogl: Extend tests and fix RGB2101010 opaque formats
Notably fix several cases where bitmap packing was broken, resulting in visual corruption with the GLES2 backend. These were reproducible with the gradient-test from https://gitlab.freedesktop.org/jadahl/wayland-test-clients Also extend testing similar to the RGB8888 formats. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
This commit is contained in:
parent
f04209dcbf
commit
4097cbbb53
@ -329,7 +329,7 @@ G_PASTE (_cogl_unpack_rgba_1010102_, component_size) (const uint8_t *src,
|
||||
dst[2] = UNPACK_10 ((v >> 2) & 0x3ff);
|
||||
dst[3] = UNPACK_2 (v & 3);
|
||||
dst += 4;
|
||||
src += 2;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,7 +347,25 @@ G_PASTE (_cogl_unpack_bgra_1010102_, component_size) (const uint8_t *src,
|
||||
dst[0] = UNPACK_10 ((v >> 2) & 0x3ff);
|
||||
dst[3] = UNPACK_2 (v & 3);
|
||||
dst += 4;
|
||||
src += 2;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
G_PASTE (_cogl_unpack_xrgb_2101010_, component_size) (const uint8_t *src,
|
||||
component_type *dst,
|
||||
int width)
|
||||
{
|
||||
while (width-- > 0)
|
||||
{
|
||||
uint32_t v = *(const uint32_t *) src;
|
||||
|
||||
dst[3] = UNPACK_2 (0x3);
|
||||
dst[0] = UNPACK_10 ((v >> 20) & 0x3ff);
|
||||
dst[1] = UNPACK_10 ((v >> 10) & 0x3ff);
|
||||
dst[2] = UNPACK_10 (v & 0x3ff);
|
||||
dst += 4;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,7 +383,25 @@ G_PASTE (_cogl_unpack_argb_2101010_, component_size) (const uint8_t *src,
|
||||
dst[1] = UNPACK_10 ((v >> 10) & 0x3ff);
|
||||
dst[2] = UNPACK_10 (v & 0x3ff);
|
||||
dst += 4;
|
||||
src += 2;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
G_PASTE (_cogl_unpack_xbgr_2101010_, component_size) (const uint8_t *src,
|
||||
component_type *dst,
|
||||
int width)
|
||||
{
|
||||
while (width-- > 0)
|
||||
{
|
||||
uint32_t v = *(const uint32_t *) src;
|
||||
|
||||
dst[3] = UNPACK_2 (0x3);
|
||||
dst[2] = UNPACK_10 ((v >> 20) & 0x3ff);
|
||||
dst[1] = UNPACK_10 ((v >> 10) & 0x3ff);
|
||||
dst[0] = UNPACK_10 (v & 0x3ff);
|
||||
dst += 4;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,7 +419,7 @@ G_PASTE (_cogl_unpack_abgr_2101010_, component_size) (const uint8_t *src,
|
||||
dst[1] = UNPACK_10 ((v >> 10) & 0x3ff);
|
||||
dst[0] = UNPACK_10 (v & 0x3ff);
|
||||
dst += 4;
|
||||
src += 2;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,11 +509,15 @@ G_PASTE (_cogl_unpack_, component_size) (CoglPixelFormat format,
|
||||
G_PASTE (_cogl_unpack_bgra_1010102_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_XRGB_2101010:
|
||||
G_PASTE (_cogl_unpack_xrgb_2101010_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||
G_PASTE (_cogl_unpack_argb_2101010_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_XBGR_2101010:
|
||||
G_PASTE (_cogl_unpack_xbgr_2101010_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010:
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||
G_PASTE (_cogl_unpack_abgr_2101010_, component_size) (src, dst, width);
|
||||
@ -809,6 +849,24 @@ G_PASTE (_cogl_pack_bgra_1010102_, component_size) (const component_type *src,
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
G_PASTE (_cogl_pack_xrgb_2101010_, component_size) (const component_type *src,
|
||||
uint8_t *dst,
|
||||
int width)
|
||||
{
|
||||
while (width-- > 0)
|
||||
{
|
||||
uint32_t *v = (uint32_t *) dst;
|
||||
|
||||
*v = ((0x3 << 30) |
|
||||
(PACK_10 (src[0]) << 20) |
|
||||
(PACK_10 (src[1]) << 10) |
|
||||
PACK_10 (src[2]));
|
||||
src += 4;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
G_PASTE (_cogl_pack_argb_2101010_, component_size) (const component_type *src,
|
||||
uint8_t *dst,
|
||||
@ -827,6 +885,24 @@ G_PASTE (_cogl_pack_argb_2101010_, component_size) (const component_type *src,
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
G_PASTE (_cogl_pack_xbgr_2101010_, component_size) (const component_type *src,
|
||||
uint8_t *dst,
|
||||
int width)
|
||||
{
|
||||
while (width-- > 0)
|
||||
{
|
||||
uint32_t *v = (uint32_t *) dst;
|
||||
|
||||
*v = ((0x3 << 30) |
|
||||
(PACK_10 (src[2]) << 20) |
|
||||
(PACK_10 (src[1]) << 10) |
|
||||
PACK_10 (src[0]));
|
||||
src += 4;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
G_PASTE (_cogl_pack_abgr_2101010_, component_size) (const component_type *src,
|
||||
uint8_t *dst,
|
||||
@ -932,11 +1008,15 @@ G_PASTE (_cogl_pack_, component_size) (CoglPixelFormat format,
|
||||
G_PASTE (_cogl_pack_bgra_1010102_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_XRGB_2101010:
|
||||
G_PASTE (_cogl_pack_xrgb_2101010_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||
G_PASTE (_cogl_pack_argb_2101010_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_XBGR_2101010:
|
||||
G_PASTE (_cogl_pack_xbgr_2101010_, component_size) (src, dst, width);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010:
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||
G_PASTE (_cogl_pack_abgr_2101010_, component_size) (src, dst, width);
|
||||
|
@ -160,7 +160,9 @@ G_BEGIN_DECLS
|
||||
* @COGL_PIXEL_FORMAT_ABGR_8888: ABGR, 32 bits
|
||||
* @COGL_PIXEL_FORMAT_RGBA_1010102 : RGBA, 32 bits, 10 bpc
|
||||
* @COGL_PIXEL_FORMAT_BGRA_1010102 : BGRA, 32 bits, 10 bpc
|
||||
* @COGL_PIXEL_FORMAT_XRGB_2101010 : XRGB, 32 bits, 10 bpc
|
||||
* @COGL_PIXEL_FORMAT_ARGB_2101010 : ARGB, 32 bits, 10 bpc
|
||||
* @COGL_PIXEL_FORMAT_XBGR_2101010 : XBGR, 32 bits, 10 bpc
|
||||
* @COGL_PIXEL_FORMAT_ABGR_2101010 : ABGR, 32 bits, 10 bpc
|
||||
* @COGL_PIXEL_FORMAT_RGBA_8888_PRE: Premultiplied RGBA, 32 bits
|
||||
* @COGL_PIXEL_FORMAT_BGRA_8888_PRE: Premultiplied BGRA, 32 bits
|
||||
|
@ -271,6 +271,10 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
||||
break;
|
||||
|
||||
case COGL_PIXEL_FORMAT_XBGR_2101010:
|
||||
glintformat = GL_RGB;
|
||||
glformat = GL_RGBA;
|
||||
gltype = GL_UNSIGNED_INT_2_10_10_10_REV;
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010:
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||
glintformat = GL_RGBA;
|
||||
@ -279,6 +283,10 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
|
||||
break;
|
||||
|
||||
case COGL_PIXEL_FORMAT_XRGB_2101010:
|
||||
glintformat = GL_RGB;
|
||||
glformat = GL_BGRA;
|
||||
gltype = GL_UNSIGNED_INT_2_10_10_10_REV;
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||
glintformat = GL_RGBA;
|
||||
|
@ -55,17 +55,19 @@ test_offscreen_texture_formats_store_rgb10 (void)
|
||||
const int rgb10_red = 514;
|
||||
const int rgb10_green = 258;
|
||||
const int rgb10_blue = 18;
|
||||
const int rgb10_alpha = 2;
|
||||
float red;
|
||||
float green;
|
||||
float blue;
|
||||
float alpha;
|
||||
GError *error = NULL;
|
||||
CoglPixelFormat formats[] = {
|
||||
COGL_PIXEL_FORMAT_ABGR_2101010,
|
||||
COGL_PIXEL_FORMAT_ARGB_2101010,
|
||||
COGL_PIXEL_FORMAT_XRGB_2101010,
|
||||
COGL_PIXEL_FORMAT_RGBA_1010102,
|
||||
COGL_PIXEL_FORMAT_BGRA_1010102,
|
||||
COGL_PIXEL_FORMAT_ARGB_2101010_PRE,
|
||||
COGL_PIXEL_FORMAT_XBGR_2101010,
|
||||
COGL_PIXEL_FORMAT_ABGR_2101010_PRE,
|
||||
COGL_PIXEL_FORMAT_RGBA_1010102_PRE,
|
||||
COGL_PIXEL_FORMAT_BGRA_1010102_PRE,
|
||||
};
|
||||
int i;
|
||||
|
||||
@ -74,6 +76,7 @@ test_offscreen_texture_formats_store_rgb10 (void)
|
||||
red = (rgb10_red / (float) (1 << 10)) + 0.00001;
|
||||
green = (rgb10_green / (float) (1 << 10)) + 0.00001;
|
||||
blue = (rgb10_blue / (float) (1 << 10)) + 0.00001;
|
||||
alpha = (rgb10_alpha / (float) (1 << 2)) + 0.00001;
|
||||
|
||||
/* Make sure that that the color value can't be represented using rgb8. */
|
||||
g_assert_cmpint (rgb8_to_rgb10 (rgb10_to_rgb8 (rgb10_red)), !=, rgb10_red);
|
||||
@ -85,8 +88,7 @@ test_offscreen_texture_formats_store_rgb10 (void)
|
||||
CoglTexture2D *tex;
|
||||
CoglOffscreen *offscreen;
|
||||
uint32_t rgb8_readback[4];
|
||||
uint8_t *rgb8_buf;
|
||||
int j;
|
||||
int j, k;
|
||||
|
||||
/* Allocate 2x2 to ensure we avoid any fast paths. */
|
||||
tex = cogl_texture_2d_new_with_format (test_ctx, 2, 2, formats[i]);
|
||||
@ -97,54 +99,60 @@ test_offscreen_texture_formats_store_rgb10 (void)
|
||||
|
||||
cogl_framebuffer_clear4f (COGL_FRAMEBUFFER (offscreen),
|
||||
COGL_BUFFER_BIT_COLOR,
|
||||
red, green, blue, 1.0);
|
||||
red, green, blue, alpha);
|
||||
|
||||
for (j = 0; j < G_N_ELEMENTS (formats); j++)
|
||||
{
|
||||
uint32_t rgb10_readback[4];
|
||||
int channels[3];
|
||||
int alpha;
|
||||
int alpha_out;
|
||||
|
||||
cogl_framebuffer_read_pixels (COGL_FRAMEBUFFER (offscreen), 0, 0, 2, 2,
|
||||
formats[j],
|
||||
(uint8_t *) &rgb10_readback);
|
||||
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
int channels[3];
|
||||
|
||||
switch (formats[j])
|
||||
{
|
||||
case COGL_PIXEL_FORMAT_RGBA_1010102:
|
||||
case COGL_PIXEL_FORMAT_BGRA_1010102:
|
||||
channels[0] = get_bits (rgb10_readback[0], 31, 22);
|
||||
channels[1] = get_bits (rgb10_readback[0], 21, 12);
|
||||
channels[2] = get_bits (rgb10_readback[0], 11, 2);
|
||||
alpha = get_bits (rgb10_readback[0], 1, 0);
|
||||
case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
|
||||
case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
|
||||
channels[0] = get_bits (rgb10_readback[k], 31, 22);
|
||||
channels[1] = get_bits (rgb10_readback[k], 21, 12);
|
||||
channels[2] = get_bits (rgb10_readback[k], 11, 2);
|
||||
alpha_out = get_bits (rgb10_readback[k], 1, 0);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_XRGB_2101010:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||
case COGL_PIXEL_FORMAT_XBGR_2101010:
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010:
|
||||
alpha = get_bits (rgb10_readback[0], 31, 30);
|
||||
channels[0] = get_bits (rgb10_readback[0], 29, 20);
|
||||
channels[1] = get_bits (rgb10_readback[0], 19, 10);
|
||||
channels[2] = get_bits (rgb10_readback[0], 9, 0);
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||
alpha_out = get_bits (rgb10_readback[k], 31, 30);
|
||||
channels[0] = get_bits (rgb10_readback[k], 29, 20);
|
||||
channels[1] = get_bits (rgb10_readback[k], 19, 10);
|
||||
channels[2] = get_bits (rgb10_readback[k], 9, 0);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
g_assert_cmpint (alpha, ==, 0x3);
|
||||
if ((formats[i] & COGL_A_BIT) && (formats[j] & COGL_A_BIT))
|
||||
g_assert_cmpint (alpha_out, ==, rgb10_alpha);
|
||||
else if (!(formats[i] & COGL_A_BIT) && !(formats[j] & COGL_A_BIT))
|
||||
g_assert_cmpint (alpha_out, ==, 0x3);
|
||||
|
||||
switch (formats[j])
|
||||
{
|
||||
case COGL_PIXEL_FORMAT_RGBA_1010102:
|
||||
case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
|
||||
case COGL_PIXEL_FORMAT_XRGB_2101010:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||
g_assert_cmpint (channels[0], ==, rgb10_red);
|
||||
g_assert_cmpint (channels[1], ==, rgb10_green);
|
||||
g_assert_cmpint (channels[2], ==, rgb10_blue);
|
||||
break;
|
||||
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:
|
||||
g_assert_cmpint (channels[0], ==, rgb10_blue);
|
||||
g_assert_cmpint (channels[1], ==, rgb10_green);
|
||||
g_assert_cmpint (channels[2], ==, rgb10_red);
|
||||
@ -153,16 +161,22 @@ test_offscreen_texture_formats_store_rgb10 (void)
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cogl_framebuffer_read_pixels (COGL_FRAMEBUFFER (offscreen), 0, 0, 2, 2,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888,
|
||||
COGL_PIXEL_FORMAT_RGBX_8888,
|
||||
(uint8_t *) &rgb8_readback);
|
||||
rgb8_buf = (uint8_t *) &rgb8_readback[0];
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
uint8_t *rgb8_buf = (uint8_t *) &rgb8_readback[k];
|
||||
|
||||
g_assert_cmpint (rgb8_buf[0], ==, rgb10_to_rgb8 (rgb10_red));
|
||||
g_assert_cmpint (rgb8_buf[1], ==, rgb10_to_rgb8 (rgb10_green));
|
||||
g_assert_cmpint (rgb8_buf[2], ==, rgb10_to_rgb8 (rgb10_blue));
|
||||
|
||||
if (!(formats[i] & COGL_A_BIT))
|
||||
g_assert_cmpint (rgb8_buf[3], ==, 0xff);
|
||||
}
|
||||
|
||||
g_object_unref (offscreen);
|
||||
cogl_object_unref (tex);
|
||||
@ -273,43 +287,61 @@ test_offscreen_texture_formats_paint_rgb10 (void)
|
||||
const int rgb10_red = 514;
|
||||
const int rgb10_green = 258;
|
||||
const int rgb10_blue = 18;
|
||||
const int rgb10_alpha = 2;
|
||||
float red;
|
||||
float green;
|
||||
float blue;
|
||||
CoglTexture2D *tex_src;
|
||||
CoglOffscreen *offscreen_src;
|
||||
CoglTexture2D *tex_dst;
|
||||
CoglOffscreen *offscreen_dst;
|
||||
CoglPipeline *pipeline;
|
||||
uint32_t rgb10_readback[4];
|
||||
GError *error = NULL;
|
||||
float alpha;
|
||||
CoglPixelFormat formats[] = {
|
||||
COGL_PIXEL_FORMAT_XRGB_2101010,
|
||||
COGL_PIXEL_FORMAT_ARGB_2101010_PRE,
|
||||
COGL_PIXEL_FORMAT_XBGR_2101010,
|
||||
COGL_PIXEL_FORMAT_ABGR_2101010_PRE,
|
||||
COGL_PIXEL_FORMAT_RGBA_1010102_PRE,
|
||||
COGL_PIXEL_FORMAT_BGRA_1010102_PRE,
|
||||
};
|
||||
int i;
|
||||
|
||||
/* The extra fraction is there to avoid rounding inconsistencies in OpenGL
|
||||
* implementations. */
|
||||
red = (rgb10_red / (float) (1 << 10)) + 0.00001;
|
||||
green = (rgb10_green / (float) (1 << 10)) + 0.00001;
|
||||
blue = (rgb10_blue / (float) (1 << 10)) + 0.00001;
|
||||
alpha = (rgb10_alpha / (float) (1 << 2)) + 0.00001;
|
||||
|
||||
/* Make sure that that the color value can't be represented using rgb8. */
|
||||
g_assert_cmpint (rgb8_to_rgb10 (rgb10_to_rgb8 (rgb10_red)), !=, rgb10_red);
|
||||
g_assert_cmpint (rgb8_to_rgb10 (rgb10_to_rgb8 (rgb10_green)), !=, rgb10_green);
|
||||
g_assert_cmpint (rgb8_to_rgb10 (rgb10_to_rgb8 (rgb10_blue)), !=, rgb10_blue);
|
||||
|
||||
tex_src = cogl_texture_2d_new_with_format (test_ctx, 2, 2,
|
||||
COGL_PIXEL_FORMAT_RGBA_1010102);
|
||||
for (i = 0; i < G_N_ELEMENTS (formats); i++)
|
||||
{
|
||||
CoglTexture2D *tex_src;
|
||||
CoglOffscreen *offscreen_src;
|
||||
GError *error = NULL;
|
||||
int j;
|
||||
|
||||
tex_src = cogl_texture_2d_new_with_format (test_ctx, 2, 2, formats[i]);
|
||||
offscreen_src = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex_src));
|
||||
cogl_framebuffer_allocate (COGL_FRAMEBUFFER (offscreen_src), &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
tex_dst = cogl_texture_2d_new_with_format (test_ctx, 2, 2,
|
||||
COGL_PIXEL_FORMAT_ABGR_2101010);
|
||||
for (j = 0; j < G_N_ELEMENTS (formats); j++)
|
||||
{
|
||||
CoglTexture2D *tex_dst;
|
||||
CoglOffscreen *offscreen_dst;
|
||||
CoglPipeline *pipeline;
|
||||
uint32_t rgb10_readback[4];
|
||||
int k;
|
||||
|
||||
tex_dst = cogl_texture_2d_new_with_format (test_ctx, 2, 2, formats[j]);
|
||||
offscreen_dst = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex_dst));
|
||||
cogl_framebuffer_allocate (COGL_FRAMEBUFFER (offscreen_dst), &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
cogl_framebuffer_clear4f (COGL_FRAMEBUFFER (offscreen_src),
|
||||
COGL_BUFFER_BIT_COLOR,
|
||||
red, green, blue, 1.0);
|
||||
red, green, blue, alpha);
|
||||
|
||||
pipeline = cogl_pipeline_new (test_ctx);
|
||||
cogl_pipeline_set_layer_texture (pipeline, 0, tex_src);
|
||||
@ -318,13 +350,70 @@ test_offscreen_texture_formats_paint_rgb10 (void)
|
||||
-1.0, -1.0, 1.0, 1.0);
|
||||
cogl_object_unref (pipeline);
|
||||
|
||||
cogl_framebuffer_read_pixels (COGL_FRAMEBUFFER (offscreen_dst), 0, 0, 2, 2,
|
||||
COGL_PIXEL_FORMAT_ABGR_2101010,
|
||||
cogl_framebuffer_read_pixels (COGL_FRAMEBUFFER (offscreen_dst),
|
||||
0, 0, 2, 2, formats[j],
|
||||
(uint8_t *) &rgb10_readback);
|
||||
g_assert_cmpint (get_bits (rgb10_readback[0], 31, 30), ==, 0x3);
|
||||
g_assert_cmpint (get_bits (rgb10_readback[0], 29, 20), ==, rgb10_blue);
|
||||
g_assert_cmpint (get_bits (rgb10_readback[0], 19, 10), ==, rgb10_green);
|
||||
g_assert_cmpint (get_bits (rgb10_readback[0], 9, 0), ==, rgb10_red);
|
||||
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
int channels[3];
|
||||
int alpha_out;
|
||||
|
||||
switch (formats[j])
|
||||
{
|
||||
case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
|
||||
case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
|
||||
channels[0] = get_bits (rgb10_readback[k], 31, 22);
|
||||
channels[1] = get_bits (rgb10_readback[k], 21, 12);
|
||||
channels[2] = get_bits (rgb10_readback[k], 11, 2);
|
||||
alpha_out = get_bits (rgb10_readback[k], 1, 0);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_XRGB_2101010:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||
case COGL_PIXEL_FORMAT_XBGR_2101010:
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||
alpha_out = get_bits (rgb10_readback[k], 31, 30);
|
||||
channels[0] = get_bits (rgb10_readback[k], 29, 20);
|
||||
channels[1] = get_bits (rgb10_readback[k], 19, 10);
|
||||
channels[2] = get_bits (rgb10_readback[k], 9, 0);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if ((formats[i] & COGL_A_BIT) && (formats[j] & COGL_A_BIT))
|
||||
g_assert_cmpint (alpha_out, ==, rgb10_alpha);
|
||||
else if (!(formats[i] & COGL_A_BIT) && !(formats[j] & COGL_A_BIT))
|
||||
g_assert_cmpint (alpha_out, ==, 0x3);
|
||||
|
||||
switch (formats[j])
|
||||
{
|
||||
case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
|
||||
case COGL_PIXEL_FORMAT_XRGB_2101010:
|
||||
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||
g_assert_cmpint (channels[0], ==, rgb10_red);
|
||||
g_assert_cmpint (channels[1], ==, rgb10_green);
|
||||
g_assert_cmpint (channels[2], ==, rgb10_blue);
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
|
||||
case COGL_PIXEL_FORMAT_XBGR_2101010:
|
||||
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||
g_assert_cmpint (channels[0], ==, rgb10_blue);
|
||||
g_assert_cmpint (channels[1], ==, rgb10_green);
|
||||
g_assert_cmpint (channels[2], ==, rgb10_red);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (offscreen_dst);
|
||||
cogl_object_unref (tex_dst);
|
||||
}
|
||||
|
||||
g_object_unref (offscreen_src);
|
||||
cogl_object_unref (tex_src);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user