gallium/util: add util_format_init that inits s3tc and util_half
authorLuca Barbieri <luca@luca-barbieri.com>
Thu, 1 Apr 2010 23:43:49 +0000 (01:43 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Fri, 2 Apr 2010 00:31:43 +0000 (02:31 +0200)
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

progs/gallium/unit/u_format_test.c
src/gallium/auxiliary/util/u_format.c
src/gallium/auxiliary/util/u_format.h
src/gallium/auxiliary/util/u_half.c
src/gallium/auxiliary/util/u_half.h
src/gallium/drivers/softpipe/sp_screen.c

index ca4c92f5b7ec42c4093ec0e1fb59834b17d5ef0b..dcdbf6548ded59fc4b3e4ed61ed9bddece078726 100644 (file)
@@ -404,7 +404,7 @@ int main(int argc, char **argv)
 {
    boolean success;
 
-   util_format_s3tc_init();
+   util_format_init();
 
    success = test_all();
 
index 7f16cf7d018447e2b9f8054f675a0b50d856f04c..d3ee1f033966ae0e7cebf223615676041a50f54e 100644 (file)
@@ -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();
+}
index 93818a31611115c10f918bc8e9ab907a879ecc9d..f7daa6d923666d9efc215f365fd202f75753a2c4 100644 (file)
@@ -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
index 96b83e5ac00b542a1ab8094d30ff886fe855e73b..4c8f8a51c5294bced29af8d7a0e904f1e7c5a047 100644 (file)
@@ -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);
index 4b80d45b919783fb0fa4acb0ad62df199159f721..02f0f2419364c7f061884c93823130ed92370db5 100644 (file)
@@ -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
index be64048abfc22f8727bdf0e8457905c1471a78cb..26a4bba57469dbe04befa388b177321ceaec34e1 100644 (file)
@@ -27,6 +27,7 @@
 
 
 #include "util/u_memory.h"
+#include "util/u_format.h"
 #include "util/u_format_s3tc.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
@@ -241,7 +242,7 @@ softpipe_create_screen(struct sw_winsys *winsys)
    screen->base.context_create = softpipe_create_context;
    screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
 
-   util_format_s3tc_init();
+   util_format_init();
 
    softpipe_init_screen_texture_funcs(&screen->base);
    softpipe_init_screen_buffer_funcs(&screen->base);