Mesa (master): mesa/es: Validate tex image targets in Mesa code rather than the ES wrapper
Ian Romanick
idr at kemper.freedesktop.org
Thu Aug 23 17:20:50 UTC 2012
Module: Mesa
Branch: master
Commit: 530c9d764b84035728a28ee2db996fffe49125ce
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=530c9d764b84035728a28ee2db996fffe49125ce
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Thu Jul 26 10:39:45 2012 -0700
mesa/es: Validate tex image targets in Mesa code rather than the ES wrapper
This should take care of all the TexImage, TexSubImage, CopyTexImage,
CompressedTexImage3DOES, and CopyTexSubImage type paths.
v2: Add proper core-profile and GLES3 filtering.
v3: Squash the CompressedTexImage3DOES patch per review comment from
Ken.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
---
src/mesa/main/APIspec.xml | 116 ---------------------------------------------
src/mesa/main/teximage.c | 43 +++++++++++-----
2 files changed, 29 insertions(+), 130 deletions(-)
diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index 1306ac7..b08f2b4 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -265,22 +265,6 @@
<param name="pixels" type="const GLvoid *"/>
</proto>
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
<desc name="internalFormat">
<value name="GL_ALPHA"/>
@@ -1620,22 +1604,6 @@
<param name="border" type="GLint"/>
</proto>
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
<desc name="internalFormat" error="GL_INVALID_VALUE">
<value name="GL_ALPHA"/>
<value name="GL_RGB"/>
@@ -1661,22 +1629,6 @@
<param name="width" type="GLsizei"/>
<param name="height" type="GLsizei"/>
</proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
</template>
<template name="TexSubImage2D">
@@ -1693,22 +1645,6 @@
<param name="pixels" type="const GLvoid *"/>
</proto>
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
<desc name="format">
<value name="GL_ALPHA"/>
@@ -1868,10 +1804,6 @@
<param name="pixels" type="const GLvoid *"/>
</proto>
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
-
<desc name="internalFormat">
<value name="GL_ALPHA"/>
<value name="GL_RGB"/>
@@ -1951,10 +1883,6 @@
<param name="pixels" type="const GLvoid *"/>
</proto>
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
-
<desc name="format">
<value name="GL_ALPHA"/>
@@ -2023,10 +1951,6 @@
<param name="width" type="GLsizei"/>
<param name="height" type="GLsizei"/>
</proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
</template>
<template name="MultiTexCoord">
@@ -2055,10 +1979,6 @@
<param name="imagesize" type="GLsizei"/>
<param name="data" type="const GLvoid *"/>
</proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
</template>
<template name="CompressedTexSubImage3D">
@@ -2076,10 +1996,6 @@
<param name="imagesize" type="GLsizei"/>
<param name="data" type="const GLvoid *"/>
</proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
</template>
<template name="ActiveTexture">
@@ -2117,22 +2033,6 @@
<param name="data" type="const GLvoid *"/>
</proto>
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
<desc name="internalFormat">
<value name="GL_ETC1_RGB8_OES" category="OES_compressed_ETC1_RGB8_texture"/>
@@ -2166,22 +2066,6 @@
<param name="data" type="const GLvoid *"/>
</proto>
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
<desc name="format">
<value name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
<value name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 095db4f..8efa179 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1426,16 +1426,19 @@ legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target)
switch (target) {
case GL_TEXTURE_1D:
case GL_PROXY_TEXTURE_1D:
- return GL_TRUE;
+ return _mesa_is_desktop_gl(ctx);
default:
return GL_FALSE;
}
case 2:
switch (target) {
case GL_TEXTURE_2D:
- case GL_PROXY_TEXTURE_2D:
return GL_TRUE;
+ case GL_PROXY_TEXTURE_2D:
+ return _mesa_is_desktop_gl(ctx);
case GL_PROXY_TEXTURE_CUBE_MAP:
+ return _mesa_is_desktop_gl(ctx)
+ && ctx->Extensions.ARB_texture_cube_map;
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
@@ -1445,23 +1448,31 @@ legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target)
return ctx->Extensions.ARB_texture_cube_map;
case GL_TEXTURE_RECTANGLE_NV:
case GL_PROXY_TEXTURE_RECTANGLE_NV:
- return ctx->Extensions.NV_texture_rectangle;
+ return _mesa_is_desktop_gl(ctx)
+ && ctx->Extensions.NV_texture_rectangle;
case GL_TEXTURE_1D_ARRAY_EXT:
case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
- return (ctx->Extensions.MESA_texture_array ||
- ctx->Extensions.EXT_texture_array);
+ return _mesa_is_desktop_gl(ctx)
+ && (ctx->Extensions.MESA_texture_array ||
+ ctx->Extensions.EXT_texture_array);
default:
return GL_FALSE;
}
case 3:
switch (target) {
case GL_TEXTURE_3D:
- case GL_PROXY_TEXTURE_3D:
return GL_TRUE;
+ case GL_PROXY_TEXTURE_3D:
+ return _mesa_is_desktop_gl(ctx);
case GL_TEXTURE_2D_ARRAY_EXT:
+ return (_mesa_is_desktop_gl(ctx)
+ && (ctx->Extensions.MESA_texture_array ||
+ ctx->Extensions.EXT_texture_array))
+ || _mesa_is_gles3(ctx);
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
- return (ctx->Extensions.MESA_texture_array ||
- ctx->Extensions.EXT_texture_array);
+ return _mesa_is_desktop_gl(ctx)
+ && (ctx->Extensions.MESA_texture_array ||
+ ctx->Extensions.EXT_texture_array);
default:
return GL_FALSE;
}
@@ -1483,7 +1494,7 @@ legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target)
{
switch (dims) {
case 1:
- return target == GL_TEXTURE_1D;
+ return _mesa_is_desktop_gl(ctx) && target == GL_TEXTURE_1D;
case 2:
switch (target) {
case GL_TEXTURE_2D:
@@ -1496,10 +1507,12 @@ legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target)
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
return ctx->Extensions.ARB_texture_cube_map;
case GL_TEXTURE_RECTANGLE_NV:
- return ctx->Extensions.NV_texture_rectangle;
+ return _mesa_is_desktop_gl(ctx)
+ && ctx->Extensions.NV_texture_rectangle;
case GL_TEXTURE_1D_ARRAY_EXT:
- return (ctx->Extensions.MESA_texture_array ||
- ctx->Extensions.EXT_texture_array);
+ return _mesa_is_desktop_gl(ctx)
+ && (ctx->Extensions.MESA_texture_array ||
+ ctx->Extensions.EXT_texture_array);
default:
return GL_FALSE;
}
@@ -1508,8 +1521,10 @@ legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target)
case GL_TEXTURE_3D:
return GL_TRUE;
case GL_TEXTURE_2D_ARRAY_EXT:
- return (ctx->Extensions.MESA_texture_array ||
- ctx->Extensions.EXT_texture_array);
+ return (_mesa_is_desktop_gl(ctx)
+ && (ctx->Extensions.MESA_texture_array ||
+ ctx->Extensions.EXT_texture_array))
+ || _mesa_is_gles3(ctx);
default:
return GL_FALSE;
}
More information about the mesa-commit
mailing list