Mesa (master): gallium/util: add util_format_init that inits s3tc and util_half

Luca Barbieri lb at kemper.freedesktop.org
Fri Apr 2 00:33:07 UTC 2010


Module: Mesa
Branch: master
Commit: aee5bb5b8ad80d4aed849519a80b1d696991e866
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=aee5bb5b8ad80d4aed849519a80b1d696991e866

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Fri Apr  2 01:43:49 2010 +0200

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

---

 progs/gallium/unit/u_format_test.c       |    2 +-
 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 ++++-
 src/gallium/drivers/softpipe/sp_screen.c |    3 ++-
 6 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c
index ca4c92f..dcdbf65 100644
--- a/progs/gallium/unit/u_format_test.c
+++ b/progs/gallium/unit/u_format_test.c
@@ -404,7 +404,7 @@ int main(int argc, char **argv)
 {
    boolean success;
 
-   util_format_s3tc_init();
+   util_format_init();
 
    success = test_all();
 
diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c
index 7f16cf7..d3ee1f0 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 93818a3..f7daa6d 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 96b83e5..4c8f8a5 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 4b80d45..02f0f24 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
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index be64048..26a4bba 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -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);




More information about the mesa-commit mailing list