Mesa (staging/21.2): 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 17:09:47 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: 996946b3fee607e24460da76fea85c556c106877
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=996946b3fee607e24460da76fea85c556c106877

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>
(cherry picked from commit 513fb5438b4466254af9219f4cd3ede5063394c6)

---

 .pick_status.json                             | 2 +-
 src/gallium/auxiliary/cso_cache/cso_context.c | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index e1e2504cb3e..6c1aa5f315a 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -130,7 +130,7 @@
         "description": "aux/cso: try harder to keep cso state in sync on cso context unbind",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "a73cb106a6771173a138f99ec063808257cd12bf"
     },
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index d49b5161c04..ba316a93a37 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -385,6 +385,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