[Mesa-dev] [PATCH] mesa/vbo: Check for invalid types in various packed vertex functions.

Kenneth Graunke kenneth at whitecape.org
Mon Nov 26 17:14:02 PST 2012


According to the ARB_vertex_type_2_10_10_10_rev specification:
"The error INVALID_ENUM is generated by VertexP*, NormalP*,
 TexCoordP*, MultiTexCoordP*, ColorP*, or SecondaryColorP if <type>
 is not UNSIGNED_INT_2_10_10_10_REV or INT_2_10_10_10_REV."

Fixes 7 subcases of oglconform's packed-vertex test.
---
 src/mesa/vbo/vbo_attrib_tmp.h | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h
index 077ca31..6882d85 100644
--- a/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/src/mesa/vbo/vbo_attrib_tmp.h
@@ -799,11 +799,17 @@ 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; \
+   }
 
 static void GLAPIENTRY
 TAG(VertexP2ui)(GLenum type, GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexP2ui");
    ATTR_UI(2, type, 0, VBO_ATTRIB_POS, value);
 }
 
@@ -811,6 +817,7 @@ static void GLAPIENTRY
 TAG(VertexP2uiv)(GLenum type, const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexP2uiv");
    ATTR_UI(2, type, 0, VBO_ATTRIB_POS, value[0]);
 }
 
@@ -818,6 +825,7 @@ static void GLAPIENTRY
 TAG(VertexP3ui)(GLenum type, GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexP3ui");
    ATTR_UI(3, type, 0, VBO_ATTRIB_POS, value);
 }
 
@@ -825,6 +833,7 @@ static void GLAPIENTRY
 TAG(VertexP3uiv)(GLenum type, const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexP3uiv");
    ATTR_UI(3, type, 0, VBO_ATTRIB_POS, value[0]);
 }
 
@@ -832,6 +841,7 @@ static void GLAPIENTRY
 TAG(VertexP4ui)(GLenum type, GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexP4ui");
    ATTR_UI(4, type, 0, VBO_ATTRIB_POS, value);
 }
 
@@ -839,6 +849,7 @@ static void GLAPIENTRY
 TAG(VertexP4uiv)(GLenum type, const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexP4uiv");
    ATTR_UI(4, type, 0, VBO_ATTRIB_POS, value[0]);
 }
 
@@ -846,6 +857,7 @@ static void GLAPIENTRY
 TAG(TexCoordP1ui)(GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "TexCoordP1ui");
    ATTR_UI(1, type, 0, VBO_ATTRIB_TEX0, coords);
 }
 
@@ -853,6 +865,7 @@ static void GLAPIENTRY
 TAG(TexCoordP1uiv)(GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "TexCoordP1uiv");
    ATTR_UI(1, type, 0, VBO_ATTRIB_TEX0, coords[0]);
 }
 
@@ -860,6 +873,7 @@ static void GLAPIENTRY
 TAG(TexCoordP2ui)(GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "TexCoordP2ui");
    ATTR_UI(2, type, 0, VBO_ATTRIB_TEX0, coords);
 }
 
@@ -867,6 +881,7 @@ static void GLAPIENTRY
 TAG(TexCoordP2uiv)(GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "TexCoordP2uiv");
    ATTR_UI(2, type, 0, VBO_ATTRIB_TEX0, coords[0]);
 }
 
@@ -874,6 +889,7 @@ static void GLAPIENTRY
 TAG(TexCoordP3ui)(GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "TexCoordP3ui");
    ATTR_UI(3, type, 0, VBO_ATTRIB_TEX0, coords);
 }
 
@@ -881,6 +897,7 @@ static void GLAPIENTRY
 TAG(TexCoordP3uiv)(GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "TexCoordP3uiv");
    ATTR_UI(3, type, 0, VBO_ATTRIB_TEX0, coords[0]);
 }
 
@@ -888,6 +905,7 @@ static void GLAPIENTRY
 TAG(TexCoordP4ui)(GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "TexCoordP4ui");
    ATTR_UI(4, type, 0, VBO_ATTRIB_TEX0, coords);
 }
 
@@ -895,6 +913,7 @@ static void GLAPIENTRY
 TAG(TexCoordP4uiv)(GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "TexCoordP4uiv");
    ATTR_UI(4, type, 0, VBO_ATTRIB_TEX0, coords[0]);
 }
 
@@ -902,6 +921,7 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP1ui)(GLenum target, GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "MultiTexCoordP1ui");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
    ATTR_UI(1, type, 0, attr, coords);
 }
@@ -910,6 +930,7 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP1uiv)(GLenum target, GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "MultiTexCoordP1uiv");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
    ATTR_UI(1, type, 0, attr, coords[0]);
 }
