+
+
+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);
+ FLUSH_CURRENT(ctx, 0);
+
+ if (count <= 0) {
+ if (count < 0)
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDrawArraysInstanced(count=%d)", count);
+ return GL_FALSE;
+ }
+
+ if (first < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDrawArraysInstanced(start=%d)", first);
+ return GL_FALSE;
+ }
+
+ if (!_mesa_valid_prim_mode(ctx, mode, "glDrawArraysInstanced")) {
+ return GL_FALSE;
+ }
+
+ if (numInstances <= 0) {
+ if (numInstances < 0)
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDrawArraysInstanced(numInstances=%d)", numInstances);
+ return GL_FALSE;
+ }
+
+ if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)"))
+ return GL_FALSE;
+
+ if (ctx->Const.CheckArrayBounds) {
+ if (first + count > (GLint) ctx->Array.ArrayObj->_MaxElement)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
+ GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices, GLsizei numInstances,
+ GLint basevertex)
+{
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ FLUSH_CURRENT(ctx, 0);
+
+ if (count <= 0) {
+ if (count < 0)
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDrawElementsInstanced(count=%d)", count);
+ return GL_FALSE;
+ }
+
+ if (!_mesa_valid_prim_mode(ctx, mode, "glDrawElementsInstanced")) {
+ return GL_FALSE;
+ }
+
+ if (!valid_elements_type(ctx, type, "glDrawElementsInstanced"))
+ return GL_FALSE;
+
+ if (numInstances <= 0) {
+ if (numInstances < 0)
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDrawElementsInstanced(numInstances=%d)", numInstances);
+ return GL_FALSE;
+ }
+
+ if (!check_valid_to_render(ctx, "glDrawElementsInstanced"))
+ 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 */
+ if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) {
+ _mesa_warning(ctx,
+ "glDrawElementsInstanced index out of buffer bounds");
+ return GL_FALSE;
+ }
+ }
+ else {
+ /* not using a VBO */
+ if (!indices)
+ return GL_FALSE;
+ }
+
+ if (!check_index_bounds(ctx, count, type, indices, basevertex))
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_validate_DrawTransformFeedback(struct gl_context *ctx,
+ GLenum mode,
+ struct gl_transform_feedback_object *obj,
+ GLuint stream,
+ GLsizei numInstances)
+{
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ FLUSH_CURRENT(ctx, 0);
+
+ if (!_mesa_valid_prim_mode(ctx, mode, "glDrawTransformFeedback*(mode)")) {
+ return GL_FALSE;
+ }
+
+ if (!obj) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTransformFeedback*(name)");
+ return GL_FALSE;
+ }
+
+ if (!obj->EndedAnytime) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*");
+ return GL_FALSE;
+ }
+
+ if (stream >= ctx->Const.MaxVertexStreams) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDrawTransformFeedbackStream*(index>=MaxVertexStream)");
+ return GL_FALSE;
+ }
+
+ if (numInstances <= 0) {
+ if (numInstances < 0)
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDrawTransformFeedback*Instanced(numInstances=%d)",
+ numInstances);
+ return GL_FALSE;
+ }
+
+ if (!check_valid_to_render(ctx, "glDrawTransformFeedback*")) {
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}