radeonsi: don't crash if input_usage_mask is 0 for a VS input
[mesa.git] / src / gallium / drivers / radeonsi / si_shader_llvm_vs.c
index 8640150b18c206c5b691d4600a84f84669149532..f0c93ac3264a90f889d9de301c8f44f8c4c5b18a 100644 (file)
@@ -132,8 +132,14 @@ static void load_input_vs(struct si_shader_context *ctx, unsigned input_index, L
       return;
    }
 
-   /* Do multiple loads for special formats. */
    unsigned required_channels = util_last_bit(info->input_usage_mask[input_index]);
+   if (required_channels == 0) {
+      for (unsigned i = 0; i < 4; ++i)
+         out[i] = LLVMGetUndef(ctx->ac.f32);
+      return;
+   }
+
+   /* Do multiple loads for special formats. */
    LLVMValueRef fetches[4];
    unsigned num_fetches;
    unsigned fetch_stride;
@@ -152,7 +158,7 @@ static void load_input_vs(struct si_shader_context *ctx, unsigned input_index, L
    for (unsigned i = 0; i < num_fetches; ++i) {
       LLVMValueRef voffset = LLVMConstInt(ctx->ac.i32, fetch_stride * i, 0);
       fetches[i] = ac_build_buffer_load_format(&ctx->ac, vb_desc, vertex_index, voffset,
-                                               channels_per_fetch, 0, true);
+                                               channels_per_fetch, 0, true, false);
    }
 
    if (num_fetches == 1 && channels_per_fetch > 1) {
@@ -235,7 +241,7 @@ void si_llvm_load_vs_inputs(struct si_shader_context *ctx, struct nir_shader *ni
 {
    uint64_t processed_inputs = 0;
 
-   nir_foreach_variable (variable, &nir->inputs) {
+   nir_foreach_shader_in_variable (variable, nir) {
       unsigned attrib_count = glsl_count_attribute_slots(variable->type, true);
       unsigned input_idx = variable->data.driver_location;
       unsigned loc = variable->data.location;
@@ -664,11 +670,10 @@ void si_llvm_build_vs_exports(struct si_shader_context *ctx,
       if (pos_args[i].out[0])
          shader->info.nr_pos_exports++;
 
-   /* Navi10-14 skip POS0 exports if EXEC=0 and DONE=0, causing a hang.
+   /* GFX10 (Navi1x) skip POS0 exports if EXEC=0 and DONE=0, causing a hang.
     * Setting valid_mask=1 prevents it and has no other effect.
     */
-   if (ctx->screen->info.family == CHIP_NAVI10 || ctx->screen->info.family == CHIP_NAVI12 ||
-       ctx->screen->info.family == CHIP_NAVI14)
+   if (ctx->screen->info.chip_class == GFX10)
       pos_args[0].valid_mask = 1;
 
    pos_idx = 0;
@@ -1014,7 +1019,7 @@ void si_llvm_init_vs_callbacks(struct si_shader_context *ctx, bool ngg_cull_shad
    else if (shader->key.opt.vs_as_prim_discard_cs)
       ctx->abi.emit_outputs = si_llvm_emit_prim_discard_cs_epilogue;
    else if (ngg_cull_shader)
-      ctx->abi.emit_outputs = gfx10_emit_ngg_culling_epilogue_4x_wave32;
+      ctx->abi.emit_outputs = gfx10_emit_ngg_culling_epilogue;
    else if (shader->key.as_ngg)
       ctx->abi.emit_outputs = gfx10_emit_ngg_epilogue;
    else