355a93c4c3dbf8d267ad3c6bc361cb53c2a6fe5e
[mesa.git] / src / mesa / main / api_validate.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.1
4 *
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 #include <stdbool.h>
26 #include "glheader.h"
27 #include "api_validate.h"
28 #include "bufferobj.h"
29 #include "context.h"
30 #include "imports.h"
31 #include "mfeatures.h"
32 #include "mtypes.h"
33 #include "enums.h"
34 #include "vbo/vbo.h"
35 #include <stdbool.h>
36
37
38 /**
39 * \return number of bytes in array [count] of type.
40 */
41 static GLsizei
42 index_bytes(GLenum type, GLsizei count)
43 {
44 if (type == GL_UNSIGNED_INT) {
45 return count * sizeof(GLuint);
46 }
47 else if (type == GL_UNSIGNED_BYTE) {
48 return count * sizeof(GLubyte);
49 }
50 else {
51 ASSERT(type == GL_UNSIGNED_SHORT);
52 return count * sizeof(GLushort);
53 }
54 }
55
56
57 /**
58 * Find the max index in the given element/index buffer
59 */
60 GLuint
61 _mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type,
62 const void *indices,
63 struct gl_buffer_object *elementBuf)
64 {
65 const GLubyte *map = NULL;
66 GLuint max = 0;
67 GLuint i;
68
69 if (_mesa_is_bufferobj(elementBuf)) {
70 /* elements are in a user-defined buffer object. need to map it */
71 map = ctx->Driver.MapBufferRange(ctx, 0, elementBuf->Size,
72 GL_MAP_READ_BIT, elementBuf);
73 /* Actual address is the sum of pointers */
74 indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
75 }
76
77 if (type == GL_UNSIGNED_INT) {
78 for (i = 0; i < count; i++)
79 if (((GLuint *) indices)[i] > max)
80 max = ((GLuint *) indices)[i];
81 }
82 else if (type == GL_UNSIGNED_SHORT) {
83 for (i = 0; i < count; i++)
84 if (((GLushort *) indices)[i] > max)
85 max = ((GLushort *) indices)[i];
86 }
87 else {
88 ASSERT(type == GL_UNSIGNED_BYTE);
89 for (i = 0; i < count; i++)
90 if (((GLubyte *) indices)[i] > max)
91 max = ((GLubyte *) indices)[i];
92 }
93
94 if (map) {
95 ctx->Driver.UnmapBuffer(ctx, elementBuf);
96 }
97
98 return max;
99 }
100
101
102 /**
103 * Check if OK to draw arrays/elements.
104 */
105 static GLboolean
106 check_valid_to_render(struct gl_context *ctx, const char *function)
107 {
108 if (!_mesa_valid_to_render(ctx, function)) {
109 return GL_FALSE;
110 }
111
112 switch (ctx->API) {
113 case API_OPENGLES2:
114 /* For ES2, we can draw if any vertex array is enabled (and we
115 * should always have a vertex program/shader). */
116 if (ctx->Array.ArrayObj->_Enabled == 0x0 || !ctx->VertexProgram._Current)
117 return GL_FALSE;
118 break;
119
120 case API_OPENGLES:
121 /* For OpenGL ES, only draw if we have vertex positions
122 */
123 if (!ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled)
124 return GL_FALSE;
125 break;
126
127 case API_OPENGL_COMPAT:
128 case API_OPENGL_CORE:
129 {
130 const struct gl_shader_program *vsProg =
131 ctx->Shader.CurrentVertexProgram;
132 GLboolean haveVertexShader = (vsProg && vsProg->LinkStatus);
133 GLboolean haveVertexProgram = ctx->VertexProgram._Enabled;
134 if (haveVertexShader || haveVertexProgram) {
135 /* Draw regardless of whether or not we have any vertex arrays.
136 * (Ex: could draw a point using a constant vertex pos)
137 */
138 return GL_TRUE;
139 }
140 else {
141 /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic
142 * array [0]).
143 */
144 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled ||
145 ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled);
146 }
147 }
148 break;
149
150 default:
151 assert(!"Invalid API value in check_valid_to_render()");
152 }
153
154 return GL_TRUE;
155 }
156
157
158 /**
159 * Do bounds checking on array element indexes. Check that the vertices
160 * pointed to by the indices don't lie outside buffer object bounds.
161 * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds
162 */
163 static GLboolean
164 check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type,
165 const GLvoid *indices, GLint basevertex)
166 {
167 struct _mesa_prim prim;
168 struct _mesa_index_buffer ib;
169 GLuint min, max;
170
171 /* Only the X Server needs to do this -- otherwise, accessing outside
172 * array/BO bounds allows application termination.
173 */
174 if (!ctx->Const.CheckArrayBounds)
175 return GL_TRUE;
176
177 memset(&prim, 0, sizeof(prim));
178 prim.count = count;
179
180 memset(&ib, 0, sizeof(ib));
181 ib.type = type;
182 ib.ptr = indices;
183 ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;
184
185 vbo_get_minmax_indices(ctx, &prim, &ib, &min, &max, 1);
186
187 if ((int)(min + basevertex) < 0 ||
188 max + basevertex >= ctx->Array.ArrayObj->_MaxElement) {
189 /* the max element is out of bounds of one or more enabled arrays */
190 _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)",
191 max, ctx->Array.ArrayObj->_MaxElement);
192 return GL_FALSE;
193 }
194
195 return GL_TRUE;
196 }
197
198
199 /**
200 * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
201 * etc? The set of legal values depends on whether geometry shaders/programs
202 * are supported.
203 */
204 GLboolean
205 _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
206 {
207 bool valid_enum;
208
209 switch (mode) {
210 case GL_POINTS:
211 case GL_LINES:
212 case GL_LINE_LOOP:
213 case GL_LINE_STRIP:
214 case GL_TRIANGLES:
215 case GL_TRIANGLE_STRIP:
216 case GL_TRIANGLE_FAN:
217 valid_enum = true;
218 break;
219 case GL_QUADS:
220 case GL_QUAD_STRIP:
221 case GL_POLYGON:
222 valid_enum = (ctx->API == API_OPENGL_COMPAT);
223 break;
224 case GL_LINES_ADJACENCY:
225 case GL_LINE_STRIP_ADJACENCY:
226 case GL_TRIANGLES_ADJACENCY:
227 case GL_TRIANGLE_STRIP_ADJACENCY:
228 valid_enum = _mesa_is_desktop_gl(ctx)
229 && ctx->Extensions.ARB_geometry_shader4;
230 break;
231 default:
232 valid_enum = false;
233 break;
234 }
235
236 if (!valid_enum) {
237 _mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode);
238 return GL_FALSE;
239 }
240
241 /* From the GL_EXT_transform_feedback spec:
242 *
243 * "The error INVALID_OPERATION is generated if Begin, or any command
244 * that performs an explicit Begin, is called when:
245 *
246 * * a geometry shader is not active and <mode> does not match the
247 * allowed begin modes for the current transform feedback state as
248 * given by table X.1.
249 *
250 * * a geometry shader is active and the output primitive type of the
251 * geometry shader does not match the allowed begin modes for the
252 * current transform feedback state as given by table X.1.
253 *
254 */
255 if (ctx->TransformFeedback.CurrentObject->Active &&
256 !ctx->TransformFeedback.CurrentObject->Paused) {
257 GLboolean pass = GL_TRUE;
258
259 switch (mode) {
260 case GL_POINTS:
261 pass = ctx->TransformFeedback.Mode == GL_POINTS;
262 break;
263 case GL_LINES:
264 case GL_LINE_STRIP:
265 case GL_LINE_LOOP:
266 pass = ctx->TransformFeedback.Mode == GL_LINES;
267 break;
268 default:
269 pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
270 break;
271 }
272 if (!pass) {
273 _mesa_error(ctx, GL_INVALID_OPERATION,
274 "%s(mode=%s vs transform feedback %s)",
275 name,
276 _mesa_lookup_prim_by_nr(mode),
277 _mesa_lookup_prim_by_nr(ctx->TransformFeedback.Mode));
278 return GL_FALSE;
279 }
280 }
281
282 return GL_TRUE;
283 }
284
285 /**
286 * Verify that the element type is valid.
287 *
288 * Generates \c GL_INVALID_ENUM and returns \c false if it is not.
289 */
290 static bool
291 valid_elements_type(struct gl_context *ctx, GLenum type, const char *name)
292 {
293 switch (type) {
294 case GL_UNSIGNED_BYTE:
295 case GL_UNSIGNED_SHORT:
296 case GL_UNSIGNED_INT:
297 return true;
298
299 default:
300 _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", name,
301 _mesa_lookup_enum_by_nr(type));
302 return false;
303 }
304 }
305
306 /**
307 * Error checking for glDrawElements(). Includes parameter checking
308 * and VBO bounds checking.
309 * \return GL_TRUE if OK to render, GL_FALSE if error found
310 */
311 GLboolean
312 _mesa_validate_DrawElements(struct gl_context *ctx,
313 GLenum mode, GLsizei count, GLenum type,
314 const GLvoid *indices, GLint basevertex)
315 {
316 struct gl_transform_feedback_object *xfb_obj
317 = ctx->TransformFeedback.CurrentObject;
318 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
319 FLUSH_CURRENT(ctx, 0);
320
321 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
322 * Primitive Capture):
323 *
324 * The error INVALID_OPERATION is also generated by DrawElements,
325 * DrawElementsInstanced, and DrawRangeElements while transform feedback
326 * is active and not paused, regardless of mode.
327 */
328 if (_mesa_is_gles3(ctx) && xfb_obj->Active && !xfb_obj->Paused) {
329 _mesa_error(ctx, GL_INVALID_OPERATION,
330 "glDrawElements(transform feedback active)");
331 return GL_FALSE;
332 }
333
334 if (count <= 0) {
335 if (count < 0)
336 _mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" );
337 return GL_FALSE;
338 }
339
340 if (!_mesa_valid_prim_mode(ctx, mode, "glDrawElements")) {
341 return GL_FALSE;
342 }
343
344 if (!valid_elements_type(ctx, type, "glDrawElements"))
345 return GL_FALSE;
346
347 if (!check_valid_to_render(ctx, "glDrawElements"))
348 return GL_FALSE;
349
350 /* Vertex buffer object tests */
351 if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
352 /* use indices in the buffer object */
353 /* make sure count doesn't go outside buffer bounds */
354 if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) {
355 _mesa_warning(ctx, "glDrawElements index out of buffer bounds");
356 return GL_FALSE;
357 }
358 }
359 else {
360 /* not using a VBO */
361 if (!indices)
362 return GL_FALSE;
363 }
364
365 if (!check_index_bounds(ctx, count, type, indices, basevertex))
366 return GL_FALSE;
367
368 return GL_TRUE;
369 }
370
371
372 /**
373 * Error checking for glMultiDrawElements(). Includes parameter checking
374 * and VBO bounds checking.
375 * \return GL_TRUE if OK to render, GL_FALSE if error found
376 */
377 GLboolean
378 _mesa_validate_MultiDrawElements(struct gl_context *ctx,
379 GLenum mode, const GLsizei *count,
380 GLenum type, const GLvoid * const *indices,
381 GLuint primcount, const GLint *basevertex)
382 {
383 unsigned i;
384
385 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
386 FLUSH_CURRENT(ctx, 0);
387
388 for (i = 0; i < primcount; i++) {
389 if (count[i] <= 0) {
390 if (count[i] < 0)
391 _mesa_error(ctx, GL_INVALID_VALUE,
392 "glMultiDrawElements(count)" );
393 return GL_FALSE;
394 }
395 }
396
397 if (!_mesa_valid_prim_mode(ctx, mode, "glMultiDrawElements")) {
398 return GL_FALSE;
399 }
400
401 if (!valid_elements_type(ctx, type, "glMultiDrawElements"))
402 return GL_FALSE;
403
404 if (!check_valid_to_render(ctx, "glMultiDrawElements"))
405 return GL_FALSE;
406
407 /* Vertex buffer object tests */
408 if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
409 /* use indices in the buffer object */
410 /* make sure count doesn't go outside buffer bounds */
411 for (i = 0; i < primcount; i++) {
412 if (index_bytes(type, count[i]) >
413 ctx->Array.ArrayObj->ElementArrayBufferObj->Size) {
414 _mesa_warning(ctx,
415 "glMultiDrawElements index out of buffer bounds");
416 return GL_FALSE;
417 }
418 }
419 }
420 else {
421 /* not using a VBO */
422 for (i = 0; i < primcount; i++) {
423 if (!indices[i])
424 return GL_FALSE;
425 }
426 }
427
428 for (i = 0; i < primcount; i++) {
429 if (!check_index_bounds(ctx, count[i], type, indices[i],
430 basevertex ? basevertex[i] : 0))
431 return GL_FALSE;
432 }
433
434 return GL_TRUE;
435 }
436
437
438 /**
439 * Error checking for glDrawRangeElements(). Includes parameter checking
440 * and VBO bounds checking.
441 * \return GL_TRUE if OK to render, GL_FALSE if error found
442 */
443 GLboolean
444 _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode,
445 GLuint start, GLuint end,
446 GLsizei count, GLenum type,
447 const GLvoid *indices, GLint basevertex)
448 {
449 struct gl_transform_feedback_object *xfb_obj
450 = ctx->TransformFeedback.CurrentObject;
451 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
452 FLUSH_CURRENT(ctx, 0);
453
454 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
455 * Primitive Capture):
456 *
457 * The error INVALID_OPERATION is also generated by DrawElements,
458 * DrawElementsInstanced, and DrawRangeElements while transform feedback
459 * is active and not paused, regardless of mode.
460 */
461 if (_mesa_is_gles3(ctx) && xfb_obj->Active && !xfb_obj->Paused) {
462 _mesa_error(ctx, GL_INVALID_OPERATION,
463 "glDrawElements(transform feedback active)");
464 return GL_FALSE;
465 }
466
467 if (count <= 0) {
468 if (count < 0)
469 _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(count)" );
470 return GL_FALSE;
471 }
472
473 if (!_mesa_valid_prim_mode(ctx, mode, "glDrawRangeElements")) {
474 return GL_FALSE;
475 }
476
477 if (end < start) {
478 _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(end<start)");
479 return GL_FALSE;
480 }
481
482 if (!valid_elements_type(ctx, type, "glDrawRangeElements"))
483 return GL_FALSE;
484
485 if (!check_valid_to_render(ctx, "glDrawRangeElements"))
486 return GL_FALSE;
487
488 /* Vertex buffer object tests */
489 if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
490 /* use indices in the buffer object */
491 /* make sure count doesn't go outside buffer bounds */
492 if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) {
493 _mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds");
494 return GL_FALSE;
495 }
496 }
497 else {
498 /* not using a VBO */
499 if (!indices)
500 return GL_FALSE;
501 }
502
503 if (!check_index_bounds(ctx, count, type, indices, basevertex))
504 return GL_FALSE;
505
506 return GL_TRUE;
507 }
508
509
510 /**
511 * Called from the tnl module to error check the function parameters and
512 * verify that we really can draw something.
513 * \return GL_TRUE if OK to render, GL_FALSE if error found
514 */
515 GLboolean
516 _mesa_validate_DrawArrays(struct gl_context *ctx,
517 GLenum mode, GLint start, GLsizei count)
518 {
519 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
520 FLUSH_CURRENT(ctx, 0);
521
522 if (count <= 0) {
523 if (count < 0)
524 _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" );
525 return GL_FALSE;
526 }
527
528 if (!_mesa_valid_prim_mode(ctx, mode, "glDrawArrays")) {
529 return GL_FALSE;
530 }
531
532 if (!check_valid_to_render(ctx, "glDrawArrays"))
533 return GL_FALSE;
534
535 if (ctx->Const.CheckArrayBounds) {
536 if (start + count > (GLint) ctx->Array.ArrayObj->_MaxElement)
537 return GL_FALSE;
538 }
539
540 return GL_TRUE;
541 }
542
543
544 GLboolean
545 _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint first,
546 GLsizei count, GLsizei numInstances)
547 {
548 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
549 FLUSH_CURRENT(ctx, 0);
550
551 if (count <= 0) {
552 if (count < 0)
553 _mesa_error(ctx, GL_INVALID_VALUE,
554 "glDrawArraysInstanced(count=%d)", count);
555 return GL_FALSE;
556 }
557
558 if (first < 0) {
559 _mesa_error(ctx, GL_INVALID_VALUE,
560 "glDrawArraysInstanced(start=%d)", first);
561 return GL_FALSE;
562 }
563
564 if (!_mesa_valid_prim_mode(ctx, mode, "glDrawArraysInstanced")) {
565 return GL_FALSE;
566 }
567
568 if (numInstances <= 0) {
569 if (numInstances < 0)
570 _mesa_error(ctx, GL_INVALID_VALUE,
571 "glDrawArraysInstanced(numInstances=%d)", numInstances);
572 return GL_FALSE;
573 }
574
575 if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)"))
576 return GL_FALSE;
577
578 if (ctx->Const.CheckArrayBounds) {
579 if (first + count > (GLint) ctx->Array.ArrayObj->_MaxElement)
580 return GL_FALSE;
581 }
582
583 return GL_TRUE;
584 }
585
586
587 GLboolean
588 _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
589 GLenum mode, GLsizei count, GLenum type,
590 const GLvoid *indices, GLsizei numInstances,
591 GLint basevertex)
592 {
593 struct gl_transform_feedback_object *xfb_obj
594 = ctx->TransformFeedback.CurrentObject;
595 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
596 FLUSH_CURRENT(ctx, 0);
597
598 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
599 * Primitive Capture):
600 *
601 * The error INVALID_OPERATION is also generated by DrawElements,
602 * DrawElementsInstanced, and DrawRangeElements while transform feedback
603 * is active and not paused, regardless of mode.
604 */
605 if (_mesa_is_gles3(ctx) && xfb_obj->Active && !xfb_obj->Paused) {
606 _mesa_error(ctx, GL_INVALID_OPERATION,
607 "glDrawElements(transform feedback active)");
608 return GL_FALSE;
609 }
610
611 if (count <= 0) {
612 if (count < 0)
613 _mesa_error(ctx, GL_INVALID_VALUE,
614 "glDrawElementsInstanced(count=%d)", count);
615 return GL_FALSE;
616 }
617
618 if (!_mesa_valid_prim_mode(ctx, mode, "glDrawElementsInstanced")) {
619 return GL_FALSE;
620 }
621
622 if (!valid_elements_type(ctx, type, "glDrawElementsInstanced"))
623 return GL_FALSE;
624
625 if (numInstances <= 0) {
626 if (numInstances < 0)
627 _mesa_error(ctx, GL_INVALID_VALUE,
628 "glDrawElementsInstanced(numInstances=%d)", numInstances);
629 return GL_FALSE;
630 }
631
632 if (!check_valid_to_render(ctx, "glDrawElementsInstanced"))
633 return GL_FALSE;
634
635 /* Vertex buffer object tests */
636 if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
637 /* use indices in the buffer object */
638 /* make sure count doesn't go outside buffer bounds */
639 if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) {
640 _mesa_warning(ctx,
641 "glDrawElementsInstanced index out of buffer bounds");
642 return GL_FALSE;
643 }
644 }
645 else {
646 /* not using a VBO */
647 if (!indices)
648 return GL_FALSE;
649 }
650
651 if (!check_index_bounds(ctx, count, type, indices, basevertex))
652 return GL_FALSE;
653
654 return GL_TRUE;
655 }
656
657
658 GLboolean
659 _mesa_validate_DrawTransformFeedback(struct gl_context *ctx,
660 GLenum mode,
661 struct gl_transform_feedback_object *obj,
662 GLuint stream,
663 GLsizei numInstances)
664 {
665 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
666 FLUSH_CURRENT(ctx, 0);
667
668 if (!_mesa_valid_prim_mode(ctx, mode, "glDrawTransformFeedback*(mode)")) {
669 return GL_FALSE;
670 }
671
672 if (!obj) {
673 _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTransformFeedback*(name)");
674 return GL_FALSE;
675 }
676
677 if (!obj->EndedAnytime) {
678 _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*");
679 return GL_FALSE;
680 }
681
682 if (stream >= ctx->Const.MaxVertexStreams) {
683 _mesa_error(ctx, GL_INVALID_VALUE,
684 "glDrawTransformFeedbackStream*(index>=MaxVertexStream)");
685 return GL_FALSE;
686 }
687
688 if (numInstances <= 0) {
689 if (numInstances < 0)
690 _mesa_error(ctx, GL_INVALID_VALUE,
691 "glDrawTransformFeedback*Instanced(numInstances=%d)",
692 numInstances);
693 return GL_FALSE;
694 }
695
696 if (!check_valid_to_render(ctx, "glDrawTransformFeedback*")) {
697 return GL_FALSE;
698 }
699
700 return GL_TRUE;
701 }