i965,iris/blorp: do not blit 0-sizes
authorSergii Romantsov <sergii.romantsov@globallogic.com>
Thu, 28 Feb 2019 11:35:54 +0000 (13:35 +0200)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sat, 30 Mar 2019 11:50:40 +0000 (11:50 +0000)
Seems there is no sense in blitting 0-sized sources
or destinations.
Additionaly it may cause segfaults for i965.

v2: Function call replaced with inline check

v3: Added check to avoid devision by zero (L. Landwerlin)

v4: Added simillar check for Iris (L. Landwerlin)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110239
Signed-off-by: Sergii Romantsov <sergii.romantsov@globallogic.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/gallium/drivers/iris/iris_blit.c
src/mesa/drivers/dri/i965/brw_meta_util.c

index 5568be937fbfbd100d6a2f9b088db993f21de106..84eb952d7918db6de2438f10996e5479da55537a 100644 (file)
@@ -198,6 +198,10 @@ apply_blit_scissor(const struct pipe_scissor_state *scissor,
     * clipping 4 * 2 = 8 > 5 in the src.
     */
 
+   if (*src_x0 == *src_x1 || *src_y0 == *src_y1
+       || *dst_x0 == *dst_x1 || *dst_y0 == *dst_y1)
+      return true;
+
    float scale_x = (float) (*src_x1 - *src_x0) / (*dst_x1 - *dst_x0);
    float scale_y = (float) (*src_y1 - *src_y0) / (*dst_y1 - *dst_y0);
 
@@ -217,7 +221,11 @@ apply_blit_scissor(const struct pipe_scissor_state *scissor,
    clip_coordinates(mirror_y, src_y1, dst_y1, dst_y0,
                     clip_dst_y1, clip_dst_y0, scale_y, false);
 
-   return false;
+   /* Check for invalid bounds
+    * Can't blit for 0-dimensions
+    */
+   return *src_x0 == *src_x1 || *src_y0 == *src_y1
+      || *dst_x0 == *dst_x1 || *dst_y0 == *dst_y1;
 }
 
 void
index 908b0989769b62288a486a73fa7710195a735a86..6a6d68425fad878d55f99068dfdd64c971b190aa 100644 (file)
@@ -220,6 +220,10 @@ brw_meta_mirror_clip_and_scissor(const struct gl_context *ctx,
     * 4 * 2 = 8 > 5 in the src.
     */
 
+   if (*srcX0 == *srcX1 || *srcY0 == *srcY1
+       || *dstX0 == *dstX1 || *dstY0 == *dstY1)
+      return true;
+
    float scaleX = (float) (*srcX1 - *srcX0) / (*dstX1 - *dstX0);
    float scaleY = (float) (*srcY1 - *srcY0) / (*dstY1 - *dstY0);
 
@@ -263,7 +267,11 @@ brw_meta_mirror_clip_and_scissor(const struct gl_context *ctx,
       *mirror_y = !*mirror_y;
    }
 
-   return false;
+   /* Check for invalid bounds
+    * Can't blit for 0-dimensions
+    */
+   return *srcX0 == *srcX1 || *srcY0 == *srcY1
+      || *dstX0 == *dstX1 || *dstY0 == *dstY1;
 }
 
 /**