Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cogl/cogl/cogl-bitmap-conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
88 changes: 63 additions & 25 deletions cogl/cogl/cogl-bitmap-packing.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
#define UNPACK_2(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
1) / 3)
#define UNPACK_4(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
7) / 15)
7) / 0xf)
#define UNPACK_5(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
15) / 31)
0xf) / 0x1f)
#define UNPACK_6(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
31) / 63)
0x1f) / 0x3f)
#define UNPACK_10(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
511) / 1023)
0x1ff) / 0x3ff)

inline static void
G_PASTE (_cogl_unpack_a_8_, component_size) (const uint8_t *src,
Expand Down Expand Up @@ -207,8 +207,8 @@ G_PASTE (_cogl_unpack_rgb_565_, component_size) (const uint8_t *src,
uint16_t v = *(const uint16_t *) src;

dst[0] = UNPACK_5 (v >> 11);
dst[1] = UNPACK_6 ((v >> 5) & 63);
dst[2] = UNPACK_5 (v & 31);
dst[1] = UNPACK_6 ((v >> 5) & 0x3f);
dst[2] = UNPACK_5 (v & 0x1f);
dst[3] = UNPACK_BYTE (255);
dst += 4;
src += 2;
Expand All @@ -225,9 +225,9 @@ G_PASTE (_cogl_unpack_rgba_4444_, component_size) (const uint8_t *src,
uint16_t v = *(const uint16_t *) src;

dst[0] = UNPACK_4 (v >> 12);
dst[1] = UNPACK_4 ((v >> 8) & 15);
dst[2] = UNPACK_4 ((v >> 4) & 15);
dst[3] = UNPACK_4 (v & 15);
dst[1] = UNPACK_4 ((v >> 8) & 0xf);
dst[2] = UNPACK_4 ((v >> 4) & 0xf);
dst[3] = UNPACK_4 (v & 0xf);
dst += 4;
src += 2;
}
Expand All @@ -243,8 +243,8 @@ G_PASTE (_cogl_unpack_rgba_5551_, component_size) (const uint8_t *src,
uint16_t v = *(const uint16_t *) src;

dst[0] = UNPACK_5 (v >> 11);
dst[1] = UNPACK_5 ((v >> 6) & 31);
dst[2] = UNPACK_5 ((v >> 1) & 31);
dst[1] = UNPACK_5 ((v >> 6) & 0x1f);
dst[2] = UNPACK_5 ((v >> 1) & 0x1f);
dst[3] = UNPACK_1 (v & 1);
dst += 4;
src += 2;
Expand All @@ -261,8 +261,8 @@ G_PASTE (_cogl_unpack_rgba_1010102_, component_size) (const uint8_t *src,
uint32_t v = *(const uint32_t *) src;

dst[0] = UNPACK_10 (v >> 22);
dst[1] = UNPACK_10 ((v >> 12) & 1023);
dst[2] = UNPACK_10 ((v >> 2) & 1023);
dst[1] = UNPACK_10 ((v >> 12) & 0x3ff);
dst[2] = UNPACK_10 ((v >> 2) & 0x3ff);
dst[3] = UNPACK_2 (v & 3);
dst += 4;
src += 2;
Expand All @@ -279,8 +279,8 @@ G_PASTE (_cogl_unpack_bgra_1010102_, component_size) (const uint8_t *src,
uint32_t v = *(const uint32_t *) src;

dst[2] = UNPACK_10 (v >> 22);
dst[1] = UNPACK_10 ((v >> 12) & 1023);
dst[0] = UNPACK_10 ((v >> 2) & 1023);
dst[1] = UNPACK_10 ((v >> 12) & 0x3ff);
dst[0] = UNPACK_10 ((v >> 2) & 0x3ff);
dst[3] = UNPACK_2 (v & 3);
dst += 4;
src += 2;
Expand All @@ -297,9 +297,9 @@ G_PASTE (_cogl_unpack_argb_2101010_, component_size) (const uint8_t *src,
uint32_t v = *(const uint32_t *) src;

dst[3] = UNPACK_2 (v >> 30);
dst[0] = UNPACK_10 ((v >> 20) & 1023);
dst[1] = UNPACK_10 ((v >> 10) & 1023);
dst[2] = UNPACK_10 (v & 1023);
dst[0] = UNPACK_10 ((v >> 20) & 0x3ff);
dst[1] = UNPACK_10 ((v >> 10) & 0x3ff);
dst[2] = UNPACK_10 (v & 0x3ff);
dst += 4;
src += 2;
}
Expand All @@ -315,14 +315,22 @@ G_PASTE (_cogl_unpack_abgr_2101010_, component_size) (const uint8_t *src,
uint32_t v = *(const uint32_t *) src;

dst[3] = UNPACK_2 (v >> 30);
dst[2] = UNPACK_10 ((v >> 20) & 1023);
dst[1] = UNPACK_10 ((v >> 10) & 1023);
dst[0] = UNPACK_10 (v & 1023);
dst[2] = UNPACK_10 ((v >> 20) & 0x3ff);
dst[1] = UNPACK_10 ((v >> 10) & 0x3ff);
dst[0] = UNPACK_10 (v & 0x3ff);
dst += 4;
src += 2;
}
}

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
Expand Down Expand Up @@ -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:
Expand All @@ -414,10 +432,10 @@ G_PASTE (_cogl_unpack_, component_size) (CoglPixelFormat format,

#define PACK_1(b) PACK_SIZE (b, 1)
#define PACK_2(b) PACK_SIZE (b, 3)
#define PACK_4(b) PACK_SIZE (b, 15)
#define PACK_5(b) PACK_SIZE (b, 31)
#define PACK_6(b) PACK_SIZE (b, 63)
#define PACK_10(b) PACK_SIZE (b, 1023)
#define PACK_4(b) PACK_SIZE (b, 0xf)
#define PACK_5(b) PACK_SIZE (b, 0x1f)
#define PACK_6(b) PACK_SIZE (b, 0x3f)
#define PACK_10(b) PACK_SIZE (b, 0x3ff)

inline static void
G_PASTE (_cogl_pack_a_8_, component_size) (const component_type *src,
Expand All @@ -432,6 +450,16 @@ G_PASTE (_cogl_pack_a_8_, 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");
}

inline static void
G_PASTE (_cogl_pack_g_8_, component_size) (const component_type *src,
uint8_t *dst,
Expand Down Expand Up @@ -757,6 +785,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:
Expand Down
8 changes: 8 additions & 0 deletions cogl/cogl/cogl-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "cogl-config.h"

#include "cogl-muffin.h"
#include "cogl-object.h"
#include "cogl-private.h"
#include "cogl-profile.h"
Expand Down Expand Up @@ -616,3 +617,10 @@ cogl_get_graphics_reset_status (CoglContext *context)
return COGL_GRAPHICS_RESET_STATUS_NO_ERROR;
}
}

gboolean
cogl_context_format_supports_upload (CoglContext *ctx,
CoglPixelFormat format)
{
return ctx->texture_driver->format_supports_upload (ctx, format);
}
4 changes: 4 additions & 0 deletions cogl/cogl/cogl-muffin.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ void cogl_renderer_set_custom_winsys (CoglRenderer *renderer,
CoglCustomWinsysVtableGetter winsys_vtable_getter,
void *user_data);

COGL_EXPORT
gboolean cogl_context_format_supports_upload (CoglContext *ctx,
CoglPixelFormat format);

#endif /* __COGL_MUFFIN_H___ */
56 changes: 56 additions & 0 deletions cogl/cogl/cogl-pixel-format.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 19 additions & 1 deletion cogl/cogl/cogl-pixel-format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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),

Expand Down
2 changes: 2 additions & 0 deletions cogl/cogl/cogl-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ typedef enum
COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL,
COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL,
COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_BGRA8888,
COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_RGBA1010102,
COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_HALF_FLOAT,
COGL_PRIVATE_FEATURE_UNPACK_SUBIMAGE,
COGL_PRIVATE_FEATURE_SAMPLER_OBJECTS,
COGL_PRIVATE_FEATURE_READ_PIXELS_ANY_FORMAT,
Expand Down
4 changes: 4 additions & 0 deletions cogl/cogl/cogl-texture-driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ struct _CoglTextureDriver
int width,
int height);

gboolean
(* format_supports_upload) (CoglContext *ctx,
CoglPixelFormat format);

/*
* The driver may impose constraints on what formats can be used to store
* texture data read from textures. For example GLES currently only supports
Expand Down
Loading
Loading