summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2013-05-01 21:09:32 -0400
committerZack Rusin <[email protected]>2013-05-02 02:43:42 -0400
commit396b861ceb4efd50638598cc8092362bd5c14c49 (patch)
tree2c2866a9340e48bc93f213e47f8883e34401aa83 /src/gallium/auxiliary/draw
parent999cd79c9e1a5dc2d3f126670a1ca7ea4e7ee128 (diff)
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 <[email protected]> Reviewed-by: José Fonseca <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/draw')
-rw-r--r--src/gallium/auxiliary/draw/draw_gs.c93
1 files changed, 54 insertions, 39 deletions
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;
+ }
}
}
}