From cda192dc1579d260348c3ed0fccdd097e0544eeb Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 12 Oct 2020 09:45:40 +1000 Subject: [PATCH] llvmpipe: fix sampler/image binding for clover. Clover uses these APIs a bit different, avoid crashes Reviewed-by: Francisco Jerez Part-of: --- .../drivers/llvmpipe/lp_state_sampler.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index 46805e257fe..4f8217b769a 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -82,7 +82,11 @@ llvmpipe_bind_sampler_states(struct pipe_context *pipe, /* set the new samplers */ for (i = 0; i < num; i++) { - llvmpipe->samplers[shader][start + i] = samplers[i]; + void *sampler = NULL; + + if (samplers && samplers[i]) + sampler = samplers[i]; + llvmpipe->samplers[shader][start + i] = sampler; } /* find highest non-null samplers[] entry */ @@ -129,20 +133,24 @@ llvmpipe_set_sampler_views(struct pipe_context *pipe, /* set the new sampler views */ for (i = 0; i < num; i++) { + struct pipe_sampler_view *view = NULL; + + if (views && views[i]) + view = views[i]; /* * Warn if someone tries to set a view created in a different context * (which is why we need the hack above in the first place). * An assert would be better but st/mesa relies on it... */ - if (views[i] && views[i]->context != pipe) { + if (view && view->context != pipe) { debug_printf("Illegal setting of sampler_view %d created in another " "context\n", i); } - if (views[i]) - llvmpipe_flush_resource(pipe, views[i]->texture, 0, true, false, false, "sampler_view"); + if (view) + llvmpipe_flush_resource(pipe, view->texture, 0, true, false, false, "sampler_view"); pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i], - views[i]); + view); } /* find highest non-null sampler_views[] entry */