summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-03-24 16:31:15 -0600
committerBrian <[email protected]>2008-03-24 16:35:25 -0600
commitae146e4bc86aeade59d018100e39e160f7553994 (patch)
treeecd4019e22dab520ce99bb15405152be75b261a7
parent7f430293772f201a59bcf62edd1ed4f942f8be29 (diff)
gallium: make a copy of the vertex shader's token array.
This solves problems when the state tracker frees the token array when the draw module still needs it.
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c7
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_llvm.c7
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_sse.c6
3 files changed, 17 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 364693e0b49..4e2fa727070 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -38,6 +38,8 @@
#include "draw_context.h"
#include "draw_vs.h"
+#include "tgsi/util/tgsi_parse.h"
+
static INLINE unsigned
compute_clipmask(const float *clip, /*const*/ float plane[][4], unsigned nr)
@@ -187,6 +189,7 @@ vs_exec_run( struct draw_vertex_shader *shader,
static void
vs_exec_delete( struct draw_vertex_shader *dvs )
{
+ FREE((void*) dvs->state.tokens);
FREE( dvs );
}
@@ -196,11 +199,13 @@ draw_create_vs_exec(struct draw_context *draw,
const struct pipe_shader_state *state)
{
struct draw_vertex_shader *vs = CALLOC_STRUCT( draw_vertex_shader );
+ uint nt = tgsi_num_tokens(state->tokens);
if (vs == NULL)
return NULL;
- vs->state = *state;
+ /* we make a private copy of the tokens */
+ vs->state.tokens = mem_dup(state->tokens, nt * sizeof(state->tokens[0]));
vs->prepare = vs_exec_prepare;
vs->run = vs_exec_run;
vs->delete = vs_exec_delete;
diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c
index 53c260be53a..bd983f2ddfa 100644
--- a/src/gallium/auxiliary/draw/draw_vs_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c
@@ -38,6 +38,8 @@
#include "draw_context.h"
#include "draw_vs.h"
+#include "tgsi/util/tgsi_parse.h"
+
#ifdef MESA_LLVM
#include "gallivm/gallivm.h"
@@ -186,6 +188,7 @@ vs_llvm_delete( struct draw_vertex_shader *base )
/* Do something to free compiled shader:
*/
+ FREE( (void*) shader->base.state.tokens );
FREE( shader );
}
@@ -197,12 +200,14 @@ draw_create_vs_llvm(struct draw_context *draw,
const struct pipe_shader_state *templ)
{
struct draw_llvm_vertex_shader *vs;
+ uint nt = tgsi_num_tokens(templ->tokens);
vs = CALLOC_STRUCT( draw_llvm_vertex_shader );
if (vs == NULL)
return NULL;
- vs->base.state = templ;
+ /* we make a private copy of the tokens */
+ vs->base.state.tokens = mem_dup(templ->tokens, nt * sizeof(templ->tokens[0]));
vs->base.prepare = vs_llvm_prepare;
vs->base.run = vs_llvm_run;
vs->base.delete = vs_llvm_delete;
diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c
index 5ee2adb3447..a4503c143ed 100644
--- a/src/gallium/auxiliary/draw/draw_vs_sse.c
+++ b/src/gallium/auxiliary/draw/draw_vs_sse.c
@@ -43,6 +43,7 @@
#include "rtasm/rtasm_x86sse.h"
#include "tgsi/exec/tgsi_sse2.h"
+#include "tgsi/util/tgsi_parse.h"
typedef void (XSTDCALL *codegen_function) (
@@ -204,6 +205,7 @@ vs_sse_delete( struct draw_vertex_shader *base )
x86_release_func( &shader->sse2_program );
+ FREE( (void*) shader->base.state.tokens );
FREE( shader );
}
@@ -213,6 +215,7 @@ draw_create_vs_sse(struct draw_context *draw,
const struct pipe_shader_state *templ)
{
struct draw_sse_vertex_shader *vs;
+ uint nt = tgsi_num_tokens(templ->tokens);
if (!draw->use_sse)
return NULL;
@@ -221,7 +224,8 @@ draw_create_vs_sse(struct draw_context *draw,
if (vs == NULL)
return NULL;
- vs->base.state = *templ;
+ /* we make a private copy of the tokens */
+ vs->base.state.tokens = mem_dup(templ->tokens, nt * sizeof(templ->tokens[0]));
vs->base.prepare = vs_sse_prepare;
vs->base.run = vs_sse_run;
vs->base.delete = vs_sse_delete;