Mesa (staging/18.3): nv50,nvc0: Fix gallium nine regression regarding sampler bindings

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Dec 3 18:33:05 UTC 2018


Module: Mesa
Branch: staging/18.3
Commit: a7c4368a66fb203786d13eec6dbe394b1eea6292
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a7c4368a66fb203786d13eec6dbe394b1eea6292

Author: Karol Herbst <kherbst at redhat.com>
Date:   Sat Nov 24 20:00:00 2018 +0100

nv50,nvc0: Fix gallium nine regression regarding sampler bindings

The new approach is that samplers don't get unbound even if they won't be used
in a draw and we should just leave them be as well.

Fixes a regression in multiple windows games using gallium nine and nouveau.

v2: adjust num_samplers to keep track of the highest sampler bound
v3: rework how to set the new value of num_samplers

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106577
Fixes: 4d6fab245eec3880e2a59424a579851f44857ce8
       "cso: don't track the number of sampler states bound"
Signed-off-by: Karol Herbst <kherbst at redhat.com>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
(cherry picked from commit fc0139d28339f58bcbb4946fea7608ecdaff93e7)

---

 src/gallium/drivers/nouveau/nv50/nv50_state.c | 14 ++++++--------
 src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 14 ++++++--------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c
index fb4a259ce1..e1b2e20810 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_state.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c
@@ -600,25 +600,23 @@ static inline void
 nv50_stage_sampler_states_bind(struct nv50_context *nv50, int s,
                                unsigned nr, void **hwcso)
 {
+   unsigned highest_found = 0;
    unsigned i;
 
    assert(nr <= PIPE_MAX_SAMPLERS);
    for (i = 0; i < nr; ++i) {
       struct nv50_tsc_entry *old = nv50->samplers[s][i];
 
+      if (hwcso[i])
+         highest_found = i;
+
       nv50->samplers[s][i] = nv50_tsc_entry(hwcso[i]);
       if (old)
          nv50_screen_tsc_unlock(nv50->screen, old);
    }
    assert(nv50->num_samplers[s] <= PIPE_MAX_SAMPLERS);
-   for (; i < nv50->num_samplers[s]; ++i) {
-      if (nv50->samplers[s][i]) {
-         nv50_screen_tsc_unlock(nv50->screen, nv50->samplers[s][i]);
-         nv50->samplers[s][i] = NULL;
-      }
-   }
-
-   nv50->num_samplers[s] = nr;
+   if (nr >= nv50->num_samplers[s])
+      nv50->num_samplers[s] = highest_found + 1;
 
    nv50->dirty_3d |= NV50_NEW_3D_SAMPLERS;
 }
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
index f2393cb27b..9653de86fe 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
@@ -464,11 +464,15 @@ nvc0_stage_sampler_states_bind(struct nvc0_context *nvc0,
                                unsigned s,
                                unsigned nr, void **hwcso)
 {
+   unsigned highest_found = 0;
    unsigned i;
 
    for (i = 0; i < nr; ++i) {
       struct nv50_tsc_entry *old = nvc0->samplers[s][i];
 
+      if (hwcso[i])
+         highest_found = i;
+
       if (hwcso[i] == old)
          continue;
       nvc0->samplers_dirty[s] |= 1 << i;
@@ -477,14 +481,8 @@ nvc0_stage_sampler_states_bind(struct nvc0_context *nvc0,
       if (old)
          nvc0_screen_tsc_unlock(nvc0->screen, old);
    }
-   for (; i < nvc0->num_samplers[s]; ++i) {
-      if (nvc0->samplers[s][i]) {
-         nvc0_screen_tsc_unlock(nvc0->screen, nvc0->samplers[s][i]);
-         nvc0->samplers[s][i] = NULL;
-      }
-   }
-
-   nvc0->num_samplers[s] = nr;
+   if (nr >= nvc0->num_samplers[s])
+      nvc0->num_samplers[s] = highest_found + 1;
 }
 
 static void




More information about the mesa-commit mailing list