[Mesa-dev] [PATCH 4/4] mesa/varray: add interface support for ARB_vertex_type_2_10_10_10_rev

Dave Airlie airlied at gmail.com
Sun Sep 4 07:05:05 PDT 2011


From: Dave Airlie <airlied at redhat.com>

This just adds all the API check for vertex arrays using 2101010 types.

2101010 is also useable with GL_BGRA.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/mesa/main/varray.c |   48 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 29a345f..e9a7b47 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -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,18 +160,26 @@ 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;
       }
       format = GL_BGRA;
       size = 4;
-   }
-   else if (size < sizeMin || size > sizeMax || size > 4) {
+   } else if (size < sizeMin || size > sizeMax || size > 4) {
       _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", func, size);
       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 +219,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 +240,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 +260,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 +309,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 +328,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 +436,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);
 
-- 
1.7.6



More information about the mesa-dev mailing list