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 /* Section 10.4 (Drawing Commands Using Vertex Arrays) of the OpenGL 4.5
83 * Core Profile spec says:
85 * "An INVALID_OPERATION error is generated if no vertex array
86 * object is bound (see section 10.3.1)."
88 if (ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
89 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(no VAO bound)", function
);
93 case API_OPENGL_COMPAT
:
95 const struct gl_shader_program
*vsProg
=
96 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_VERTEX
];
97 GLboolean haveVertexShader
= (vsProg
&& vsProg
->LinkStatus
);
98 GLboolean haveVertexProgram
= ctx
->VertexProgram
._Enabled
;
99 if (haveVertexShader
|| haveVertexProgram
) {
100 /* Draw regardless of whether or not we have any vertex arrays.
101 * (Ex: could draw a point using a constant vertex pos)
106 /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic
109 return (ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
||
110 ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
);
116 assert(!"Invalid API value in check_valid_to_render()");
124 * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
125 * etc? The set of legal values depends on whether geometry shaders/programs
127 * Note: This may be called during display list compilation.
130 _mesa_is_valid_prim_mode(struct gl_context
*ctx
, GLenum mode
)
138 case GL_TRIANGLE_STRIP
:
139 case GL_TRIANGLE_FAN
:
144 return (ctx
->API
== API_OPENGL_COMPAT
);
145 case GL_LINES_ADJACENCY
:
146 case GL_LINE_STRIP_ADJACENCY
:
147 case GL_TRIANGLES_ADJACENCY
:
148 case GL_TRIANGLE_STRIP_ADJACENCY
:
149 return _mesa_has_geometry_shaders(ctx
);
157 * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
158 * etc? Also, do additional checking related to transformation feedback.
159 * Note: this function cannot be called during glNewList(GL_COMPILE) because
160 * this code depends on current transform feedback state.
163 _mesa_valid_prim_mode(struct gl_context
*ctx
, GLenum mode
, const char *name
)
165 bool valid_enum
= _mesa_is_valid_prim_mode(ctx
, mode
);
168 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(mode=%x)", name
, mode
);
172 /* From the ARB_geometry_shader4 spec:
174 * The error INVALID_OPERATION is generated if Begin, or any command that
175 * implicitly calls Begin, is called when a geometry shader is active and:
177 * * the input primitive type of the current geometry shader is
178 * POINTS and <mode> is not POINTS,
180 * * the input primitive type of the current geometry shader is
181 * LINES and <mode> is not LINES, LINE_STRIP, or LINE_LOOP,
183 * * the input primitive type of the current geometry shader is
184 * TRIANGLES and <mode> is not TRIANGLES, TRIANGLE_STRIP or
187 * * the input primitive type of the current geometry shader is
188 * LINES_ADJACENCY_ARB and <mode> is not LINES_ADJACENCY_ARB or
189 * LINE_STRIP_ADJACENCY_ARB, or
191 * * the input primitive type of the current geometry shader is
192 * TRIANGLES_ADJACENCY_ARB and <mode> is not
193 * TRIANGLES_ADJACENCY_ARB or TRIANGLE_STRIP_ADJACENCY_ARB.
196 if (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]) {
197 const GLenum geom_mode
=
198 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]->Geom
.InputType
;
201 valid_enum
= (geom_mode
== GL_POINTS
);
206 valid_enum
= (geom_mode
== GL_LINES
);
209 case GL_TRIANGLE_STRIP
:
210 case GL_TRIANGLE_FAN
:
211 valid_enum
= (geom_mode
== GL_TRIANGLES
);
218 case GL_LINES_ADJACENCY
:
219 case GL_LINE_STRIP_ADJACENCY
:
220 valid_enum
= (geom_mode
== GL_LINES_ADJACENCY
);
222 case GL_TRIANGLES_ADJACENCY
:
223 case GL_TRIANGLE_STRIP_ADJACENCY
:
224 valid_enum
= (geom_mode
== GL_TRIANGLES_ADJACENCY
);
231 _mesa_error(ctx
, GL_INVALID_OPERATION
,
232 "%s(mode=%s vs geometry shader input %s)",
234 _mesa_lookup_prim_by_nr(mode
),
235 _mesa_lookup_prim_by_nr(geom_mode
));
240 /* From the GL_EXT_transform_feedback spec:
242 * "The error INVALID_OPERATION is generated if Begin, or any command
243 * that performs an explicit Begin, is called when:
245 * * a geometry shader is not active and <mode> does not match the
246 * allowed begin modes for the current transform feedback state as
247 * given by table X.1.
249 * * a geometry shader is active and the output primitive type of the
250 * geometry shader does not match the allowed begin modes for the
251 * current transform feedback state as given by table X.1.
254 if (_mesa_is_xfb_active_and_unpaused(ctx
)) {
255 GLboolean pass
= GL_TRUE
;
257 if(ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]) {
258 switch (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]->Geom
.OutputType
) {
260 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
263 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
265 case GL_TRIANGLE_STRIP
:
266 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
275 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
280 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
283 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
288 _mesa_error(ctx
, GL_INVALID_OPERATION
,
289 "%s(mode=%s vs transform feedback %s)",
291 _mesa_lookup_prim_by_nr(mode
),
292 _mesa_lookup_prim_by_nr(ctx
->TransformFeedback
.Mode
));
301 * Verify that the element type is valid.
303 * Generates \c GL_INVALID_ENUM and returns \c false if it is not.
306 valid_elements_type(struct gl_context
*ctx
, GLenum type
, const char *name
)
309 case GL_UNSIGNED_BYTE
:
310 case GL_UNSIGNED_SHORT
:
311 case GL_UNSIGNED_INT
:
315 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(type = %s)", name
,
316 _mesa_lookup_enum_by_nr(type
));
322 * Error checking for glDrawElements(). Includes parameter checking
323 * and VBO bounds checking.
324 * \return GL_TRUE if OK to render, GL_FALSE if error found
327 _mesa_validate_DrawElements(struct gl_context
*ctx
,
328 GLenum mode
, GLsizei count
, GLenum type
,
329 const GLvoid
*indices
, GLint basevertex
)
331 FLUSH_CURRENT(ctx
, 0);
333 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
334 * Primitive Capture):
336 * The error INVALID_OPERATION is also generated by DrawElements,
337 * DrawElementsInstanced, and DrawRangeElements while transform feedback
338 * is active and not paused, regardless of mode.
340 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
341 _mesa_error(ctx
, GL_INVALID_OPERATION
,
342 "glDrawElements(transform feedback active)");
347 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawElements(count)" );
351 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawElements")) {
355 if (!valid_elements_type(ctx
, type
, "glDrawElements"))
358 if (!check_valid_to_render(ctx
, "glDrawElements"))
361 /* Vertex buffer object tests */
362 if (_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
363 /* use indices in the buffer object */
364 /* make sure count doesn't go outside buffer bounds */
365 if (index_bytes(type
, count
) > ctx
->Array
.VAO
->IndexBufferObj
->Size
) {
366 _mesa_warning(ctx
, "glDrawElements index out of buffer bounds");
371 /* not using a VBO */
384 * Error checking for glMultiDrawElements(). Includes parameter checking
385 * and VBO bounds checking.
386 * \return GL_TRUE if OK to render, GL_FALSE if error found
389 _mesa_validate_MultiDrawElements(struct gl_context
*ctx
,
390 GLenum mode
, const GLsizei
*count
,
391 GLenum type
, const GLvoid
* const *indices
,
392 GLuint primcount
, const GLint
*basevertex
)
396 FLUSH_CURRENT(ctx
, 0);
398 for (i
= 0; i
< primcount
; i
++) {
400 _mesa_error(ctx
, GL_INVALID_VALUE
,
401 "glMultiDrawElements(count)" );
406 if (!_mesa_valid_prim_mode(ctx
, mode
, "glMultiDrawElements")) {
410 if (!valid_elements_type(ctx
, type
, "glMultiDrawElements"))
413 if (!check_valid_to_render(ctx
, "glMultiDrawElements"))
416 /* Vertex buffer object tests */
417 if (_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
418 /* use indices in the buffer object */
419 /* make sure count doesn't go outside buffer bounds */
420 for (i
= 0; i
< primcount
; i
++) {
421 if (index_bytes(type
, count
[i
]) >
422 ctx
->Array
.VAO
->IndexBufferObj
->Size
) {
424 "glMultiDrawElements index out of buffer bounds");
430 /* not using a VBO */
431 for (i
= 0; i
< primcount
; i
++) {
442 * Error checking for glDrawRangeElements(). Includes parameter checking
443 * and VBO bounds checking.
444 * \return GL_TRUE if OK to render, GL_FALSE if error found
447 _mesa_validate_DrawRangeElements(struct gl_context
*ctx
, GLenum mode
,
448 GLuint start
, GLuint end
,
449 GLsizei count
, GLenum type
,
450 const GLvoid
*indices
, GLint basevertex
)
452 FLUSH_CURRENT(ctx
, 0);
454 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
455 * Primitive Capture):
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.
461 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
462 _mesa_error(ctx
, GL_INVALID_OPERATION
,
463 "glDrawElements(transform feedback active)");
468 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawRangeElements(count)" );
472 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawRangeElements")) {
477 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawRangeElements(end<start)");
481 if (!valid_elements_type(ctx
, type
, "glDrawRangeElements"))
484 if (!check_valid_to_render(ctx
, "glDrawRangeElements"))
487 /* Vertex buffer object tests */
488 if (_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
489 /* use indices in the buffer object */
490 /* make sure count doesn't go outside buffer bounds */
491 if (index_bytes(type
, count
) > ctx
->Array
.VAO
->IndexBufferObj
->Size
) {
492 _mesa_warning(ctx
, "glDrawRangeElements index out of buffer bounds");
497 /* not using a VBO */
510 * Called from the tnl module to error check the function parameters and
511 * verify that we really can draw something.
512 * \return GL_TRUE if OK to render, GL_FALSE if error found
515 _mesa_validate_DrawArrays(struct gl_context
*ctx
,
516 GLenum mode
, GLint start
, GLsizei count
)
518 struct gl_transform_feedback_object
*xfb_obj
519 = ctx
->TransformFeedback
.CurrentObject
;
520 FLUSH_CURRENT(ctx
, 0);
523 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawArrays(count)" );
527 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawArrays")) {
531 if (!check_valid_to_render(ctx
, "glDrawArrays"))
534 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
535 * Primitive Capture):
537 * The error INVALID_OPERATION is generated by DrawArrays and
538 * DrawArraysInstanced if recording the vertices of a primitive to the
539 * buffer objects being used for transform feedback purposes would result
540 * in either exceeding the limits of any buffer object’s size, or in
541 * exceeding the end position offset + size − 1, as set by
544 * This is in contrast to the behaviour of desktop GL, where the extra
545 * primitives are silently dropped from the transform feedback buffer.
547 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
548 size_t prim_count
= vbo_count_tessellated_primitives(mode
, count
, 1);
549 if (xfb_obj
->GlesRemainingPrims
< prim_count
) {
550 _mesa_error(ctx
, GL_INVALID_OPERATION
,
551 "glDrawArrays(exceeds transform feedback size)");
554 xfb_obj
->GlesRemainingPrims
-= prim_count
;
565 _mesa_validate_DrawArraysInstanced(struct gl_context
*ctx
, GLenum mode
, GLint first
,
566 GLsizei count
, GLsizei numInstances
)
568 struct gl_transform_feedback_object
*xfb_obj
569 = ctx
->TransformFeedback
.CurrentObject
;
570 FLUSH_CURRENT(ctx
, 0);
573 _mesa_error(ctx
, GL_INVALID_VALUE
,
574 "glDrawArraysInstanced(count=%d)", count
);
579 _mesa_error(ctx
, GL_INVALID_VALUE
,
580 "glDrawArraysInstanced(start=%d)", first
);
584 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawArraysInstanced")) {
588 if (numInstances
<= 0) {
589 if (numInstances
< 0)
590 _mesa_error(ctx
, GL_INVALID_VALUE
,
591 "glDrawArraysInstanced(numInstances=%d)", numInstances
);
595 if (!check_valid_to_render(ctx
, "glDrawArraysInstanced(invalid to render)"))
598 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
599 * Primitive Capture):
601 * The error INVALID_OPERATION is generated by DrawArrays and
602 * DrawArraysInstanced if recording the vertices of a primitive to the
603 * buffer objects being used for transform feedback purposes would result
604 * in either exceeding the limits of any buffer object’s size, or in
605 * exceeding the end position offset + size − 1, as set by
608 * This is in contrast to the behaviour of desktop GL, where the extra
609 * primitives are silently dropped from the transform feedback buffer.
611 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
613 = vbo_count_tessellated_primitives(mode
, count
, numInstances
);
614 if (xfb_obj
->GlesRemainingPrims
< prim_count
) {
615 _mesa_error(ctx
, GL_INVALID_OPERATION
,
616 "glDrawArraysInstanced(exceeds transform feedback size)");
619 xfb_obj
->GlesRemainingPrims
-= prim_count
;
630 _mesa_validate_DrawElementsInstanced(struct gl_context
*ctx
,
631 GLenum mode
, GLsizei count
, GLenum type
,
632 const GLvoid
*indices
, GLsizei numInstances
,
635 FLUSH_CURRENT(ctx
, 0);
637 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
638 * Primitive Capture):
640 * The error INVALID_OPERATION is also generated by DrawElements,
641 * DrawElementsInstanced, and DrawRangeElements while transform feedback
642 * is active and not paused, regardless of mode.
644 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
645 _mesa_error(ctx
, GL_INVALID_OPERATION
,
646 "glDrawElements(transform feedback active)");
651 _mesa_error(ctx
, GL_INVALID_VALUE
,
652 "glDrawElementsInstanced(count=%d)", count
);
656 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawElementsInstanced")) {
660 if (!valid_elements_type(ctx
, type
, "glDrawElementsInstanced"))
663 if (numInstances
<= 0) {
664 if (numInstances
< 0)
665 _mesa_error(ctx
, GL_INVALID_VALUE
,
666 "glDrawElementsInstanced(numInstances=%d)", numInstances
);
670 if (!check_valid_to_render(ctx
, "glDrawElementsInstanced"))
673 /* Vertex buffer object tests */
674 if (_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
675 /* use indices in the buffer object */
676 /* make sure count doesn't go outside buffer bounds */
677 if (index_bytes(type
, count
) > ctx
->Array
.VAO
->IndexBufferObj
->Size
) {
679 "glDrawElementsInstanced index out of buffer bounds");
684 /* not using a VBO */
697 _mesa_validate_DrawTransformFeedback(struct gl_context
*ctx
,
699 struct gl_transform_feedback_object
*obj
,
701 GLsizei numInstances
)
703 FLUSH_CURRENT(ctx
, 0);
705 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawTransformFeedback*(mode)")) {
710 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawTransformFeedback*(name)");
714 if (stream
>= ctx
->Const
.MaxVertexStreams
) {
715 _mesa_error(ctx
, GL_INVALID_VALUE
,
716 "glDrawTransformFeedbackStream*(index>=MaxVertexStream)");
720 if (!obj
->EndedAnytime
) {
721 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawTransformFeedback*");
725 if (numInstances
<= 0) {
726 if (numInstances
< 0)
727 _mesa_error(ctx
, GL_INVALID_VALUE
,
728 "glDrawTransformFeedback*Instanced(numInstances=%d)",
733 if (!check_valid_to_render(ctx
, "glDrawTransformFeedback*")) {
741 valid_draw_indirect(struct gl_context
*ctx
,
742 GLenum mode
, const GLvoid
*indirect
,
743 GLsizei size
, const char *name
)
745 const GLsizeiptr end
= (GLsizeiptr
)indirect
+ size
;
747 if (!_mesa_valid_prim_mode(ctx
, mode
, name
))
751 /* From the ARB_draw_indirect specification:
752 * "An INVALID_OPERATION error is generated [...] if <indirect> is no
755 if ((GLsizeiptr
)indirect
& (sizeof(GLuint
) - 1)) {
756 _mesa_error(ctx
, GL_INVALID_OPERATION
,
757 "%s(indirect is not aligned)", name
);
761 if (!_mesa_is_bufferobj(ctx
->DrawIndirectBuffer
)) {
762 _mesa_error(ctx
, GL_INVALID_OPERATION
,
763 "%s: no buffer bound to DRAW_INDIRECT_BUFFER", name
);
767 if (_mesa_check_disallowed_mapping(ctx
->DrawIndirectBuffer
)) {
768 _mesa_error(ctx
, GL_INVALID_OPERATION
,
769 "%s(DRAW_INDIRECT_BUFFER is mapped)", name
);
773 /* From the ARB_draw_indirect specification:
774 * "An INVALID_OPERATION error is generated if the commands source data
775 * beyond the end of the buffer object [...]"
777 if (ctx
->DrawIndirectBuffer
->Size
< end
) {
778 _mesa_error(ctx
, GL_INVALID_OPERATION
,
779 "%s(DRAW_INDIRECT_BUFFER too small)", name
);
783 if (!check_valid_to_render(ctx
, name
))
789 static inline GLboolean
790 valid_draw_indirect_elements(struct gl_context
*ctx
,
791 GLenum mode
, GLenum type
, const GLvoid
*indirect
,
792 GLsizeiptr size
, const char *name
)
794 if (!valid_elements_type(ctx
, type
, name
))
798 * Unlike regular DrawElementsInstancedBaseVertex commands, the indices
799 * may not come from a client array and must come from an index buffer.
800 * If no element array buffer is bound, an INVALID_OPERATION error is
803 if (!_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
804 _mesa_error(ctx
, GL_INVALID_OPERATION
,
805 "%s(no buffer bound to GL_ELEMENT_ARRAY_BUFFER)", name
);
809 return valid_draw_indirect(ctx
, mode
, indirect
, size
, name
);
812 static inline GLboolean
813 valid_draw_indirect_multi(struct gl_context
*ctx
,
814 GLsizei primcount
, GLsizei stride
,
818 /* From the ARB_multi_draw_indirect specification:
819 * "INVALID_VALUE is generated by MultiDrawArraysIndirect or
820 * MultiDrawElementsIndirect if <primcount> is negative."
822 * "<primcount> must be positive, otherwise an INVALID_VALUE error will
826 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(primcount < 0)", name
);
831 /* From the ARB_multi_draw_indirect specification:
832 * "<stride> must be a multiple of four, otherwise an INVALID_VALUE
833 * error is generated."
836 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(stride %% 4)", name
);
844 _mesa_validate_DrawArraysIndirect(struct gl_context
*ctx
,
846 const GLvoid
*indirect
)
848 const unsigned drawArraysNumParams
= 4;
850 FLUSH_CURRENT(ctx
, 0);
852 return valid_draw_indirect(ctx
, mode
,
853 indirect
, drawArraysNumParams
* sizeof(GLuint
),
854 "glDrawArraysIndirect");
858 _mesa_validate_DrawElementsIndirect(struct gl_context
*ctx
,
859 GLenum mode
, GLenum type
,
860 const GLvoid
*indirect
)
862 const unsigned drawElementsNumParams
= 5;
864 FLUSH_CURRENT(ctx
, 0);
866 return valid_draw_indirect_elements(ctx
, mode
, type
,
867 indirect
, drawElementsNumParams
* sizeof(GLuint
),
868 "glDrawElementsIndirect");
872 _mesa_validate_MultiDrawArraysIndirect(struct gl_context
*ctx
,
874 const GLvoid
*indirect
,
875 GLsizei primcount
, GLsizei stride
)
878 const unsigned drawArraysNumParams
= 4;
880 FLUSH_CURRENT(ctx
, 0);
882 /* caller has converted stride==0 to drawArraysNumParams * sizeof(GLuint) */
885 if (!valid_draw_indirect_multi(ctx
, primcount
, stride
,
886 "glMultiDrawArraysIndirect"))
889 /* number of bytes of the indirect buffer which will be read */
891 ? (primcount
- 1) * stride
+ drawArraysNumParams
* sizeof(GLuint
)
894 if (!valid_draw_indirect(ctx
, mode
, indirect
, size
,
895 "glMultiDrawArraysIndirect"))
902 _mesa_validate_MultiDrawElementsIndirect(struct gl_context
*ctx
,
903 GLenum mode
, GLenum type
,
904 const GLvoid
*indirect
,
905 GLsizei primcount
, GLsizei stride
)
908 const unsigned drawElementsNumParams
= 5;
910 FLUSH_CURRENT(ctx
, 0);
912 /* caller has converted stride==0 to drawElementsNumParams * sizeof(GLuint) */
915 if (!valid_draw_indirect_multi(ctx
, primcount
, stride
,
916 "glMultiDrawElementsIndirect"))
919 /* number of bytes of the indirect buffer which will be read */
921 ? (primcount
- 1) * stride
+ drawElementsNumParams
* sizeof(GLuint
)
924 if (!valid_draw_indirect_elements(ctx
, mode
, type
,
926 "glMultiDrawElementsIndirect"))