i965: switch gen6 to use its own cc state bo
[mesa.git] / src / mesa / main / clear.c
index 8085bedf1c19d38ea3f4c71ff0ddad640c287b57..43a9ccc116a1777dc45502130109486e349e73f9 100644 (file)
@@ -35,6 +35,8 @@
 #include "context.h"
 #include "colormac.h"
 #include "enums.h"
+#include "macros.h"
+#include "mtypes.h"
 #include "state.h"
 
 
@@ -51,11 +53,6 @@ _mesa_ClearIndex( GLfloat c )
 
    FLUSH_VERTICES(ctx, _NEW_COLOR);
    ctx->Color.ClearIndex = (GLuint) c;
-
-   if (!ctx->Visual.rgbMode && ctx->Driver.ClearIndex) {
-      /* it's OK to call glClearIndex in RGBA mode but it should be a NOP */
-      (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex );
-   }
 }
 #endif
 
@@ -92,19 +89,81 @@ _mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
    FLUSH_VERTICES(ctx, _NEW_COLOR);
    COPY_4V(ctx->Color.ClearColor, tmp);
 
-   if (ctx->Visual.rgbMode && ctx->Driver.ClearColor) {
+   if (ctx->Driver.ClearColor) {
       /* it's OK to call glClearColor in CI mode but it should be a NOP */
       (*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor);
    }
 }
 
 
+/**
+ * GL_EXT_texture_integer
+ */
+void GLAPIENTRY
+_mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a)
+{
+   GLfloat tmp[4];
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   tmp[0] = (GLfloat) r;
+   tmp[1] = (GLfloat) g;
+   tmp[2] = (GLfloat) b;
+   tmp[3] = (GLfloat) a;
+
+   if (TEST_EQ_4V(tmp, ctx->Color.ClearColor))
+      return; /* no change */
+
+   FLUSH_VERTICES(ctx, _NEW_COLOR);
+
+   /* XXX we should eventually have a float/int/uint union for
+    * the ctx->Color.ClearColor state.
+    */
+   COPY_4V(ctx->Color.ClearColor, tmp);
+
+   if (ctx->Driver.ClearColor) {
+      ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
+   }
+}
+
+
+/**
+ * GL_EXT_texture_integer
+ */
+void GLAPIENTRY
+_mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a)
+{
+   GLfloat tmp[4];
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   tmp[0] = (GLfloat) r;
+   tmp[1] = (GLfloat) g;
+   tmp[2] = (GLfloat) b;
+   tmp[3] = (GLfloat) a;
+
+   if (TEST_EQ_4V(tmp, ctx->Color.ClearColor))
+      return; /* no change */
+
+   FLUSH_VERTICES(ctx, _NEW_COLOR);
+
+   /* XXX we should eventually have a float/int/uint union for
+    * the ctx->Color.ClearColor state.
+    */
+   COPY_4V(ctx->Color.ClearColor, tmp);
+
+   if (ctx->Driver.ClearColor) {
+      ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
+   }
+}
+
+
 /**
  * Clear buffers.
  * 
  * \param mask bit-mask indicating the buffers to be cleared.
  *
- * Flushes the vertices and verifies the parameter. If __GLcontextRec::NewState
+ * Flushes the vertices and verifies the parameter. If __struct gl_contextRec::NewState
  * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin,
  * etc. If the rasterization mode is set to GL_RENDER then requests the driver
  * to clear the buffers, via the dd_function_table::Clear callback.
@@ -195,7 +254,7 @@ _mesa_Clear( GLbitfield mask )
  * Return INVALID_MASK if the drawbuffer value is invalid.
  */
 static GLbitfield
-make_color_buffer_mask(GLcontext *ctx, GLint drawbuffer)
+make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer)
 {
    const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment;
    GLbitfield mask = 0x0;
@@ -261,11 +320,6 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
 
    FLUSH_CURRENT(ctx, 0);
 
-   if (!ctx->DrawBuffer->Visual.rgbMode) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glClearBufferiv()");
-      return;
-   }
-
    if (ctx->NewState) {
       _mesa_update_state( ctx );
    }
@@ -342,11 +396,6 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
 
    FLUSH_CURRENT(ctx, 0);
 
-   if (!ctx->DrawBuffer->Visual.rgbMode) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glClearBufferuiv()");
-      return;
-   }
-
    if (ctx->NewState) {
       _mesa_update_state( ctx );
    }
@@ -356,7 +405,7 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
       {
          const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer);
          if (mask == INVALID_MASK) {
-            _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)",
+            _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferuiv(drawbuffer=%d)",
                         drawbuffer);
             return;
          }
@@ -401,11 +450,6 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
 
    FLUSH_CURRENT(ctx, 0);
 
-   if (!ctx->DrawBuffer->Visual.rgbMode) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glClearBufferfv()");
-      return;
-   }
-
    if (ctx->NewState) {
       _mesa_update_state( ctx );
    }
@@ -480,11 +524,6 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
 
    FLUSH_CURRENT(ctx, 0);
 
-   if (!ctx->DrawBuffer->Visual.rgbMode) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glClearBufferfi()");
-      return;
-   }
-
    if (buffer != GL_DEPTH_STENCIL) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfi(buffer=%s)",
                   _mesa_lookup_enum_by_nr(buffer));