Merge branch 'gallium-0.1' into gallium-tex-surfaces
[mesa.git] / src / gallium / drivers / softpipe / sp_state_fs.c
index b0238f817376ecafcc13a5d70bb85f35d5f76fe2..9e77b7e91bc79e83d91389c376cb0e8e9606a371 100644 (file)
@@ -36,6 +36,7 @@
 #include "pipe/p_shader_tokens.h"
 #include "draw/draw_context.h"
 #include "tgsi/util/tgsi_dump.h"
+#include "tgsi/util/tgsi_scan.h"
 
 
 void *
@@ -45,20 +46,24 @@ softpipe_create_fs_state(struct pipe_context *pipe,
    struct softpipe_context *softpipe = softpipe_context(pipe);
    struct sp_fragment_shader *state;
 
+   /* debug */
    if (softpipe->dump_fs) 
       tgsi_dump(templ->tokens, 0);
 
+   /* codegen */
    state = softpipe_create_fs_llvm( softpipe, templ );
-   if (state)
-      return state;
-   
-   state = softpipe_create_fs_sse( softpipe, templ );
-   if (state)
-      return state;
-
-   state = softpipe_create_fs_exec( softpipe, templ );
+   if (!state) {
+      state = softpipe_create_fs_sse( softpipe, templ );
+      if (!state) {
+         state = softpipe_create_fs_exec( softpipe, templ );
+      }
+   }
 
    assert(state);
+
+   /* get/save the summary info for this shader */
+   tgsi_scan_shader(templ->tokens, &state->info);
+
    return state;
 }
 
@@ -78,6 +83,8 @@ void
 softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct sp_fragment_shader *state = fs;
+
+   assert(fs != softpipe_context(pipe)->fs);
    
    state->delete( state );
 }
@@ -115,7 +122,8 @@ softpipe_bind_vs_state(struct pipe_context *pipe, void *vs)
 
    softpipe->vs = (const struct sp_vertex_shader *)vs;
 
-   draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data);
+   draw_bind_vertex_shader(softpipe->draw,
+                           (softpipe->vs ? softpipe->vs->draw_data : NULL));
 
    softpipe->dirty |= SP_NEW_VS;
 }