From: Zack Rusin Date: Thu, 2 May 2013 01:09:32 +0000 (-0400) Subject: draw/gs: don't crash when vs/gs signatures don't match X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=396b861ceb4efd50638598cc8092362bd5c14c49;p=mesa.git draw/gs: don't crash when vs/gs signatures don't match instead of crashing just fill zeros at the input slots that don't match, that's the mandated behavior and it avoids debug asserts. Signed-off-by: Zack Rusin Reviewed-by: José Fonseca Reviewed-by: Roland Scheidegger --- diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index fbb01b457d1..fcd6e2ddfdb 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -57,7 +57,6 @@ draw_gs_get_input_index(int semantic, int index, input_semantic_indices[i] == index) return i; } - debug_assert(0); return -1; } @@ -154,29 +153,37 @@ static void tgsi_fetch_gs_input(struct draw_geometry_shader *shader, (float)shader->in_prim_idx; } else { vs_slot = draw_gs_get_input_index( - shader->info.input_semantic_name[slot], - shader->info.input_semantic_index[slot], - shader->input_info); + shader->info.input_semantic_name[slot], + shader->info.input_semantic_index[slot], + shader->input_info); + if (vs_slot < 0) { + debug_printf("VS/GS signature mismatch!\n"); + machine->Inputs[idx].xyzw[0].f[prim_idx] = 0; + machine->Inputs[idx].xyzw[1].f[prim_idx] = 0; + machine->Inputs[idx].xyzw[2].f[prim_idx] = 0; + machine->Inputs[idx].xyzw[3].f[prim_idx] = 0; + } else { #if DEBUG_INPUTS - debug_printf("\tSlot = %d, vs_slot = %d, idx = %d:\n", - slot, vs_slot, idx); - assert(!util_is_inf_or_nan(input[vs_slot][0])); - assert(!util_is_inf_or_nan(input[vs_slot][1])); - assert(!util_is_inf_or_nan(input[vs_slot][2])); - assert(!util_is_inf_or_nan(input[vs_slot][3])); + debug_printf("\tSlot = %d, vs_slot = %d, idx = %d:\n", + slot, vs_slot, idx); + assert(!util_is_inf_or_nan(input[vs_slot][0])); + assert(!util_is_inf_or_nan(input[vs_slot][1])); + assert(!util_is_inf_or_nan(input[vs_slot][2])); + assert(!util_is_inf_or_nan(input[vs_slot][3])); #endif - machine->Inputs[idx].xyzw[0].f[prim_idx] = input[vs_slot][0]; - machine->Inputs[idx].xyzw[1].f[prim_idx] = input[vs_slot][1]; - machine->Inputs[idx].xyzw[2].f[prim_idx] = input[vs_slot][2]; - machine->Inputs[idx].xyzw[3].f[prim_idx] = input[vs_slot][3]; + machine->Inputs[idx].xyzw[0].f[prim_idx] = input[vs_slot][0]; + machine->Inputs[idx].xyzw[1].f[prim_idx] = input[vs_slot][1]; + machine->Inputs[idx].xyzw[2].f[prim_idx] = input[vs_slot][2]; + machine->Inputs[idx].xyzw[3].f[prim_idx] = input[vs_slot][3]; #if DEBUG_INPUTS - debug_printf("\t\t%f %f %f %f\n", - machine->Inputs[idx].xyzw[0].f[prim_idx], - machine->Inputs[idx].xyzw[1].f[prim_idx], - machine->Inputs[idx].xyzw[2].f[prim_idx], - machine->Inputs[idx].xyzw[3].f[prim_idx]); + debug_printf("\t\t%f %f %f %f\n", + machine->Inputs[idx].xyzw[0].f[prim_idx], + machine->Inputs[idx].xyzw[1].f[prim_idx], + machine->Inputs[idx].xyzw[2].f[prim_idx], + machine->Inputs[idx].xyzw[3].f[prim_idx]); #endif - ++vs_slot; + ++vs_slot; + } } } } @@ -241,29 +248,37 @@ llvm_fetch_gs_input(struct draw_geometry_shader *shader, /* skip. we handle system values through gallivm */ } else { vs_slot = draw_gs_get_input_index( - shader->info.input_semantic_name[slot], - shader->info.input_semantic_index[slot], - shader->input_info); + shader->info.input_semantic_name[slot], + shader->info.input_semantic_index[slot], + shader->input_info); + if (vs_slot < 0) { + debug_printf("VS/GS signature mismatch!\n"); + (*input_data)[i][slot][0][prim_idx] = 0; + (*input_data)[i][slot][1][prim_idx] = 0; + (*input_data)[i][slot][2][prim_idx] = 0; + (*input_data)[i][slot][3][prim_idx] = 0; + } else { #if DEBUG_INPUTS - debug_printf("\tSlot = %d, vs_slot = %d, i = %d:\n", - slot, vs_slot, i); - assert(!util_is_inf_or_nan(input[vs_slot][0])); - assert(!util_is_inf_or_nan(input[vs_slot][1])); - assert(!util_is_inf_or_nan(input[vs_slot][2])); - assert(!util_is_inf_or_nan(input[vs_slot][3])); + debug_printf("\tSlot = %d, vs_slot = %d, i = %d:\n", + slot, vs_slot, i); + assert(!util_is_inf_or_nan(input[vs_slot][0])); + assert(!util_is_inf_or_nan(input[vs_slot][1])); + assert(!util_is_inf_or_nan(input[vs_slot][2])); + assert(!util_is_inf_or_nan(input[vs_slot][3])); #endif - (*input_data)[i][slot][0][prim_idx] = input[vs_slot][0]; - (*input_data)[i][slot][1][prim_idx] = input[vs_slot][1]; - (*input_data)[i][slot][2][prim_idx] = input[vs_slot][2]; - (*input_data)[i][slot][3][prim_idx] = input[vs_slot][3]; + (*input_data)[i][slot][0][prim_idx] = input[vs_slot][0]; + (*input_data)[i][slot][1][prim_idx] = input[vs_slot][1]; + (*input_data)[i][slot][2][prim_idx] = input[vs_slot][2]; + (*input_data)[i][slot][3][prim_idx] = input[vs_slot][3]; #if DEBUG_INPUTS - debug_printf("\t\t%f %f %f %f\n", - (*input_data)[i][slot][0][prim_idx], - (*input_data)[i][slot][1][prim_idx], - (*input_data)[i][slot][2][prim_idx], - (*input_data)[i][slot][3][prim_idx]); + debug_printf("\t\t%f %f %f %f\n", + (*input_data)[i][slot][0][prim_idx], + (*input_data)[i][slot][1][prim_idx], + (*input_data)[i][slot][2][prim_idx], + (*input_data)[i][slot][3][prim_idx]); #endif - ++vs_slot; + ++vs_slot; + } } } }