mesa/varray: add interface support for ARB_vertex_type_2_10_10_10_rev (v2)
authorDave Airlie <airlied@redhat.com>
Sat, 13 Aug 2011 14:30:38 +0000 (15:30 +0100)
committerDave Airlie <airlied@redhat.com>
Tue, 6 Sep 2011 09:18:18 +0000 (10:18 +0100)
This just adds all the API check for vertex arrays using 2101010 types.

2101010 is also useable with GL_BGRA.

v2: fix whitespace.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/varray.c

index 29a345f9425dbc0a0938c87380a25a475511937d..9c9d0d66ea957c3a97cb96cd5f080ae18e9691cb 100644 (file)
@@ -59,6 +59,8 @@
 #define DOUBLE_BIT           0x200
 #define FIXED_ES_BIT         0x400
 #define FIXED_GL_BIT         0x800
+#define UNSIGNED_INT_2_10_10_10_REV_BIT 0x1000
+#define INT_2_10_10_10_REV_BIT 0x2000
 
 
 /** Convert GL datatype enum into a <type>_BIT value seen above */
@@ -91,6 +93,10 @@ type_to_bit(const struct gl_context *ctx, GLenum type)
       return DOUBLE_BIT;
    case GL_FIXED:
       return ctx->API == API_OPENGL ? FIXED_GL_BIT : FIXED_ES_BIT;
+   case GL_UNSIGNED_INT_2_10_10_10_REV:
+      return UNSIGNED_INT_2_10_10_10_REV_BIT;
+   case GL_INT_2_10_10_10_REV:
+      return INT_2_10_10_10_REV_BIT;
    default:
       return 0;
    }
@@ -135,6 +141,10 @@ update_array(struct gl_context *ctx,
    if (!ctx->Extensions.ARB_ES2_compatibility) {
       legalTypesMask &= ~FIXED_GL_BIT;
    }
+   if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) {
+      legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT |
+                          INT_2_10_10_10_REV_BIT);
+   }
 
    typeBit = type_to_bit(ctx, type);
    if (typeBit == 0x0 || (typeBit & legalTypesMask) == 0x0) {
@@ -150,7 +160,10 @@ update_array(struct gl_context *ctx,
    if (ctx->Extensions.EXT_vertex_array_bgra &&
        sizeMax == BGRA_OR_4 &&
        size == GL_BGRA) {
-      if (type != GL_UNSIGNED_BYTE) {
+      if (type != GL_UNSIGNED_BYTE &&
+         (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev &&
+          (type != GL_UNSIGNED_INT_2_10_10_10_REV &&
+           type != GL_INT_2_10_10_10_REV))) {
          _mesa_error(ctx, GL_INVALID_VALUE, "%s(GL_BGRA/GLubyte)", func);
          return;
       }
@@ -162,6 +175,12 @@ update_array(struct gl_context *ctx,
       return;
    }
 
+   if (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev &&
+       (type == GL_UNSIGNED_INT_2_10_10_10_REV ||
+        type == GL_INT_2_10_10_10_REV) && size != 4) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(size=%d)", func, size);
+   }
+
    ASSERT(size <= 4);
 
    if (stride < 0) {
@@ -201,7 +220,9 @@ void GLAPIENTRY
 _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
 {
    GLbitfield legalTypes = (SHORT_BIT | INT_BIT | FLOAT_BIT |
-                            DOUBLE_BIT | HALF_BIT | FIXED_ES_BIT);
+                            DOUBLE_BIT | HALF_BIT | FIXED_ES_BIT |
+                            UNSIGNED_INT_2_10_10_10_REV_BIT |
+                            INT_2_10_10_10_REV_BIT);
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
@@ -220,7 +241,9 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
 {
    const GLbitfield legalTypes = (BYTE_BIT | SHORT_BIT | INT_BIT |
                                   HALF_BIT | FLOAT_BIT | DOUBLE_BIT |
-                                  FIXED_ES_BIT);
+                                  FIXED_ES_BIT |
+                                  UNSIGNED_INT_2_10_10_10_REV_BIT |
+                                  INT_2_10_10_10_REV_BIT);
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
@@ -238,7 +261,9 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
                                   SHORT_BIT | UNSIGNED_SHORT_BIT |
                                   INT_BIT | UNSIGNED_INT_BIT |
                                   HALF_BIT | FLOAT_BIT | DOUBLE_BIT |
-                                  FIXED_ES_BIT);
+                                  FIXED_ES_BIT |
+                                  UNSIGNED_INT_2_10_10_10_REV_BIT |
+                                  INT_2_10_10_10_REV_BIT);
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
@@ -285,7 +310,9 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
    const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT |
                                   SHORT_BIT | UNSIGNED_SHORT_BIT |
                                   INT_BIT | UNSIGNED_INT_BIT |
-                                  HALF_BIT | FLOAT_BIT | DOUBLE_BIT);
+                                  HALF_BIT | FLOAT_BIT | DOUBLE_BIT |
+                                  UNSIGNED_INT_2_10_10_10_REV_BIT |
+                                  INT_2_10_10_10_REV_BIT);
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
@@ -302,7 +329,9 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
 {
    GLbitfield legalTypes = (SHORT_BIT | INT_BIT |
                             HALF_BIT | FLOAT_BIT | DOUBLE_BIT |
-                            FIXED_ES_BIT);
+                            FIXED_ES_BIT |
+                            UNSIGNED_INT_2_10_10_10_REV_BIT |
+                            INT_2_10_10_10_REV_BIT);
    GET_CURRENT_CONTEXT(ctx);
    const GLuint unit = ctx->Array.ActiveTexture;
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -408,7 +437,9 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
                                   SHORT_BIT | UNSIGNED_SHORT_BIT |
                                   INT_BIT | UNSIGNED_INT_BIT |
                                   HALF_BIT | FLOAT_BIT | DOUBLE_BIT |
-                                  FIXED_ES_BIT | FIXED_GL_BIT);
+                                  FIXED_ES_BIT | FIXED_GL_BIT |
+                                  UNSIGNED_INT_2_10_10_10_REV_BIT |
+                                  INT_2_10_10_10_REV_BIT);
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);