[Mesa-dev] [PATCH 2/2] nv50, nvc0: Fix gallium nine regression regarding sampler bindings

Ilia Mirkin imirkin at alum.mit.edu
Sun Nov 25 01:11:02 UTC 2018


Using this approach, num_samplers will never go down. Also, this
applies to more than just samplers -- textures, everything else.
On Sat, Nov 24, 2018 at 6:04 PM Karol Herbst <kherbst at redhat.com> wrote:
>
> 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.
>
> Fixes: 4d6fab245eec3880e2a59424a579851f44857ce8
>        "cso: don't track the number of sampler states bound"
> Signed-off-by: Karol Herbst <kherbst at redhat.com>
> ---
>  src/gallium/drivers/nouveau/nv50/nv50_state.c | 13 ++-----------
>  src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 17 +++++------------
>  2 files changed, 7 insertions(+), 23 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c
> index fb4a259ce16..59437b22c9c 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_state.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c
> @@ -600,25 +600,16 @@ static inline void
>  nv50_stage_sampler_states_bind(struct nv50_context *nv50, int s,
>                                 unsigned nr, void **hwcso)
>  {
> -   unsigned i;
> -
>     assert(nr <= PIPE_MAX_SAMPLERS);
> -   for (i = 0; i < nr; ++i) {
> +   for (unsigned i = 0; i < nr; ++i) {
>        struct nv50_tsc_entry *old = nv50->samplers[s][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;
> +   nv50->num_samplers[s] = MAX2(nv50->num_samplers[s], nr);
>
>     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 f2393cb27b5..12765af8585 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
> @@ -449,10 +449,12 @@ nvc0_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
>  {
>     unsigned s, i;
>
> -   for (s = 0; s < 6; ++s)
> +   for (s = 0; s < 6; ++s) {
>        for (i = 0; i < nvc0_context(pipe)->num_samplers[s]; ++i)
>           if (nvc0_context(pipe)->samplers[s][i] == hwcso)
>              nvc0_context(pipe)->samplers[s][i] = NULL;
> +      nvc0_context(pipe)->num_samplers[s] = 0;
> +   }
>
>     nvc0_screen_tsc_free(nvc0_context(pipe)->screen, nv50_tsc_entry(hwcso));
>
> @@ -464,9 +466,7 @@ nvc0_stage_sampler_states_bind(struct nvc0_context *nvc0,
>                                 unsigned s,
>                                 unsigned nr, void **hwcso)
>  {
> -   unsigned i;
> -
> -   for (i = 0; i < nr; ++i) {
> +   for (unsigned i = 0; i < nr; ++i) {
>        struct nv50_tsc_entry *old = nvc0->samplers[s][i];
>
>        if (hwcso[i] == old)
> @@ -477,14 +477,7 @@ 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;
> +   nvc0->num_samplers[s] = MAX2(nvc0->num_samplers[s], nr);
>  }
>
>  static void
> --
> 2.19.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list