summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw/draw_context.c
diff options
context:
space:
mode:
authorZack Rusin <zackr@vmware.com>2013-05-13 23:07:14 -0400
committerZack Rusin <zackr@vmware.com>2013-05-14 03:10:56 -0400
commit5104ed3dbf18d47736fc67a8e3e317ea18360fa8 (patch)
treed161f1e6f09b3ab6846b064105b8cfc014b203cc /src/gallium/auxiliary/draw/draw_context.c
parentd5250da8189d0fb9741049cdbfc50e84aab44ecb (diff)
downloadexternal_mesa3d-5104ed3dbf18d47736fc67a8e3e317ea18360fa8.tar.gz
external_mesa3d-5104ed3dbf18d47736fc67a8e3e317ea18360fa8.tar.bz2
external_mesa3d-5104ed3dbf18d47736fc67a8e3e317ea18360fa8.zip
draw: try to prevent overflows on index buffers
Pass in the size of the index buffer, when available, and use it to handle out of bounds conditions. The behavior in the case of an overflow needs to be the same as with other overflows in the vertex processing pipeline meaning that a vertex should still be generated but all attributes in it set to zero. Signed-off-by: Zack Rusin <zackr@vmware.com> Reviewed-by: José Fonseca <jfonseca@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_context.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 4eb1919b87..78190388ef 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -627,7 +627,8 @@ void draw_set_render( struct draw_context *draw,
*/
void
draw_set_indexes(struct draw_context *draw,
- const void *elements, unsigned elem_size)
+ const void *elements, unsigned elem_size,
+ unsigned elem_buffer_space)
{
assert(elem_size == 0 ||
elem_size == 1 ||
@@ -635,6 +636,10 @@ draw_set_indexes(struct draw_context *draw,
elem_size == 4);
draw->pt.user.elts = elements;
draw->pt.user.eltSizeIB = elem_size;
+ if (elem_size)
+ draw->pt.user.eltMax = elem_buffer_space / elem_size;
+ else
+ draw->pt.user.eltMax = 0;
}