summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2007-12-16 16:01:25 +1100
committerBen Skeggs <skeggsb@gmail.com>2007-12-16 16:01:25 +1100
commitab4c2e014d4117d6ef43685a57c0ea1b93ba5562 (patch)
treeda12e103c50c0970dcc2f8af84a361cfa628ba7c /src/mesa
parentaf0b4a50e59435a782f59ccec7ad0552c0304016 (diff)
nv40: destroy programs
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/pipe/nv40/nv40_context.h4
-rw-r--r--src/mesa/pipe/nv40/nv40_fragprog.c30
-rw-r--r--src/mesa/pipe/nv40/nv40_state.c12
-rw-r--r--src/mesa/pipe/nv40/nv40_vertprog.c9
4 files changed, 33 insertions, 22 deletions
diff --git a/src/mesa/pipe/nv40/nv40_context.h b/src/mesa/pipe/nv40/nv40_context.h
index bf1534b69b..9a93ed35ac 100644
--- a/src/mesa/pipe/nv40/nv40_context.h
+++ b/src/mesa/pipe/nv40/nv40_context.h
@@ -79,12 +79,16 @@ extern void nv40_vertprog_translate(struct nv40_context *,
struct nv40_vertex_program *);
extern void nv40_vertprog_bind(struct nv40_context *,
struct nv40_vertex_program *);
+extern void nv40_vertprog_destroy(struct nv40_context *,
+ struct nv40_vertex_program *);
/* nv40_fragprog.c */
extern void nv40_fragprog_translate(struct nv40_context *,
struct nv40_fragment_program *);
extern void nv40_fragprog_bind(struct nv40_context *,
struct nv40_fragment_program *);
+extern void nv40_fragprog_destroy(struct nv40_context *,
+ struct nv40_fragment_program *);
/* nv40_state.c and friends */
extern void nv40_emit_hw_state(struct nv40_context *nv40);
diff --git a/src/mesa/pipe/nv40/nv40_fragprog.c b/src/mesa/pipe/nv40/nv40_fragprog.c
index a0d98ae4dc..e801dae8e1 100644
--- a/src/mesa/pipe/nv40/nv40_fragprog.c
+++ b/src/mesa/pipe/nv40/nv40_fragprog.c
@@ -27,22 +27,6 @@
#define abs(s) nv40_sr_abs((s))
#define scale(s,v) nv40_sr_scale((s), NV40_FP_OP_DST_SCALE_##v)
-static uint32_t
-passthrough_fp_data[] = {
- 0x01403e81, 0x1c9dc801, 0x0001c800, 0x3fe1c800
-};
-
-static struct nv40_fragment_program
-passthrough_fp = {
- .pipe = NULL,
- .translated = TRUE,
- .insn = passthrough_fp_data,
- .insn_len = sizeof(passthrough_fp_data) / sizeof(uint32_t),
- .buffer = NULL,
- .uses_kil = 0,
- .num_regs = 2,
-};
-
struct nv40_fpc {
struct nv40_fragment_program *fp;
@@ -705,10 +689,8 @@ nv40_fragprog_bind(struct nv40_context *nv40, struct nv40_fragment_program *fp)
if (!fp->translated) {
nv40_fragprog_translate(nv40, fp);
- if (!fp->translated) {
- NOUVEAU_ERR("invalid, using passthrough shader\n");
- fp = &passthrough_fp;
- }
+ if (!fp->translated)
+ assert(0);
}
if (fp->num_consts) {
@@ -763,3 +745,11 @@ nv40_fragprog_bind(struct nv40_context *nv40, struct nv40_fragment_program *fp)
nv40->fragprog.active = fp;
}
+void
+nv40_fragprog_destroy(struct nv40_context *nv40,
+ struct nv40_fragment_program *fp)
+{
+ if (fp->insn_len)
+ free(fp->insn);
+}
+
diff --git a/src/mesa/pipe/nv40/nv40_state.c b/src/mesa/pipe/nv40/nv40_state.c
index 5aeba684ee..5b070a280d 100644
--- a/src/mesa/pipe/nv40/nv40_state.c
+++ b/src/mesa/pipe/nv40/nv40_state.c
@@ -505,7 +505,11 @@ nv40_vp_state_bind(struct pipe_context *pipe, void *hwcso)
static void
nv40_vp_state_delete(struct pipe_context *pipe, void *hwcso)
{
- free(hwcso);
+ struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_vertex_program *vp = hwcso;
+
+ nv40_vertprog_destroy(nv40, vp);
+ free(vp);
}
static void *
@@ -533,7 +537,11 @@ nv40_fp_state_bind(struct pipe_context *pipe, void *hwcso)
static void
nv40_fp_state_delete(struct pipe_context *pipe, void *hwcso)
{
- free(hwcso);
+ struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_fragment_program *fp = hwcso;
+
+ nv40_fragprog_destroy(nv40, fp);
+ free(fp);
}
static void
diff --git a/src/mesa/pipe/nv40/nv40_vertprog.c b/src/mesa/pipe/nv40/nv40_vertprog.c
index c9e1f251e8..981d70ec92 100644
--- a/src/mesa/pipe/nv40/nv40_vertprog.c
+++ b/src/mesa/pipe/nv40/nv40_vertprog.c
@@ -721,3 +721,12 @@ nv40_vertprog_bind(struct nv40_context *nv40, struct nv40_vertex_program *vp)
nv40->vertprog.active = vp;
}
+void
+nv40_vertprog_destroy(struct nv40_context *nv40, struct nv40_vertex_program *vp)
+{
+ if (vp->nr_consts)
+ free(vp->consts);
+ if (vp->nr_insns)
+ free(vp->insns);
+}
+