Re: [Mesa-dev] [PATCH] intel: Avoid divide by zero for very small linear blits

2012-02-03 Thread Eric Anholt
On Thu,  2 Feb 2012 16:50:32 -0700, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 If size is small (such as 1),
 
pitch = ROUND_DOWN_TO(MIN2(size, (1  15) - 1), 4);
 
 makes pitch = 0.  Then
 
height = size / pitch;
 
 causes a division-by-zero exception.  If pitch is zero, set height to
 1 and avoid the division.
 
 This fixes piglit's bin/getteximage-formats test and glean's
 bufferObject test.

Looks simpler than my patch, while correct.

Reviewed-by: Eric Anholt e...@anholt.net


pgpkzWzpt3Wb3.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] intel: Avoid divide by zero for very small linear blits

2012-02-02 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

If size is small (such as 1),

   pitch = ROUND_DOWN_TO(MIN2(size, (1  15) - 1), 4);

makes pitch = 0.  Then

   height = size / pitch;

causes a division-by-zero exception.  If pitch is zero, set height to
1 and avoid the division.

This fixes piglit's bin/getteximage-formats test and glean's
bufferObject test.

NOTE: This is a candidate for the 8.0 release branch.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44971
---
 src/mesa/drivers/dri/intel/intel_blit.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_blit.c 
b/src/mesa/drivers/dri/intel/intel_blit.c
index 9eacadd..fd4a86c 100644
--- a/src/mesa/drivers/dri/intel/intel_blit.c
+++ b/src/mesa/drivers/dri/intel/intel_blit.c
@@ -492,7 +492,7 @@ intel_emit_linear_blit(struct intel_context *intel,
 * rounding that down to the nearest DWORD is 1  15 - 4
 */
pitch = ROUND_DOWN_TO(MIN2(size, (1  15) - 1), 4);
-   height = size / pitch;
+   height = (pitch == 0) ? 1 : size / pitch;
ok = intelEmitCopyBlit(intel, 1,
  pitch, src_bo, src_offset, I915_TILING_NONE,
  pitch, dst_bo, dst_offset, I915_TILING_NONE,
-- 
1.7.6.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev