cogl: COGL_FEATURE_TEXTURE_NPOT_BASIC is always available

https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
This commit is contained in:
Adam Jackson 2019-03-28 15:11:53 -04:00
parent 007297f1a6
commit 48f04c7968
9 changed files with 73 additions and 144 deletions

View File

@ -562,28 +562,21 @@ create_migration_texture (CoglContext *ctx,
CoglTexture *tex;
CoglError *skip_error = NULL;
if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
(cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC)))
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
_cogl_texture_set_internal_format (tex, internal_format);
/* TODO: instead of allocating storage here it would be better
* if we had some api that let us just check that the size is
* supported by the hardware so storage could be allocated
* lazily when uploading data. */
if (!cogl_texture_allocate (tex, &skip_error))
{
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
width, height));
_cogl_texture_set_internal_format (tex, internal_format);
/* TODO: instead of allocating storage here it would be better
* if we had some api that let us just check that the size is
* supported by the hardware so storage could be allocated
* lazily when uploading data. */
if (!cogl_texture_allocate (tex, &skip_error))
{
cogl_error_free (skip_error);
cogl_object_unref (tex);
tex = NULL;
}
cogl_error_free (skip_error);
cogl_object_unref (tex);
tex = NULL;
}
else
tex = NULL;
if (!tex)
{

View File

@ -174,12 +174,6 @@ cogl_is_context (void *object);
* experimental since it's only useable with experimental API... */
/**
* CoglFeatureID:
* @COGL_FEATURE_ID_TEXTURE_NPOT_BASIC: The hardware supports non power
* of two textures, but you also need to check the
* %COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP and %COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT
* features to know if the hardware supports npot texture mipmaps
* or repeat modes other than
* %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE respectively.
* @COGL_FEATURE_ID_TEXTURE_NPOT: Non power of two textures are supported
* by the hardware. This is a equivalent to the
* %COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, %COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP
@ -229,8 +223,7 @@ cogl_is_context (void *object);
*/
typedef enum _CoglFeatureID
{
COGL_FEATURE_ID_TEXTURE_NPOT_BASIC = 1,
COGL_FEATURE_ID_TEXTURE_NPOT,
COGL_FEATURE_ID_TEXTURE_NPOT = 1,
COGL_FEATURE_ID_TEXTURE_RECTANGLE,
COGL_FEATURE_ID_OFFSCREEN,
COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE,

View File

@ -333,12 +333,6 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
* %COGL_INDICES_TYPE_UNSIGNED_INT is supported in
* cogl_vertex_buffer_indices_new().
* @COGL_FEATURE_DEPTH_RANGE: cogl_material_set_depth_range() support
* @COGL_FEATURE_TEXTURE_NPOT_BASIC: The hardware supports non power
* of two textures, but you also need to check the
* %COGL_FEATURE_TEXTURE_NPOT_MIPMAP and %COGL_FEATURE_TEXTURE_NPOT_REPEAT
* features to know if the hardware supports npot texture mipmaps
* or repeat modes other than
* %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE respectively.
* @COGL_FEATURE_POINT_SPRITE: Whether
* cogl_material_set_layer_point_sprite_coords_enabled() is supported.
* @COGL_FEATURE_MAP_BUFFER_FOR_READ: Whether cogl_buffer_map() is
@ -367,7 +361,6 @@ typedef enum
COGL_FEATURE_PBOS = (1 << 12),
COGL_FEATURE_UNSIGNED_INT_INDICES = (1 << 13),
COGL_FEATURE_DEPTH_RANGE = (1 << 14),
COGL_FEATURE_TEXTURE_NPOT_BASIC = (1 << 15),
COGL_FEATURE_POINT_SPRITE = (1 << 18),
COGL_FEATURE_MAP_BUFFER_FOR_READ = (1 << 21),
COGL_FEATURE_MAP_BUFFER_FOR_WRITE = (1 << 22),

View File

@ -82,24 +82,18 @@ cogl_texture_new_with_size (unsigned int width,
_COGL_GET_CONTEXT (ctx, NULL);
if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
(cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC)))
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
_cogl_texture_set_internal_format (tex, internal_format);
if (!cogl_texture_allocate (tex, &skip_error))
{
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
_cogl_texture_set_internal_format (tex, internal_format);
if (!cogl_texture_allocate (tex, &skip_error))
{
cogl_error_free (skip_error);
skip_error = NULL;
cogl_object_unref (tex);
tex = NULL;
}
cogl_error_free (skip_error);
skip_error = NULL;
cogl_object_unref (tex);
tex = NULL;
}
else
tex = NULL;
if (!tex)
{
@ -209,7 +203,6 @@ _cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
gboolean can_convert_in_place,
CoglError **error)
{
CoglContext *ctx = _cogl_bitmap_get_context (bitmap);
CoglTexture *tex;
CoglError *internal_error = NULL;
@ -233,25 +226,18 @@ _cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
}
/* If that doesn't work try a fast path 2D texture */
if ((_cogl_util_is_pot (bitmap->width) &&
_cogl_util_is_pot (bitmap->height)) ||
(cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC)))
tex = COGL_TEXTURE (_cogl_texture_2d_new_from_bitmap (bitmap,
can_convert_in_place));
_cogl_texture_set_internal_format (tex, internal_format);
if (!cogl_texture_allocate (tex, &internal_error))
{
tex = COGL_TEXTURE (_cogl_texture_2d_new_from_bitmap (bitmap,
can_convert_in_place));
_cogl_texture_set_internal_format (tex, internal_format);
if (!cogl_texture_allocate (tex, &internal_error))
{
cogl_error_free (internal_error);
internal_error = NULL;
cogl_object_unref (tex);
tex = NULL;
}
cogl_error_free (internal_error);
internal_error = NULL;
cogl_object_unref (tex);
tex = NULL;
}
else
tex = NULL;
if (!tex)
{

View File

@ -83,13 +83,6 @@ _cogl_texture_2d_gl_can_create (CoglContext *ctx,
GLenum gl_format;
GLenum gl_type;
/* If NPOT textures aren't supported then the size must be a power
of two */
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
(!_cogl_util_is_pot (width) ||
!_cogl_util_is_pot (height)))
return FALSE;
ctx->driver_vtable->pixel_format_to_gl (ctx,
internal_format,
&gl_intformat,

View File

@ -407,10 +407,8 @@ _cogl_driver_update_features (CoglContext *ctx,
gl_minor,
gl_extensions);
flags |= COGL_FEATURE_TEXTURE_NPOT
| COGL_FEATURE_TEXTURE_NPOT_BASIC;
flags |= COGL_FEATURE_TEXTURE_NPOT;
COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_NPOT, TRUE);
COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, TRUE);
if (_cogl_check_extension ("GL_MESA_pack_invert", gl_extensions))
COGL_FLAGS_SET (private_features,

View File

@ -305,11 +305,8 @@ _cogl_driver_update_features (CoglContext *context,
flags |= COGL_FEATURE_OFFSCREEN;
/* Note GLES 2 core doesn't support mipmaps for npot textures or
* repeat modes other than CLAMP_TO_EDGE. */
flags |= COGL_FEATURE_TEXTURE_NPOT_BASIC;
flags |= COGL_FEATURE_DEPTH_RANGE;
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_OFFSCREEN, TRUE);
COGL_FLAGS_SET (context->features,
COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, TRUE);
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_DEPTH_RANGE, TRUE);
COGL_FLAGS_SET (context->features,
COGL_FEATURE_ID_MIRRORED_REPEAT, TRUE);
@ -349,11 +346,8 @@ _cogl_driver_update_features (CoglContext *context,
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_DEPTH_TEXTURE, TRUE);
}
flags |= (COGL_FEATURE_TEXTURE_NPOT |
COGL_FEATURE_TEXTURE_NPOT_BASIC);
flags |= COGL_FEATURE_TEXTURE_NPOT;
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TEXTURE_NPOT, TRUE);
COGL_FLAGS_SET (context->features,
COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, TRUE);
if (context->glMapBuffer)
{

View File

@ -582,28 +582,21 @@ create_fallback_texture (CoglContext *ctx,
CoglTexture *tex;
CoglError *skip_error = NULL;
if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
(cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC)))
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
_cogl_texture_set_internal_format (tex, internal_format);
/* TODO: instead of allocating storage here it would be better
* if we had some api that let us just check that the size is
* supported by the hardware so storage could be allocated
* lazily when uploading data. */
if (!cogl_texture_allocate (tex, &skip_error))
{
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
width, height));
_cogl_texture_set_internal_format (tex, internal_format);
/* TODO: instead of allocating storage here it would be better
* if we had some api that let us just check that the size is
* supported by the hardware so storage could be allocated
* lazily when uploading data. */
if (!cogl_texture_allocate (tex, &skip_error))
{
cogl_error_free (skip_error);
cogl_object_unref (tex);
tex = NULL;
}
cogl_error_free (skip_error);
cogl_object_unref (tex);
tex = NULL;
}
else
tex = NULL;
if (!tex)
{

View File

@ -361,24 +361,17 @@ test_utils_texture_new_with_size (CoglContext *ctx,
CoglTexture *tex;
CoglError *skip_error = NULL;
if ((test_utils_is_pot (width) && test_utils_is_pot (height)) ||
(cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC)))
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
cogl_texture_set_components (tex, components);
if (!cogl_texture_allocate (tex, &skip_error))
{
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
width, height));
cogl_texture_set_components (tex, components);
if (!cogl_texture_allocate (tex, &skip_error))
{
cogl_error_free (skip_error);
cogl_object_unref (tex);
tex = NULL;
}
cogl_error_free (skip_error);
cogl_object_unref (tex);
tex = NULL;
}
else
tex = NULL;
if (!tex)
{
@ -439,30 +432,23 @@ test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
}
/* If that doesn't work try a fast path 2D texture */
if ((test_utils_is_pot (cogl_bitmap_get_width (bitmap)) &&
test_utils_is_pot (cogl_bitmap_get_height (bitmap))) ||
(cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC)))
tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap));
cogl_texture_set_premultiplied (tex, premultiplied);
if (cogl_error_matches (internal_error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_NO_MEMORY))
{
tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap));
cogl_texture_set_premultiplied (tex, premultiplied);
if (cogl_error_matches (internal_error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_NO_MEMORY))
{
g_assert_not_reached ();
return NULL;
}
if (!tex)
{
cogl_error_free (internal_error);
internal_error = NULL;
}
g_assert_not_reached ();
return NULL;
}
if (!tex)
{
cogl_error_free (internal_error);
internal_error = NULL;
}
else
tex = NULL;
if (!tex)
{