Mesa (master): mesa: Handle uninitialized textures like other textures in get_tex_level_parameter_image

Ian Romanick idr at kemper.freedesktop.org
Tue Jul 15 17:54:57 UTC 2014


Module: Mesa
Branch: master
Commit: ee58c71a65bb5b769a03e4b25bd13c57a6b742d8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee58c71a65bb5b769a03e4b25bd13c57a6b742d8

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Tue Jun 17 14:58:14 2014 -0700

mesa: Handle uninitialized textures like other textures in get_tex_level_parameter_image

Instead of catching the special case early, handle it by constructing a
fake gl_texture_image that will cause the values required by the OpenGL
4.0 spec to be returned.

Previously, calling

    glGenTextures(1, &t);
    glBindTexture(GL_TEXTURE_2D, t);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, 0xDEADBEEF, &value);

would not generate an error.

Anuj: Can you verify this does not regress proxy_textures_invalid_size?

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Suggested-by: Brian Paul <brianp at vmware.com>
Cc: "10.2" <mesa-stable at lists.freedesktop.org>
Cc: Anuj Phogat <anuj.phogat at gmail.com>

---

 src/mesa/main/texparam.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index dc17ea5..6767f32 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1051,6 +1051,7 @@ get_tex_level_parameter_image(struct gl_context *ctx,
                               GLenum pname, GLint *params)
 {
    const struct gl_texture_image *img = NULL;
+   struct gl_texture_image dummy_image;
    mesa_format texFormat;
 
    img = _mesa_select_tex_image(ctx, texObj, target, level);
@@ -1062,12 +1063,12 @@ get_tex_level_parameter_image(struct gl_context *ctx,
        *     instead of 1. TEXTURE_COMPONENTS is deprecated; always
        *     use TEXTURE_INTERNAL_FORMAT."
        */
+      memset(&dummy_image, 0, sizeof(dummy_image));
+      dummy_image.TexFormat = MESA_FORMAT_NONE;
+      dummy_image.InternalFormat = GL_RGBA;
+      dummy_image._BaseFormat = GL_NONE;
 
-      if (pname == GL_TEXTURE_INTERNAL_FORMAT)
-         *params = GL_RGBA;
-      else
-         *params = 0;
-      return;
+      img = &dummy_image;
    }
 
    texFormat = img->TexFormat;




More information about the mesa-commit mailing list