i965/vec4: Print the predicate in dump_instructions().
[mesa.git] / src / mesa / vbo / vbo_attrib_tmp.h
index de1b4512f4dc00680c604c5248ee2075e946ecfa..a2ea6d0c8333dbc9852f26ba9c8459d4b48ec782 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
 
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
+Copyright 2002 VMware, Inc.
 Copyright 2011 Dave Airlie (ARB_vertex_type_2_10_10_10_rev support)
 All Rights Reserved.
 
@@ -18,13 +18,15 @@ Software.
 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+VMWARE AND/OR THEIR SUPPLIERS 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 "util/u_format_r11g11b10f.h"
+
 /* float */
 #define ATTR1FV( A, V ) ATTR( A, 1, GL_FLOAT, (V)[0], 0, 0, 1 )
 #define ATTR2FV( A, V ) ATTR( A, 2, GL_FLOAT, (V)[0], (V)[1], 0, 1 )
@@ -140,7 +142,7 @@ static inline float conv_i10_to_norm_float(const struct gl_context *ctx, int i10
        (ctx->API == API_OPENGL_CORE && ctx->Version >= 42)) {
       /* Equation 2.3 above. */
       float f = ((float) val.x) / 511.0F;
-      return MAX2(f, -1.0);
+      return MAX2(f, -1.0f);
    } else {
       /* Equation 2.2 above. */
       return (2.0F * (float)val.x + 1.0F) * (1.0F  / 1023.0F);
@@ -156,7 +158,7 @@ static inline float conv_i2_to_norm_float(const struct gl_context *ctx, int i2)
        (ctx->API == API_OPENGL_CORE && ctx->Version >= 42)) {
       /* Equation 2.3 above. */
       float f = (float) val.x;
-      return MAX2(f, -1.0);
+      return MAX2(f, -1.0f);
    } else {
       /* Equation 2.2 above. */
       return (2.0F * (float)val.x + 1.0F) * (1.0F / 3.0F);
@@ -205,6 +207,10 @@ static inline float conv_i2_to_norm_float(const struct gl_context *ctx, int i2)
       } else {                                                 \
         ATTRI10_##val((attr), (arg));                          \
       }                                                                \
+   } else if ((type) == GL_UNSIGNED_INT_10F_11F_11F_REV) {     \
+      float res[4];                                            \
+      r11g11b10f_to_float3((arg), res);                                \
+      ATTR##val##FV((attr), res);                              \
    } else                                                      \
       ERROR(GL_INVALID_VALUE);                                 \
    } while(0)
@@ -835,12 +841,26 @@ TAG(VertexAttrib4fvNV)(GLuint index, const GLfloat * v)
       ATTR4FV(index, v);
 }
 
+
 #define ERROR_IF_NOT_PACKED_TYPE(ctx, type, func) \
    if (type != GL_INT_2_10_10_10_REV && type != GL_UNSIGNED_INT_2_10_10_10_REV) { \
       _mesa_error(ctx, GL_INVALID_ENUM, "%s(type)", func); \
       return; \
    }
 
+/* Extended version of ERROR_IF_NOT_PACKED_TYPE which also
+ * accepts GL_UNSIGNED_INT_10F_11F_11F_REV.
+ *
+ * Only used for VertexAttribP[123]ui[v]; VertexAttribP4* cannot use this type,
+ * and neither can legacy vertex attribs.
+ */
+#define ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, func) \
+   if (type != GL_INT_2_10_10_10_REV && type != GL_UNSIGNED_INT_2_10_10_10_REV && \
+       type != GL_UNSIGNED_INT_10F_11F_11F_REV) { \
+      _mesa_error(ctx, GL_INVALID_ENUM, "%s(type)", func); \
+      return; \
+   }
+
 static void GLAPIENTRY
 TAG(VertexP2ui)(GLenum type, GLuint value)
 {
@@ -957,8 +977,8 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP1ui)(GLenum target, GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP1ui");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP1ui");
    ATTR_UI(ctx, 1, type, 0, attr, coords);
 }
 
@@ -966,8 +986,8 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP1uiv)(GLenum target, GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP1uiv");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP1uiv");
    ATTR_UI(ctx, 1, type, 0, attr, coords[0]);
 }
 
@@ -975,8 +995,8 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP2ui)(GLenum target, GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP2ui");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP2ui");
    ATTR_UI(ctx, 2, type, 0, attr, coords);
 }
 
@@ -984,8 +1004,8 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP2uiv)(GLenum target, GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP2uiv");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP2uiv");
    ATTR_UI(ctx, 2, type, 0, attr, coords[0]);
 }
 
@@ -993,8 +1013,8 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP3ui)(GLenum target, GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP3ui");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP3ui");
    ATTR_UI(ctx, 3, type, 0, attr, coords);
 }
 
@@ -1002,8 +1022,8 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP3uiv)(GLenum target, GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP3uiv");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP3uiv");
    ATTR_UI(ctx, 3, type, 0, attr, coords[0]);
 }
 
@@ -1011,8 +1031,8 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP4ui)(GLenum target, GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP4ui");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP4ui");
    ATTR_UI(ctx, 4, type, 0, attr, coords);
 }
 
@@ -1020,8 +1040,8 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP4uiv)(GLenum target, GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP4uiv");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP4uiv");
    ATTR_UI(ctx, 4, type, 0, attr, coords[0]);
 }
 
@@ -1094,7 +1114,7 @@ TAG(VertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized,
                      GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexAttribP1ui");
+   ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP1ui");
    ATTR_UI_INDEX(ctx, 1, type, normalized, index, value);
 }
 
@@ -1103,7 +1123,7 @@ TAG(VertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized,
                      GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexAttribP2ui");
+   ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP2ui");
    ATTR_UI_INDEX(ctx, 2, type, normalized, index, value);
 }
 
@@ -1112,7 +1132,7 @@ TAG(VertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized,
                      GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexAttribP3ui");
+   ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP3ui");
    ATTR_UI_INDEX(ctx, 3, type, normalized, index, value);
 }
 
@@ -1130,7 +1150,7 @@ TAG(VertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized,
                       const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexAttribP1uiv");
+   ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP1uiv");
    ATTR_UI_INDEX(ctx, 1, type, normalized, index, *value);
 }
 
@@ -1139,7 +1159,7 @@ TAG(VertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized,
                       const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexAttribP2uiv");
+   ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP2uiv");
    ATTR_UI_INDEX(ctx, 2, type, normalized, index, *value);
 }
 
@@ -1148,7 +1168,7 @@ TAG(VertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized,
                       const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexAttribP3uiv");
+   ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP3uiv");
    ATTR_UI_INDEX(ctx, 3, type, normalized, index, *value);
 }