From 312e04689a9d8d4f9c319e69c61220e10653cfcd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 7 Jan 2020 18:16:59 -0500 Subject: [PATCH] radeonsi: don't allow draw calls with uninitialized VS inputs These always hang, because vertex buffer descriptors are not set up. Reviewed-by: Pierre-Eric Pelloux-Prayer --- src/gallium/drivers/radeonsi/si_shader.h | 1 + src/gallium/drivers/radeonsi/si_state_draw.c | 4 +++- src/gallium/drivers/radeonsi/si_state_shaders.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 30dbe1c6a6e..089b534b4bb 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -339,6 +339,7 @@ struct si_shader_selector { bool vs_needs_prolog; bool force_correct_derivs_after_kill; bool prim_discard_cs_allowed; + unsigned num_vs_inputs; unsigned pa_cl_vs_out_cntl; ubyte clipdist_mask; ubyte culldist_mask; diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index e43120cf9ba..aaf25be66c7 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -1789,7 +1789,9 @@ static void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *i return; } - if (unlikely(!sctx->vs_shader.cso || + struct si_shader_selector *vs = sctx->vs_shader.cso; + if (unlikely(!vs || + sctx->num_vertex_elements < vs->num_vs_inputs || (!sctx->ps_shader.cso && !rs->rasterizer_discard) || (!!sctx->tes_shader.cso != (prim == PIPE_PRIM_PATCHES)))) { assert(0); diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 151085b781a..18015bbec48 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -2714,6 +2714,10 @@ static void *si_create_shader_selector(struct pipe_context *ctx, (sel->so.output[i].stream * 4); } + sel->num_vs_inputs = sel->type == PIPE_SHADER_VERTEX && + !sel->info.properties[TGSI_PROPERTY_VS_BLIT_SGPRS_AMD] ? + sel->info.num_inputs : 0; + /* The prolog is a no-op if there are no inputs. */ sel->vs_needs_prolog = sel->type == PIPE_SHADER_VERTEX && sel->info.num_inputs && -- 2.30.2