[Mesa-dev] [PATCH 2/5] cso: put cso_release_all into cso_destroy_context

Marek Olšák maraeo at gmail.com
Tue Dec 9 03:28:19 PST 2014


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/auxiliary/cso_cache/cso_context.c | 20 +++++---------------
 src/gallium/auxiliary/cso_cache/cso_context.h |  4 ----
 src/gallium/auxiliary/util/u_tests.c          |  1 -
 src/gallium/state_trackers/nine/device9.c     |  1 -
 src/gallium/state_trackers/vega/vg_context.c  |  1 -
 src/gallium/state_trackers/xa/xa_context.c    |  1 -
 src/gallium/tests/trivial/quad-tex.c          |  7 +------
 src/gallium/tests/trivial/tri.c               |  4 +---
 src/mesa/state_tracker/st_context.c           |  8 ++------
 9 files changed, 9 insertions(+), 38 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 3d8860f..5d597ba 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -286,9 +286,9 @@ out:
 }
 
 /**
- * Prior to context destruction, this function unbinds all state objects.
+ * Free the CSO context.
  */
-void cso_release_all( struct cso_context *ctx )
+void cso_destroy_context( struct cso_context *ctx )
 {
    unsigned i, shader;
 
@@ -355,20 +355,10 @@ void cso_release_all( struct cso_context *ctx )
       cso_cache_delete( ctx->cache );
       ctx->cache = NULL;
    }
-}
 
-
-/**
- * Free the CSO context.  NOTE: the state tracker should have previously called
- * cso_release_all().
- */
-void cso_destroy_context( struct cso_context *ctx )
-{
-   if (ctx) {
-      if (ctx->vbuf)
-         u_vbuf_destroy(ctx->vbuf);
-      FREE( ctx );
-   }
+   if (ctx->vbuf)
+      u_vbuf_destroy(ctx->vbuf);
+   FREE( ctx );
 }
 
 
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index f0a08bb..aa56c58 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -42,13 +42,9 @@ struct cso_context;
 struct u_vbuf;
 
 struct cso_context *cso_create_context( struct pipe_context *pipe );
-
-void cso_release_all( struct cso_context *ctx );
-
 void cso_destroy_context( struct cso_context *cso );
 
 
-
 enum pipe_error cso_set_blend( struct cso_context *cso,
                                const struct pipe_blend_state *blend );
 void cso_save_blend(struct cso_context *cso);
diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c
index c0f6327..b42f5e1 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -248,7 +248,6 @@ tgsi_vs_window_space_position(struct pipe_context *ctx)
                                        cb->width0, cb->height0, red);
 
    /* Cleanup. */
-   cso_release_all(cso);
    cso_destroy_context(cso);
    ctx->delete_vs_state(ctx, vs);
    ctx->delete_fs_state(ctx, fs);
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index e9599b8..b0e42eb 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -360,7 +360,6 @@ NineDevice9_dtor( struct NineDevice9 *This )
     /* state stuff */
     if (This->pipe) {
         if (This->cso) {
-            cso_release_all(This->cso);
             cso_destroy_context(This->cso);
         }
         if (This->pipe->destroy) { This->pipe->destroy(This->pipe); }
diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c
index 46c7d96..48a03c5 100644
--- a/src/gallium/state_trackers/vega/vg_context.c
+++ b/src/gallium/state_trackers/vega/vg_context.c
@@ -161,7 +161,6 @@ void vg_destroy_context(struct vg_context *ctx)
    if (ctx->mask.set_fs)
       vg_shader_destroy(ctx, ctx->mask.set_fs);
 
-   cso_release_all(ctx->cso_context);
    cso_destroy_context(ctx->cso_context);
 
    cso_hash_delete(ctx->owned_objects[VG_OBJECT_PAINT]);
diff --git a/src/gallium/state_trackers/xa/xa_context.c b/src/gallium/state_trackers/xa/xa_context.c
index df3043c..fd49c82 100644
--- a/src/gallium/state_trackers/xa/xa_context.c
+++ b/src/gallium/state_trackers/xa/xa_context.c
@@ -82,7 +82,6 @@ xa_context_destroy(struct xa_context *r)
         pipe_surface_reference(&r->srf, NULL);
 
     if (r->cso) {
-	cso_release_all(r->cso);
 	cso_destroy_context(r->cso);
 	r->cso = NULL;
     }
diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c
index 0d38012..abecedb 100644
--- a/src/gallium/tests/trivial/quad-tex.c
+++ b/src/gallium/tests/trivial/quad-tex.c
@@ -275,11 +275,7 @@ static void init_prog(struct program *p)
 
 static void close_prog(struct program *p)
 {
-	/* unset bound textures as well */
-	cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 0, NULL);
-
-	/* unset all state */
-	cso_release_all(p->cso);
+	cso_destroy_context(p->cso);
 
 	p->pipe->delete_vs_state(p->pipe, p->vs);
 	p->pipe->delete_fs_state(p->pipe, p->fs);
@@ -290,7 +286,6 @@ static void close_prog(struct program *p)
 	pipe_resource_reference(&p->tex, NULL);
 	pipe_resource_reference(&p->vbuf, NULL);
 
-	cso_destroy_context(p->cso);
 	p->pipe->destroy(p->pipe);
 	p->screen->destroy(p->screen);
 	pipe_loader_release(&p->dev, 1);
diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
index 13cc801..078beb8 100644
--- a/src/gallium/tests/trivial/tri.c
+++ b/src/gallium/tests/trivial/tri.c
@@ -221,8 +221,7 @@ static void init_prog(struct program *p)
 
 static void close_prog(struct program *p)
 {
-	/* unset all state */
-	cso_release_all(p->cso);
+	cso_destroy_context(p->cso);
 
 	p->pipe->delete_vs_state(p->pipe, p->vs);
 	p->pipe->delete_fs_state(p->pipe, p->fs);
@@ -231,7 +230,6 @@ static void close_prog(struct program *p)
 	pipe_resource_reference(&p->target, NULL);
 	pipe_resource_reference(&p->vbuf, NULL);
 
-	cso_destroy_context(p->cso);
 	p->pipe->destroy(p->pipe);
 	p->screen->destroy(p->screen);
 	pipe_loader_release(&p->dev, 1);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 9da0c77..9fd6cae 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -136,6 +136,8 @@ st_destroy_context_priv(struct st_context *st)
    if (st->constbuf_uploader) {
       u_upload_destroy(st->constbuf_uploader);
    }
+
+   cso_destroy_context(st->cso_context);
    free( st );
 }
 
@@ -348,15 +350,11 @@ destroy_tex_sampler_cb(GLuint id, void *data, void *userData)
 void st_destroy_context( struct st_context *st )
 {
    struct pipe_context *pipe = st->pipe;
-   struct cso_context *cso = st->cso_context;
    struct gl_context *ctx = st->ctx;
    GLuint i;
 
    _mesa_HashWalk(ctx->Shared->TexObjects, destroy_tex_sampler_cb, st);
 
-   /* need to unbind and destroy CSO objects before anything else */
-   cso_release_all(st->cso_context);
-
    st_reference_fragprog(st, &st->fp, NULL);
    st_reference_geomprog(st, &st->gp, NULL);
    st_reference_vertprog(st, &st->vp, NULL);
@@ -386,8 +384,6 @@ void st_destroy_context( struct st_context *st )
    st_destroy_context_priv(st);
    st = NULL;
 
-   cso_destroy_context(cso);
-
    pipe->destroy( pipe );
 
    free(ctx);
-- 
2.1.0



More information about the mesa-dev mailing list