mesa/es: Validate glMaterial face and pname in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 27 Jul 2012 23:07:19 +0000 (16:07 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 29 Aug 2012 22:09:35 +0000 (15:09 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/APIspec.xml
src/mesa/main/es1_conversion.c
src/mesa/vbo/vbo_exec_api.c

index e7777a7cbcf57a162eba48b69da05162d5de9014..baa7abf7f49ca6eaf8ca0e371ac5bac89d28f8d4 100644 (file)
                        <param name="param" type="GLtype"/>
                </vector>
        </proto>
-
-       <desc name="face">
-               <value name="GL_FRONT_AND_BACK"/>
-       </desc>
-
-       <desc name="pname">
-               <value name="GL_AMBIENT"/>
-               <value name="GL_DIFFUSE"/>
-               <value name="GL_AMBIENT_AND_DIFFUSE"/>
-               <value name="GL_SPECULAR"/>
-               <value name="GL_EMISSION"/>
-
-               <desc name="params" vector_size="4"/>
-       </desc>
-
-       <desc name="pname">
-               <value name="GL_SHININESS"/>
-
-               <desc name="params" vector_size="1"/>
-       </desc>
 </template>
 
 <template name="PointSize">
index c1bcfbe1f5749d23ac7d15a9baa42daf9eea8a55..9b13f13d8a3a1e82ab83d6a3783837e417fa590a 100644 (file)
@@ -635,18 +635,13 @@ _es_LoadMatrixx(const GLfixed *m)
 void GL_APIENTRY
 _es_Materialx(GLenum face, GLenum pname, GLfixed param)
 {
-   switch(face) {
-   case GL_FRONT_AND_BACK:
-      break;
-   default:
+   if (face != GL_FRONT_AND_BACK) {
       _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
                   "glMaterialx(face=0x%x)", face);
       return;
    }
-   switch(pname) {
-   case GL_SHININESS:
-      break;
-   default:
+
+   if (pname != GL_SHININESS) {
       _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
                   "glMaterialx(pname=0x%x)", pname);
       return;
@@ -662,14 +657,12 @@ _es_Materialxv(GLenum face, GLenum pname, const GLfixed *params)
    unsigned int n_params = 4;
    GLfloat converted_params[4];
 
-   switch(face) {
-   case GL_FRONT_AND_BACK:
-      break;
-   default:
+   if (face != GL_FRONT_AND_BACK) {
       _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
                   "glMaterialxv(face=0x%x)", face);
       return;
    }
+
    switch(pname) {
    case GL_AMBIENT:
    case GL_DIFFUSE:
index fc7e4069232d50fe6b039a45d42adf0df31d0606..a97f8d7f3b407dfd0aa1f060d40e5136f9cd0050 100644 (file)
@@ -457,10 +457,10 @@ vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params)
       updateMats = ALL_MATERIAL_BITS;
    }
 
-   if (face == GL_FRONT) {
+   if (ctx->API == API_OPENGL && face == GL_FRONT) {
       updateMats &= FRONT_MATERIAL_BITS;
    }
-   else if (face == GL_BACK) {
+   else if (ctx->API == API_OPENGL && face == GL_BACK) {
       updateMats &= BACK_MATERIAL_BITS;
    }
    else if (face != GL_FRONT_AND_BACK) {
@@ -506,6 +506,10 @@ vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params)
          MAT_ATTR(VBO_ATTRIB_MAT_BACK_SHININESS, 1, params);
       break;
    case GL_COLOR_INDEXES:
+      if (ctx->API != API_OPENGL) {
+         _mesa_error(ctx, GL_INVALID_ENUM, "glMaterialfv(pname)");
+         return;
+      }
       if (updateMats & MAT_BIT_FRONT_INDEXES)
          MAT_ATTR(VBO_ATTRIB_MAT_FRONT_INDEXES, 3, params);
       if (updateMats & MAT_BIT_BACK_INDEXES)