@@ -918,6 +939,7 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP2ui)(GLenum target, GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "MultiTexCoordP2ui");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
    ATTR_UI(2, type, 0, attr, coords);
 }
@@ -926,6 +948,7 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP2uiv)(GLenum target, GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "MultiTexCoordP2uiv");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
    ATTR_UI(2, type, 0, attr, coords[0]);
 }
@@ -934,6 +957,7 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP3ui)(GLenum target, GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "MultiTexCoordP3ui");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
    ATTR_UI(3, type, 0, attr, coords);
 }
@@ -942,6 +966,7 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP3uiv)(GLenum target, GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "MultiTexCoordP3uiv");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
    ATTR_UI(3, type, 0, attr, coords[0]);
 }
@@ -950,6 +975,7 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP4ui)(GLenum target, GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "MultiTexCoordP4ui");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
    ATTR_UI(4, type, 0, attr, coords);
 }
@@ -958,6 +984,7 @@ static void GLAPIENTRY
 TAG(MultiTexCoordP4uiv)(GLenum target, GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "MultiTexCoordP4uiv");
    GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
    ATTR_UI(4, type, 0, attr, coords[0]);
 }
@@ -966,6 +993,7 @@ static void GLAPIENTRY
 TAG(NormalP3ui)(GLenum type, GLuint coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "NormalP3ui");
    ATTR_UI(3, type, 1, VBO_ATTRIB_NORMAL, coords);
 }
 
@@ -973,6 +1001,7 @@ static void GLAPIENTRY
 TAG(NormalP3uiv)(GLenum type, const GLuint *coords)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "NormalP3uiv");
    ATTR_UI(3, type, 1, VBO_ATTRIB_NORMAL, coords[0]);
 }
 
@@ -980,6 +1009,7 @@ static void GLAPIENTRY
 TAG(ColorP3ui)(GLenum type, GLuint color)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "ColorP3ui");
    ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR0, color);
 }
 
@@ -987,6 +1017,7 @@ static void GLAPIENTRY
 TAG(ColorP3uiv)(GLenum type, const GLuint *color)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "ColorP3uiv");
    ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR0, color[0]);
 }
 
@@ -994,6 +1025,7 @@ static void GLAPIENTRY
 TAG(ColorP4ui)(GLenum type, GLuint color)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "ColorP4ui");
    ATTR_UI(4, type, 1, VBO_ATTRIB_COLOR0, color);
 }
 
@@ -1001,6 +1033,7 @@ static void GLAPIENTRY
 TAG(ColorP4uiv)(GLenum type, const GLuint *color)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "ColorP4uiv");
    ATTR_UI(4, type, 1, VBO_ATTRIB_COLOR0, color[0]);
 }
 
@@ -1008,6 +1041,7 @@ static void GLAPIENTRY
 TAG(SecondaryColorP3ui)(GLenum type, GLuint color)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "SecondaryColorP3ui");
    ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR1, color);
 }
 
@@ -1015,6 +1049,7 @@ static void GLAPIENTRY
 TAG(SecondaryColorP3uiv)(GLenum type, const GLuint *color)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "SecondaryColorP3uiv");
    ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR1, color[0]);
 }
 
@@ -1023,6 +1058,7 @@ TAG(VertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized,
 		      GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexAttribP1ui");
    ATTR_UI_INDEX(1, type, normalized, index, value);
 }
 
@@ -1031,6 +1067,7 @@ TAG(VertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized,
 		      GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexAttribP2ui");
    ATTR_UI_INDEX(2, type, normalized, index, value);
 }
 
@@ -1039,6 +1076,7 @@ TAG(VertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized,
 		      GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexAttribP3ui");
    ATTR_UI_INDEX(3, type, normalized, index, value);
 }
 
@@ -1047,6 +1085,7 @@ TAG(VertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized,
 		      GLuint value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexAttribP4ui");
    ATTR_UI_INDEX(4, type, normalized, index, value);
 }
 
@@ -1055,6 +1094,7 @@ TAG(VertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized,
 		       const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexAttribP1uiv");
    ATTR_UI_INDEX(1, type, normalized, index, *value);
 }
 
@@ -1063,6 +1103,7 @@ TAG(VertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized,
 		       const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexAttribP2uiv");
    ATTR_UI_INDEX(2, type, normalized, index, *value);
 }
 
@@ -1071,6 +1112,7 @@ TAG(VertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized,
 		       const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexAttribP3uiv");
    ATTR_UI_INDEX(3, type, normalized, index, *value);
 }
 
@@ -1079,6 +1121,7 @@ TAG(VertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized,
 		      const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
+   ERROR_IF_NOT_PACKED_TYPE(ctx, type, "VertexAttribP4uiv");
    ATTR_UI_INDEX(4, type, normalized, index, *value);
 }
 
-- 
1.8.0



More information about the mesa-dev mailing list