[Mesa-dev] [PATCH 1/2] swrast: avoid calling _mesa_get_srgb_format_linear() inside a loop

Eric Anholt eric at anholt.net
Thu Nov 10 17:09:23 PST 2011


On Thu, 10 Nov 2011 18:01:46 -0700, Brian Paul <brianp at vmware.com> wrote:
> ---
>  src/mesa/swrast/s_readpix.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
> index 54f42db..3cef730 100644
> --- a/src/mesa/swrast/s_readpix.c
> +++ b/src/mesa/swrast/s_readpix.c
> @@ -236,6 +236,7 @@ slow_read_rgba_pixels( struct gl_context *ctx,
>  		       GLbitfield transferOps )
>  {
>     struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
> +   const gl_format rbFormat = _mesa_get_srgb_format_linear(rb->Format);
>     union {
>        float f[MAX_WIDTH][4];
>        unsigned int i[MAX_WIDTH][4];
> @@ -252,11 +253,10 @@ slow_read_rgba_pixels( struct gl_context *ctx,
>  
>     for (j = 0; j < height; j++) {
>        if (_mesa_is_integer_format(format)) {
> -	 _mesa_unpack_int_rgba_row(rb->Format, width, map, rgba.i);
> +	 _mesa_unpack_int_rgba_row(rbFormat, width, map, rgba.i);
>  	 _mesa_pack_rgba_span_int(ctx, width, rgba.i, format, type, dst);
>        } else {
> -	 _mesa_unpack_rgba_row(_mesa_get_srgb_format_linear(rb->Format),
> -			       width, map, rgba.f);
> +	 _mesa_unpack_rgba_row(rbFormat, width, map, rgba.f);
>  	 _mesa_pack_rgba_span_float(ctx, width, rgba.f, format, type, dst,
>  				    packing, transferOps);
>        }

It's lame that we keep having to do the compiler's job for it.  I'd like
us to just annotate these constant format functions with the attribute
that tells the compiler so.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20111110/2153a58f/attachment.pgp>


More information about the mesa-dev mailing list