summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2012-07-26 18:15:40 -0700
committerIan Romanick <[email protected]>2012-08-23 10:15:30 -0700
commitc9689e3e55928d4a95f1c10c7a33fffba8cbdece (patch)
treed91e9717b2456b7ca65665a110fd4f863b4c144c
parentb3dd524a1082efd12d4a796122c300a61ba016d9 (diff)
mesa/es: Validate glGetTexParameter pnames in Mesa code rather than the ES wrapper
This also adds a missing extension (and API) check around GL_TEXTURE_CROP_RECT_OES. v2: Add proper core-profile and GLES3 filtering. GL_TEXTURE_MAX_LEVEL is (incorrectly) accepted in ES contexts. A future patch will add GL_APPLE_texture_max_level, and meta really needs this. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
-rw-r--r--src/mesa/main/APIspec.xml16
-rw-r--r--src/mesa/main/texparam.c97
2 files changed, 84 insertions, 29 deletions
diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index af98440e037..09ba424609b 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -1174,22 +1174,6 @@
<param name="pname" type="GLenum"/>
<vector name="params" type="GLtype *" size="dynamic"/>
</proto>
-
- <desc name="pname">
- <value name="GL_TEXTURE_WRAP_S"/>
- <value name="GL_TEXTURE_WRAP_T"/>
- <value name="GL_TEXTURE_WRAP_R_OES" category="OES_texture_3D"/>
- <value name="GL_TEXTURE_MIN_FILTER"/>
- <value name="GL_TEXTURE_MAG_FILTER"/>
- <value name="GL_GENERATE_MIPMAP" category="GLES1.1"/>
-
- <desc name="params" vector_size="1" convert="false"/>
- </desc>
-
- <desc name="pname" category="OES_draw_texture">
- <value name="GL_TEXTURE_CROP_RECT_OES"/>
- <desc name="params" vector_size="4"/>
- </desc>
</template>
<template name="IsEnabled" direction="get">
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 05d31c1cfc8..e6140eb65f8 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1310,6 +1310,9 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
*params = ENUM_TO_FLOAT(obj->Sampler.WrapR);
break;
case GL_TEXTURE_BORDER_COLOR:
+ if (!_mesa_is_desktop_gl(ctx))
+ goto invalid_pname;
+
if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
_mesa_update_state_locked(ctx);
if (ctx->Color._ClampFragmentColor) {
@@ -1326,18 +1329,33 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
}
break;
case GL_TEXTURE_RESIDENT:
+ if (ctx->API != API_OPENGL)
+ goto invalid_pname;
+
*params = 1.0F;
break;
case GL_TEXTURE_PRIORITY:
+ if (ctx->API != API_OPENGL)
+ goto invalid_pname;
+
*params = obj->Priority;
break;
case GL_TEXTURE_MIN_LOD:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_pname;
+
*params = obj->Sampler.MinLod;
break;
case GL_TEXTURE_MAX_LOD:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_pname;
+
*params = obj->Sampler.MaxLod;
break;
case GL_TEXTURE_BASE_LEVEL:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_pname;
+
*params = (GLfloat) obj->BaseLevel;
break;
case GL_TEXTURE_MAX_LEVEL:
@@ -1349,28 +1367,42 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
*params = obj->Sampler.MaxAnisotropy;
break;
case GL_GENERATE_MIPMAP_SGIS:
+ if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
+ goto invalid_pname;
+
*params = (GLfloat) obj->GenerateMipmap;
break;
case GL_TEXTURE_COMPARE_MODE_ARB:
- if (!ctx->Extensions.ARB_shadow)
+ if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow)
+ && !_mesa_is_gles3(ctx))
goto invalid_pname;
*params = (GLfloat) obj->Sampler.CompareMode;
break;
case GL_TEXTURE_COMPARE_FUNC_ARB:
- if (!ctx->Extensions.ARB_shadow)
+ if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow)
+ && !_mesa_is_gles3(ctx))
goto invalid_pname;
*params = (GLfloat) obj->Sampler.CompareFunc;
break;
case GL_DEPTH_TEXTURE_MODE_ARB:
- if (!ctx->Extensions.ARB_depth_texture)
+ /* GL_DEPTH_TEXTURE_MODE_ARB is removed in core-profile and it has
+ * never existed in OpenGL ES.
+ */
+ if (ctx->API != API_OPENGL || !ctx->Extensions.ARB_depth_texture)
goto invalid_pname;
*params = (GLfloat) obj->DepthMode;
break;
case GL_TEXTURE_LOD_BIAS:
+ if (ctx->API != API_OPENGL)
+ goto invalid_pname;
+
*params = obj->Sampler.LodBias;
break;
#if FEATURE_OES_draw_texture
case GL_TEXTURE_CROP_RECT_OES:
+ if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
+ goto invalid_pname;
+
params[0] = obj->CropRect[0];
params[1] = obj->CropRect[1];
params[2] = obj->CropRect[2];
@@ -1382,13 +1414,17 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
case GL_TEXTURE_SWIZZLE_G_EXT:
case GL_TEXTURE_SWIZZLE_B_EXT:
case GL_TEXTURE_SWIZZLE_A_EXT:
- if (!ctx->Extensions.EXT_texture_swizzle)
+ if ((!_mesa_is_desktop_gl(ctx)
+ || !ctx->Extensions.EXT_texture_swizzle)
+ && !_mesa_is_gles3(ctx))
goto invalid_pname;
*params = (GLfloat) obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT];
break;
case GL_TEXTURE_SWIZZLE_RGBA_EXT:
- if (!ctx->Extensions.EXT_texture_swizzle) {
+ if ((!_mesa_is_desktop_gl(ctx)
+ || !ctx->Extensions.EXT_texture_swizzle)
+ && !_mesa_is_gles3(ctx)) {
goto invalid_pname;
}
else {
@@ -1400,7 +1436,8 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
break;
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
- if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
+ if (!_mesa_is_desktop_gl(ctx)
+ || !ctx->Extensions.AMD_seamless_cubemap_per_texture)
goto invalid_pname;
*params = (GLfloat) obj->Sampler.CubeMapSeamless;
break;
@@ -1454,6 +1491,9 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
*params = (GLint) obj->Sampler.WrapR;
break;
case GL_TEXTURE_BORDER_COLOR:
+ if (!_mesa_is_desktop_gl(ctx))
+ goto invalid_pname;
+
{
GLfloat b[4];
b[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
@@ -1467,18 +1507,33 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_TEXTURE_RESIDENT:
+ if (ctx->API != API_OPENGL)
+ goto invalid_pname;
+
*params = 1;
break;
case GL_TEXTURE_PRIORITY:
+ if (ctx->API != API_OPENGL)
+ goto invalid_pname;
+
*params = FLOAT_TO_INT(obj->Priority);
break;
case GL_TEXTURE_MIN_LOD:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_pname;
+
*params = (GLint) obj->Sampler.MinLod;
break;
case GL_TEXTURE_MAX_LOD:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_pname;
+
*params = (GLint) obj->Sampler.MaxLod;
break;
case GL_TEXTURE_BASE_LEVEL:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_pname;
+
*params = obj->BaseLevel;
break;
case GL_TEXTURE_MAX_LEVEL:
@@ -1490,28 +1545,39 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
*params = (GLint) obj->Sampler.MaxAnisotropy;
break;
case GL_GENERATE_MIPMAP_SGIS:
+ if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
+ goto invalid_pname;
+
*params = (GLint) obj->GenerateMipmap;
break;
case GL_TEXTURE_COMPARE_MODE_ARB:
- if (!ctx->Extensions.ARB_shadow)
+ if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow)
+ && !_mesa_is_gles3(ctx))
goto invalid_pname;
*params = (GLint) obj->Sampler.CompareMode;
break;
case GL_TEXTURE_COMPARE_FUNC_ARB:
- if (!ctx->Extensions.ARB_shadow)
+ if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow)
+ && !_mesa_is_gles3(ctx))
goto invalid_pname;
*params = (GLint) obj->Sampler.CompareFunc;
break;
case GL_DEPTH_TEXTURE_MODE_ARB:
- if (!ctx->Extensions.ARB_depth_texture)
+ if (ctx->API != API_OPENGL || !ctx->Extensions.ARB_depth_texture)
goto invalid_pname;
*params = (GLint) obj->DepthMode;
break;
case GL_TEXTURE_LOD_BIAS:
+ if (ctx->API != API_OPENGL)
+ goto invalid_pname;
+
*params = (GLint) obj->Sampler.LodBias;
break;
#if FEATURE_OES_draw_texture
case GL_TEXTURE_CROP_RECT_OES:
+ if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
+ goto invalid_pname;
+
params[0] = obj->CropRect[0];
params[1] = obj->CropRect[1];
params[2] = obj->CropRect[2];
@@ -1522,19 +1588,24 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
case GL_TEXTURE_SWIZZLE_G_EXT:
case GL_TEXTURE_SWIZZLE_B_EXT:
case GL_TEXTURE_SWIZZLE_A_EXT:
- if (!ctx->Extensions.EXT_texture_swizzle)
+ if ((!_mesa_is_desktop_gl(ctx)
+ || !ctx->Extensions.EXT_texture_swizzle)
+ && !_mesa_is_gles3(ctx))
goto invalid_pname;
*params = obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT];
break;
case GL_TEXTURE_SWIZZLE_RGBA_EXT:
- if (!ctx->Extensions.EXT_texture_swizzle)
+ if ((!_mesa_is_desktop_gl(ctx)
+ || !ctx->Extensions.EXT_texture_swizzle)
+ && !_mesa_is_gles3(ctx))
goto invalid_pname;
COPY_4V(params, obj->Swizzle);
break;
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
- if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
+ if (!_mesa_is_desktop_gl(ctx)
+ || !ctx->Extensions.AMD_seamless_cubemap_per_texture)
goto invalid_pname;
*params = (GLint) obj->Sampler.CubeMapSeamless;
break;
@@ -1546,7 +1617,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
break;
case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
- if (!ctx->Extensions.OES_EGL_image_external)
+ if (!_mesa_is_gles(ctx) || !ctx->Extensions.OES_EGL_image_external)
goto invalid_pname;
*params = obj->RequiredTextureImageUnits;
break;