cogl: Add API to check whether a format is supported by the driver
Will let us advertise what we actually support at runtime. https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
This commit is contained in:
parent
6777a547ca
commit
d6b5f89a1c
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "cogl-config.h"
|
#include "cogl-config.h"
|
||||||
|
|
||||||
|
#include "cogl-mutter.h"
|
||||||
#include "cogl-object.h"
|
#include "cogl-object.h"
|
||||||
#include "cogl-private.h"
|
#include "cogl-private.h"
|
||||||
#include "cogl-profile.h"
|
#include "cogl-profile.h"
|
||||||
@ -464,3 +465,10 @@ cogl_context_is_hardware_accelerated (CoglContext *context)
|
|||||||
{
|
{
|
||||||
return context->driver_vtable->is_hardware_accelerated (context);
|
return context->driver_vtable->is_hardware_accelerated (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_context_format_supports_upload (CoglContext *ctx,
|
||||||
|
CoglPixelFormat format)
|
||||||
|
{
|
||||||
|
return ctx->texture_driver->format_supports_upload (ctx, format);
|
||||||
|
}
|
||||||
|
@ -48,4 +48,8 @@ void cogl_renderer_set_custom_winsys (CoglRenderer *renderer,
|
|||||||
CoglCustomWinsysVtableGetter winsys_vtable_getter,
|
CoglCustomWinsysVtableGetter winsys_vtable_getter,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
|
COGL_EXPORT
|
||||||
|
gboolean cogl_context_format_supports_upload (CoglContext *ctx,
|
||||||
|
CoglPixelFormat format);
|
||||||
|
|
||||||
#endif /* __COGL_MUTTER_H___ */
|
#endif /* __COGL_MUTTER_H___ */
|
||||||
|
@ -128,6 +128,11 @@ struct _CoglTextureDriver
|
|||||||
int width,
|
int width,
|
||||||
int height);
|
int height);
|
||||||
|
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
(* format_supports_upload) (CoglContext *ctx,
|
||||||
|
CoglPixelFormat format);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The driver may impose constraints on what formats can be used to store
|
* The driver may impose constraints on what formats can be used to store
|
||||||
* texture data read from textures. For example GLES currently only supports
|
* texture data read from textures. For example GLES currently only supports
|
||||||
|
@ -396,6 +396,64 @@ _cogl_texture_driver_size_supported (CoglContext *ctx,
|
|||||||
return new_width != 0;
|
return new_width != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_cogl_texture_driver_upload_supported (CoglContext *ctx,
|
||||||
|
CoglPixelFormat format)
|
||||||
|
{
|
||||||
|
switch (format)
|
||||||
|
{
|
||||||
|
case COGL_PIXEL_FORMAT_A_8:
|
||||||
|
case COGL_PIXEL_FORMAT_G_8:
|
||||||
|
case COGL_PIXEL_FORMAT_RG_88:
|
||||||
|
case COGL_PIXEL_FORMAT_BGRA_8888:
|
||||||
|
case COGL_PIXEL_FORMAT_BGRA_8888_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_RGB_888:
|
||||||
|
case COGL_PIXEL_FORMAT_BGR_888:
|
||||||
|
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_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_2101010:
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_2101010:
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_8888:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_8888_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_8888:
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_8888_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_8888:
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_8888_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_RGB_565:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_4444:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_4444_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_5551:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_5551_PRE:
|
||||||
|
return TRUE;
|
||||||
|
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:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_FP_16161616:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE:
|
||||||
|
if (_cogl_has_private_feature
|
||||||
|
(ctx, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_HALF_FLOAT))
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
case COGL_PIXEL_FORMAT_DEPTH_16:
|
||||||
|
case COGL_PIXEL_FORMAT_DEPTH_32:
|
||||||
|
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:
|
||||||
|
case COGL_PIXEL_FORMAT_ANY:
|
||||||
|
case COGL_PIXEL_FORMAT_YUV:
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert_not_reached ();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static CoglPixelFormat
|
static CoglPixelFormat
|
||||||
_cogl_texture_driver_find_best_gl_get_data_format
|
_cogl_texture_driver_find_best_gl_get_data_format
|
||||||
(CoglContext *context,
|
(CoglContext *context,
|
||||||
@ -419,5 +477,6 @@ _cogl_texture_driver_gl =
|
|||||||
_cogl_texture_driver_prep_gl_for_pixels_download,
|
_cogl_texture_driver_prep_gl_for_pixels_download,
|
||||||
_cogl_texture_driver_gl_get_tex_image,
|
_cogl_texture_driver_gl_get_tex_image,
|
||||||
_cogl_texture_driver_size_supported,
|
_cogl_texture_driver_size_supported,
|
||||||
|
_cogl_texture_driver_upload_supported,
|
||||||
_cogl_texture_driver_find_best_gl_get_data_format
|
_cogl_texture_driver_find_best_gl_get_data_format
|
||||||
};
|
};
|
||||||
|
@ -439,6 +439,75 @@ _cogl_texture_driver_size_supported (CoglContext *ctx,
|
|||||||
return width <= max_size && height <= max_size;
|
return width <= max_size && height <= max_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_cogl_texture_driver_upload_supported (CoglContext *ctx,
|
||||||
|
CoglPixelFormat format)
|
||||||
|
{
|
||||||
|
switch (format)
|
||||||
|
{
|
||||||
|
case COGL_PIXEL_FORMAT_A_8:
|
||||||
|
case COGL_PIXEL_FORMAT_G_8:
|
||||||
|
case COGL_PIXEL_FORMAT_RG_88:
|
||||||
|
case COGL_PIXEL_FORMAT_BGRA_8888:
|
||||||
|
case COGL_PIXEL_FORMAT_BGRA_8888_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_RGB_888:
|
||||||
|
case COGL_PIXEL_FORMAT_BGR_888:
|
||||||
|
return TRUE;
|
||||||
|
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_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_2101010:
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_2101010:
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
|
||||||
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
|
if (_cogl_has_private_feature
|
||||||
|
(ctx, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_RGBA1010102))
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
#else
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_8888:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_8888_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_8888:
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_8888_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_8888:
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_8888_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_RGB_565:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_4444:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_4444_PRE:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_5551:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_5551_PRE:
|
||||||
|
return TRUE;
|
||||||
|
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:
|
||||||
|
return FALSE;
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_FP_16161616:
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE:
|
||||||
|
if (_cogl_has_private_feature
|
||||||
|
(ctx, COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_HALF_FLOAT))
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
case COGL_PIXEL_FORMAT_DEPTH_16:
|
||||||
|
case COGL_PIXEL_FORMAT_DEPTH_32:
|
||||||
|
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:
|
||||||
|
case COGL_PIXEL_FORMAT_ANY:
|
||||||
|
case COGL_PIXEL_FORMAT_YUV:
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert_not_reached ();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static CoglPixelFormat
|
static CoglPixelFormat
|
||||||
_cogl_texture_driver_find_best_gl_get_data_format
|
_cogl_texture_driver_find_best_gl_get_data_format
|
||||||
(CoglContext *context,
|
(CoglContext *context,
|
||||||
@ -463,5 +532,6 @@ _cogl_texture_driver_gles =
|
|||||||
_cogl_texture_driver_prep_gl_for_pixels_download,
|
_cogl_texture_driver_prep_gl_for_pixels_download,
|
||||||
_cogl_texture_driver_gl_get_tex_image,
|
_cogl_texture_driver_gl_get_tex_image,
|
||||||
_cogl_texture_driver_size_supported,
|
_cogl_texture_driver_size_supported,
|
||||||
|
_cogl_texture_driver_upload_supported,
|
||||||
_cogl_texture_driver_find_best_gl_get_data_format
|
_cogl_texture_driver_find_best_gl_get_data_format
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user