mesa/es: Validate glLightModel pname in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 27 Jul 2012 23:13:02 +0000 (16:13 -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/main/light.c

index baa7abf7f49ca6eaf8ca0e371ac5bac89d28f8d4..5c265020e8e877b3fe10355a7feb43a43fd5a536 100644 (file)
                        <param name="param" type="GLtype"/>
                </vector>
        </proto>
-
-       <desc name="pname">
-               <value name="GL_LIGHT_MODEL_AMBIENT"/>
-
-               <desc name="params" vector_size="4"/>
-       </desc>
-
-       <desc name="pname">
-               <value name="GL_LIGHT_MODEL_TWO_SIDE"/>
-               <desc name="param">
-                       <value name="GL_TRUE"/>
-                       <value name="GL_FALSE"/>
-               </desc>
-       </desc>
 </template>
 
 <template name="LineWidth">
index 9b13f13d8a3a1e82ab83d6a3783837e417fa590a..a71becc1066fb4e25583cb6ae8e2c28db664c709 100644 (file)
@@ -508,20 +508,6 @@ _es_GetTexParameterxv(GLenum target, GLenum pname, GLfixed *params)
 void GL_APIENTRY
 _es_LightModelx(GLenum pname, GLfixed param)
 {
-   switch(pname) {
-   case GL_LIGHT_MODEL_TWO_SIDE:
-      if (param != GL_TRUE && param != GL_FALSE) {
-         _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
-                     "glLightModelx(pname=0x%x)", pname);
-         return;
-      }
-      break;
-   default:
-      _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
-                  "glLightModelx(pname=0x%x)", pname);
-      return;
-   }
-
    _mesa_LightModelf(pname, (GLfloat) param);
 }
 
@@ -538,11 +524,6 @@ _es_LightModelxv(GLenum pname, const GLfixed *params)
       n_params = 4;
       break;
    case GL_LIGHT_MODEL_TWO_SIDE:
-      if (params[0] != GL_TRUE && params[0] != GL_FALSE) {
-         _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
-                     "glLightModelxv(pname=0x%x)", pname);
-         return;
-      }
       convert_params_value = false;
       n_params = 1;
       break;
index a6039353e662c9afab789af51ad176e3dc55882e..cfb53dc061c934155807aef4754c84ccc2a75f61 100644 (file)
@@ -466,6 +466,8 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
          COPY_4V( ctx->Light.Model.Ambient, params );
          break;
       case GL_LIGHT_MODEL_LOCAL_VIEWER:
+         if (ctx->API != API_OPENGL)
+            goto invalid_pname;
          newbool = (params[0]!=0.0);
         if (ctx->Light.Model.LocalViewer == newbool)
            return;
@@ -484,6 +486,8 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
             ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
          break;
       case GL_LIGHT_MODEL_COLOR_CONTROL:
+         if (ctx->API != API_OPENGL)
+            goto invalid_pname;
          if (params[0] == (GLfloat) GL_SINGLE_COLOR)
            newenum = GL_SINGLE_COLOR;
          else if (params[0] == (GLfloat) GL_SEPARATE_SPECULAR_COLOR)
@@ -499,12 +503,17 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
         ctx->Light.Model.ColorControl = newenum;
          break;
       default:
-         _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(pname=0x%x)", pname );
-         break;
+         goto invalid_pname;
    }
 
    if (ctx->Driver.LightModelfv)
       ctx->Driver.LightModelfv( ctx, pname, params );
+
+   return;
+
+invalid_pname:
+   _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(pname=0x%x)", pname );
+   return;
 }