From 513fb5438b4466254af9219f4cd3ede5063394c6 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 6 Aug 2021 17:23:19 +0200 Subject: [PATCH] aux/cso: try harder to keep cso state in sync on cso context unbind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before a73cb106a677, cso contexts were never reused, but now that they are we need to be extra careful that the state in the cso context and in the pipe context matches even after an unbind, since when the cso context is reused the state might otherwise get out of sync (as there is no concept of "initial state", basically cso always relied on the default values being the same both in cso and the drivers). This fixes some errors we've seen internally with lavapipe. Fixes: a73cb106a677 ("aux/cso: split cso_destroy_context into unbind and a destroy functions") Reviewed-By: Mike Blumenkrantz Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/cso_cache/cso_context.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 0bb5c1a50ee..42b64b34c1d 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -386,6 +386,14 @@ void cso_unbind_context(struct cso_context *ctx) 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)); + ctx->sample_mask = ~0; + /* + * If the cso context is reused (with the same pipe context), + * need to really make sure the context state doesn't get out of sync. + */ + ctx->pipe->set_sample_mask(ctx->pipe, ctx->sample_mask); + if (ctx->pipe->set_min_samples) + ctx->pipe->set_min_samples(ctx->pipe, ctx->min_samples); } /**