From a73cb106a6771173a138f99ec063808257cd12bf Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 4 Jun 2021 09:18:02 -0400 Subject: [PATCH] aux/cso: split cso_destroy_context into unbind and a destroy functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit this makes the unbind function reusable Reviewed-by: Marek Olšák Reviewed-by: Dave Airlie Part-of: --- 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 b0ebe70..99aeb6f 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 f92fd5b..32420fe 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); -- 2.7.4