mesa/copyimage: make sure number of samples match.
authorDave Airlie <airlied@redhat.com>
Tue, 3 May 2016 06:09:38 +0000 (16:09 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 3 May 2016 10:13:29 +0000 (20:13 +1000)
This fixes
GL43-CTS.copy_image.samples_missmatch
which otherwise asserts in the radeonsi driver.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/mesa/main/copyimage.c

index a0f1c691220dadc268ee1b38b4378e9e46dda38f..63ce13ad72cdd7cfadcea86fc25b9f3cf49b2f97 100644 (file)
@@ -552,12 +552,26 @@ _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel,
                             "dst"))
       return;
 
+   /* Section 18.3.2 (Copying Between Images) of the OpenGL 4.5 Core Profile
+    * spec says:
+    *
+    *    An INVALID_OPERATION error is generated if either object is a texture
+    *    and the texture is not complete, if the source and destination internal
+    *    formats are not compatible, or if the number of samples do not match.
+    */
    if (!copy_format_compatible(ctx, srcIntFormat, dstIntFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glCopyImageSubData(internalFormat mismatch)");
       return;
    }
 
+   if (srcTexImage && dstTexImage &&
+       srcTexImage->NumSamples != dstTexImage->NumSamples) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glCopyImageSubData(number of samples mismatch)");
+      return;
+   }
+
    /* loop over 2D slices/faces/layers */
    for (i = 0; i < srcDepth; ++i) {
       int newSrcZ = srcZ + i;