summaryrefslogtreecommitdiff
path: root/tests/general
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2016-10-10 09:53:24 -0700
committerIan Romanick <ian.d.romanick@intel.com>2016-10-14 11:29:58 -0700
commit5f0406dc0855dcee636ef6ceb1e077d9c6ab2011 (patch)
treee5a914cd991bb35ad74f70134fb6f3f78ddf7620 /tests/general
parent21be1997fe7305925abfa16a559515ca9622e715 (diff)
triangle-rasterization: Use log2u utility function
The log2i code was broken for values < 0 anyway because -1 >> 1 == -1. The result would have been an infinite loop. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Cc: James Benton <jbenton@vmware.com>
Diffstat (limited to 'tests/general')
-rw-r--r--tests/general/triangle-rasterization.cpp12
1 files changed, 1 insertions, 11 deletions
diff --git a/tests/general/triangle-rasterization.cpp b/tests/general/triangle-rasterization.cpp
index f93842fdb..e196280e9 100644
--- a/tests/general/triangle-rasterization.cpp
+++ b/tests/general/triangle-rasterization.cpp
@@ -153,16 +153,6 @@ int64_t iround(float v)
return (int64_t)v;
}
-/* Calculate log2 for integers */
-int log2i(int x)
-{
- int res = 0 ;
- while (x >>= 1)
- ++res;
- return res ;
-}
-
-
/* Based on http://devmaster.net/forums/topic/1145-advanced-rasterization */
void rast_triangle(uint8_t* buffer, uint32_t stride, const Triangle& tri)
{
@@ -408,7 +398,7 @@ GLboolean test_triangle(const Triangle& tri)
/* Generate a random triangle */
void random_triangle(Triangle& tri)
{
- int size = 1 << (mersenne.value() % (log2i(fbo_width) + 1));
+ int size = 1 << (mersenne.value() % (log2u(fbo_width) + 1));
for (int i = 0; i < 3; ++i) {
tri[i].x = (mersenne.value() % (size * FIXED_ONE)) * (1.0f / FIXED_ONE);