From 53ef20f08d4340c1bad0b45a2501f4daba7fb479 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 27 Sep 2021 20:24:01 -0400 Subject: [PATCH] panfrost: Handle NULL sampler views Fixes a NULL dereference in Piglit fp-fragment-position. Signed-off-by: Alyssa Rosenzweig Cc: mesa-stable Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index e7e67830fdf..3ef83c3f4e1 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -1376,6 +1376,12 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch, for (int i = 0; i < ctx->sampler_view_count[stage]; ++i) { struct panfrost_sampler_view *view = ctx->sampler_views[stage][i]; + + if (!view) { + memset(&out[i], 0, sizeof(out[i])); + continue; + } + struct pipe_sampler_view *pview = &view->base; struct panfrost_resource *rsrc = pan_resource(pview->texture); @@ -1388,11 +1394,14 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch, return T.gpu; #else - uint64_t trampolines[PIPE_MAX_SHADER_SAMPLER_VIEWS]; + uint64_t trampolines[PIPE_MAX_SHADER_SAMPLER_VIEWS] = { 0 }; for (int i = 0; i < ctx->sampler_view_count[stage]; ++i) { struct panfrost_sampler_view *view = ctx->sampler_views[stage][i]; + if (!view) + continue; + panfrost_update_sampler_view(view, &ctx->base); trampolines[i] = panfrost_get_tex_desc(batch, stage, view);