draw: Make copy of the TGSI tokens.
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 23 Sep 2011 15:32:31 +0000 (16:32 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Sun, 25 Sep 2011 10:04:29 +0000 (11:04 +0100)
There is no guarantee that the tokens TGSI will persist beyond the
create_fs_state. The pipe driver (and therefore the draw module) is
responsible for making copies of the TGSI tokens when it needs them.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_aapoint.c

index 458f85def2cb8674d18f487c084cd07350e8eab1..7ecd2aa3f45409471127643b3924c651a9a7d2cd 100644 (file)
@@ -848,7 +848,7 @@ aaline_create_fs_state(struct pipe_context *pipe,
    if (aafs == NULL)
       return NULL;
 
-   aafs->state = *fs;
+   aafs->state.tokens = tgsi_dup_tokens(fs->tokens);
 
    /* pass-through */
    aafs->driver_fs = aaline->driver_create_fs_state(pipe, fs);
@@ -882,6 +882,8 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
    if (aafs->aaline_fs)
       aaline->driver_delete_fs_state(pipe, aafs->aaline_fs);
 
+   FREE((void*)aafs->state.tokens);
+
    FREE(aafs);
 }
 
index 9265c379de88622be55dd30aba16a4607b998c2c..698ab13cddb02ef4f1d4ab34331cf02ec06a6cc2 100644 (file)
@@ -834,7 +834,7 @@ aapoint_create_fs_state(struct pipe_context *pipe,
    if (aafs == NULL) 
       return NULL;
 
-   aafs->state = *fs;
+   aafs->state.tokens = tgsi_dup_tokens(fs->tokens);
 
    /* pass-through */
    aafs->driver_fs = aapoint->driver_create_fs_state(pipe, fs);
@@ -868,6 +868,8 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs)
    if (aafs->aapoint_fs)
       aapoint->driver_delete_fs_state(pipe, aafs->aapoint_fs);
 
+   FREE((void*)aafs->state.tokens);
+
    FREE(aafs);
 }