[Mesa-dev] [PATCH v2] nouveau: force luminance clear colors to have the same g/b values as r

Francisco Jerez currojerez at riseup.net
Wed Aug 13 21:16:26 PDT 2014


Ilia Mirkin <imirkin at alum.mit.edu> writes:

> Fixes the LUMINANCE_ALPHA formats of fbo-clear-formats piglit test.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  src/mesa/drivers/dri/nouveau/nouveau_driver.c | 10 +++++++++-
>  src/mesa/drivers/dri/nouveau/nouveau_util.h   |  9 +++++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c
> index b0afb69..e61bf4e 100644
> --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c
> +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c
> @@ -114,8 +114,16 @@ nouveau_clear(struct gl_context *ctx, GLbitfield buffers)
>  			fb->Attachment[i].Renderbuffer)->surface;
>  
>  		if (buf & BUFFER_BITS_COLOR) {
> +			float *color = ctx->Color.ClearColor.f;

This should probably be declared const.  With that fixed:

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

> +
> +			if (fb->Attachment[i].Renderbuffer->_BaseFormat ==
> +			    GL_LUMINANCE_ALPHA)
> +				value = pack_la_clamp_f(
> +						s->format, color[0], color[3]);
> +			else
> +				value = pack_rgba_clamp_f(s->format, color);
> +
>  			mask = pack_rgba_i(s->format, ctx->Color.ColorMask[0]);
> -			value = pack_rgba_clamp_f(s->format, ctx->Color.ClearColor.f);
>  
>  			if (mask)
>  				context_drv(ctx)->surface_fill(
> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_util.h b/src/mesa/drivers/dri/nouveau/nouveau_util.h
> index 56b819b..d11bae2 100644
> --- a/src/mesa/drivers/dri/nouveau/nouveau_util.h
> +++ b/src/mesa/drivers/dri/nouveau/nouveau_util.h
> @@ -92,6 +92,15 @@ pack_zs_f(mesa_format f, float z, uint8_t s)
>  	return pack_zs_i(f, FLOAT_TO_UINT(z), s);
>  }
>  
> +static inline unsigned
> +pack_la_clamp_f(mesa_format f, float l, float a)
> +{
> +	GLubyte lb, ab;
> +	UNCLAMPED_FLOAT_TO_UBYTE(lb, l);
> +	UNCLAMPED_FLOAT_TO_UBYTE(ab, a);
> +	return pack_rgba_i(f, (uint8_t []) { lb, lb, lb, ab });
> +}
> +
>  /* Integer base-2 logarithm, rounded towards zero. */
>  static inline unsigned
>  log2i(unsigned i)
> -- 
> 1.8.5.5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140814/51259d03/attachment-0001.sig>


More information about the mesa-dev mailing list