Mesa (master): util/u_draw: Skip rendering instead of aborting when excessive number of instances is found .
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Tue Dec 4 19:35:24 UTC 2012
Module: Mesa
Branch: master
Commit: 4da0cb83ab6d82ba3cf011bb3b9b012bd27f7bfc
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4da0cb83ab6d82ba3cf011bb3b9b012bd27f7bfc
Author: José Fonseca <jfonseca at vmware.com>
Date: Fri Nov 16 17:57:38 2012 +0000
util/u_draw: Skip rendering instead of aborting when excessive number of instances is found.
This is a temporary hack. I believe the only way of properly fixing this
is to check buffer overflow just before fetching based on addresses,
instead of number of vertices/instances. This change simply allows tests
that stress buffer overflows to complete without asserting, and should
not affect valid rendering.
Reviewed-by: Brian Paul <brianp at vmware.com>
---
src/gallium/auxiliary/util/u_draw.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_draw.c b/src/gallium/auxiliary/util/u_draw.c
index 5b3c412..83d9284 100644
--- a/src/gallium/auxiliary/util/u_draw.c
+++ b/src/gallium/auxiliary/util/u_draw.c
@@ -108,8 +108,15 @@ util_draw_max_index(
else {
/* Per-instance data. Simply make sure the state tracker didn't
* request more instances than those that fit in the buffer */
- assert((info->start_instance + info->instance_count)/element->instance_divisor
- <= (buffer_max_index + 1));
+ if ((info->start_instance + info->instance_count)/element->instance_divisor
+ > (buffer_max_index + 1)) {
+ /* FIXME: We really should stop thinking in terms of maximum
+ * indices/instances and simply start clamping against buffer
+ * size. */
+ debug_printf("%s: too many instances for vertex buffer\n",
+ __FUNCTION__);
+ return 0;
+ }
}
}
}
More information about the mesa-commit
mailing list