Mesa (master): etnaviv: handle NULL views in set_sampler_views

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 25 20:48:24 UTC 2021


Module: Mesa
Branch: master
Commit: 81ab9fe2d0c2c2d9961107c88209f2fff1f136c4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=81ab9fe2d0c2c2d9961107c88209f2fff1f136c4

Author: Christian Gmeiner <christian.gmeiner at gmail.com>
Date:   Sat Jan 23 16:15:38 2021 +0100

etnaviv: handle NULL views in set_sampler_views

Passing NULL for the views parameter should be the same as passing an
array of NULL, according to the documentation. So let's respect that
detail.

This fixes a crash when using GALLIUM_HUD. The wrong handling of views
parameter was causing problems starting with
2813688f8db ("gallium/hud: don't use cso_context to restore VBs, constbuf 0 and sampler views").

Cc: <mesa-stable at lists.freedesktop.org>
Fixes: c9e8b49b885 ("etnaviv: gallium driver for Vivante GPUs")
Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Reviewed-by: Lucas Stach <l.stach at pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8670>

---

 src/gallium/drivers/etnaviv/etnaviv_texture.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c b/src/gallium/drivers/etnaviv/etnaviv_texture.c
index 9202bda9168..ac3f85269dd 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_texture.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c
@@ -247,8 +247,10 @@ set_sampler_views(struct etna_context *ctx, unsigned start, unsigned end,
    uint32_t prev_active_sampler_views = ctx->active_sampler_views;
 
    for (i = start, j = 0; j < nr; i++, j++, mask <<= 1) {
-      pipe_sampler_view_reference(&ctx->sampler_view[i], views[j]);
-      if (views[j]) {
+      struct pipe_sampler_view *view = views ? views[i] : NULL;
+
+      pipe_sampler_view_reference(&ctx->sampler_view[i], view);
+      if (view) {
          ctx->active_sampler_views |= mask;
          ctx->dirty_sampler_views |= mask;
       } else



More information about the mesa-commit mailing list