From 65026f980a6df01a7d437ce51a47de911820041e Mon Sep 17 00:00:00 2001
From: Bhanu Chetlapalli <bhanu@mips.com>
Date: Wed, 25 Jan 2012 14:45:30 -0800
Subject: [PATCH] Prevent bit shifting if num bits is negative
Causes OpenGL Software Renderer to generate incorrect window
coordinates on MIPS & possibly x86
Change-Id: I3c51b6a5a4e6af75e9b31d9d47e4e4d894825888
Signed-off-by: Bhanu Chetlapalli <bhanu@mips.com>
---
libpixelflinger/fixed.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libpixelflinger/fixed.cpp b/libpixelflinger/fixed.cpp
index 5b920628ba..5094537766 100644
--- a/libpixelflinger/fixed.cpp
+++ b/libpixelflinger/fixed.cpp
@@ -62,7 +62,8 @@ int32_t gglRecipQ(GGLfixed x, int q)
int shift;
x = gglRecipQNormalized(x, &shift);
shift += 16-q;
- x += 1L << (shift-1); // rounding
+ if (shift > 0)
+ x += 1L << (shift-1); // rounding
x >>= shift;
return x;
}
--
GitLab