2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
27 #include "api_validate.h"
28 #include "bufferobj.h"
34 #include "transformfeedback.h"
39 * \return number of bytes in array [count] of type.
42 index_bytes(GLenum type
, GLsizei count
)
44 if (type
== GL_UNSIGNED_INT
) {
45 return count
* sizeof(GLuint
);
47 else if (type
== GL_UNSIGNED_BYTE
) {
48 return count
* sizeof(GLubyte
);
51 ASSERT(type
== GL_UNSIGNED_SHORT
);
52 return count
* sizeof(GLushort
);
58 * Check if OK to draw arrays/elements.
61 check_valid_to_render(struct gl_context
*ctx
, const char *function
)
63 if (!_mesa_valid_to_render(ctx
, function
)) {
69 /* For ES2, we can draw if we have a vertex program/shader). */
70 if (!ctx
->VertexProgram
._Current
)
75 /* For OpenGL ES, only draw if we have vertex positions
77 if (!ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
)
82 if (ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
)
85 case API_OPENGL_COMPAT
:
87 const struct gl_shader_program
*vsProg
=
88 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_VERTEX
];
89 GLboolean haveVertexShader
= (vsProg
&& vsProg
->LinkStatus
);
90 GLboolean haveVertexProgram
= ctx
->VertexProgram
._Enabled
;
91 if (haveVertexShader
|| haveVertexProgram
) {
92 /* Draw regardless of whether or not we have any vertex arrays.
93 * (Ex: could draw a point using a constant vertex pos)
98 /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic
101 return (ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
||
102 ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
);
108 assert(!"Invalid API value in check_valid_to_render()");
116 * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
117 * etc? The set of legal values depends on whether geometry shaders/programs
119 * Note: This may be called during display list compilation.
122 _mesa_is_valid_prim_mode(struct gl_context
*ctx
, GLenum mode
)
130 case GL_TRIANGLE_STRIP
:
131 case GL_TRIANGLE_FAN
:
136 return (ctx
->API
== API_OPENGL_COMPAT
);
137 case GL_LINES_ADJACENCY
:
138 case GL_LINE_STRIP_ADJACENCY
:
139 case GL_TRIANGLES_ADJACENCY
:
140 case GL_TRIANGLE_STRIP_ADJACENCY
:
141 return _mesa_has_geometry_shaders(ctx
);
149 * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
150 * etc? Also, do additional checking related to transformation feedback.
151 * Note: this function cannot be called during glNewList(GL_COMPILE) because
152 * this code depends on current transform feedback state.
155 _mesa_valid_prim_mode(struct gl_context
*ctx
, GLenum mode
, const char *name
)
157 bool valid_enum
= _mesa_is_valid_prim_mode(ctx
, mode
);
160 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(mode=%x)", name
, mode
);
164 /* From the ARB_geometry_shader4 spec:
166 * The error INVALID_OPERATION is generated if Begin, or any command that
167 * implicitly calls Begin, is called when a geometry shader is active and:
169 * * the input primitive type of the current geometry shader is
170 * POINTS and <mode> is not POINTS,
172 * * the input primitive type of the current geometry shader is
173 * LINES and <mode> is not LINES, LINE_STRIP, or LINE_LOOP,
175 * * the input primitive type of the current geometry shader is
176 * TRIANGLES and <mode> is not TRIANGLES, TRIANGLE_STRIP or
179 * * the input primitive type of the current geometry shader is
180 * LINES_ADJACENCY_ARB and <mode> is not LINES_ADJACENCY_ARB or
181 * LINE_STRIP_ADJACENCY_ARB, or
183 * * the input primitive type of the current geometry shader is
184 * TRIANGLES_ADJACENCY_ARB and <mode> is not
185 * TRIANGLES_ADJACENCY_ARB or TRIANGLE_STRIP_ADJACENCY_ARB.
188 if (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]) {
189 const GLenum geom_mode
=
190 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]->Geom
.InputType
;
193 valid_enum
= (geom_mode
== GL_POINTS
);
198 valid_enum
= (geom_mode
== GL_LINES
);
201 case GL_TRIANGLE_STRIP
:
202 case GL_TRIANGLE_FAN
:
203 valid_enum
= (geom_mode
== GL_TRIANGLES
);
210 case GL_LINES_ADJACENCY
:
211 case GL_LINE_STRIP_ADJACENCY
:
212 valid_enum
= (geom_mode
== GL_LINES_ADJACENCY
);
214 case GL_TRIANGLES_ADJACENCY
:
215 case GL_TRIANGLE_STRIP_ADJACENCY
:
216 valid_enum
= (geom_mode
== GL_TRIANGLES_ADJACENCY
);
223 _mesa_error(ctx
, GL_INVALID_OPERATION
,
224 "%s(mode=%s vs geometry shader input %s)",
226 _mesa_lookup_prim_by_nr(mode
),
227 _mesa_lookup_prim_by_nr(geom_mode
));
232 /* From the GL_EXT_transform_feedback spec:
234 * "The error INVALID_OPERATION is generated if Begin, or any command
235 * that performs an explicit Begin, is called when:
237 * * a geometry shader is not active and <mode> does not match the
238 * allowed begin modes for the current transform feedback state as
239 * given by table X.1.
241 * * a geometry shader is active and the output primitive type of the
242 * geometry shader does not match the allowed begin modes for the
243 * current transform feedback state as given by table X.1.
246 if (_mesa_is_xfb_active_and_unpaused(ctx
)) {
247 GLboolean pass
= GL_TRUE
;
249 if(ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]) {
250 switch (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]->Geom
.OutputType
) {
252 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
255 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
257 case GL_TRIANGLE_STRIP
:
258 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
267 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
272 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
275 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
280 _mesa_error(ctx
, GL_INVALID_OPERATION
,
281 "%s(mode=%s vs transform feedback %s)",
283 _mesa_lookup_prim_by_nr(mode
),
284 _mesa_lookup_prim_by_nr(ctx
->TransformFeedback
.Mode
));
293 * Verify that the element type is valid.
295 * Generates \c GL_INVALID_ENUM and returns \c false if it is not.
298 valid_elements_type(struct gl_context
*ctx
, GLenum type
, const char *name
)
301 case GL_UNSIGNED_BYTE
:
302 case GL_UNSIGNED_SHORT
:
303 case GL_UNSIGNED_INT
:
307 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(type = %s)", name
,
308 _mesa_lookup_enum_by_nr(type
));
314 * Error checking for glDrawElements(). Includes parameter checking
315 * and VBO bounds checking.
316 * \return GL_TRUE if OK to render, GL_FALSE if error found
319 _mesa_validate_DrawElements(struct gl_context
*ctx
,
320 GLenum mode
, GLsizei count
, GLenum type
,
321 const GLvoid
*indices
, GLint basevertex
)
323 FLUSH_CURRENT(ctx
, 0);
325 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
326 * Primitive Capture):
328 * The error INVALID_OPERATION is also generated by DrawElements,
329 * DrawElementsInstanced, and DrawRangeElements while transform feedback
330 * is active and not paused, regardless of mode.
332 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
333 _mesa_error(ctx
, GL_INVALID_OPERATION
,
334 "glDrawElements(transform feedback active)");
339 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawElements(count)" );
343 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawElements")) {
347 if (!valid_elements_type(ctx
, type
, "glDrawElements"))
350 if (!check_valid_to_render(ctx
, "glDrawElements"))
353 /* Vertex buffer object tests */
354 if (_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
355 /* use indices in the buffer object */
356 /* make sure count doesn't go outside buffer bounds */
357 if (index_bytes(type
, count
) > ctx
->Array
.VAO
->IndexBufferObj
->Size
) {
358 _mesa_warning(ctx
, "glDrawElements index out of buffer bounds");
363 /* not using a VBO */
376 * Error checking for glMultiDrawElements(). Includes parameter checking
377 * and VBO bounds checking.
378 * \return GL_TRUE if OK to render, GL_FALSE if error found
381 _mesa_validate_MultiDrawElements(struct gl_context
*ctx
,
382 GLenum mode
, const GLsizei
*count
,
383 GLenum type
, const GLvoid
* const *indices
,
384 GLuint primcount
, const GLint
*basevertex
)
388 FLUSH_CURRENT(ctx
, 0);
390 for (i
= 0; i
< primcount
; i
++) {
392 _mesa_error(ctx
, GL_INVALID_VALUE
,
393 "glMultiDrawElements(count)" );
398 if (!_mesa_valid_prim_mode(ctx
, mode
, "glMultiDrawElements")) {
402 if (!valid_elements_type(ctx
, type
, "glMultiDrawElements"))
405 if (!check_valid_to_render(ctx
, "glMultiDrawElements"))
408 /* Vertex buffer object tests */
409 if (_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
410 /* use indices in the buffer object */
411 /* make sure count doesn't go outside buffer bounds */
412 for (i
= 0; i
< primcount
; i
++) {
413 if (index_bytes(type
, count
[i
]) >
414 ctx
->Array
.VAO
->IndexBufferObj
->Size
) {
416 "glMultiDrawElements index out of buffer bounds");
422 /* not using a VBO */
423 for (i
= 0; i
< primcount
; i
++) {
434 * Error checking for glDrawRangeElements(). Includes parameter checking
435 * and VBO bounds checking.
436 * \return GL_TRUE if OK to render, GL_FALSE if error found
439 _mesa_validate_DrawRangeElements(struct gl_context
*ctx
, GLenum mode
,
440 GLuint start
, GLuint end
,
441 GLsizei count
, GLenum type
,
442 const GLvoid
*indices
, GLint basevertex
)
444 FLUSH_CURRENT(ctx
, 0);
446 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
447 * Primitive Capture):
449 * The error INVALID_OPERATION is also generated by DrawElements,
450 * DrawElementsInstanced, and DrawRangeElements while transform feedback
451 * is active and not paused, regardless of mode.
453 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
454 _mesa_error(ctx
, GL_INVALID_OPERATION
,
455 "glDrawElements(transform feedback active)");
460 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawRangeElements(count)" );
464 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawRangeElements")) {
469 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawRangeElements(end<start)");
473 if (!valid_elements_type(ctx
, type
, "glDrawRangeElements"))
476 if (!check_valid_to_render(ctx
, "glDrawRangeElements"))
479 /* Vertex buffer object tests */
480 if (_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
481 /* use indices in the buffer object */
482 /* make sure count doesn't go outside buffer bounds */
483 if (index_bytes(type
, count
) > ctx
->Array
.VAO
->IndexBufferObj
->Size
) {
484 _mesa_warning(ctx
, "glDrawRangeElements index out of buffer bounds");
489 /* not using a VBO */
502 * Called from the tnl module to error check the function parameters and
503 * verify that we really can draw something.
504 * \return GL_TRUE if OK to render, GL_FALSE if error found
507 _mesa_validate_DrawArrays(struct gl_context
*ctx
,
508 GLenum mode
, GLint start
, GLsizei count
)
510 struct gl_transform_feedback_object
*xfb_obj
511 = ctx
->TransformFeedback
.CurrentObject
;
512 FLUSH_CURRENT(ctx
, 0);
515 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawArrays(count)" );
519 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawArrays")) {
523 if (!check_valid_to_render(ctx
, "glDrawArrays"))
526 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
527 * Primitive Capture):
529 * The error INVALID_OPERATION is generated by DrawArrays and
530 * DrawArraysInstanced if recording the vertices of a primitive to the
531 * buffer objects being used for transform feedback purposes would result
532 * in either exceeding the limits of any buffer object’s size, or in
533 * exceeding the end position offset + size − 1, as set by
536 * This is in contrast to the behaviour of desktop GL, where the extra
537 * primitives are silently dropped from the transform feedback buffer.
539 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
540 size_t prim_count
= vbo_count_tessellated_primitives(mode
, count
, 1);
541 if (xfb_obj
->GlesRemainingPrims
< prim_count
) {
542 _mesa_error(ctx
, GL_INVALID_OPERATION
,
543 "glDrawArrays(exceeds transform feedback size)");
546 xfb_obj
->GlesRemainingPrims
-= prim_count
;
557 _mesa_validate_DrawArraysInstanced(struct gl_context
*ctx
, GLenum mode
, GLint first
,
558 GLsizei count
, GLsizei numInstances
)
560 struct gl_transform_feedback_object
*xfb_obj
561 = ctx
->TransformFeedback
.CurrentObject
;
562 FLUSH_CURRENT(ctx
, 0);
565 _mesa_error(ctx
, GL_INVALID_VALUE
,
566 "glDrawArraysInstanced(count=%d)", count
);
571 _mesa_error(ctx
, GL_INVALID_VALUE
,
572 "glDrawArraysInstanced(start=%d)", first
);
576 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawArraysInstanced")) {
580 if (numInstances
<= 0) {
581 if (numInstances
< 0)
582 _mesa_error(ctx
, GL_INVALID_VALUE
,
583 "glDrawArraysInstanced(numInstances=%d)", numInstances
);
587 if (!check_valid_to_render(ctx
, "glDrawArraysInstanced(invalid to render)"))
590 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
591 * Primitive Capture):
593 * The error INVALID_OPERATION is generated by DrawArrays and
594 * DrawArraysInstanced if recording the vertices of a primitive to the
595 * buffer objects being used for transform feedback purposes would result
596 * in either exceeding the limits of any buffer object’s size, or in
597 * exceeding the end position offset + size − 1, as set by
600 * This is in contrast to the behaviour of desktop GL, where the extra
601 * primitives are silently dropped from the transform feedback buffer.
603 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
605 = vbo_count_tessellated_primitives(mode
, count
, numInstances
);
606 if (xfb_obj
->GlesRemainingPrims
< prim_count
) {
607 _mesa_error(ctx
, GL_INVALID_OPERATION
,
608 "glDrawArraysInstanced(exceeds transform feedback size)");
611 xfb_obj
->GlesRemainingPrims
-= prim_count
;
622 _mesa_validate_DrawElementsInstanced(struct gl_context
*ctx
,
623 GLenum mode
, GLsizei count
, GLenum type
,
624 const GLvoid
*indices
, GLsizei numInstances
,
627 FLUSH_CURRENT(ctx
, 0);
629 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
630 * Primitive Capture):
632 * The error INVALID_OPERATION is also generated by DrawElements,
633 * DrawElementsInstanced, and DrawRangeElements while transform feedback
634 * is active and not paused, regardless of mode.
636 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
637 _mesa_error(ctx
, GL_INVALID_OPERATION
,
638 "glDrawElements(transform feedback active)");
643 _mesa_error(ctx
, GL_INVALID_VALUE
,
644 "glDrawElementsInstanced(count=%d)", count
);
648 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawElementsInstanced")) {
652 if (!valid_elements_type(ctx
, type
, "glDrawElementsInstanced"))
655 if (numInstances
<= 0) {
656 if (numInstances
< 0)
657 _mesa_error(ctx
, GL_INVALID_VALUE
,
658 "glDrawElementsInstanced(numInstances=%d)", numInstances
);
662 if (!check_valid_to_render(ctx
, "glDrawElementsInstanced"))
665 /* Vertex buffer object tests */
666 if (_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
667 /* use indices in the buffer object */
668 /* make sure count doesn't go outside buffer bounds */
669 if (index_bytes(type
, count
) > ctx
->Array
.VAO
->IndexBufferObj
->Size
) {
671 "glDrawElementsInstanced index out of buffer bounds");
676 /* not using a VBO */
689 _mesa_validate_DrawTransformFeedback(struct gl_context
*ctx
,
691 struct gl_transform_feedback_object
*obj
,
693 GLsizei numInstances
)
695 FLUSH_CURRENT(ctx
, 0);
697 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawTransformFeedback*(mode)")) {
702 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawTransformFeedback*(name)");
706 if (stream
>= ctx
->Const
.MaxVertexStreams
) {
707 _mesa_error(ctx
, GL_INVALID_VALUE
,
708 "glDrawTransformFeedbackStream*(index>=MaxVertexStream)");
712 if (!obj
->EndedAnytime
) {
713 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawTransformFeedback*");
717 if (numInstances
<= 0) {
718 if (numInstances
< 0)
719 _mesa_error(ctx
, GL_INVALID_VALUE
,
720 "glDrawTransformFeedback*Instanced(numInstances=%d)",
725 if (!check_valid_to_render(ctx
, "glDrawTransformFeedback*")) {
733 valid_draw_indirect(struct gl_context
*ctx
,
734 GLenum mode
, const GLvoid
*indirect
,
735 GLsizei size
, const char *name
)
737 const GLsizeiptr end
= (GLsizeiptr
)indirect
+ size
;
739 if (!_mesa_valid_prim_mode(ctx
, mode
, name
))
743 /* From the ARB_draw_indirect specification:
744 * "An INVALID_OPERATION error is generated [...] if <indirect> is no
747 if ((GLsizeiptr
)indirect
& (sizeof(GLuint
) - 1)) {
748 _mesa_error(ctx
, GL_INVALID_OPERATION
,
749 "%s(indirect is not aligned)", name
);
753 if (!_mesa_is_bufferobj(ctx
->DrawIndirectBuffer
)) {
754 _mesa_error(ctx
, GL_INVALID_OPERATION
,
755 "%s: no buffer bound to DRAW_INDIRECT_BUFFER", name
);
759 if (_mesa_check_disallowed_mapping(ctx
->DrawIndirectBuffer
)) {
760 _mesa_error(ctx
, GL_INVALID_OPERATION
,
761 "%s(DRAW_INDIRECT_BUFFER is mapped)", name
);
765 /* From the ARB_draw_indirect specification:
766 * "An INVALID_OPERATION error is generated if the commands source data
767 * beyond the end of the buffer object [...]"
769 if (ctx
->DrawIndirectBuffer
->Size
< end
) {
770 _mesa_error(ctx
, GL_INVALID_OPERATION
,
771 "%s(DRAW_INDIRECT_BUFFER too small)", name
);
775 if (!check_valid_to_render(ctx
, name
))
781 static inline GLboolean
782 valid_draw_indirect_elements(struct gl_context
*ctx
,
783 GLenum mode
, GLenum type
, const GLvoid
*indirect
,
784 GLsizeiptr size
, const char *name
)
786 if (!valid_elements_type(ctx
, type
, name
))
790 * Unlike regular DrawElementsInstancedBaseVertex commands, the indices
791 * may not come from a client array and must come from an index buffer.
792 * If no element array buffer is bound, an INVALID_OPERATION error is
795 if (!_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
796 _mesa_error(ctx
, GL_INVALID_OPERATION
,
797 "%s(no buffer bound to GL_ELEMENT_ARRAY_BUFFER)", name
);
801 return valid_draw_indirect(ctx
, mode
, indirect
, size
, name
);
804 static inline GLboolean
805 valid_draw_indirect_multi(struct gl_context
*ctx
,
806 GLsizei primcount
, GLsizei stride
,
810 /* From the ARB_multi_draw_indirect specification:
811 * "INVALID_VALUE is generated by MultiDrawArraysIndirect or
812 * MultiDrawElementsIndirect if <primcount> is negative."
814 * "<primcount> must be positive, otherwise an INVALID_VALUE error will
818 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(primcount < 0)", name
);
823 /* From the ARB_multi_draw_indirect specification:
824 * "<stride> must be a multiple of four, otherwise an INVALID_VALUE
825 * error is generated."
828 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(stride %% 4)", name
);
836 _mesa_validate_DrawArraysIndirect(struct gl_context
*ctx
,
838 const GLvoid
*indirect
)
840 const unsigned drawArraysNumParams
= 4;
842 FLUSH_CURRENT(ctx
, 0);
844 return valid_draw_indirect(ctx
, mode
,
845 indirect
, drawArraysNumParams
* sizeof(GLuint
),
846 "glDrawArraysIndirect");
850 _mesa_validate_DrawElementsIndirect(struct gl_context
*ctx
,
851 GLenum mode
, GLenum type
,
852 const GLvoid
*indirect
)
854 const unsigned drawElementsNumParams
= 5;
856 FLUSH_CURRENT(ctx
, 0);
858 return valid_draw_indirect_elements(ctx
, mode
, type
,
859 indirect
, drawElementsNumParams
* sizeof(GLuint
),
860 "glDrawElementsIndirect");
864 _mesa_validate_MultiDrawArraysIndirect(struct gl_context
*ctx
,
866 const GLvoid
*indirect
,
867 GLsizei primcount
, GLsizei stride
)
870 const unsigned drawArraysNumParams
= 4;
872 FLUSH_CURRENT(ctx
, 0);
874 /* caller has converted stride==0 to drawArraysNumParams * sizeof(GLuint) */
877 if (!valid_draw_indirect_multi(ctx
, primcount
, stride
,
878 "glMultiDrawArraysIndirect"))
881 /* number of bytes of the indirect buffer which will be read */
883 ? (primcount
- 1) * stride
+ drawArraysNumParams
* sizeof(GLuint
)
886 if (!valid_draw_indirect(ctx
, mode
, indirect
, size
,
887 "glMultiDrawArraysIndirect"))
894 _mesa_validate_MultiDrawElementsIndirect(struct gl_context
*ctx
,
895 GLenum mode
, GLenum type
,
896 const GLvoid
*indirect
,
897 GLsizei primcount
, GLsizei stride
)
900 const unsigned drawElementsNumParams
= 5;
902 FLUSH_CURRENT(ctx
, 0);
904 /* caller has converted stride==0 to drawElementsNumParams * sizeof(GLuint) */
907 if (!valid_draw_indirect_multi(ctx
, primcount
, stride
,
908 "glMultiDrawElementsIndirect"))
911 /* number of bytes of the indirect buffer which will be read */
913 ? (primcount
- 1) * stride
+ drawElementsNumParams
* sizeof(GLuint
)
916 if (!valid_draw_indirect_elements(ctx
, mode
, type
,
918 "glMultiDrawElementsIndirect"))