Mesa (main): aux/cso: try harder to keep cso state in sync on cso context unbind

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 12 03:19:07 UTC 2021


Module: Mesa
Branch: main
Commit: 513fb5438b4466254af9219f4cd3ede5063394c6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=513fb5438b4466254af9219f4cd3ede5063394c6

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Fri Aug  6 17:23:19 2021 +0200

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

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 <michael.blumenkrantz at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12261>

---

 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);
 }
 
 /**



More information about the mesa-commit mailing list