nouveau: force luminance clear colors to have the same g/b values as r
authorIlia Mirkin <imirkin@alum.mit.edu>
Sun, 10 Aug 2014 19:13:44 +0000 (15:13 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Thu, 14 Aug 2014 06:05:06 +0000 (02:05 -0400)
Fixes the LUMINANCE_ALPHA formats of fbo-clear-formats piglit test.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/mesa/drivers/dri/nouveau/nouveau_driver.c
src/mesa/drivers/dri/nouveau/nouveau_util.h

index b0afb69e221de95a48954783e733fa5e06a6789b..b2887f83e6c07e7194616188193a2f501b71e90d 100644 (file)
@@ -114,8 +114,16 @@ nouveau_clear(struct gl_context *ctx, GLbitfield buffers)
                        fb->Attachment[i].Renderbuffer)->surface;
 
                if (buf & BUFFER_BITS_COLOR) {
+                       const float *color = ctx->Color.ClearColor.f;
+
+                       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(
index 56b819bcff869c9b21412e6f9b251637e6d88477..e9721c3a7abd533025b0a00ea44e18a387f28347 100644 (file)
@@ -31,7 +31,7 @@
 #include "main/colormac.h"
 
 static inline unsigned
-pack_rgba_i(mesa_format f, uint8_t c[])
+pack_rgba_i(mesa_format f, const uint8_t c[])
 {
        switch (f) {
        case MESA_FORMAT_B8G8R8A8_UNORM:
@@ -69,7 +69,7 @@ pack_zs_i(mesa_format f, uint32_t z, uint8_t s)
 }
 
 static inline unsigned
-pack_rgba_f(mesa_format f, float c[])
+pack_rgba_f(mesa_format f, const float c[])
 {
        return pack_rgba_i(f, (uint8_t []) {
                           FLOAT_TO_UBYTE(c[RCOMP]),
@@ -79,7 +79,7 @@ pack_rgba_f(mesa_format f, float c[])
 }
 
 static inline unsigned
-pack_rgba_clamp_f(mesa_format f, float c[])
+pack_rgba_clamp_f(mesa_format f, const float c[])
 {
        GLubyte bytes[4];
        _mesa_unclamped_float_rgba_to_ubyte(bytes, c);
@@ -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)