mesa: add KHR_no_error support for glBindVertexBuffer()
[mesa.git] / src / mesa / main / accum.c
index e2d7726b5047d2ad11b8beca92a1cd7b02e4d108..c0a3e7ea72ae1e24e0c23ff0cb0ddb20b10c95e3 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
  *
  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #include "glheader.h"
@@ -30,7 +30,6 @@
 #include "format_pack.h"
 #include "imports.h"
 #include "macros.h"
-#include "mfeatures.h"
 #include "state.h"
 #include "mtypes.h"
 #include "main/dispatch.h"
@@ -41,7 +40,6 @@ _mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
 {
    GLfloat tmp[4];
    GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    tmp[0] = CLAMP( red,   -1.0F, 1.0F );
    tmp[1] = CLAMP( green, -1.0F, 1.0F );
@@ -55,65 +53,6 @@ _mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
 }
 
 
-static void GLAPIENTRY
-_mesa_Accum( GLenum op, GLfloat value )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
-   switch (op) {
-   case GL_ADD:
-   case GL_MULT:
-   case GL_ACCUM:
-   case GL_LOAD:
-   case GL_RETURN:
-      /* OK */
-      break;
-   default:
-      _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)");
-      return;
-   }
-
-   if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum buffer)");
-      return;
-   }
-
-   if (ctx->DrawBuffer != ctx->ReadBuffer) {
-      /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read,
-       * or GL_EXT_framebuffer_blit.
-       */
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glAccum(different read/draw buffers)");
-      return;
-   }
-
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
-   if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
-      _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
-                  "glAccum(incomplete framebuffer)");
-      return;
-   }
-
-   if (ctx->RasterDiscard)
-      return;
-
-   if (ctx->RenderMode == GL_RENDER) {
-      _mesa_accum(ctx, op, value);
-   }
-}
-
-
-void
-_mesa_init_accum_dispatch(struct _glapi_table *disp)
-{
-   SET_Accum(disp, _mesa_Accum);
-   SET_ClearAccum(disp, _mesa_ClearAccum);
-}
-
-
 /**
  * Clear the accumulation buffer by mapping the renderbuffer and
  * writing the clear color to it.  Called by the driver's implementation
@@ -148,7 +87,7 @@ _mesa_clear_accum_buffer(struct gl_context *ctx)
       return;
    }
 
-   if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
+   if (accRb->Format == MESA_FORMAT_RGBA_SNORM16) {
       const GLshort clearR = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]);
       const GLshort clearG = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]);
       const GLshort clearB = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]);
@@ -203,7 +142,7 @@ accum_scale_or_bias(struct gl_context *ctx, GLfloat value,
       return;
    }
 
-   if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
+   if (accRb->Format == MESA_FORMAT_RGBA_SNORM16) {
       const GLshort incr = (GLshort) (value * 32767.0f);
       GLint i, j;
       if (bias) {
@@ -281,7 +220,7 @@ accum_or_load(struct gl_context *ctx, GLfloat value,
       return;
    }
 
-   if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
+   if (accRb->Format == MESA_FORMAT_RGBA_SNORM16) {
       const GLfloat scale = value * 32767.0f;
       GLint i, j;
       GLfloat (*rgba)[4];
@@ -373,7 +312,7 @@ accum_return(struct gl_context *ctx, GLfloat value,
          continue;
       }
 
-      if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
+      if (accRb->Format == MESA_FORMAT_RGBA_SNORM16) {
          const GLfloat scale = value / 32767.0f;
          GLint i, j;
          GLfloat (*rgba)[4], (*dest)[4];
@@ -446,8 +385,8 @@ accum_return(struct gl_context *ctx, GLfloat value,
  * signed 16-bit color channels could implement hardware accumulation
  * operations, but no driver does so at this time.
  */
-void
-_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value)
+static void
+accum(struct gl_context *ctx, GLenum op, GLfloat value)
 {
    GLint xpos, ypos, width, height;
 
@@ -487,7 +426,7 @@ _mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value)
       accum_return(ctx, value, xpos, ypos, width, height);
       break;
    default:
-      _mesa_problem(ctx, "invalid mode in _mesa_accum()");
+      unreachable("invalid mode in _mesa_Accum()");
       break;
    }
 }
@@ -499,3 +438,54 @@ _mesa_init_accum( struct gl_context *ctx )
    /* Accumulate buffer group */
    ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 );
 }
+
+
+void GLAPIENTRY
+_mesa_Accum( GLenum op, GLfloat value )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+
+   switch (op) {
+   case GL_ADD:
+   case GL_MULT:
+   case GL_ACCUM:
+   case GL_LOAD:
+   case GL_RETURN:
+      /* OK */
+      break;
+   default:
+      _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)");
+      return;
+   }
+
+   if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum buffer)");
+      return;
+   }
+
+   if (ctx->DrawBuffer != ctx->ReadBuffer) {
+      /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read,
+       * or GL_EXT_framebuffer_blit.
+       */
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glAccum(different read/draw buffers)");
+      return;
+   }
+
+   if (ctx->NewState)
+      _mesa_update_state(ctx);
+
+   if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+      _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+                  "glAccum(incomplete framebuffer)");
+      return;
+   }
+
+   if (ctx->RasterDiscard)
+      return;
+
+   if (ctx->RenderMode == GL_RENDER) {
+      accum(ctx, op, value);
+   }
+}