Commit f5939399 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Use __builtin_clz() in wined3d_log2i() when available.

parent 42b8a767
......@@ -16448,6 +16448,39 @@ done
LIBS="$ac_save_LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_clz" >&5
$as_echo_n "checking for __builtin_clz... " >&6; }
if ${ac_cv_have___builtin_clz+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return __builtin_clz(1)
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_have___builtin_clz="yes"
else
ac_cv_have___builtin_clz="no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have___builtin_clz" >&5
$as_echo "$ac_cv_have___builtin_clz" >&6; }
if test "$ac_cv_have___builtin_clz" = "yes"
then
$as_echo "#define HAVE___BUILTIN_CLZ 1" >>confdefs.h
fi
case $host_cpu in
*i[3456789]86*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we need to define __i386__" >&5
......
......@@ -2595,6 +2595,15 @@ AC_CHECK_FUNCS(\
)
LIBS="$ac_save_LIBS"
dnl Check for __builtin_clz
AC_CACHE_CHECK([for __builtin_clz], ac_cv_have___builtin_clz,
AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[return __builtin_clz(1)]])],
[ac_cv_have___builtin_clz="yes"], [ac_cv_have___builtin_clz="no"]))
if test "$ac_cv_have___builtin_clz" = "yes"
then
AC_DEFINE(HAVE___BUILTIN_CLZ, 1, [Define to 1 if you have the `__builtin_clz' built-in function.])
fi
dnl *** check for the need to define platform-specific symbols
case $host_cpu in
......
......@@ -3929,8 +3929,12 @@ const struct wine_rb_functions wined3d_ffp_vertex_program_rb_functions =
wined3d_ffp_vertex_program_key_compare,
};
/* Return the integer base-2 logarithm of x. Undefined for x == 0. */
UINT wined3d_log2i(UINT32 x)
{
#ifdef HAVE___BUILTIN_CLZ
return __builtin_clz(x) ^ 0x1f;
#else
static const UINT l[] =
{
~0U, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
......@@ -3953,6 +3957,7 @@ UINT wined3d_log2i(UINT32 x)
UINT32 i;
return (i = x >> 16) ? (x = i >> 8) ? l[x] + 24 : l[i] + 16 : (i = x >> 8) ? l[i] + 8 : l[x];
#endif
}
const struct blit_shader *wined3d_select_blitter(const struct wined3d_gl_info *gl_info, enum wined3d_blit_op blit_op,
......
......@@ -1281,6 +1281,9 @@
/* Define to 1 if you have the `_vsnprintf' function. */
#undef HAVE__VSNPRINTF
/* Define to 1 if you have the `__builtin_clz' built-in function. */
#undef HAVE___BUILTIN_CLZ
/* Define to 1 if you have the `__res_getservers' function. */
#undef HAVE___RES_GETSERVERS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment