draw: Always use the llvm middle end when available & enabled.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 26 Apr 2010 14:31:37 +0000 (15:31 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 26 Apr 2010 15:05:06 +0000 (16:05 +0100)
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt.c

index 4bb3282f62c4c1bdc4981304dfc03ffa784129b8..a2bfb693c098c615a521da2c3e08183c0ae674a8 100644 (file)
@@ -132,6 +132,7 @@ struct draw_context
          struct draw_pt_middle_end *fetch_emit;
          struct draw_pt_middle_end *fetch_shade_emit;
          struct draw_pt_middle_end *general;
+         struct draw_pt_middle_end *llvm;
       } middle;
 
       struct {
@@ -253,8 +254,8 @@ struct draw_context
 
 #ifdef HAVE_LLVM
    LLVMExecutionEngineRef engine;
-   boolean use_llvm;
 #endif
+
    void *driver_private;
 };
 
index c40c25dc3a1c44ff730b0d97ca303d4a6ad4bcc4..1d9395e06c3666e75e76858471551444d19c1afd 100644 (file)
@@ -97,12 +97,16 @@ draw_pt_arrays(struct draw_context *draw,
       opt |= PT_SHADE;
    }
       
-   if (opt == 0) 
-      middle = draw->pt.middle.fetch_emit;
-   else if (opt == PT_SHADE && !draw->pt.no_fse)
-      middle = draw->pt.middle.fetch_shade_emit;
-   else
-      middle = draw->pt.middle.general;
+   if (draw->pt.middle.llvm) {
+      middle = draw->pt.middle.llvm;
+   } else {
+      if (opt == 0)
+         middle = draw->pt.middle.fetch_emit;
+      else if (opt == PT_SHADE && !draw->pt.no_fse)
+         middle = draw->pt.middle.fetch_shade_emit;
+      else
+         middle = draw->pt.middle.general;
+   }
 
 
    /* Pick the right frontend
@@ -148,25 +152,26 @@ boolean draw_pt_init( struct draw_context *draw )
    if (!draw->pt.middle.fetch_shade_emit)
       return FALSE;
 
-#if HAVE_LLVM
-   draw->use_llvm = debug_get_option_draw_use_llvm();
-   if (draw->use_llvm)
-      draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit_llvm( draw );
-#else
-   draw->pt.middle.general = NULL;
-#endif
-
-   if (!draw->pt.middle.general)
-      draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit( draw );
+   draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit( draw );
    if (!draw->pt.middle.general)
       return FALSE;
 
+#if HAVE_LLVM
+   if (debug_get_option_draw_use_llvm())
+      draw->pt.middle.llvm = draw_pt_fetch_pipeline_or_emit_llvm( draw );
+#endif
+
    return TRUE;
 }
 
 
 void draw_pt_destroy( struct draw_context *draw )
 {
+   if (draw->pt.middle.llvm) {
+      draw->pt.middle.llvm->destroy( draw->pt.middle.llvm );
+      draw->pt.middle.llvm = NULL;
+   }
+
    if (draw->pt.middle.general) {
       draw->pt.middle.general->destroy( draw->pt.middle.general );
       draw->pt.middle.general = NULL;