From aee5bb5b8ad80d4aed849519a80b1d696991e866 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Fri, 2 Apr 2010 01:43:49 +0200 Subject: gallium/util: add util_format_init that inits s3tc and util_half Switch from auto-init to explicit init for util_half per Brian Paul's indication. NOTE: this is probably broken because not enough things call util_format_init. Will be fixed shortly --- src/gallium/auxiliary/util/u_format.c | 10 ++++++++++ src/gallium/auxiliary/util/u_format.h | 3 +++ src/gallium/auxiliary/util/u_half.c | 8 ++++---- src/gallium/auxiliary/util/u_half.h | 5 ++++- 4 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c index 7f16cf7d01..d3ee1f0339 100644 --- a/src/gallium/auxiliary/util/u_format.c +++ b/src/gallium/auxiliary/util/u_format.c @@ -33,6 +33,8 @@ */ #include "u_format.h" +#include "u_format_s3tc.h" +#include "u_half.h" void @@ -116,3 +118,11 @@ util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_ format_desc->pack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h); } +boolean util_format_inited; + +void +util_format_do_init(void) +{ + util_format_s3tc_init(); + util_half_init(); +} diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 93818a3161..f7daa6d923 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -32,6 +32,7 @@ #include "pipe/p_format.h" #include "util/u_debug.h" +#include "util/u_inline_init.h" #ifdef __cplusplus extern "C" { @@ -530,6 +531,8 @@ util_format_write_4ub(enum pipe_format format, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h); +UTIL_INLINE_INIT(util_format); + #ifdef __cplusplus } // extern "C" { #endif diff --git a/src/gallium/auxiliary/util/u_half.c b/src/gallium/auxiliary/util/u_half.c index 96b83e5ac0..4c8f8a51c5 100644 --- a/src/gallium/auxiliary/util/u_half.c +++ b/src/gallium/auxiliary/util/u_half.c @@ -59,8 +59,10 @@ uint32_t util_half_to_float_offset_table[64]; uint16_t util_float_to_half_base_table[512]; uint8_t util_float_to_half_shift_table[512]; -static void -util_half_init_tables(void) +boolean util_half_inited; + +void +util_half_do_init(void) { int i; @@ -161,5 +163,3 @@ util_half_init_tables(void) util_float_to_half_shift_table[256 + i] = util_float_to_half_shift_table[i]; } } - -UTIL_INIT(util_half_init_tables); diff --git a/src/gallium/auxiliary/util/u_half.h b/src/gallium/auxiliary/util/u_half.h index 4b80d45b91..02f0f24193 100644 --- a/src/gallium/auxiliary/util/u_half.h +++ b/src/gallium/auxiliary/util/u_half.h @@ -2,7 +2,8 @@ #define U_HALF_H #include "pipe/p_compiler.h" -#include "u_math.h" +#include "util/u_math.h" +#include "util/u_inline_init.h" #ifdef __cplusplus extern "C" { @@ -55,6 +56,8 @@ util_float_to_half(float f) return util_floatui_to_half(i.ui); } +UTIL_INLINE_INIT(util_half); + #ifdef __cplusplus } #endif -- cgit v1.2.3