[Mesa-dev] [PATCH 16/20] mesa/es: Validate glLightModel pname in Mesa code rather than the ES wrapper
Ian Romanick
idr at freedesktop.org
Fri Aug 24 08:47:00 PDT 2012
From: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/main/APIspec.xml | 14 --------------
src/mesa/main/es1_conversion.c | 19 -------------------
src/mesa/main/light.c | 13 +++++++++++--
3 files changed, 11 insertions(+), 35 deletions(-)
diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index baa7abf..5c26502 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -94,20 +94,6 @@
<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">
diff --git a/src/mesa/main/es1_conversion.c b/src/mesa/main/es1_conversion.c
index 9b13f13..a71becc 100644
--- a/src/mesa/main/es1_conversion.c
+++ b/src/mesa/main/es1_conversion.c
@@ -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;
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index a603935..cfb53dc 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -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;
}
--
1.7.6.5
More information about the mesa-dev
mailing list