[Mesa-dev] [PATCH 2/2] draw/gs: don't crash when vs/gs signatures don't match
Jose Fonseca
jfonseca at vmware.com
Thu May 2 04:22:18 PDT 2013
----- Original Message -----
> 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 <zackr at vmware.com>
> ---
> src/gallium/auxiliary/draw/draw_gs.c | 93
> ++++++++++++++++++++--------------
> 1 file changed, 54 insertions(+), 39 deletions(-)
>
> diff --git a/src/gallium/auxiliary/draw/draw_gs.c
> b/src/gallium/auxiliary/draw/draw_gs.c
> index fbb01b4..fcd6e2d 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;
> + }
> }
> }
> }
> --
> 1.7.10.4
>
Series is
Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
More information about the mesa-dev
mailing list