Mesa (master): draw: Init llvm if not provided

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Mon Jan 24 02:30:21 UTC 2011


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

Author: Jakob Bornecrantz <wallbraker at gmail.com>
Date:   Sun Jan 23 05:22:30 2011 +0100

draw: Init llvm if not provided

---

 src/gallium/auxiliary/draw/draw_context.c   |   15 ++++++++++++---
 src/gallium/auxiliary/draw/draw_private.h   |    1 +
 src/gallium/auxiliary/gallivm/lp_bld_init.c |    6 +++++-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index e045313..11eba8a 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -88,8 +88,14 @@ draw_create_gallivm(struct pipe_context *pipe, struct gallivm_state *gallivm)
       goto fail;
 
 #if HAVE_LLVM
-   if (draw_get_option_use_llvm() && gallivm) {
-      draw->llvm = draw_llvm_create(draw, gallivm);
+   if (draw_get_option_use_llvm()) {
+      if (!gallivm) {
+         gallivm = gallivm_create();
+         draw->own_gallivm = gallivm;
+      }
+
+      if (gallivm)
+         draw->llvm = draw_llvm_create(draw, gallivm);
    }
 #endif
 
@@ -180,8 +186,11 @@ void draw_destroy( struct draw_context *draw )
    draw_vs_destroy( draw );
    draw_gs_destroy( draw );
 #ifdef HAVE_LLVM
-   if(draw->llvm)
+   if (draw->llvm)
       draw_llvm_destroy( draw->llvm );
+
+   if (draw->own_gallivm)
+      gallivm_destroy(draw->own_gallivm);
 #endif
 
    FREE( draw );
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 06ed4d6..db2e3c5 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -286,6 +286,7 @@ struct draw_context
 
 #ifdef HAVE_LLVM
    struct draw_llvm *llvm;
+   struct gallivm_state *own_gallivm;
 #endif
 
    struct pipe_sampler_view *sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 7504cb5..45addee 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -222,11 +222,12 @@ free_gallivm_state(struct gallivm_state *gallivm)
 static boolean
 init_gallivm_state(struct gallivm_state *gallivm)
 {
-   assert(gallivm_initialized);
    assert(!gallivm->context);
    assert(!gallivm->module);
    assert(!gallivm->provider);
 
+   lp_build_init();
+
    gallivm->context = LLVMContextCreate();
    if (!gallivm->context)
       goto fail;
@@ -387,6 +388,9 @@ gallivm_garbage_collect(struct gallivm_state *gallivm)
 void
 lp_build_init(void)
 {
+   if (gallivm_initialized)
+      return;
+
 #ifdef DEBUG
    gallivm_debug = debug_get_option_gallivm_debug();
 #endif




More information about the mesa-commit mailing list