aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/api_validate.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-06-29 09:50:56 +0200
committermarha <marha@users.sourceforge.net>2012-06-29 09:50:56 +0200
commitf6d1847eef027266daa0f75ee92ceb09698b2761 (patch)
tree7ce3418e8255a636034d90be862167046c06473d /mesalib/src/mesa/main/api_validate.c
parent67551627d34fff4a0fbe719bce33a3bacb55ccef (diff)
downloadvcxsrv-f6d1847eef027266daa0f75ee92ceb09698b2761.tar.gz
vcxsrv-f6d1847eef027266daa0f75ee92ceb09698b2761.tar.bz2
vcxsrv-f6d1847eef027266daa0f75ee92ceb09698b2761.zip
xkeyboard-config xserver pixman mesa git update 29 Jun 2012
Diffstat (limited to 'mesalib/src/mesa/main/api_validate.c')
-rw-r--r--mesalib/src/mesa/main/api_validate.c82
1 files changed, 76 insertions, 6 deletions
diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c
index 02495a15a..631bceecf 100644
--- a/mesalib/src/mesa/main/api_validate.c
+++ b/mesalib/src/mesa/main/api_validate.c
@@ -272,7 +272,7 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLint basevertex)
{
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, GL_FALSE);
if (count <= 0) {
if (count < 0)
@@ -318,6 +318,76 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
/**
+ * Error checking for glMultiDrawElements(). Includes parameter checking
+ * and VBO bounds checking.
+ * \return GL_TRUE if OK to render, GL_FALSE if error found
+ */
+GLboolean
+_mesa_validate_MultiDrawElements(struct gl_context *ctx,
+ GLenum mode, const GLsizei *count,
+ GLenum type, const GLvoid * const *indices,
+ GLuint primcount, const GLint *basevertex)
+{
+ unsigned i;
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, GL_FALSE);
+
+ for (i = 0; i < primcount; i++) {
+ if (count[i] <= 0) {
+ if (count[i] < 0)
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glMultiDrawElements(count)" );
+ return GL_FALSE;
+ }
+ }
+
+ if (!_mesa_valid_prim_mode(ctx, mode, "glMultiDrawElements")) {
+ return GL_FALSE;
+ }
+
+ if (type != GL_UNSIGNED_INT &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_UNSIGNED_SHORT)
+ {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glMultiDrawElements(type)" );
+ return GL_FALSE;
+ }
+
+ if (!check_valid_to_render(ctx, "glMultiDrawElements"))
+ return GL_FALSE;
+
+ /* Vertex buffer object tests */
+ if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
+ /* use indices in the buffer object */
+ /* make sure count doesn't go outside buffer bounds */
+ for (i = 0; i < primcount; i++) {
+ if (index_bytes(type, count[i]) >
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Size) {
+ _mesa_warning(ctx,
+ "glMultiDrawElements index out of buffer bounds");
+ return GL_FALSE;
+ }
+ }
+ }
+ else {
+ /* not using a VBO */
+ for (i = 0; i < primcount; i++) {
+ if (!indices[i])
+ return GL_FALSE;
+ }
+ }
+
+ for (i = 0; i < primcount; i++) {
+ if (!check_index_bounds(ctx, count[i], type, indices[i],
+ basevertex ? basevertex[i] : 0))
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
* Error checking for glDrawRangeElements(). Includes parameter checking
* and VBO bounds checking.
* \return GL_TRUE if OK to render, GL_FALSE if error found
@@ -328,7 +398,7 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode,
GLsizei count, GLenum type,
const GLvoid *indices, GLint basevertex)
{
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, GL_FALSE);
if (count <= 0) {
if (count < 0)
@@ -386,7 +456,7 @@ GLboolean
_mesa_validate_DrawArrays(struct gl_context *ctx,
GLenum mode, GLint start, GLsizei count)
{
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, GL_FALSE);
if (count <= 0) {
if (count < 0)
@@ -414,7 +484,7 @@ GLboolean
_mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint first,
GLsizei count, GLsizei numInstances)
{
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, GL_FALSE);
if (count <= 0) {
if (count < 0)
@@ -458,7 +528,7 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
const GLvoid *indices, GLsizei numInstances,
GLint basevertex)
{
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, GL_FALSE);
if (count <= 0) {
if (count < 0)
@@ -519,7 +589,7 @@ _mesa_validate_DrawTransformFeedback(struct gl_context *ctx,
GLenum mode,
struct gl_transform_feedback_object *obj)
{
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, GL_FALSE);
if (!_mesa_valid_prim_mode(ctx, mode, "glDrawTransformFeedback")) {
return GL_FALSE;