[mutter] cogl: COGL_FEATURE_TEXTURE_NPOT_BASIC is always available



commit 48f04c7968966d8f25a1ff35ded8f0d9467051d3
Author: Adam Jackson <ajax redhat com>
Date:   Thu Mar 28 15:11:53 2019 -0400

    cogl: COGL_FEATURE_TEXTURE_NPOT_BASIC is always available
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/546

 cogl/cogl/cogl-atlas.c                      | 31 ++++++---------
 cogl/cogl/cogl-context.h                    |  9 +----
 cogl/cogl/cogl-types.h                      |  7 ----
 cogl/cogl/deprecated/cogl-auto-texture.c    | 50 +++++++++----------------
 cogl/cogl/driver/gl/cogl-texture-2d-gl.c    |  7 ----
 cogl/cogl/driver/gl/gl/cogl-driver-gl.c     |  4 +-
 cogl/cogl/driver/gl/gles/cogl-driver-gles.c |  8 +---
 cogl/cogl/winsys/cogl-texture-pixmap-x11.c  | 31 ++++++---------
 cogl/test-fixtures/test-utils.c             | 58 +++++++++++------------------
 9 files changed, 67 insertions(+), 138 deletions(-)
---
diff --git a/cogl/cogl/cogl-atlas.c b/cogl/cogl/cogl-atlas.c
index ba6086df1..1d52c2849 100644
--- a/cogl/cogl/cogl-atlas.c
+++ b/cogl/cogl/cogl-atlas.c
@@ -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));
+  /* 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);
+  _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;
-        }
+  /* 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;
     }
-  else
-    tex = NULL;
 
   if (!tex)
     {
diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h
index ddbe1f357..65ef4308e 100644
--- a/cogl/cogl/cogl-context.h
+++ b/cogl/cogl/cogl-context.h
@@ -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,
diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h
index 86793bd81..e674921d3 100644
--- a/cogl/cogl/cogl-types.h
+++ b/cogl/cogl/cogl-types.h
@@ -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),
diff --git a/cogl/cogl/deprecated/cogl-auto-texture.c b/cogl/cogl/deprecated/cogl-auto-texture.c
index 3ab155588..5fc2732aa 100644
--- a/cogl/cogl/deprecated/cogl-auto-texture.c
+++ b/cogl/cogl/deprecated/cogl-auto-texture.c
@@ -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));
+  /* 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);
+  _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;
-        }
+  if (!cogl_texture_allocate (tex, &skip_error))
+    {
+      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));
+  tex = COGL_TEXTURE (_cogl_texture_2d_new_from_bitmap (bitmap,
+                                                        can_convert_in_place));
 
-      _cogl_texture_set_internal_format (tex, internal_format);
+  _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;
-        }
+  if (!cogl_texture_allocate (tex, &internal_error))
+    {
+      cogl_error_free (internal_error);
+      internal_error = NULL;
+      cogl_object_unref (tex);
+      tex = NULL;
     }
-  else
-    tex = NULL;
 
   if (!tex)
     {
diff --git a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
index e36c3523e..2f9e3424c 100644
--- a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
+++ b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
@@ -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,
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index 96b12e56a..5f6ad6915 100644
--- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -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,
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index 5095f4888..1766846b0 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -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)
     {
diff --git a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c
index d0acbc709..1cb599e48 100644
--- a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -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));
+  /* 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);
+  _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;
-        }
+  /* 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;
     }
-  else
-    tex = NULL;
 
   if (!tex)
     {
diff --git a/cogl/test-fixtures/test-utils.c b/cogl/test-fixtures/test-utils.c
index 7e3e233b8..06fe2e2d4 100644
--- a/cogl/test-fixtures/test-utils.c
+++ b/cogl/test-fixtures/test-utils.c
@@ -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));
+  /* 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);
+  cogl_texture_set_components (tex, components);
 
-      if (!cogl_texture_allocate (tex, &skip_error))
-        {
-          cogl_error_free (skip_error);
-          cogl_object_unref (tex);
-          tex = NULL;
-        }
+  if (!cogl_texture_allocate (tex, &skip_error))
+    {
+      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));
+  tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap));
 
-      cogl_texture_set_premultiplied (tex, premultiplied);
+  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 (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;
-        }
+  if (!tex)
+    {
+      cogl_error_free (internal_error);
+      internal_error = NULL;
     }
-  else
-    tex = NULL;
 
   if (!tex)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]