glsl: fix some uninitialized pointers
[mesa.git] / src / mesa / state_tracker / st_cb_clear.c
index 5bdc6a13309348008fe7f1da150a9b57cdb1fb83..8a8c99f7e171e5ee1368e8c6991a26aa964949ca 100644 (file)
@@ -45,6 +45,7 @@
 #include "st_program.h"
 #include "st_public.h"
 #include "st_mesa_to_tgsi.h"
+#include "st_inlines.h"
 
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
@@ -102,20 +103,6 @@ st_destroy_clear(struct st_context *st)
 }
 
 
-static GLboolean
-is_depth_stencil_format(enum pipe_format pipeFormat)
-{
-   switch (pipeFormat) {
-   case PIPE_FORMAT_S8Z24_UNORM:
-   case PIPE_FORMAT_Z24S8_UNORM:
-      return GL_TRUE;
-   default:
-      return GL_FALSE;
-   }
-}
-
-
-
 /**
  * Draw a screen-aligned quadrilateral.
  * Coords are window coords with y=0=bottom.  These will be passed
@@ -166,10 +153,10 @@ draw_quad(GLcontext *ctx,
    }
 
    /* put vertex data into vbuf */
-   pipe_buffer_write(pipe->screen, st->clear.vbuf, 
-                     st->clear.vbuf_slot * sizeof(st->clear.vertices),
-                     sizeof(st->clear.vertices),
-                     st->clear.vertices);
+   st_no_flush_pipe_buffer_write(st, st->clear.vbuf,
+                                st->clear.vbuf_slot * sizeof(st->clear.vertices),
+                                sizeof(st->clear.vertices),
+                                st->clear.vertices);
 
    /* draw */
    util_draw_vertex_buffer(pipe, 
@@ -293,7 +280,11 @@ clear_with_quad(GLcontext *ctx,
 static INLINE GLboolean
 check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 {
-   if (ctx->Scissor.Enabled)
+   if (ctx->Scissor.Enabled &&
+       (ctx->Scissor.X != 0 ||
+        ctx->Scissor.Y != 0 ||
+        ctx->Scissor.Width < rb->Width ||
+        ctx->Scissor.Height < rb->Height))
       return TRUE;
 
    if (!ctx->Color.ColorMask[0] ||
@@ -313,7 +304,11 @@ check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
    GLboolean maskStencil
       = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
 
-   if (ctx->Scissor.Enabled)
+   if (ctx->Scissor.Enabled &&
+       (ctx->Scissor.X != 0 ||
+        ctx->Scissor.Y != 0 ||
+        ctx->Scissor.Width < rb->Width ||
+        ctx->Scissor.Height < rb->Height))
       return TRUE;
 
    if (maskStencil)
@@ -330,9 +325,13 @@ static INLINE GLboolean
 check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 {
    const struct st_renderbuffer *strb = st_renderbuffer(rb);
-   const GLboolean isDS = is_depth_stencil_format(strb->surface->format);
+   const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
 
-   if (ctx->Scissor.Enabled)
+   if (ctx->Scissor.Enabled &&
+       (ctx->Scissor.X != 0 ||
+        ctx->Scissor.Y != 0 ||
+        ctx->Scissor.Width < rb->Width ||
+        ctx->Scissor.Height < rb->Height))
       return TRUE;
 
    if (isDS && 
@@ -350,7 +349,7 @@ static INLINE GLboolean
 check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 {
    const struct st_renderbuffer *strb = st_renderbuffer(rb);
-   const GLboolean isDS = is_depth_stencil_format(strb->surface->format);
+   const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
    const GLuint stencilMax = (1 << rb->StencilBits) - 1;
    const GLboolean maskStencil
       = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
@@ -358,7 +357,11 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
    if (maskStencil) 
       return TRUE;
 
-   if (ctx->Scissor.Enabled)
+   if (ctx->Scissor.Enabled &&
+       (ctx->Scissor.X != 0 ||
+        ctx->Scissor.Y != 0 ||
+        ctx->Scissor.Width < rb->Width ||
+        ctx->Scissor.Height < rb->Height))
       return TRUE;
 
    /* This is correct, but it is necessary to look at the depth clear