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 * Check if OK to draw arrays/elements.
42 check_valid_to_render(struct gl_context
*ctx
, const char *function
)
44 if (!_mesa_valid_to_render(ctx
, function
)) {
50 /* For ES2, we can draw if we have a vertex program/shader). */
51 return ctx
->VertexProgram
._Current
!= NULL
;
54 /* For OpenGL ES, only draw if we have vertex positions
56 if (!ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
)
61 /* Section 10.4 (Drawing Commands Using Vertex Arrays) of the OpenGL 4.5
62 * Core Profile spec says:
64 * "An INVALID_OPERATION error is generated if no vertex array
65 * object is bound (see section 10.3.1)."
67 if (ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
68 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(no VAO bound)", function
);
72 /* The spec argues that this is allowed because a tess ctrl shader
73 * without a tess eval shader can be used with transform feedback.
74 * However, glBeginTransformFeedback doesn't allow GL_PATCHES and
75 * therefore doesn't allow tessellation.
77 * Further investigation showed that this is indeed a spec bug and
78 * a tess ctrl shader without a tess eval shader shouldn't have been
79 * allowed, because there is no API in GL 4.0 that can make use this
80 * to produce something useful.
82 * Also, all vendors except one don't support a tess ctrl shader without
83 * a tess eval shader anyway.
85 if (ctx
->TessCtrlProgram
._Current
&& !ctx
->TessEvalProgram
._Current
) {
86 _mesa_error(ctx
, GL_INVALID_OPERATION
,
87 "%s(tess eval shader is missing)", function
);
91 /* Section 7.3 (Program Objects) of the OpenGL 4.5 Core Profile spec
94 * "If there is no active program for the vertex or fragment shader
95 * stages, the results of vertex and/or fragment processing will be
96 * undefined. However, this is not an error."
98 * The fragment shader is not tested here because other state (e.g.,
99 * GL_RASTERIZER_DISCARD) affects whether or not we actually care.
101 return ctx
->VertexProgram
._Current
!= NULL
;
103 case API_OPENGL_COMPAT
:
104 if (ctx
->VertexProgram
._Current
!= NULL
) {
105 /* Draw regardless of whether or not we have any vertex arrays.
106 * (Ex: could draw a point using a constant vertex pos)
110 /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic
113 return (ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
||
114 ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
);
119 unreachable("Invalid API value in check_valid_to_render()");
127 * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
128 * etc? The set of legal values depends on whether geometry shaders/programs
130 * Note: This may be called during display list compilation.
133 _mesa_is_valid_prim_mode(struct gl_context
*ctx
, GLenum mode
)
135 /* The overwhelmingly common case is (mode <= GL_TRIANGLE_FAN). Test that
136 * first and exit. You would think that a switch-statement would be the
137 * right approach, but at least GCC 4.7.2 generates some pretty dire code
138 * for the common case.
140 if (likely(mode
<= GL_TRIANGLE_FAN
))
143 if (mode
<= GL_POLYGON
)
144 return (ctx
->API
== API_OPENGL_COMPAT
);
146 if (mode
<= GL_TRIANGLE_STRIP_ADJACENCY
)
147 return _mesa_has_geometry_shaders(ctx
);
149 if (mode
== GL_PATCHES
)
150 return _mesa_has_tessellation(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.
161 * Also, do additional checking related to tessellation shaders.
164 _mesa_valid_prim_mode(struct gl_context
*ctx
, GLenum mode
, const char *name
)
166 bool valid_enum
= _mesa_is_valid_prim_mode(ctx
, mode
);
169 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(mode=%x)", name
, mode
);
173 /* From the ARB_geometry_shader4 spec:
175 * The error INVALID_OPERATION is generated if Begin, or any command that
176 * implicitly calls Begin, is called when a geometry shader is active and:
178 * * the input primitive type of the current geometry shader is
179 * POINTS and <mode> is not POINTS,
181 * * the input primitive type of the current geometry shader is
182 * LINES and <mode> is not LINES, LINE_STRIP, or LINE_LOOP,
184 * * the input primitive type of the current geometry shader is
185 * TRIANGLES and <mode> is not TRIANGLES, TRIANGLE_STRIP or
188 * * the input primitive type of the current geometry shader is
189 * LINES_ADJACENCY_ARB and <mode> is not LINES_ADJACENCY_ARB or
190 * LINE_STRIP_ADJACENCY_ARB, or
192 * * the input primitive type of the current geometry shader is
193 * TRIANGLES_ADJACENCY_ARB and <mode> is not
194 * TRIANGLES_ADJACENCY_ARB or TRIANGLE_STRIP_ADJACENCY_ARB.
196 * The GL spec doesn't mention any interaction with tessellation, which
197 * is clearly a spec bug. The same rule should apply, but instead of
198 * the draw primitive mode, the tessellation evaluation shader primitive
199 * mode should be used for the checking.
201 if (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]) {
202 const GLenum geom_mode
=
203 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]->Geom
.InputType
;
204 struct gl_shader_program
*tes
=
205 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_EVAL
];
206 GLenum mode_before_gs
= mode
;
209 if (tes
->TessEval
.PointMode
)
210 mode_before_gs
= GL_POINTS
;
211 else if (tes
->TessEval
.PrimitiveMode
== GL_ISOLINES
)
212 mode_before_gs
= GL_LINES
;
214 /* the GL_QUADS mode generates triangles too */
215 mode_before_gs
= GL_TRIANGLES
;
218 switch (mode_before_gs
) {
220 valid_enum
= (geom_mode
== GL_POINTS
);
225 valid_enum
= (geom_mode
== GL_LINES
);
228 case GL_TRIANGLE_STRIP
:
229 case GL_TRIANGLE_FAN
:
230 valid_enum
= (geom_mode
== GL_TRIANGLES
);
237 case GL_LINES_ADJACENCY
:
238 case GL_LINE_STRIP_ADJACENCY
:
239 valid_enum
= (geom_mode
== GL_LINES_ADJACENCY
);
241 case GL_TRIANGLES_ADJACENCY
:
242 case GL_TRIANGLE_STRIP_ADJACENCY
:
243 valid_enum
= (geom_mode
== GL_TRIANGLES_ADJACENCY
);
250 _mesa_error(ctx
, GL_INVALID_OPERATION
,
251 "%s(mode=%s vs geometry shader input %s)",
253 _mesa_lookup_prim_by_nr(mode_before_gs
),
254 _mesa_lookup_prim_by_nr(geom_mode
));
259 /* From the OpenGL 4.0 (Core Profile) spec (section 2.12):
261 * "Tessellation operates only on patch primitives. If tessellation is
262 * active, any command that transfers vertices to the GL will
263 * generate an INVALID_OPERATION error if the primitive mode is not
265 * Patch primitives are not supported by pipeline stages below the
266 * tessellation evaluation shader. If there is no active program
267 * object or the active program object does not contain a tessellation
268 * evaluation shader, the error INVALID_OPERATION is generated by any
269 * command that transfers vertices to the GL if the primitive mode is
273 if (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_EVAL
] ||
274 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_CTRL
]) {
275 if (mode
!= GL_PATCHES
) {
276 _mesa_error(ctx
, GL_INVALID_OPERATION
,
277 "only GL_PATCHES valid with tessellation");
282 if (mode
== GL_PATCHES
) {
283 _mesa_error(ctx
, GL_INVALID_OPERATION
,
284 "GL_PATCHES only valid with tessellation");
289 /* From the GL_EXT_transform_feedback spec:
291 * "The error INVALID_OPERATION is generated if Begin, or any command
292 * that performs an explicit Begin, is called when:
294 * * a geometry shader is not active and <mode> does not match the
295 * allowed begin modes for the current transform feedback state as
296 * given by table X.1.
298 * * a geometry shader is active and the output primitive type of the
299 * geometry shader does not match the allowed begin modes for the
300 * current transform feedback state as given by table X.1.
303 if (_mesa_is_xfb_active_and_unpaused(ctx
)) {
304 GLboolean pass
= GL_TRUE
;
306 if(ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]) {
307 switch (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]->Geom
.OutputType
) {
309 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
312 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
314 case GL_TRIANGLE_STRIP
:
315 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
321 else if (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_EVAL
]) {
322 struct gl_shader_program
*tes
=
323 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_EVAL
];
325 if (tes
->TessEval
.PointMode
)
326 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
327 else if (tes
->TessEval
.PrimitiveMode
== GL_ISOLINES
)
328 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
330 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
335 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
340 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
343 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
348 _mesa_error(ctx
, GL_INVALID_OPERATION
,
349 "%s(mode=%s vs transform feedback %s)",
351 _mesa_lookup_prim_by_nr(mode
),
352 _mesa_lookup_prim_by_nr(ctx
->TransformFeedback
.Mode
));
361 * Verify that the element type is valid.
363 * Generates \c GL_INVALID_ENUM and returns \c false if it is not.
366 valid_elements_type(struct gl_context
*ctx
, GLenum type
, const char *name
)
369 case GL_UNSIGNED_BYTE
:
370 case GL_UNSIGNED_SHORT
:
371 case GL_UNSIGNED_INT
:
375 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(type = %s)", name
,
376 _mesa_enum_to_string(type
));
382 validate_DrawElements_common(struct gl_context
*ctx
,
383 GLenum mode
, GLsizei count
, GLenum type
,
384 const GLvoid
*indices
,
387 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
388 * Primitive Capture):
390 * The error INVALID_OPERATION is also generated by DrawElements,
391 * DrawElementsInstanced, and DrawRangeElements while transform feedback
392 * is active and not paused, regardless of mode.
394 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
395 _mesa_error(ctx
, GL_INVALID_OPERATION
,
396 "%s(transform feedback active)", caller
);
401 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(count)", caller
);
405 if (!_mesa_valid_prim_mode(ctx
, mode
, caller
)) {
409 if (!valid_elements_type(ctx
, type
, caller
))
412 if (!check_valid_to_render(ctx
, caller
))
415 /* Not using a VBO for indices, so avoid NULL pointer derefs later.
417 if (!_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
) && indices
== NULL
)
427 * Error checking for glDrawElements(). Includes parameter checking
428 * and VBO bounds checking.
429 * \return GL_TRUE if OK to render, GL_FALSE if error found
432 _mesa_validate_DrawElements(struct gl_context
*ctx
,
433 GLenum mode
, GLsizei count
, GLenum type
,
434 const GLvoid
*indices
)
436 FLUSH_CURRENT(ctx
, 0);
438 return validate_DrawElements_common(ctx
, mode
, count
, type
, indices
,
444 * Error checking for glMultiDrawElements(). Includes parameter checking
445 * and VBO bounds checking.
446 * \return GL_TRUE if OK to render, GL_FALSE if error found
449 _mesa_validate_MultiDrawElements(struct gl_context
*ctx
,
450 GLenum mode
, const GLsizei
*count
,
451 GLenum type
, const GLvoid
* const *indices
,
456 FLUSH_CURRENT(ctx
, 0);
458 for (i
= 0; i
< primcount
; i
++) {
460 _mesa_error(ctx
, GL_INVALID_VALUE
,
461 "glMultiDrawElements(count)" );
466 if (!_mesa_valid_prim_mode(ctx
, mode
, "glMultiDrawElements")) {
470 if (!valid_elements_type(ctx
, type
, "glMultiDrawElements"))
473 if (!check_valid_to_render(ctx
, "glMultiDrawElements"))
476 /* Not using a VBO for indices, so avoid NULL pointer derefs later.
478 if (!_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
479 for (i
= 0; i
< primcount
; i
++) {
490 * Error checking for glDrawRangeElements(). Includes parameter checking
491 * and VBO bounds checking.
492 * \return GL_TRUE if OK to render, GL_FALSE if error found
495 _mesa_validate_DrawRangeElements(struct gl_context
*ctx
, GLenum mode
,
496 GLuint start
, GLuint end
,
497 GLsizei count
, GLenum type
,
498 const GLvoid
*indices
)
500 FLUSH_CURRENT(ctx
, 0);
503 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawRangeElements(end<start)");
507 return validate_DrawElements_common(ctx
, mode
, count
, type
, indices
,
508 "glDrawRangeElements");
513 * Called from the tnl module to error check the function parameters and
514 * verify that we really can draw something.
515 * \return GL_TRUE if OK to render, GL_FALSE if error found
518 _mesa_validate_DrawArrays(struct gl_context
*ctx
, GLenum mode
, GLsizei count
)
520 struct gl_transform_feedback_object
*xfb_obj
521 = ctx
->TransformFeedback
.CurrentObject
;
522 FLUSH_CURRENT(ctx
, 0);
525 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawArrays(count)" );
529 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawArrays")) {
533 if (!check_valid_to_render(ctx
, "glDrawArrays"))
536 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
537 * Primitive Capture):
539 * The error INVALID_OPERATION is generated by DrawArrays and
540 * DrawArraysInstanced if recording the vertices of a primitive to the
541 * buffer objects being used for transform feedback purposes would result
542 * in either exceeding the limits of any buffer object’s size, or in
543 * exceeding the end position offset + size − 1, as set by
546 * This is in contrast to the behaviour of desktop GL, where the extra
547 * primitives are silently dropped from the transform feedback buffer.
549 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
550 size_t prim_count
= vbo_count_tessellated_primitives(mode
, count
, 1);
551 if (xfb_obj
->GlesRemainingPrims
< prim_count
) {
552 _mesa_error(ctx
, GL_INVALID_OPERATION
,
553 "glDrawArrays(exceeds transform feedback size)");
556 xfb_obj
->GlesRemainingPrims
-= prim_count
;
567 _mesa_validate_DrawArraysInstanced(struct gl_context
*ctx
, GLenum mode
, GLint first
,
568 GLsizei count
, GLsizei numInstances
)
570 struct gl_transform_feedback_object
*xfb_obj
571 = ctx
->TransformFeedback
.CurrentObject
;
572 FLUSH_CURRENT(ctx
, 0);
575 _mesa_error(ctx
, GL_INVALID_VALUE
,
576 "glDrawArraysInstanced(count=%d)", count
);
581 _mesa_error(ctx
, GL_INVALID_VALUE
,
582 "glDrawArraysInstanced(start=%d)", first
);
586 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawArraysInstanced")) {
590 if (numInstances
<= 0) {
591 if (numInstances
< 0)
592 _mesa_error(ctx
, GL_INVALID_VALUE
,
593 "glDrawArraysInstanced(numInstances=%d)", numInstances
);
597 if (!check_valid_to_render(ctx
, "glDrawArraysInstanced(invalid to render)"))
600 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
601 * Primitive Capture):
603 * The error INVALID_OPERATION is generated by DrawArrays and
604 * DrawArraysInstanced if recording the vertices of a primitive to the
605 * buffer objects being used for transform feedback purposes would result
606 * in either exceeding the limits of any buffer object’s size, or in
607 * exceeding the end position offset + size − 1, as set by
610 * This is in contrast to the behaviour of desktop GL, where the extra
611 * primitives are silently dropped from the transform feedback buffer.
613 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
)) {
615 = vbo_count_tessellated_primitives(mode
, count
, numInstances
);
616 if (xfb_obj
->GlesRemainingPrims
< prim_count
) {
617 _mesa_error(ctx
, GL_INVALID_OPERATION
,
618 "glDrawArraysInstanced(exceeds transform feedback size)");
621 xfb_obj
->GlesRemainingPrims
-= prim_count
;
632 _mesa_validate_DrawElementsInstanced(struct gl_context
*ctx
,
633 GLenum mode
, GLsizei count
, GLenum type
,
634 const GLvoid
*indices
, GLsizei numInstances
)
636 FLUSH_CURRENT(ctx
, 0);
638 if (numInstances
< 0) {
639 _mesa_error(ctx
, GL_INVALID_VALUE
,
640 "glDrawElementsInstanced(numInstances=%d)", numInstances
);
644 return validate_DrawElements_common(ctx
, mode
, count
, type
, indices
,
645 "glDrawElementsInstanced")
646 && (numInstances
> 0);
651 _mesa_validate_DrawTransformFeedback(struct gl_context
*ctx
,
653 struct gl_transform_feedback_object
*obj
,
655 GLsizei numInstances
)
657 FLUSH_CURRENT(ctx
, 0);
659 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawTransformFeedback*(mode)")) {
664 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawTransformFeedback*(name)");
668 if (stream
>= ctx
->Const
.MaxVertexStreams
) {
669 _mesa_error(ctx
, GL_INVALID_VALUE
,
670 "glDrawTransformFeedbackStream*(index>=MaxVertexStream)");
674 if (!obj
->EndedAnytime
) {
675 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawTransformFeedback*");
679 if (numInstances
<= 0) {
680 if (numInstances
< 0)
681 _mesa_error(ctx
, GL_INVALID_VALUE
,
682 "glDrawTransformFeedback*Instanced(numInstances=%d)",
687 if (!check_valid_to_render(ctx
, "glDrawTransformFeedback*")) {
695 valid_draw_indirect(struct gl_context
*ctx
,
696 GLenum mode
, const GLvoid
*indirect
,
697 GLsizei size
, const char *name
)
699 const GLsizeiptr end
= (GLsizeiptr
)indirect
+ size
;
701 if (!_mesa_valid_prim_mode(ctx
, mode
, name
))
705 /* From the ARB_draw_indirect specification:
706 * "An INVALID_OPERATION error is generated [...] if <indirect> is no
709 if ((GLsizeiptr
)indirect
& (sizeof(GLuint
) - 1)) {
710 _mesa_error(ctx
, GL_INVALID_OPERATION
,
711 "%s(indirect is not aligned)", name
);
715 if (!_mesa_is_bufferobj(ctx
->DrawIndirectBuffer
)) {
716 _mesa_error(ctx
, GL_INVALID_OPERATION
,
717 "%s: no buffer bound to DRAW_INDIRECT_BUFFER", name
);
721 if (_mesa_check_disallowed_mapping(ctx
->DrawIndirectBuffer
)) {
722 _mesa_error(ctx
, GL_INVALID_OPERATION
,
723 "%s(DRAW_INDIRECT_BUFFER is mapped)", name
);
727 /* From the ARB_draw_indirect specification:
728 * "An INVALID_OPERATION error is generated if the commands source data
729 * beyond the end of the buffer object [...]"
731 if (ctx
->DrawIndirectBuffer
->Size
< end
) {
732 _mesa_error(ctx
, GL_INVALID_OPERATION
,
733 "%s(DRAW_INDIRECT_BUFFER too small)", name
);
737 if (!check_valid_to_render(ctx
, name
))
743 static inline GLboolean
744 valid_draw_indirect_elements(struct gl_context
*ctx
,
745 GLenum mode
, GLenum type
, const GLvoid
*indirect
,
746 GLsizeiptr size
, const char *name
)
748 if (!valid_elements_type(ctx
, type
, name
))
752 * Unlike regular DrawElementsInstancedBaseVertex commands, the indices
753 * may not come from a client array and must come from an index buffer.
754 * If no element array buffer is bound, an INVALID_OPERATION error is
757 if (!_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
758 _mesa_error(ctx
, GL_INVALID_OPERATION
,
759 "%s(no buffer bound to GL_ELEMENT_ARRAY_BUFFER)", name
);
763 return valid_draw_indirect(ctx
, mode
, indirect
, size
, name
);
766 static inline GLboolean
767 valid_draw_indirect_multi(struct gl_context
*ctx
,
768 GLsizei primcount
, GLsizei stride
,
772 /* From the ARB_multi_draw_indirect specification:
773 * "INVALID_VALUE is generated by MultiDrawArraysIndirect or
774 * MultiDrawElementsIndirect if <primcount> is negative."
776 * "<primcount> must be positive, otherwise an INVALID_VALUE error will
780 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(primcount < 0)", name
);
785 /* From the ARB_multi_draw_indirect specification:
786 * "<stride> must be a multiple of four, otherwise an INVALID_VALUE
787 * error is generated."
790 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(stride %% 4)", name
);
798 _mesa_validate_DrawArraysIndirect(struct gl_context
*ctx
,
800 const GLvoid
*indirect
)
802 const unsigned drawArraysNumParams
= 4;
804 FLUSH_CURRENT(ctx
, 0);
806 return valid_draw_indirect(ctx
, mode
,
807 indirect
, drawArraysNumParams
* sizeof(GLuint
),
808 "glDrawArraysIndirect");
812 _mesa_validate_DrawElementsIndirect(struct gl_context
*ctx
,
813 GLenum mode
, GLenum type
,
814 const GLvoid
*indirect
)
816 const unsigned drawElementsNumParams
= 5;
818 FLUSH_CURRENT(ctx
, 0);
820 return valid_draw_indirect_elements(ctx
, mode
, type
,
821 indirect
, drawElementsNumParams
* sizeof(GLuint
),
822 "glDrawElementsIndirect");
826 _mesa_validate_MultiDrawArraysIndirect(struct gl_context
*ctx
,
828 const GLvoid
*indirect
,
829 GLsizei primcount
, GLsizei stride
)
832 const unsigned drawArraysNumParams
= 4;
834 FLUSH_CURRENT(ctx
, 0);
836 /* caller has converted stride==0 to drawArraysNumParams * sizeof(GLuint) */
839 if (!valid_draw_indirect_multi(ctx
, primcount
, stride
,
840 "glMultiDrawArraysIndirect"))
843 /* number of bytes of the indirect buffer which will be read */
845 ? (primcount
- 1) * stride
+ drawArraysNumParams
* sizeof(GLuint
)
848 if (!valid_draw_indirect(ctx
, mode
, indirect
, size
,
849 "glMultiDrawArraysIndirect"))
856 _mesa_validate_MultiDrawElementsIndirect(struct gl_context
*ctx
,
857 GLenum mode
, GLenum type
,
858 const GLvoid
*indirect
,
859 GLsizei primcount
, GLsizei stride
)
862 const unsigned drawElementsNumParams
= 5;
864 FLUSH_CURRENT(ctx
, 0);
866 /* caller has converted stride==0 to drawElementsNumParams * sizeof(GLuint) */
869 if (!valid_draw_indirect_multi(ctx
, primcount
, stride
,
870 "glMultiDrawElementsIndirect"))
873 /* number of bytes of the indirect buffer which will be read */
875 ? (primcount
- 1) * stride
+ drawElementsNumParams
* sizeof(GLuint
)
878 if (!valid_draw_indirect_elements(ctx
, mode
, type
,
880 "glMultiDrawElementsIndirect"))