From d909692148b8748480b95d0d2738e089bbb832ee Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 16 Aug 2013 02:00:35 +0000 Subject: [PATCH] Allow compiler to unroll pow2ize --- common/include/ogl_init.h | 2 +- similar/arch/ogl/ogl.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/common/include/ogl_init.h b/common/include/ogl_init.h index bb53bbc35..419efdc0f 100644 --- a/common/include/ogl_init.h +++ b/common/include/ogl_init.h @@ -108,7 +108,7 @@ bool g3_draw_tmap_2(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,g3s_lrgb *lig void ogl_draw_vertex_reticle(int cross,int primary,int secondary,int color,int alpha,int size_offs); void ogl_toggle_depth_test(int enable); void ogl_set_blending(); -int pow2ize(int x);//from ogl.c +unsigned pow2ize(unsigned x);//from ogl.c #ifdef __cplusplus } diff --git a/similar/arch/ogl/ogl.c b/similar/arch/ogl/ogl.c index 059cf712c..305788e36 100644 --- a/similar/arch/ogl/ogl.c +++ b/similar/arch/ogl/ogl.c @@ -1254,10 +1254,15 @@ void gr_flip(void) } //little hack to find the nearest bigger power of 2 for a given number -int pow2ize(int x){ - int i; - for (i=2; i 0;) + f1 |= f1 >> (1 << i); + unsigned f2 = f1 + 1; + assert(f2 >= f0); + assert(!(f2 & f1)); + assert((f2 >> 1) < f0); + return f2; } // Allocate the pixel buffers 'pixels' and 'texbuf' based on current screen resolution