summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2013-06-10 23:36:59 -0400
committerZack Rusin <[email protected]>2013-06-13 12:13:11 -0400
commit5507c11f85dda4fbcdc9b36494551c933471a070 (patch)
treeded8a6152801200b5b6d79f02a180f838e7af763 /src/gallium/auxiliary
parentb63eeaf7b7df83a2c52c5ddb701454fd8a49b987 (diff)
gallium/draw: add limits to the clip and cull distances
There are strict limits on those registers. Define the maximums and use them instead of magic numbers. Also allows us to add some extra sanity checks. Suggested by Brian. Signed-off-by: Zack Rusin <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_gs.c10
-rw-r--r--src/gallium/auxiliary/draw/draw_gs.h4
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.c10
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.h4
5 files changed, 16 insertions, 14 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 0dbddb45111..22c0e9be998 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -738,6 +738,7 @@ draw_current_shader_clipvertex_output(const struct draw_context *draw)
uint
draw_current_shader_clipdistance_output(const struct draw_context *draw, int index)
{
+ debug_assert(index < PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
if (draw->gs.geometry_shader)
return draw->gs.geometry_shader->clipdistance_output[index];
return draw->vs.clipdistance_output[index];
@@ -756,6 +757,7 @@ draw_current_shader_num_written_clipdistances(const struct draw_context *draw)
uint
draw_current_shader_culldistance_output(const struct draw_context *draw, int index)
{
+ debug_assert(index < PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
if (draw->gs.geometry_shader)
return draw->gs.geometry_shader->culldistance_output[index];
return draw->vs.vertex_shader->culldistance_output[index];
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index b762dd6cb57..cd63e2bf9e3 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -792,13 +792,13 @@ draw_create_geometry_shader(struct draw_context *draw,
if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_VIEWPORT_INDEX)
gs->viewport_index_output = i;
if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_CLIPDIST) {
- if (gs->info.output_semantic_index[i] == 0)
- gs->clipdistance_output[0] = i;
- else
- gs->clipdistance_output[1] = i;
+ debug_assert(gs->info.output_semantic_index[i] <
+ PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
+ gs->clipdistance_output[gs->info.output_semantic_index[i]] = i;
}
if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_CULLDIST) {
- debug_assert(gs->info.output_semantic_index[i] < Elements(gs->culldistance_output));
+ debug_assert(gs->info.output_semantic_index[i] <
+ PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
gs->culldistance_output[gs->info.output_semantic_index[i]] = i;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_gs.h b/src/gallium/auxiliary/draw/draw_gs.h
index 05d666d752d..e279a809089 100644
--- a/src/gallium/auxiliary/draw/draw_gs.h
+++ b/src/gallium/auxiliary/draw/draw_gs.h
@@ -67,8 +67,8 @@ struct draw_geometry_shader {
struct tgsi_shader_info info;
unsigned position_output;
unsigned viewport_index_output;
- unsigned clipdistance_output[2];
- unsigned culldistance_output[2];
+ unsigned clipdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
+ unsigned culldistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
unsigned max_output_vertices;
unsigned primitive_boundary;
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index a0bebcc7666..bbccbe4de03 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -86,12 +86,12 @@ draw_create_vertex_shader(struct draw_context *draw,
found_clipvertex = TRUE;
vs->clipvertex_output = i;
} else if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_CLIPDIST) {
- if (vs->info.output_semantic_index[i] == 0)
- vs->clipdistance_output[0] = i;
- else
- vs->clipdistance_output[1] = i;
+ debug_assert(vs->info.output_semantic_index[i] <
+ PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
+ vs->clipdistance_output[vs->info.output_semantic_index[i]] = i;
} else if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_CULLDIST) {
- debug_assert(vs->info.output_semantic_index[i] < Elements(vs->culldistance_output));
+ debug_assert(vs->info.output_semantic_index[i] <
+ PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
vs->culldistance_output[vs->info.output_semantic_index[i]] = i;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h
index 7635abaade5..425efa397dc 100644
--- a/src/gallium/auxiliary/draw/draw_vs.h
+++ b/src/gallium/auxiliary/draw/draw_vs.h
@@ -112,8 +112,8 @@ struct draw_vertex_shader {
unsigned position_output;
unsigned edgeflag_output;
unsigned clipvertex_output;
- unsigned clipdistance_output[2];
- unsigned culldistance_output[2];
+ unsigned clipdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
+ unsigned culldistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
/* Extracted from shader:
*/
const float (*immediates)[4];