Allow compiler to unroll pow2ize
This commit is contained in:
parent
20cf3f4cdb
commit
d909692148
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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<x; i*=2) {}; //corrected by MD2211: was previously limited to 4096
|
||||
return i;
|
||||
unsigned pow2ize(unsigned f0){
|
||||
unsigned f1 = (f0 - 1) | 1;
|
||||
for (unsigned i = 4; 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
|
||||
|
|
Loading…
Reference in a new issue