diff options
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r-- | mesalib/src/mesa/main/api_validate.c | 82 | ||||
-rw-r--r-- | mesalib/src/mesa/main/api_validate.h | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/main/bufferobj.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/main/config.h | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/main/context.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/main/get.c | 8 | ||||
-rw-r--r-- | mesalib/src/mesa/main/mtypes.h | 12 | ||||
-rw-r--r-- | mesalib/src/mesa/main/transformfeedback.c | 8 |
8 files changed, 99 insertions, 22 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; diff --git a/mesalib/src/mesa/main/api_validate.h b/mesalib/src/mesa/main/api_validate.h index d92fd433f..59f329768 100644 --- a/mesalib/src/mesa/main/api_validate.h +++ b/mesalib/src/mesa/main/api_validate.h @@ -56,6 +56,12 @@ _mesa_validate_DrawElements(struct gl_context *ctx, const GLvoid *indices, GLint basevertex); extern GLboolean +_mesa_validate_MultiDrawElements(struct gl_context *ctx, + GLenum mode, const GLsizei *count, + GLenum type, const GLvoid * const *indices, + GLuint primcount, const GLint *basevertex); + +extern GLboolean _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index ea48af97e..7d72092a2 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -869,7 +869,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) if (ctx->TransformFeedback.CurrentBuffer == bufObj) { _mesa_BindBufferARB( GL_TRANSFORM_FEEDBACK_BUFFER, 0 ); } - for (j = 0; j < MAX_FEEDBACK_ATTRIBS; j++) { + for (j = 0; j < MAX_FEEDBACK_BUFFERS; j++) { if (ctx->TransformFeedback.CurrentObject->Buffers[j] == bufObj) { _mesa_BindBufferBase( GL_TRANSFORM_FEEDBACK_BUFFER, j, 0 ); } diff --git a/mesalib/src/mesa/main/config.h b/mesalib/src/mesa/main/config.h index 1d5a0622d..ead1d323c 100644 --- a/mesalib/src/mesa/main/config.h +++ b/mesalib/src/mesa/main/config.h @@ -249,6 +249,7 @@ #define SUPPORTED_ATI_BUMP_UNITS 0xff /** For GL_EXT_transform_feedback */ +#define MAX_FEEDBACK_BUFFERS 4 #define MAX_FEEDBACK_ATTRIBS 32 /** For GL_ARB_geometry_shader4 */ diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index 643476b94..7de714b81 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -652,7 +652,7 @@ _mesa_init_constants(struct gl_context *ctx) ctx->Const.QuadsFollowProvokingVertexConvention = GL_TRUE; /* GL_EXT_transform_feedback */ - ctx->Const.MaxTransformFeedbackSeparateAttribs = MAX_FEEDBACK_ATTRIBS; + ctx->Const.MaxTransformFeedbackBuffers = MAX_FEEDBACK_BUFFERS; ctx->Const.MaxTransformFeedbackSeparateComponents = 4 * MAX_FEEDBACK_ATTRIBS; ctx->Const.MaxTransformFeedbackInterleavedComponents = 4 * MAX_FEEDBACK_ATTRIBS; diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 67732521c..a83d36721 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -1232,7 +1232,7 @@ static const struct value_desc values[] = { CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents), extra_EXT_transform_feedback }, { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, - CONTEXT_INT(Const.MaxTransformFeedbackSeparateAttribs), + CONTEXT_INT(Const.MaxTransformFeedbackBuffers), extra_EXT_transform_feedback }, { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, CONTEXT_INT(Const.MaxTransformFeedbackSeparateComponents), @@ -2544,7 +2544,7 @@ find_value_indexed(const char *func, GLenum pname, int index, union value *v) return TYPE_INT_4; case GL_TRANSFORM_FEEDBACK_BUFFER_START: - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) + if (index >= ctx->Const.MaxTransformFeedbackBuffers) goto invalid_value; if (!ctx->Extensions.EXT_transform_feedback) goto invalid_enum; @@ -2552,7 +2552,7 @@ find_value_indexed(const char *func, GLenum pname, int index, union value *v) return TYPE_INT64; case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) + if (index >= ctx->Const.MaxTransformFeedbackBuffers) goto invalid_value; if (!ctx->Extensions.EXT_transform_feedback) goto invalid_enum; @@ -2560,7 +2560,7 @@ find_value_indexed(const char *func, GLenum pname, int index, union value *v) return TYPE_INT64; case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) + if (index >= ctx->Const.MaxTransformFeedbackBuffers) goto invalid_value; if (!ctx->Extensions.EXT_transform_feedback) goto invalid_enum; diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index d37c1f3de..5768ed7cd 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1795,7 +1795,7 @@ struct gl_transform_feedback_info * hardware back-ends to determine the correct stride when interleaving * multiple transform feedback outputs in the same buffer. */ - unsigned BufferStride[MAX_FEEDBACK_ATTRIBS]; + unsigned BufferStride[MAX_FEEDBACK_BUFFERS]; }; @@ -1812,13 +1812,13 @@ struct gl_transform_feedback_object at least once? */ /** The feedback buffers */ - GLuint BufferNames[MAX_FEEDBACK_ATTRIBS]; - struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS]; + GLuint BufferNames[MAX_FEEDBACK_BUFFERS]; + struct gl_buffer_object *Buffers[MAX_FEEDBACK_BUFFERS]; /** Start of feedback data in dest buffer */ - GLintptr Offset[MAX_FEEDBACK_ATTRIBS]; + GLintptr Offset[MAX_FEEDBACK_BUFFERS]; /** Max data to put into dest buffer (in bytes) */ - GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS]; + GLsizeiptr Size[MAX_FEEDBACK_BUFFERS]; }; @@ -2834,7 +2834,7 @@ struct gl_constants GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ /** GL_EXT_transform_feedback */ - GLuint MaxTransformFeedbackSeparateAttribs; + GLuint MaxTransformFeedbackBuffers; GLuint MaxTransformFeedbackSeparateComponents; GLuint MaxTransformFeedbackInterleavedComponents; diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c index d02b6a056..6f8221201 100644 --- a/mesalib/src/mesa/main/transformfeedback.c +++ b/mesalib/src/mesa/main/transformfeedback.c @@ -447,7 +447,7 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx, return; } - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { + if (index >= ctx->Const.MaxTransformFeedbackBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d)", index); return; } @@ -490,7 +490,7 @@ _mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx, return; } - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { + if (index >= ctx->Const.MaxTransformFeedbackBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index); return; } @@ -531,7 +531,7 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, return; } - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { + if (index >= ctx->Const.MaxTransformFeedbackBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferOffsetEXT(index=%d)", index); return; @@ -590,7 +590,7 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count, if (count < 0 || (bufferMode == GL_SEPARATE_ATTRIBS && - (GLuint) count > ctx->Const.MaxTransformFeedbackSeparateAttribs)) { + (GLuint) count > ctx->Const.MaxTransformFeedbackBuffers)) { _mesa_error(ctx, GL_INVALID_VALUE, "glTransformFeedbackVaryings(count=%d)", count); return; |