In vertex shaders also expect the template to be stack allocated
authorZack Rusin <zack@tungstengraphics.com>
Wed, 3 Oct 2007 16:00:52 +0000 (12:00 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Wed, 3 Oct 2007 16:01:18 +0000 (12:01 -0400)
structure so allocate a private copy of it.

src/mesa/pipe/softpipe/sp_state_fs.c

index 390340fa8dcfb9c986cbb0555ab90852603dd97f..88d9bd9716827d5c128d6bc6c2e1fb485ebc556d 100644 (file)
@@ -67,8 +67,11 @@ void * softpipe_create_vs_state(struct pipe_context *pipe,
    struct softpipe_context *softpipe = softpipe_context(pipe);
    struct sp_vertex_shader_state *state =
       malloc(sizeof(struct sp_vertex_shader_state));
+   struct pipe_shader_state *templ_copy =
+      malloc(sizeof(struct pipe_shader_state));
+   memcpy(templ_copy, templ, sizeof(struct pipe_shader_state));
 
-   state->state = templ;
+   state->state = templ_copy;
    state->draw_data = draw_create_vertex_shader(softpipe->draw,
                                                 state->state);
 
@@ -95,6 +98,7 @@ void softpipe_delete_vs_state(struct pipe_context *pipe,
       (struct sp_vertex_shader_state *)vs;
 
    draw_delete_vertex_shader(softpipe->draw, state->draw_data);
+   free(state->state);
    free(state);
 }