texgetimage: Add check for the effective target to GetTextureSubImage
authorEduardo Lima Mitev <elima@igalia.com>
Thu, 2 Feb 2017 16:07:24 +0000 (17:07 +0100)
committerEduardo Lima Mitev <elima@igalia.com>
Thu, 2 Feb 2017 23:43:46 +0000 (00:43 +0100)
OpenGL 4.5 spec, section "8.11.4 Texture Image Queries", page 233 of
the PDF states:

    "An INVALID_OPERATION error is generated if texture is the name of a buffer
     or multisample texture."

This is currently not being checked and e.g a multisample texture image can
be passed down to the driver hook. On i965, it is crashing the driver with an
assertion:

intel_mipmap_tree.c:3125: intel_miptree_map: Assertion `mt->num_samples <= 1' failed.

v2: (Ilia Mirkin) Move the check from gettextimage_error_check() to
    GetTextureSubImage() and use the texObj target.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/mesa/main/texgetimage.c

index d5cb1636605b54b4cbc919a8ef29a03f7e45f38f..b0ced1eac0f87c02f0574b5465fdd3a189618890 100644 (file)
@@ -1465,6 +1465,12 @@ _mesa_GetTextureSubImage(GLuint texture, GLint level,
       return;
    }
 
+   if (!legal_getteximage_target(ctx, texObj->Target, true)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "%s(buffer/multisample texture)", caller);
+      return;
+   }
+
    if (getteximage_error_check(ctx, texObj, texObj->Target, level,
                                xoffset, yoffset, zoffset, width, height, depth,
                                format, type, bufSize, pixels, caller)) {