radv: Only save the descriptor set if we have one.
[mesa.git] / src / mesa / drivers / dri / nouveau / nouveau_driver.c
index 1a8afa2af121488f42e5df5ea1eb2b7cf1239dfc..1698df6ab1908089fe40c1ae6b3bec221acded42 100644 (file)
@@ -24,6 +24,7 @@
  *
  */
 
+#include <stdio.h>
 #include "main/mtypes.h"
 #include "main/fbobject.h"
 
 
 #include "drivers/common/meta.h"
 
-static const GLubyte *
-nouveau_get_string(struct gl_context *ctx, GLenum name)
+const char * const nouveau_vendor_string = "Nouveau";
+
+const char *
+nouveau_get_renderer_string(unsigned chipset)
 {
-       static char buffer[128];
        char hardware_name[32];
+       static char buffer[128];
+
+       snprintf(hardware_name, sizeof(hardware_name), "nv%02X", chipset);
+       driGetRendererString(buffer, hardware_name, 0);
 
+       return buffer;
+}
+
+static const GLubyte *
+nouveau_get_string(struct gl_context *ctx, GLenum name)
+{
        switch (name) {
                case GL_VENDOR:
-                       return (GLubyte *)"Nouveau";
+                       return (GLubyte *)nouveau_vendor_string;
 
                case GL_RENDERER:
-                       sprintf(hardware_name, "nv%02X", context_chipset(ctx));
-                       driGetRendererString(buffer, hardware_name, 0);
-
-                       return (GLubyte *)buffer;
+                       return (GLubyte *)nouveau_get_renderer_string(context_chipset(ctx));
                default:
                        return NULL;
        }
@@ -114,8 +123,22 @@ nouveau_clear(struct gl_context *ctx, GLbitfield buffers)
                        fb->Attachment[i].Renderbuffer)->surface;
 
                if (buf & BUFFER_BITS_COLOR) {
-                       mask = pack_rgba_i(s->format, ctx->Color.ColorMask[0]);
-                       value = pack_rgba_clamp_f(s->format, ctx->Color.ClearColor.f);
+                       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);
+
+                       const uint8_t colormask[4] = {
+                               GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0) ? 0xff : 0,
+                               GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1) ? 0xff : 0,
+                               GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2) ? 0xff : 0,
+                               GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3) ? 0xff : 0,
+                       };
+                       mask = pack_rgba_i(s->format, colormask);
 
                        if (mask)
                                context_drv(ctx)->surface_fill(
@@ -155,5 +178,5 @@ nouveau_driver_functions_init(struct dd_function_table *functions)
        functions->DrawPixels = _mesa_meta_DrawPixels;
        functions->CopyPixels = _mesa_meta_CopyPixels;
        functions->Bitmap = _mesa_meta_Bitmap;
-       functions->BlitFramebuffer = _mesa_meta_BlitFramebuffer;
+       functions->BlitFramebuffer = _mesa_meta_and_swrast_BlitFramebuffer;
 }