cogl: Remove always-set COGL_FEATURE_ID_OFFSCREEN

https://gitlab.gnome.org/GNOME/mutter/merge_requests/866
This commit is contained in:
Adam Jackson 2019-10-17 18:30:28 -04:00 committed by Georges Basile Stavracas Neto
parent 4523251849
commit 6a8830a551
10 changed files with 9 additions and 133 deletions

View File

@ -729,18 +729,6 @@ allocate_space (CoglAtlasTexture *atlas_tex,
return FALSE;
}
/* If we can't use FBOs then it will be too slow to migrate textures
and we shouldn't use the atlas */
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
{
g_set_error_literal (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Atlasing disabled because migrations "
"would be too slow");
return FALSE;
}
/* Look for an existing atlas that can hold the texture */
for (l = ctx->atlases; l; l = l->next)
{

View File

@ -177,7 +177,6 @@ cogl_is_context (void *object);
* @COGL_FEATURE_ID_TEXTURE_RG: Support for
* %COGL_TEXTURE_COMPONENTS_RG as the internal components of a
* texture.
* @COGL_FEATURE_ID_OFFSCREEN: Offscreen rendering support
* @COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE: Multisample support for
* offscreen framebuffers
* @COGL_FEATURE_ID_ONSCREEN_MULTIPLE: Multiple onscreen framebuffers
@ -208,7 +207,6 @@ cogl_is_context (void *object);
*/
typedef enum _CoglFeatureID
{
COGL_FEATURE_ID_OFFSCREEN,
COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE,
COGL_FEATURE_ID_ONSCREEN_MULTIPLE,
COGL_FEATURE_ID_UNSIGNED_INT_INDICES,

View File

@ -728,14 +728,6 @@ cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
{
CoglOffscreen *offscreen = COGL_OFFSCREEN (framebuffer);
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
{
g_set_error_literal (error, COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Offscreen framebuffers not supported by system");
return FALSE;
}
if (!cogl_texture_allocate (offscreen->texture, error))
return FALSE;

View File

@ -546,9 +546,6 @@ get_texture_bits_via_offscreen (CoglTexture *meta_texture,
GError *ignore_error = NULL;
CoglPixelFormat real_format;
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
return FALSE;
offscreen = _cogl_offscreen_new_with_texture_full
(sub_texture,
COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL,

View File

@ -279,8 +279,6 @@ _cogl_framebuffer_gl_bind (CoglFramebuffer *framebuffer, GLenum target)
const CoglWinsysVtable *winsys =
_cogl_framebuffer_get_winsys (framebuffer);
winsys->onscreen_bind (COGL_ONSCREEN (framebuffer));
/* glBindFramebuffer is an an extension with OpenGL ES 1.1 */
if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
GE (ctx, glBindFramebuffer (target, 0));
/* Initialise the glDrawBuffer state the first time the context

View File

@ -238,35 +238,6 @@ allocate_from_bitmap (CoglTexture2D *tex_2d,
NULL,
NULL);
/* Keep a copy of the first pixel so that if glGenerateMipmap isn't
supported we can fallback to using GL_GENERATE_MIPMAP */
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
{
GError *ignore = NULL;
uint8_t *data = _cogl_bitmap_map (upload_bmp,
COGL_BUFFER_ACCESS_READ, 0,
&ignore);
CoglPixelFormat format = cogl_bitmap_get_format (upload_bmp);
tex_2d->first_pixel.gl_format = gl_format;
tex_2d->first_pixel.gl_type = gl_type;
if (data)
{
memcpy (tex_2d->first_pixel.data, data,
cogl_pixel_format_get_bytes_per_pixel (format, 0));
_cogl_bitmap_unmap (upload_bmp);
}
else
{
g_warning ("Failed to read first pixel of bitmap for "
"glGenerateMipmap fallback");
g_error_free (ignore);
memset (tex_2d->first_pixel.data, 0,
cogl_pixel_format_get_bytes_per_pixel (format, 0));
}
}
tex_2d->gl_texture =
ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, internal_format);
if (!ctx->texture_driver->upload_to_gl (ctx,
@ -724,32 +695,7 @@ _cogl_texture_2d_gl_get_gl_handle (CoglTexture2D *tex_2d)
void
_cogl_texture_2d_gl_generate_mipmap (CoglTexture2D *tex_2d)
{
CoglContext *ctx = COGL_TEXTURE (tex_2d)->context;
/* glGenerateMipmap is defined in the FBO extension. If it's not
available we'll fallback to temporarily enabling
GL_GENERATE_MIPMAP and reuploading the first pixel */
if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
_cogl_texture_gl_generate_mipmaps (COGL_TEXTURE (tex_2d));
#ifdef HAVE_COGL_GL
else
{
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
tex_2d->gl_texture,
tex_2d->is_foreign);
GE( ctx, glTexParameteri (GL_TEXTURE_2D,
GL_GENERATE_MIPMAP,
GL_TRUE) );
GE( ctx, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 1, 1,
tex_2d->first_pixel.gl_format,
tex_2d->first_pixel.gl_type,
tex_2d->first_pixel.data) );
GE( ctx, glTexParameteri (GL_TEXTURE_2D,
GL_GENERATE_MIPMAP,
GL_FALSE) );
}
#endif
}
gboolean
@ -793,36 +739,6 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
&gl_format,
&gl_type);
/* If this touches the first pixel then we'll update our copy */
if (dst_x == 0 && dst_y == 0 &&
!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
{
GError *ignore = NULL;
uint8_t *data =
_cogl_bitmap_map (upload_bmp, COGL_BUFFER_ACCESS_READ, 0, &ignore);
int bpp = cogl_pixel_format_get_bytes_per_pixel (upload_format, 0);
tex_2d->first_pixel.gl_format = gl_format;
tex_2d->first_pixel.gl_type = gl_type;
if (data)
{
memcpy (tex_2d->first_pixel.data,
(data +
cogl_bitmap_get_rowstride (upload_bmp) * src_y +
bpp * src_x),
bpp);
_cogl_bitmap_unmap (bmp);
}
else
{
g_warning ("Failed to read first bitmap pixel for "
"glGenerateMipmap fallback");
g_error_free (ignore);
memset (tex_2d->first_pixel.data, 0, bpp);
}
}
status = ctx->texture_driver->upload_subregion_to_gl (ctx,
tex,
FALSE,

View File

@ -416,7 +416,6 @@ _cogl_driver_update_features (CoglContext *ctx,
return FALSE;
}
flags |= COGL_FEATURE_OFFSCREEN;
COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_OFFSCREEN, TRUE);
COGL_FLAGS_SET (private_features,
COGL_PRIVATE_FEATURE_QUERY_FRAMEBUFFER_BITS,
TRUE);

View File

@ -304,7 +304,6 @@ _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. */
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_OFFSCREEN, TRUE);
COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_ANY_GL, TRUE);
COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_ALPHA_TEXTURES, TRUE);
@ -312,7 +311,6 @@ _cogl_driver_update_features (CoglContext *context,
if (context->glGenRenderbuffers)
{
flags |= COGL_FEATURE_OFFSCREEN;
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_OFFSCREEN, TRUE);
}
if (context->glBlitFramebuffer)

View File

@ -2223,9 +2223,6 @@ get_fbconfig_for_depth (CoglContext *context,
stencil = value;
/* glGenerateMipmap is defined in the offscreen extension */
if (cogl_has_feature (context, COGL_FEATURE_ID_OFFSCREEN))
{
glx_renderer->glXGetFBConfigAttrib (dpy,
fbconfigs[i],
GLX_BIND_TO_MIPMAP_TEXTURE_EXT,
@ -2235,7 +2232,6 @@ get_fbconfig_for_depth (CoglContext *context,
continue;
mipmap = value;
}
*fbconfig_ret = fbconfigs[i];
*can_mipmap_ret = mipmap;

View File

@ -36,12 +36,6 @@ check_flags (TestFlags flags,
return FALSE;
}
if (flags & TEST_REQUIREMENT_OFFSCREEN &&
!cogl_has_feature (test_ctx, COGL_FEATURE_ID_OFFSCREEN))
{
return FALSE;
}
if (flags & TEST_REQUIREMENT_FENCE &&
!cogl_has_feature (test_ctx, COGL_FEATURE_ID_FENCE))
{