[Mesa-dev] [PATCH] Allow glTexImage2D with a depth component cube map
Brian Paul
brianp at vmware.com
Mon Nov 21 15:12:59 PST 2011
On 11/21/2011 03:45 PM, anuj.phogat at gmail.com wrote:
> From: Anuj Phogat<anuj.phogat at gmail.com>
>
> Thanks for the review comments. Here is the updated patch to allow depth component cube maps in GL 3.0.
> I'll post the piglit testcase for this patch in a separate e-mail.
>
> Anuj
>
> Signed-off-by: Anuj Phogat<anuj.phogat at gmail.com>
> ---
> src/mesa/main/teximage.c | 27 +++++++++++++++++++++------
> 1 files changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index acf7187..f1391be 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1596,7 +1596,7 @@ texture_error_check( struct gl_context *ctx,
>
> /* additional checks for depth textures */
> if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) {
> - /* Only 1D, 2D, rect and array textures supported, not 3D or cubes */
> + /* Only 1D, 2D, rect, cube and array textures are supported, not 3D*/
> if (target != GL_TEXTURE_1D&&
> target != GL_PROXY_TEXTURE_1D&&
> target != GL_TEXTURE_2D&&
> @@ -1607,13 +1607,28 @@ texture_error_check( struct gl_context *ctx,
> target != GL_PROXY_TEXTURE_2D_ARRAY&&
> target != GL_TEXTURE_RECTANGLE_ARB&&
> target != GL_PROXY_TEXTURE_RECTANGLE_ARB) {
> - if (!isProxy)
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glTexImage(target/internalFormat)");
> - return GL_TRUE;
> + if (ctx->VersionMajor>= 3 || ctx->Extensions.EXT_gpu_shader4) {
> + /*Cubemaps are only supported for GL version> 3.0 or with EXT_gpu_shader4*/
> + if (target != GL_TEXTURE_CUBE_MAP_POSITIVE_X&&
> + target != GL_TEXTURE_CUBE_MAP_NEGATIVE_X&&
> + target != GL_TEXTURE_CUBE_MAP_POSITIVE_Y&&
> + target != GL_TEXTURE_CUBE_MAP_NEGATIVE_Y&&
> + target != GL_TEXTURE_CUBE_MAP_POSITIVE_Z&&
> + target != GL_TEXTURE_CUBE_MAP_NEGATIVE_Z&&
> + target != GL_PROXY_TEXTURE_CUBE_MAP) {
> + if (!isProxy)
> + _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target/internalFormat)");
> + return GL_TRUE;
> + }
> + }
> + else {
> + if (!isProxy)
> + _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target/internalFormat)");
> + return GL_TRUE;
> + }
> }
> }
> -
> +
> /* additional checks for compressed textures */
> if (_mesa_is_compressed_format(ctx, internalFormat)) {
> if (!target_can_be_compressed(ctx, target, internalFormat)) {
I think something like this would be simpler:
@@ -1629,7 +1629,9 @@ texture_error_check( struct gl_context *ctx,
target != GL_TEXTURE_2D_ARRAY &&
target != GL_PROXY_TEXTURE_2D_ARRAY &&
target != GL_TEXTURE_RECTANGLE_ARB &&
- target != GL_PROXY_TEXTURE_RECTANGLE_ARB) {
+ target != GL_PROXY_TEXTURE_RECTANGLE_ARB &&
+ !((_mesa_is_cube_face(target) || target ==
GL_PROXY_TEXTURE_CUBE_MAP) &&
+ (ctx->VersionMajor >= 3 ||
ctx->Extensions.EXT_gpu_shader4))) {
if (!isProxy)
_mesa_error(ctx, GL_INVALID_ENUM,
"glTexImage(target/internalFormat)");
I haven't tested this so the logic might be incorrect.
-Brian
More information about the mesa-dev
mailing list