mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
cogl: Revert swizzling for BGRA buffers
As it was originally reported on https://bugzilla.gnome.org/show_bug.cgi?id=779234#c0, the hottest path was convert_ubyte() in mesa. Reverting this shows no trace of those hot paths, nor any higher than usual CPU activity. As the improvements at the time were real, I can only conclude that pixel conversion was happening somewhere further the pipeline, and swizzling just helped indirectly. That got eventually fixed, so swizzling just stayed to cause grief. And lots it caused. Time to bin this, it seems. https://gitlab.gnome.org/GNOME/mutter/merge_requests/486
This commit is contained in:
parent
d83a325f98
commit
a871d56f88
@ -55,13 +55,6 @@ struct _CoglDriverVtable
|
|||||||
GLenum *out_glintformat,
|
GLenum *out_glintformat,
|
||||||
GLenum *out_glformat,
|
GLenum *out_glformat,
|
||||||
GLenum *out_gltype);
|
GLenum *out_gltype);
|
||||||
CoglPixelFormat
|
|
||||||
(* pixel_format_to_gl_with_target) (CoglContext *context,
|
|
||||||
CoglPixelFormat format,
|
|
||||||
CoglPixelFormat target_format,
|
|
||||||
GLenum *out_glintformat,
|
|
||||||
GLenum *out_glformat,
|
|
||||||
GLenum *out_gltype);
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
(* update_features) (CoglContext *context,
|
(* update_features) (CoglContext *context,
|
||||||
|
@ -198,7 +198,6 @@ struct _CoglTextureDriver
|
|||||||
CoglPixelFormat
|
CoglPixelFormat
|
||||||
(* find_best_gl_get_data_format) (CoglContext *context,
|
(* find_best_gl_get_data_format) (CoglContext *context,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
CoglPixelFormat target_format,
|
|
||||||
GLenum *closest_gl_format,
|
GLenum *closest_gl_format,
|
||||||
GLenum *closest_gl_type);
|
GLenum *closest_gl_type);
|
||||||
};
|
};
|
||||||
|
@ -787,7 +787,6 @@ cogl_texture_get_data (CoglTexture *texture,
|
|||||||
|
|
||||||
closest_format =
|
closest_format =
|
||||||
ctx->texture_driver->find_best_gl_get_data_format (ctx,
|
ctx->texture_driver->find_best_gl_get_data_format (ctx,
|
||||||
texture_format,
|
|
||||||
format,
|
format,
|
||||||
&closest_gl_format,
|
&closest_gl_format,
|
||||||
&closest_gl_type);
|
&closest_gl_type);
|
||||||
|
@ -1274,12 +1274,8 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
|
|||||||
if (!cogl_is_offscreen (framebuffer))
|
if (!cogl_is_offscreen (framebuffer))
|
||||||
y = framebuffer_height - y - height;
|
y = framebuffer_height - y - height;
|
||||||
|
|
||||||
/* Use target format ANY, because GL texture_swizzle extension cannot
|
required_format = ctx->driver_vtable->pixel_format_to_gl (ctx,
|
||||||
* ever apply for glReadPixels.
|
|
||||||
*/
|
|
||||||
required_format = ctx->driver_vtable->pixel_format_to_gl_with_target (ctx,
|
|
||||||
format,
|
format,
|
||||||
COGL_PIXEL_FORMAT_ANY,
|
|
||||||
&gl_intformat,
|
&gl_intformat,
|
||||||
&gl_format,
|
&gl_format,
|
||||||
&gl_type);
|
&gl_type);
|
||||||
|
@ -781,9 +781,8 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
|
|||||||
|
|
||||||
upload_format = cogl_bitmap_get_format (upload_bmp);
|
upload_format = cogl_bitmap_get_format (upload_bmp);
|
||||||
|
|
||||||
ctx->driver_vtable->pixel_format_to_gl_with_target (ctx,
|
ctx->driver_vtable->pixel_format_to_gl (ctx,
|
||||||
upload_format,
|
upload_format,
|
||||||
_cogl_texture_get_format (tex),
|
|
||||||
NULL, /* internal gl format */
|
NULL, /* internal gl format */
|
||||||
&gl_format,
|
&gl_format,
|
||||||
&gl_type);
|
&gl_type);
|
||||||
|
@ -94,9 +94,8 @@ _cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CoglPixelFormat
|
static CoglPixelFormat
|
||||||
_cogl_driver_pixel_format_to_gl_with_target (CoglContext *context,
|
_cogl_driver_pixel_format_to_gl (CoglContext *context,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
CoglPixelFormat target_format,
|
|
||||||
GLenum *out_glintformat,
|
GLenum *out_glintformat,
|
||||||
GLenum *out_glformat,
|
GLenum *out_glformat,
|
||||||
GLenum *out_gltype)
|
GLenum *out_gltype)
|
||||||
@ -173,15 +172,6 @@ _cogl_driver_pixel_format_to_gl_with_target (CoglContext *context,
|
|||||||
case COGL_PIXEL_FORMAT_BGRA_8888:
|
case COGL_PIXEL_FORMAT_BGRA_8888:
|
||||||
case COGL_PIXEL_FORMAT_BGRA_8888_PRE:
|
case COGL_PIXEL_FORMAT_BGRA_8888_PRE:
|
||||||
glintformat = GL_RGBA;
|
glintformat = GL_RGBA;
|
||||||
/* If the driver has texture_swizzle, pretend internal
|
|
||||||
* and buffer format are the same here, the pixels
|
|
||||||
* will be flipped through this extension.
|
|
||||||
*/
|
|
||||||
if (target_format == format &&
|
|
||||||
_cogl_has_private_feature
|
|
||||||
(context, COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE))
|
|
||||||
glformat = GL_RGBA;
|
|
||||||
else
|
|
||||||
glformat = GL_BGRA;
|
glformat = GL_BGRA;
|
||||||
gltype = GL_UNSIGNED_BYTE;
|
gltype = GL_UNSIGNED_BYTE;
|
||||||
break;
|
break;
|
||||||
@ -297,20 +287,6 @@ _cogl_driver_pixel_format_to_gl_with_target (CoglContext *context,
|
|||||||
return required_format;
|
return required_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglPixelFormat
|
|
||||||
_cogl_driver_pixel_format_to_gl (CoglContext *context,
|
|
||||||
CoglPixelFormat format,
|
|
||||||
GLenum *out_glintformat,
|
|
||||||
GLenum *out_glformat,
|
|
||||||
GLenum *out_gltype)
|
|
||||||
{
|
|
||||||
return _cogl_driver_pixel_format_to_gl_with_target (context,
|
|
||||||
format, format,
|
|
||||||
out_glintformat,
|
|
||||||
out_glformat,
|
|
||||||
out_gltype);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_get_gl_version (CoglContext *ctx,
|
_cogl_get_gl_version (CoglContext *ctx,
|
||||||
int *major_out,
|
int *major_out,
|
||||||
@ -685,7 +661,6 @@ _cogl_driver_gl =
|
|||||||
{
|
{
|
||||||
_cogl_driver_pixel_format_from_gl_internal,
|
_cogl_driver_pixel_format_from_gl_internal,
|
||||||
_cogl_driver_pixel_format_to_gl,
|
_cogl_driver_pixel_format_to_gl,
|
||||||
_cogl_driver_pixel_format_to_gl_with_target,
|
|
||||||
_cogl_driver_update_features,
|
_cogl_driver_update_features,
|
||||||
_cogl_offscreen_gl_allocate,
|
_cogl_offscreen_gl_allocate,
|
||||||
_cogl_offscreen_gl_free,
|
_cogl_offscreen_gl_free,
|
||||||
|
@ -112,18 +112,6 @@ _cogl_texture_driver_gen (CoglContext *ctx,
|
|||||||
red_swizzle) );
|
red_swizzle) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If swizzle extension is available, prefer it to flip bgra buffers to rgba */
|
|
||||||
if ((internal_format == COGL_PIXEL_FORMAT_BGRA_8888 ||
|
|
||||||
internal_format == COGL_PIXEL_FORMAT_BGRA_8888_PRE) &&
|
|
||||||
_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE))
|
|
||||||
{
|
|
||||||
static const GLint bgra_swizzle[] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
|
||||||
|
|
||||||
GE( ctx, glTexParameteriv (gl_target,
|
|
||||||
GL_TEXTURE_SWIZZLE_RGBA,
|
|
||||||
bgra_swizzle) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,13 +519,11 @@ static CoglPixelFormat
|
|||||||
_cogl_texture_driver_find_best_gl_get_data_format
|
_cogl_texture_driver_find_best_gl_get_data_format
|
||||||
(CoglContext *context,
|
(CoglContext *context,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
CoglPixelFormat target_format,
|
|
||||||
GLenum *closest_gl_format,
|
GLenum *closest_gl_format,
|
||||||
GLenum *closest_gl_type)
|
GLenum *closest_gl_type)
|
||||||
{
|
{
|
||||||
return context->driver_vtable->pixel_format_to_gl_with_target (context,
|
return context->driver_vtable->pixel_format_to_gl (context,
|
||||||
format,
|
format,
|
||||||
target_format,
|
|
||||||
NULL, /* don't need */
|
NULL, /* don't need */
|
||||||
closest_gl_format,
|
closest_gl_format,
|
||||||
closest_gl_type);
|
closest_gl_type);
|
||||||
|
@ -65,9 +65,8 @@ _cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CoglPixelFormat
|
static CoglPixelFormat
|
||||||
_cogl_driver_pixel_format_to_gl_with_target (CoglContext *context,
|
_cogl_driver_pixel_format_to_gl (CoglContext *context,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
CoglPixelFormat target_format,
|
|
||||||
GLenum *out_glintformat,
|
GLenum *out_glintformat,
|
||||||
GLenum *out_glformat,
|
GLenum *out_glformat,
|
||||||
GLenum *out_gltype)
|
GLenum *out_gltype)
|
||||||
@ -218,20 +217,6 @@ _cogl_driver_pixel_format_to_gl_with_target (CoglContext *context,
|
|||||||
return required_format;
|
return required_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglPixelFormat
|
|
||||||
_cogl_driver_pixel_format_to_gl (CoglContext *context,
|
|
||||||
CoglPixelFormat format,
|
|
||||||
GLenum *out_glintformat,
|
|
||||||
GLenum *out_glformat,
|
|
||||||
GLenum *out_gltype)
|
|
||||||
{
|
|
||||||
return _cogl_driver_pixel_format_to_gl_with_target (context,
|
|
||||||
format, format,
|
|
||||||
out_glintformat,
|
|
||||||
out_glformat,
|
|
||||||
out_gltype);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_get_gl_version (CoglContext *ctx,
|
_cogl_get_gl_version (CoglContext *ctx,
|
||||||
int *major_out,
|
int *major_out,
|
||||||
@ -449,7 +434,6 @@ _cogl_driver_gles =
|
|||||||
{
|
{
|
||||||
_cogl_driver_pixel_format_from_gl_internal,
|
_cogl_driver_pixel_format_from_gl_internal,
|
||||||
_cogl_driver_pixel_format_to_gl,
|
_cogl_driver_pixel_format_to_gl,
|
||||||
_cogl_driver_pixel_format_to_gl_with_target,
|
|
||||||
_cogl_driver_update_features,
|
_cogl_driver_update_features,
|
||||||
_cogl_offscreen_gl_allocate,
|
_cogl_offscreen_gl_allocate,
|
||||||
_cogl_offscreen_gl_free,
|
_cogl_offscreen_gl_free,
|
||||||
|
@ -613,7 +613,6 @@ static CoglPixelFormat
|
|||||||
_cogl_texture_driver_find_best_gl_get_data_format
|
_cogl_texture_driver_find_best_gl_get_data_format
|
||||||
(CoglContext *context,
|
(CoglContext *context,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
CoglPixelFormat target_format,
|
|
||||||
GLenum *closest_gl_format,
|
GLenum *closest_gl_format,
|
||||||
GLenum *closest_gl_type)
|
GLenum *closest_gl_type)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,6 @@ _cogl_driver_nop =
|
|||||||
{
|
{
|
||||||
NULL, /* pixel_format_from_gl_internal */
|
NULL, /* pixel_format_from_gl_internal */
|
||||||
NULL, /* pixel_format_to_gl */
|
NULL, /* pixel_format_to_gl */
|
||||||
NULL, /* pixel_format_to_gl_with_target */
|
|
||||||
_cogl_driver_update_features,
|
_cogl_driver_update_features,
|
||||||
_cogl_offscreen_nop_allocate,
|
_cogl_offscreen_nop_allocate,
|
||||||
_cogl_offscreen_nop_free,
|
_cogl_offscreen_nop_free,
|
||||||
|
Loading…
Reference in New Issue
Block a user