summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYounes Manton <younes.m@gmail.com>2008-07-23 23:35:23 -0400
committerYounes Manton <younes.m@gmail.com>2008-07-23 23:46:45 -0400
commita8da04cb861b8f9caf3acd33f52f64621f0c15e2 (patch)
treebacbfd492330e23f9d670e4319c3f8c07f004153
parentb4d198e47704f3b79c5a61877846172ae9d4b4c0 (diff)
nv all: Copy shader tokens on create, free on delete.
Must copy token stream on shader create, client is allowed to free their copy after creating the state object.
-rw-r--r--src/gallium/drivers/nv04/nv04_state.c4
-rw-r--r--src/gallium/drivers/nv04/nv04_state.h2
-rw-r--r--src/gallium/drivers/nv10/nv10_state.c4
-rw-r--r--src/gallium/drivers/nv10/nv10_state.h2
-rw-r--r--src/gallium/drivers/nv30/nv30_state.c8
-rw-r--r--src/gallium/drivers/nv40/nv40_state.c8
-rw-r--r--src/gallium/drivers/nv50/nv50_state.c18
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_context.c20
8 files changed, 42 insertions, 24 deletions
diff --git a/src/gallium/drivers/nv04/nv04_state.c b/src/gallium/drivers/nv04/nv04_state.c
index d618465a20..7e71dee7b5 100644
--- a/src/gallium/drivers/nv04/nv04_state.c
+++ b/src/gallium/drivers/nv04/nv04_state.c
@@ -4,6 +4,7 @@
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
+#include "tgsi/util/tgsi_parse.h"
#include "nv04_context.h"
#include "nv04_state.h"
@@ -291,7 +292,7 @@ nv04_fp_state_create(struct pipe_context *pipe,
struct nv04_fragment_program *fp;
fp = CALLOC(1, sizeof(struct nv04_fragment_program));
- fp->pipe = cso;
+ fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
return (void *)fp;
}
@@ -313,6 +314,7 @@ nv04_fp_state_delete(struct pipe_context *pipe, void *hwcso)
struct nv04_fragment_program *fp = hwcso;
nv04_fragprog_destroy(nv04, fp);
+ free((void*)fp->pipe.tokens);
free(fp);
}
diff --git a/src/gallium/drivers/nv04/nv04_state.h b/src/gallium/drivers/nv04/nv04_state.h
index 7487819c3a..39f7cd17b3 100644
--- a/src/gallium/drivers/nv04/nv04_state.h
+++ b/src/gallium/drivers/nv04/nv04_state.h
@@ -47,7 +47,7 @@ struct nv04_fragment_program_data {
};
struct nv04_fragment_program {
- const struct pipe_shader_state *pipe;
+ struct pipe_shader_state pipe;
struct tgsi_shader_info info;
boolean translated;
diff --git a/src/gallium/drivers/nv10/nv10_state.c b/src/gallium/drivers/nv10/nv10_state.c
index 9b8b7801cd..43b9c32f12 100644
--- a/src/gallium/drivers/nv10/nv10_state.c
+++ b/src/gallium/drivers/nv10/nv10_state.c
@@ -4,6 +4,7 @@
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
+#include "tgsi/util/tgsi_parse.h"
#include "nv10_context.h"
#include "nv10_state.h"
@@ -407,7 +408,7 @@ nv10_fp_state_create(struct pipe_context *pipe,
struct nv10_fragment_program *fp;
fp = CALLOC(1, sizeof(struct nv10_fragment_program));
- fp->pipe = cso;
+ fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
tgsi_scan_shader(cso->tokens, &fp->info);
@@ -431,6 +432,7 @@ nv10_fp_state_delete(struct pipe_context *pipe, void *hwcso)
struct nv10_fragment_program *fp = hwcso;
nv10_fragprog_destroy(nv10, fp);
+ FREE((void*)fp->pipe.tokens);
FREE(fp);
}
diff --git a/src/gallium/drivers/nv10/nv10_state.h b/src/gallium/drivers/nv10/nv10_state.h
index 3ca501d135..f1f9a12110 100644
--- a/src/gallium/drivers/nv10/nv10_state.h
+++ b/src/gallium/drivers/nv10/nv10_state.h
@@ -79,7 +79,7 @@ struct nv10_fragment_program_data {
};
struct nv10_fragment_program {
- const struct pipe_shader_state *pipe;
+ struct pipe_shader_state pipe;
struct tgsi_shader_info info;
boolean translated;
diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
index 4d6303ebc2..ba02413de5 100644
--- a/src/gallium/drivers/nv30/nv30_state.c
+++ b/src/gallium/drivers/nv30/nv30_state.c
@@ -3,6 +3,8 @@
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "tgsi/util/tgsi_parse.h"
+
#include "nv30_context.h"
#include "nv30_state.h"
@@ -503,7 +505,7 @@ nv30_vp_state_create(struct pipe_context *pipe,
struct nv30_vertex_program *vp;
vp = CALLOC(1, sizeof(struct nv30_vertex_program));
- vp->pipe = *cso;
+ vp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
/*vp->draw = draw_create_vertex_shader(nv30->draw, &vp->pipe);*/
return (void *)vp;
@@ -527,6 +529,7 @@ nv30_vp_state_delete(struct pipe_context *pipe, void *hwcso)
/*draw_delete_vertex_shader(nv30->draw, vp->draw);*/
nv30_vertprog_destroy(nv30, vp);
+ FREE((void*)vp->pipe.tokens);
FREE(vp);
}
@@ -537,7 +540,7 @@ nv30_fp_state_create(struct pipe_context *pipe,
struct nv30_fragment_program *fp;
fp = CALLOC(1, sizeof(struct nv30_fragment_program));
- fp->pipe = *cso;
+ fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
tgsi_scan_shader(fp->pipe.tokens, &fp->info);
@@ -560,6 +563,7 @@ nv30_fp_state_delete(struct pipe_context *pipe, void *hwcso)
struct nv30_fragment_program *fp = hwcso;
nv30_fragprog_destroy(nv30, fp);
+ FREE((void*)fp->pipe.tokens);
FREE(fp);
}
diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
index afcf336a65..5d2c3ab881 100644
--- a/src/gallium/drivers/nv40/nv40_state.c
+++ b/src/gallium/drivers/nv40/nv40_state.c
@@ -5,6 +5,8 @@
#include "draw/draw_context.h"
+#include "tgsi/util/tgsi_parse.h"
+
#include "nv40_context.h"
#include "nv40_state.h"
@@ -516,7 +518,7 @@ nv40_vp_state_create(struct pipe_context *pipe,
struct nv40_vertex_program *vp;
vp = CALLOC(1, sizeof(struct nv40_vertex_program));
- vp->pipe = *cso;
+ vp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
vp->draw = draw_create_vertex_shader(nv40->draw, &vp->pipe);
return (void *)vp;
@@ -540,6 +542,7 @@ nv40_vp_state_delete(struct pipe_context *pipe, void *hwcso)
draw_delete_vertex_shader(nv40->draw, vp->draw);
nv40_vertprog_destroy(nv40, vp);
+ FREE((void*)vp->pipe.tokens);
FREE(vp);
}
@@ -550,7 +553,7 @@ nv40_fp_state_create(struct pipe_context *pipe,
struct nv40_fragment_program *fp;
fp = CALLOC(1, sizeof(struct nv40_fragment_program));
- fp->pipe = *cso;
+ fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
tgsi_scan_shader(fp->pipe.tokens, &fp->info);
@@ -573,6 +576,7 @@ nv40_fp_state_delete(struct pipe_context *pipe, void *hwcso)
struct nv40_fragment_program *fp = hwcso;
nv40_fragprog_destroy(nv40, fp);
+ FREE((void*)fp->pipe.tokens);
FREE(fp);
}
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index c552a0b0aa..731409bed4 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -25,6 +25,8 @@
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "tgsi/util/tgsi_parse.h"
+
#include "nv50_context.h"
#include "nv50_texture.h"
@@ -438,7 +440,7 @@ nv50_vp_state_create(struct pipe_context *pipe,
{
struct nv50_program *p = CALLOC_STRUCT(nv50_program);
- p->pipe = *cso;
+ p->pipe.tokens = tgsi_dup_tokens(cso->tokens);
p->type = PIPE_SHADER_VERTEX;
tgsi_scan_shader(p->pipe.tokens, &p->info);
return (void *)p;
@@ -457,9 +459,11 @@ static void
nv50_vp_state_delete(struct pipe_context *pipe, void *hwcso)
{
struct nv50_context *nv50 = nv50_context(pipe);
+ struct nv50_program *p = hwcso;
- nv50_program_destroy(nv50, hwcso);
- FREE(hwcso);
+ nv50_program_destroy(nv50, p);
+ FREE((void*)p->pipe.tokens);
+ FREE(p);
}
static void *
@@ -468,7 +472,7 @@ nv50_fp_state_create(struct pipe_context *pipe,
{
struct nv50_program *p = CALLOC_STRUCT(nv50_program);
- p->pipe = *cso;
+ p->pipe.tokens = tgsi_dup_tokens(cso->tokens);
p->type = PIPE_SHADER_FRAGMENT;
tgsi_scan_shader(p->pipe.tokens, &p->info);
return (void *)p;
@@ -487,9 +491,11 @@ static void
nv50_fp_state_delete(struct pipe_context *pipe, void *hwcso)
{
struct nv50_context *nv50 = nv50_context(pipe);
+ struct nv50_program *p = hwcso;
- nv50_program_destroy(nv50, hwcso);
- FREE(hwcso);
+ nv50_program_destroy(nv50, p);
+ FREE((void*)p->pipe.tokens);
+ FREE(p);
}
static void
diff --git a/src/gallium/state_trackers/g3dvl/vl_context.c b/src/gallium/state_trackers/g3dvl/vl_context.c
index 850a769376..638900b3f4 100644
--- a/src/gallium/state_trackers/g3dvl/vl_context.c
+++ b/src/gallium/state_trackers/g3dvl/vl_context.c
@@ -358,7 +358,7 @@ static int vlCreateVertexShaderIMC(struct VL_CONTEXT *context)
vs.tokens = tokens;
context->states.mc.i_vs = pipe->create_vs_state(pipe, &vs);
- //free(tokens);
+ free(tokens);
return 0;
}
@@ -436,7 +436,7 @@ static int vlCreateFragmentShaderIMC(struct VL_CONTEXT *context)
fs.tokens = tokens;
context->states.mc.i_fs = pipe->create_fs_state(pipe, &fs);
- //free(tokens);
+ free(tokens);
return 0;
}
@@ -535,7 +535,7 @@ static int vlCreateVertexShaderFramePMC(struct VL_CONTEXT *context)
vs.tokens = tokens;
context->states.mc.p_vs[0] = pipe->create_vs_state(pipe, &vs);
- //free(tokens);
+ free(tokens);
return 0;
}
@@ -655,7 +655,7 @@ static int vlCreateVertexShaderFieldPMC(struct VL_CONTEXT *context)
vs.tokens = tokens;
context->states.mc.p_vs[1] = pipe->create_vs_state(pipe, &vs);
- //free(tokens);
+ free(tokens);
return 0;
}
@@ -777,7 +777,7 @@ static int vlCreateFragmentShaderFramePMC(struct VL_CONTEXT *context)
fs.tokens = tokens;
context->states.mc.p_fs[0] = pipe->create_fs_state(pipe, &fs);
- //free(tokens);
+ free(tokens);
return 0;
}
@@ -948,7 +948,7 @@ static int vlCreateFragmentShaderFieldPMC(struct VL_CONTEXT *context)
fs.tokens = tokens;
context->states.mc.p_fs[1] = pipe->create_fs_state(pipe, &fs);
- //free(tokens);
+ free(tokens);
return 0;
}
@@ -1054,7 +1054,7 @@ static int vlCreateVertexShaderFrameBMC(struct VL_CONTEXT *context)
vs.tokens = tokens;
context->states.mc.b_vs[0] = pipe->create_vs_state(pipe, &vs);
- //free(tokens);
+ free(tokens);
return 0;
}
@@ -1176,7 +1176,7 @@ static int vlCreateVertexShaderFieldBMC(struct VL_CONTEXT *context)
vs.tokens = tokens;
context->states.mc.b_vs[1] = pipe->create_vs_state(pipe, &vs);
- //free(tokens);
+ free(tokens);
return 0;
}
@@ -1315,7 +1315,7 @@ static int vlCreateFragmentShaderFrameBMC(struct VL_CONTEXT *context)
fs.tokens = tokens;
context->states.mc.b_fs[0] = pipe->create_fs_state(pipe, &fs);
- //free(tokens);
+ free(tokens);
return 0;
}
@@ -1515,7 +1515,7 @@ static int vlCreateFragmentShaderFieldBMC(struct VL_CONTEXT *context)
fs.tokens = tokens;
context->states.mc.b_fs[1] = pipe->create_fs_state(pipe, &fs);
- //free(tokens);
+ free(tokens);
return 0;
}