[mutter] cogl: NPOT textures are always available
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cogl: NPOT textures are always available
- Date: Thu, 18 Apr 2019 19:06:10 +0000 (UTC)
commit fc09fa50a5c0adc25568246339e96b64ca09dd8a
Author: Adam Jackson <ajax redhat com>
Date: Thu Mar 28 15:17:14 2019 -0400
cogl: NPOT textures are always available
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
clutter/clutter/clutter-enums.h | 2 -
clutter/clutter/clutter-feature.c | 3 --
cogl/cogl/cogl-context.h | 7 +--
cogl/cogl/cogl-texture-2d-sliced.c | 74 ++---------------------------
cogl/cogl/cogl-types.h | 9 +---
cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 3 --
cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 3 --
cogl/cogl/winsys/cogl-winsys-glx.c | 5 +-
cogl/test-fixtures/test-utils.c | 6 ---
cogl/tests/conform/test-npot-texture.c | 14 +-----
src/compositor/cogl-utils.c | 15 ------
11 files changed, 8 insertions(+), 133 deletions(-)
---
diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h
index 9cb296788..e131209fd 100644
--- a/clutter/clutter/clutter-enums.h
+++ b/clutter/clutter/clutter-enums.h
@@ -909,7 +909,6 @@ typedef enum
/**
* ClutterFeatureFlags:
- * @CLUTTER_FEATURE_TEXTURE_NPOT: Set if NPOTS textures supported.
* @CLUTTER_FEATURE_SWAP_THROTTLE: Set if backend throttles buffer swaps.
* @CLUTTER_FEATURE_TEXTURE_YUV: Set if YUV based textures supported.
* @CLUTTER_FEATURE_TEXTURE_READ_PIXELS: Set if texture pixels can be read.
@@ -928,7 +927,6 @@ typedef enum
*/
typedef enum
{
- CLUTTER_FEATURE_TEXTURE_NPOT = (1 << 2),
CLUTTER_FEATURE_SWAP_THROTTLE = (1 << 3),
CLUTTER_FEATURE_TEXTURE_YUV = (1 << 4),
CLUTTER_FEATURE_TEXTURE_READ_PIXELS = (1 << 5),
diff --git a/clutter/clutter/clutter-feature.c b/clutter/clutter/clutter-feature.c
index 08d9749df..5741391ff 100644
--- a/clutter/clutter/clutter-feature.c
+++ b/clutter/clutter/clutter-feature.c
@@ -64,9 +64,6 @@ clutter_features_from_cogl (guint cogl_flags)
{
ClutterFeatureFlags clutter_flags = 0;
- if (cogl_flags & COGL_FEATURE_TEXTURE_NPOT)
- clutter_flags |= CLUTTER_FEATURE_TEXTURE_NPOT;
-
if (cogl_flags & COGL_FEATURE_TEXTURE_YUV)
clutter_flags |= CLUTTER_FEATURE_TEXTURE_YUV;
diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h
index 65ef4308e..a32e38dba 100644
--- a/cogl/cogl/cogl-context.h
+++ b/cogl/cogl/cogl-context.h
@@ -174,10 +174,6 @@ cogl_is_context (void *object);
* experimental since it's only useable with experimental API... */
/**
* CoglFeatureID:
- * @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
- * and %COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT features combined.
* @COGL_FEATURE_ID_TEXTURE_RECTANGLE: Support for rectangular
* textures with non-normalized texture coordinates.
* @COGL_FEATURE_ID_TEXTURE_RG: Support for
@@ -223,8 +219,7 @@ cogl_is_context (void *object);
*/
typedef enum _CoglFeatureID
{
- COGL_FEATURE_ID_TEXTURE_NPOT = 1,
- COGL_FEATURE_ID_TEXTURE_RECTANGLE,
+ COGL_FEATURE_ID_TEXTURE_RECTANGLE = 1,
COGL_FEATURE_ID_OFFSCREEN,
COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE,
COGL_FEATURE_ID_ONSCREEN_MULTIPLE,
diff --git a/cogl/cogl/cogl-texture-2d-sliced.c b/cogl/cogl/cogl-texture-2d-sliced.c
index 57a0bc601..ab302450a 100644
--- a/cogl/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl/cogl-texture-2d-sliced.c
@@ -585,65 +585,6 @@ _cogl_rect_slices_for_size (int size_to_fill,
return n_spans;
}
-static int
-_cogl_pot_slices_for_size (int size_to_fill,
- int max_span_size,
- int max_waste,
- GArray *out_spans)
-{
- int n_spans = 0;
- CoglSpan span;
-
- /* Init first slice span */
- span.start = 0;
- span.size = max_span_size;
- span.waste = 0;
-
- /* Fix invalid max_waste */
- if (max_waste < 0)
- max_waste = 0;
-
- while (TRUE)
- {
- /* Is the whole area covered? */
- if (size_to_fill > span.size)
- {
- /* Not yet - add a span of this size */
- if (out_spans)
- g_array_append_val (out_spans, span);
-
- span.start += span.size;
- size_to_fill -= span.size;
- n_spans++;
- }
- else if (span.size - size_to_fill <= max_waste)
- {
- /* Yes and waste is small enough */
- /* Pick the next power of two up from size_to_fill. This can
- sometimes be less than the span.size that would be chosen
- otherwise */
- span.size = _cogl_util_next_p2 (size_to_fill);
- span.waste = span.size - size_to_fill;
- if (out_spans)
- g_array_append_val (out_spans, span);
-
- return ++n_spans;
- }
- else
- {
- /* Yes but waste is too large */
- while (span.size - size_to_fill > max_waste)
- {
- span.size /= 2;
- g_assert (span.size > 0);
- }
- }
- }
-
- /* Can't get here */
- return 0;
-}
-
static void
_cogl_texture_2d_sliced_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
GLenum wrap_mode_s,
@@ -700,18 +641,9 @@ setup_spans (CoglContext *ctx,
int (*slices_for_size) (int, int, int, GArray*);
/* Initialize size of largest slice according to supported features */
- if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
- {
- max_width = width;
- max_height = height;
- slices_for_size = _cogl_rect_slices_for_size;
- }
- else
- {
- max_width = _cogl_util_next_p2 (width);
- max_height = _cogl_util_next_p2 (height);
- slices_for_size = _cogl_pot_slices_for_size;
- }
+ max_width = width;
+ max_height = height;
+ slices_for_size = _cogl_rect_slices_for_size;
/* Negative number means no slicing forced by the user */
if (max_waste <= -1)
diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h
index e674921d3..70b2937a5 100644
--- a/cogl/cogl/cogl-types.h
+++ b/cogl/cogl/cogl-types.h
@@ -316,10 +316,6 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
/**
* CoglFeatureFlags:
* @COGL_FEATURE_TEXTURE_RECTANGLE: ARB_texture_rectangle support
- * @COGL_FEATURE_TEXTURE_NPOT: Non power of two textures are supported
- * by the hardware. This is a equivalent to the
- * %COGL_FEATURE_TEXTURE_NPOT_BASIC, %COGL_FEATURE_TEXTURE_NPOT_MIPMAP
- * and %COGL_FEATURE_TEXTURE_NPOT_REPEAT features combined.
* @COGL_FEATURE_TEXTURE_YUV: ycbcr conversion support
* @COGL_FEATURE_TEXTURE_READ_PIXELS: glReadPixels() support
* @COGL_FEATURE_OFFSCREEN: FBO support
@@ -349,7 +345,6 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
typedef enum
{
COGL_FEATURE_TEXTURE_RECTANGLE = (1 << 1),
- COGL_FEATURE_TEXTURE_NPOT = (1 << 2),
COGL_FEATURE_TEXTURE_YUV = (1 << 3),
COGL_FEATURE_TEXTURE_READ_PIXELS = (1 << 4),
COGL_FEATURE_OFFSCREEN = (1 << 6),
@@ -541,9 +536,7 @@ cogl_blend_string_error_quark (void);
*
* <itemizedlist>
* <listitem><para>You've tried to use a feature that is not
- * advertised by cogl_has_feature(). This could happen if you create
- * a 2d texture with a non-power-of-two size when
- * %COGL_FEATURE_ID_TEXTURE_NPOT is not advertised.</para></listitem>
+ * advertised by cogl_has_feature().</para></listitem>
* <listitem><para>The GPU can not handle the configuration you have
* requested. An example might be if you try to use too many texture
* layers in a single #CoglPipeline</para></listitem>
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index 5f6ad6915..57afe5e32 100644
--- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -407,9 +407,6 @@ _cogl_driver_update_features (CoglContext *ctx,
gl_minor,
gl_extensions);
- flags |= COGL_FEATURE_TEXTURE_NPOT;
- COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_NPOT, TRUE);
-
if (_cogl_check_extension ("GL_MESA_pack_invert", gl_extensions))
COGL_FLAGS_SET (private_features,
COGL_PRIVATE_FEATURE_MESA_PACK_INVERT, TRUE);
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index 1766846b0..d2769a805 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -346,9 +346,6 @@ _cogl_driver_update_features (CoglContext *context,
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_DEPTH_TEXTURE, TRUE);
}
- flags |= COGL_FEATURE_TEXTURE_NPOT;
- COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TEXTURE_NPOT, TRUE);
-
if (context->glMapBuffer)
{
/* The GL_OES_mapbuffer extension doesn't support mapping for
diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c
index 235cfe81f..98edfe3a1 100644
--- a/cogl/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/cogl/winsys/cogl-winsys-glx.c
@@ -2545,10 +2545,7 @@ should_use_rectangle (CoglContext *context)
the env var is set to 'allow' or not set and NPOTs textures
are not available */
- context->rectangle_state =
- cogl_has_feature (context, COGL_FEATURE_ID_TEXTURE_NPOT) ?
- COGL_WINSYS_RECTANGLE_STATE_DISABLE :
- COGL_WINSYS_RECTANGLE_STATE_ENABLE;
+ context->rectangle_state = COGL_WINSYS_RECTANGLE_STATE_DISABLE;
if ((rect_env = g_getenv ("COGL_PIXMAP_TEXTURE_RECTANGLE")) ||
/* For compatibility, we'll also look at the old Clutter
diff --git a/cogl/test-fixtures/test-utils.c b/cogl/test-fixtures/test-utils.c
index 06fe2e2d4..c77a90a7c 100644
--- a/cogl/test-fixtures/test-utils.c
+++ b/cogl/test-fixtures/test-utils.c
@@ -24,12 +24,6 @@ check_flags (TestFlags flags,
return FALSE;
}
- if (flags & TEST_REQUIREMENT_NPOT &&
- !cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
- {
- return FALSE;
- }
-
if (flags & TEST_REQUIREMENT_TEXTURE_RECTANGLE &&
!cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
{
diff --git a/cogl/tests/conform/test-npot-texture.c b/cogl/tests/conform/test-npot-texture.c
index fb5639b5c..551f72b7b 100644
--- a/cogl/tests/conform/test-npot-texture.c
+++ b/cogl/tests/conform/test-npot-texture.c
@@ -106,10 +106,8 @@ make_texture (void)
g_print ("Texture is not sliced\n");
}
- /* The texture should be sliced unless NPOTs are supported */
- g_assert (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT)
- ? !cogl_texture_is_sliced (tex)
- : cogl_texture_is_sliced (tex));
+ /* The texture should be sliced unless NPOTs are supported, which they are */
+ g_assert (!cogl_texture_is_sliced (tex));
return tex;
}
@@ -147,14 +145,6 @@ paint (void)
void
test_npot_texture (void)
{
- if (cogl_test_verbose ())
- {
- if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
- g_print ("NPOT textures are supported\n");
- else
- g_print ("NPOT textures are not supported\n");
- }
-
cogl_framebuffer_orthographic (test_fb,
0, 0,
cogl_framebuffer_get_width (test_fb),
diff --git a/src/compositor/cogl-utils.c b/src/compositor/cogl-utils.c
index aed5208fe..68db1118d 100644
--- a/src/compositor/cogl-utils.c
+++ b/src/compositor/cogl-utils.c
@@ -67,11 +67,6 @@ meta_create_texture_pipeline (CoglTexture *src_texture)
return pipeline;
}
-static gboolean is_pot(int x)
-{
- return x > 0 && (x & (x - 1)) == 0;
-}
-
/**
* meta_create_texture:
* @width: width of the texture to create
@@ -108,16 +103,6 @@ meta_create_texture (int width,
gboolean should_use_rectangle = FALSE;
- if (!(is_pot (width) && is_pot (height)) &&
- !cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
- {
- if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
- should_use_rectangle = TRUE;
- else
- g_error ("Cannot create texture. Support for GL_ARB_texture_non_power_of_two or "
- "ARB_texture_rectangle is required");
- }
-
if (should_use_rectangle)
texture = COGL_TEXTURE (cogl_texture_rectangle_new_with_size (ctx, width, height));
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]