Module: Mesa Branch: main Commit: 2f0cd4029ce3fb631b994d4fadeba7a864b20f19 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f0cd4029ce3fb631b994d4fadeba7a864b20f19
Author: Marek Olšák <[email protected]> Date: Sat Aug 6 17:30:02 2022 -0400 cso: don't destroy CSOs that are saved I think this can't happen in practice, but better safe than sorry. Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Reviewed-By: Mike Blumenkrantz <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19129> --- src/gallium/auxiliary/cso_cache/cso_context.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 4c0502aa8fb..1f952724d09 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -137,19 +137,23 @@ delete_cso(struct cso_context *ctx, { switch (type) { case CSO_BLEND: - if (ctx->blend == ((struct cso_blend*)state)->data) + if (ctx->blend == ((struct cso_blend*)state)->data || + ctx->blend_saved == ((struct cso_blend*)state)->data) return false; break; case CSO_DEPTH_STENCIL_ALPHA: - if (ctx->depth_stencil == ((struct cso_depth_stencil_alpha*)state)->data) + if (ctx->depth_stencil == ((struct cso_depth_stencil_alpha*)state)->data || + ctx->depth_stencil_saved == ((struct cso_depth_stencil_alpha*)state)->data) return false; break; case CSO_RASTERIZER: - if (ctx->rasterizer == ((struct cso_rasterizer*)state)->data) + if (ctx->rasterizer == ((struct cso_rasterizer*)state)->data || + ctx->rasterizer_saved == ((struct cso_rasterizer*)state)->data) return false; break; case CSO_VELEMENTS: - if (ctx->velements == ((struct cso_velements*)state)->data) + if (ctx->velements == ((struct cso_velements*)state)->data || + ctx->velements_saved == ((struct cso_velements*)state)->data) return false; break; case CSO_SAMPLER: @@ -184,7 +188,7 @@ sanitize_hash(struct cso_hash *hash, enum cso_cache_type type, return; if (type == CSO_SAMPLER) { - samplers_to_restore = MALLOC(PIPE_SHADER_TYPES * PIPE_MAX_SAMPLERS * + samplers_to_restore = MALLOC((PIPE_SHADER_TYPES + 2) * PIPE_MAX_SAMPLERS * sizeof(*samplers_to_restore)); /* Temporarily remove currently bound sampler states from the hash @@ -198,6 +202,18 @@ sanitize_hash(struct cso_hash *hash, enum cso_cache_type type, samplers_to_restore[to_restore++] = sampler; } } + for (int j = 0; j < PIPE_MAX_SAMPLERS; j++) { + struct cso_sampler *sampler = ctx->fragment_samplers_saved.cso_samplers[j]; + + if (sampler && cso_hash_take(hash, sampler->hash_key)) + samplers_to_restore[to_restore++] = sampler; + } + for (int j = 0; j < PIPE_MAX_SAMPLERS; j++) { + struct cso_sampler *sampler = ctx->compute_samplers_saved.cso_samplers[j]; + + if (sampler && cso_hash_take(hash, sampler->hash_key)) + samplers_to_restore[to_restore++] = sampler; + } } struct cso_hash_iter iter = cso_hash_first_node(hash);
