Mesa (master): nv50,nvc0: zero out program struct on program_destroy

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Wed Jan 11 19:27:37 UTC 2012


Module: Mesa
Branch: master
Commit: f6b994b3058d1c6cd7c28eef522c08df3d83bea7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6b994b3058d1c6cd7c28eef522c08df3d83bea7

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Wed Jan 11 18:50:15 2012 +0100

nv50,nvc0: zero out program struct on program_destroy

Prevent any state from carrying over to a new translation in cases
where we assume that data is still zero from initial calloc (these
would require us to do individual zeroing before translation which
would be more code).

---

 src/gallium/drivers/nv50/nv50_program.c |    8 +++++++-
 src/gallium/drivers/nvc0/nvc0_program.c |    8 ++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index c8b708c..c141a91 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -677,6 +677,9 @@ out:
 void
 nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
 {
+   const struct pipe_shader_state pipe = p->pipe;
+   const ubyte type = p->type;
+
    if (p->res)
       nouveau_resource_free(&p->res);
 
@@ -686,5 +689,8 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
    if (p->fixups)
       FREE(p->fixups);
 
-   p->translated = FALSE;
+   memset(p, 0, sizeof(*p));
+
+   p->pipe = pipe;
+   p->type = type;
 }
diff --git a/src/gallium/drivers/nvc0/nvc0_program.c b/src/gallium/drivers/nvc0/nvc0_program.c
index 42cd21d..813008c 100644
--- a/src/gallium/drivers/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nvc0/nvc0_program.c
@@ -711,6 +711,9 @@ nvc0_program_library_upload(struct nvc0_context *nvc0)
 void
 nvc0_program_destroy(struct nvc0_context *nvc0, struct nvc0_program *prog)
 {
+   const struct pipe_shader_state pipe = prog->pipe;
+   const ubyte type = prog->type;
+
    if (prog->res)
       nouveau_resource_free(&prog->res);
 
@@ -726,7 +729,8 @@ nvc0_program_destroy(struct nvc0_context *nvc0, struct nvc0_program *prog)
       FREE(prog->tfb);
    }
 
-   memset(prog->hdr, 0, sizeof(prog->hdr));
+   memset(prog, 0, sizeof(*prog));
 
-   prog->translated = FALSE;
+   prog->pipe = pipe;
+   prog->type = type;
 }




More information about the mesa-commit mailing list