radeonsi: don't allow draw calls with uninitialized VS inputs
authorMarek Olšák <marek.olsak@amd.com>
Tue, 7 Jan 2020 23:16:59 +0000 (18:16 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 13 Jan 2020 20:57:07 +0000 (15:57 -0500)
These always hang, because vertex buffer descriptors are not set up.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_draw.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index 30dbe1c6a6e0243a39cc70cafd0804811e2d0e65..089b534b4bb574e6487b9ed8daf1e4e183c3c0ad 100644 (file)
@@ -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;
index e43120cf9bac9becc9de4fb6ef07bba45ea8cde3..aaf25be66c77ebbc6b98bbc64c29fe3b95fb5119 100644 (file)
@@ -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);
index 151085b781af10425c04ef966ad1ccc2c3485249..18015bbec485f74bfffdd202d240d112ce64c808 100644 (file)
@@ -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 &&