cogl: NPOT textures are always available

https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
This commit is contained in:
Adam Jackson 2019-03-28 15:17:14 -04:00
parent 48f04c7968
commit fc09fa50a5
11 changed files with 8 additions and 133 deletions

View File

@ -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),

View File

@ -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;

View File

@ -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,

View File

@ -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;
}
/* Negative number means no slicing forced by the user */
if (max_waste <= -1)

View File

@ -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>

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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))
{

View File

@ -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),

View File

@ -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