Mesa (main): aux/cso: split cso_destroy_context into unbind and a destroy functions
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 11 17:42:42 UTC 2021
Module: Mesa
Branch: main
Commit: a73cb106a6771173a138f99ec063808257cd12bf
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a73cb106a6771173a138f99ec063808257cd12bf
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Fri Jun 4 09:18:02 2021 -0400
aux/cso: split cso_destroy_context into unbind and a destroy functions
this makes the unbind function reusable
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11071>
---
src/gallium/auxiliary/cso_cache/cso_context.c | 17 +++++++++++++----
src/gallium/auxiliary/cso_cache/cso_context.h | 1 +
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index b0ebe70d2a5..99aeb6f2d99 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -285,10 +285,7 @@ cso_create_context(struct pipe_context *pipe, unsigned flags)
return ctx;
}
-/**
- * Free the CSO context.
- */
-void cso_destroy_context( struct cso_context *ctx )
+void cso_unbind_context(struct cso_context *ctx)
{
unsigned i;
@@ -355,6 +352,8 @@ void cso_destroy_context( struct cso_context *ctx )
}
ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL );
+ struct pipe_stencil_ref sr = {0};
+ ctx->pipe->set_stencil_ref(ctx->pipe, sr);
ctx->pipe->bind_fs_state( ctx->pipe, NULL );
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, false, NULL);
ctx->pipe->bind_vs_state( ctx->pipe, NULL );
@@ -383,6 +382,16 @@ void cso_destroy_context( struct cso_context *ctx )
pipe_so_target_reference(&ctx->so_targets_saved[i], NULL);
}
+ memset(&ctx->samplers, 0, sizeof(ctx->samplers));
+ memset(&ctx->nr_so_targets, 0, offsetof(struct cso_context, cache) - offsetof(struct cso_context, nr_so_targets));
+}
+
+/**
+ * Free the CSO context.
+ */
+void cso_destroy_context( struct cso_context *ctx )
+{
+ cso_unbind_context(ctx);
cso_cache_delete(&ctx->cache);
if (ctx->vbuf)
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index f92fd5b8b15..32420fe3845 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -48,6 +48,7 @@ struct u_vbuf;
struct cso_context *cso_create_context(struct pipe_context *pipe,
unsigned flags);
+void cso_unbind_context(struct cso_context *ctx);
void cso_destroy_context( struct cso_context *cso );
struct pipe_context *cso_get_pipe_context(struct cso_context *cso);
More information about the mesa-commit
mailing list