intel: Fix glCopyTexSubImage on buffers whose width >= 32kbytes
[mesa.git] / src / mesa / drivers / dri / intel / intel_tex_copy.c
index 1af7b1c5671d6be651d556d73b2b2424dc17d8f2..c9cbcf480d52ff2fb64756d3e1eb51b26cbddd70 100644 (file)
@@ -70,6 +70,27 @@ intel_copy_texsubimage(struct intel_context *intel,
       assert(region);
    }
 
+   /* According to the Ivy Bridge PRM, Vol1 Part4, section 1.2.1.2 (Graphics
+    * Data Size Limitations):
+    *
+    *    The BLT engine is capable of transferring very large quantities of
+    *    graphics data. Any graphics data read from and written to the
+    *    destination is permitted to represent a number of pixels that
+    *    occupies up to 65,536 scan lines and up to 32,768 bytes per scan line
+    *    at the destination. The maximum number of pixels that may be
+    *    represented per scan line’s worth of graphics data depends on the
+    *    color depth.
+    *
+    * Furthermore, intelEmitCopyBlit (which is called below) uses a signed
+    * 16-bit integer to represent buffer pitch, so it can only handle buffer
+    * pitches < 32k.
+    *
+    * As a result of these two limitations, we can only use the blitter to do
+    * this copy when the region's pitch is less than 32k.
+    */
+   if (region->pitch >= 32768)
+      return false;
+
    if (intelImage->base.Base.TexObject->Target == GL_TEXTURE_1D_ARRAY ||
        intelImage->base.Base.TexObject->Target == GL_TEXTURE_2D_ARRAY) {
       perf_debug("no support for array textures\n");