llvmpipe: maintain fragment shader state for draw module
authorBrian Paul <brianp@vmware.com>
Mon, 20 Sep 2010 18:52:16 +0000 (12:52 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 20 Sep 2010 18:52:16 +0000 (12:52 -0600)
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_state_fs.h

index e54dd9f0a3c91560a65551090d22efb37d82a43b..fb673db6d0f153e3e60acbf7c9242be0066484c1 100644 (file)
@@ -886,6 +886,7 @@ static void *
 llvmpipe_create_fs_state(struct pipe_context *pipe,
                          const struct pipe_shader_state *templ)
 {
+   struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
    struct lp_fragment_shader *shader;
    int nr_samplers;
 
@@ -902,6 +903,12 @@ llvmpipe_create_fs_state(struct pipe_context *pipe,
    /* we need to keep a local copy of the tokens */
    shader->base.tokens = tgsi_dup_tokens(templ->tokens);
 
+   shader->draw_data = draw_create_fragment_shader(llvmpipe->draw, templ);
+   if (shader->draw_data == NULL) {
+      FREE((void *) shader->base.tokens);
+      return NULL;
+   }
+
    nr_samplers = shader->info.file_max[TGSI_FILE_SAMPLER] + 1;
 
    shader->variant_key_size = Offset(struct lp_fragment_shader_variant_key,
@@ -938,6 +945,9 @@ llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 
    draw_flush(llvmpipe->draw);
 
+   draw_bind_fragment_shader(llvmpipe->draw,
+                             (llvmpipe->fs ? llvmpipe->fs->draw_data : NULL));
+
    llvmpipe->fs = fs;
 
    llvmpipe->dirty |= LP_NEW_FS;
@@ -995,6 +1005,8 @@ llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
       li = next;
    }
 
+   draw_delete_fragment_shader(llvmpipe->draw, shader->draw_data);
+
    assert(shader->variants_cached == 0);
    FREE((void *) shader->base.tokens);
    FREE(shader);
index 2914e7d7efd7cfacc7b8706643aaf396fd3d5b4c..4999b8dca1a2433d41ea508de10b6f314e5ff30e 100644 (file)
@@ -100,6 +100,8 @@ struct lp_fragment_shader
 
    struct lp_fs_variant_list_item variants;
 
+   struct draw_fragment_shader *draw_data;
+
    /* For debugging/profiling purposes */
    unsigned variant_key_size;
    unsigned no;