[Cogl] [PATCH 5/5] Add a workaround for slow read pixels on Mesa

Robert Bragg robert at sixbynine.org
Tue Apr 3 10:23:10 PDT 2012


> @@ -1983,6 +2075,17 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
>         return TRUE;
>     }
>
> +  /* Workaround for cases where its faster to read into a temporary
> +     PBO */
> +  if ((ctx->gpu.driver_bugs & COGL_GPU_DRIVER_BUG_SLOW_READ_PIXELS) &&
> +      (width > 8 || height > 8) &&
> +      (format & ~COGL_PREMULT_BIT) == COGL_PIXEL_FORMAT_BGRA_8888 &&
> +      cogl_bitmap_get_buffer (bitmap) == NULL)
> +    return _cogl_framebuffer_slow_read_pixels_workaround (framebuffer,
> +                                                          x, y,
> +                                                          source,
> +                                                          bitmap);
> +

The checks for (width > 8 || height > 8) and (format &
~COGL_PREMULT_BIT) == COGL_PIXEL_FORMAT_BGRA_8888 look like they are
checking for very specific constraints for using the PBO fast path in
the intel mesa driver that you would only know from reading the mesa
source code.

It seems that we should have a big comment here explaining why these
are things we need to check for.

I also wonder if "COGL_GPU_DRIVER_BUG_SLOW_READ_PIXELS" is too vague
and if it should maybe be something more explicit like
"COGL_GPU_DRIVER_BUG_MESA_LT_8_0_1_SLOW_READ_PIXELS". I can imagine
that this won't be the last bug we see relating to slow read-pixels
performance.

Maybe we could even include a bugzilla number by convention in our
driver bug enums to help make it easier to look up more detailed info
about a particular workaround?

Apart from that this patch looks good to me assuming we figure out the
things raised about new cogl_gpu_ api it builds on.

thanks,
- Robert


More information about the Cogl mailing list