From 6a8830a5513458615a8fce263eb72d20f1dd2247 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 17 Oct 2019 18:30:28 -0400 Subject: [PATCH] cogl: Remove always-set COGL_FEATURE_ID_OFFSCREEN https://gitlab.gnome.org/GNOME/mutter/merge_requests/866 --- cogl/cogl/cogl-atlas-texture.c | 12 --- cogl/cogl/cogl-context.h | 2 - cogl/cogl/cogl-framebuffer.c | 8 -- cogl/cogl/cogl-texture.c | 3 - cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 4 +- cogl/cogl/driver/gl/cogl-texture-2d-gl.c | 86 +-------------------- cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 1 - cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 2 - cogl/cogl/winsys/cogl-winsys-glx.c | 18 ++--- cogl/test-fixtures/test-utils.c | 6 -- 10 files changed, 9 insertions(+), 133 deletions(-) diff --git a/cogl/cogl/cogl-atlas-texture.c b/cogl/cogl/cogl-atlas-texture.c index 766d747d3..907a441f4 100644 --- a/cogl/cogl/cogl-atlas-texture.c +++ b/cogl/cogl/cogl-atlas-texture.c @@ -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) { diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h index f0f47240c..2f77960ee 100644 --- a/cogl/cogl/cogl-context.h +++ b/cogl/cogl/cogl-context.h @@ -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, diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index a9fffac5b..31a04f229 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -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; diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index c1c67ecda..86b94e9d3 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -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, diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c index c0a15a688..d9d9e5690 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c @@ -279,9 +279,7 @@ _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)); + GE (ctx, glBindFramebuffer (target, 0)); /* Initialise the glDrawBuffer state the first time the context * is bound to the default framebuffer. If the winsys is using a diff --git a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c index 7c6526db3..1ffcc968b 100644 --- a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c +++ b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c @@ -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 + _cogl_texture_gl_generate_mipmaps (COGL_TEXTURE (tex_2d)); } 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, diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index d39b986a3..d0e3e5091 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -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); diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index 59e6d50a9..dfe17be4b 100644 --- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c @@ -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) diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c index 992093454..068316ac4 100644 --- a/cogl/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/cogl/winsys/cogl-winsys-glx.c @@ -2223,19 +2223,15 @@ 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, - &value); + glx_renderer->glXGetFBConfigAttrib (dpy, + fbconfigs[i], + GLX_BIND_TO_MIPMAP_TEXTURE_EXT, + &value); - if (value < mipmap) - continue; + if (value < mipmap) + continue; - mipmap = value; - } + mipmap = value; *fbconfig_ret = fbconfigs[i]; *can_mipmap_ret = mipmap; diff --git a/cogl/test-fixtures/test-utils.c b/cogl/test-fixtures/test-utils.c index f734cb62a..6834f9fac 100644 --- a/cogl/test-fixtures/test-utils.c +++ b/cogl/test-fixtures/test-utils.c @@ -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)) {