aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/varray.h
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-04-07 07:49:55 +0000
committermarha <marha@users.sourceforge.net>2011-04-07 07:49:55 +0000
commit143921f2eb615190ed77e57a6f93f02ffb325c91 (patch)
tree19c73ab0992ee863cc67e7b98da84d2347a77ef7 /mesalib/src/mesa/main/varray.h
parente2b908c356746281aba48128da7dc15a28f5a773 (diff)
parentde1c6801fc854692d39fb2f8d53bf54ab25a1287 (diff)
downloadvcxsrv-143921f2eb615190ed77e57a6f93f02ffb325c91.tar.gz
vcxsrv-143921f2eb615190ed77e57a6f93f02ffb325c91.tar.bz2
vcxsrv-143921f2eb615190ed77e57a6f93f02ffb325c91.zip
svn merge ^/branches/released .
Diffstat (limited to 'mesalib/src/mesa/main/varray.h')
-rw-r--r--mesalib/src/mesa/main/varray.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/mesalib/src/mesa/main/varray.h b/mesalib/src/mesa/main/varray.h
index 1e3ab10c9..493494e5c 100644
--- a/mesalib/src/mesa/main/varray.h
+++ b/mesalib/src/mesa/main/varray.h
@@ -34,6 +34,37 @@
struct gl_client_array;
struct gl_context;
+
+/**
+ * Compute the index of the last array element that can be safely accessed in
+ * a vertex array. We can really only do this when the array lives in a VBO.
+ * The array->_MaxElement field will be updated.
+ * Later in glDrawArrays/Elements/etc we can do some bounds checking.
+ */
+static INLINE void
+_mesa_update_array_max_element(struct gl_client_array *array)
+{
+ assert(array->Enabled);
+
+ if (array->BufferObj->Name) {
+ GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr;
+ GLsizeiptrARB bufSize = (GLsizeiptrARB) array->BufferObj->Size;
+
+ if (offset < bufSize) {
+ array->_MaxElement = (bufSize - offset + array->StrideB
+ - array->_ElementSize) / array->StrideB;
+ }
+ else {
+ array->_MaxElement = 0;
+ }
+ }
+ else {
+ /* user-space array, no idea how big it is */
+ array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
+ }
+}
+
+
#if _HAVE_FULL_GL
extern void GLAPIENTRY