aux/cso: try harder to keep cso state in sync on cso context unbind

Before a73cb106a6, 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: a73cb106a6 ("aux/cso: split cso_destroy_context into unbind and a destroy functions")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12261>
This commit is contained in:
Roland Scheidegger
2021-08-06 17:23:19 +02:00
committed by Marge Bot
parent 4b8f4bae01
commit 513fb5438b
@@ -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);
}
/**