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"
29 #include "bufferobj.h"
33 #include "pipelineobj.h"
36 #include "transformfeedback.h"
39 #include "program/prog_print.h"
43 check_blend_func_error(struct gl_context
*ctx
)
45 /* The ARB_blend_func_extended spec's ERRORS section says:
47 * "The error INVALID_OPERATION is generated by Begin or any procedure
48 * that implicitly calls Begin if any draw buffer has a blend function
49 * requiring the second color input (SRC1_COLOR, ONE_MINUS_SRC1_COLOR,
50 * SRC1_ALPHA or ONE_MINUS_SRC1_ALPHA), and a framebuffer is bound that
51 * has more than the value of MAX_DUAL_SOURCE_DRAW_BUFFERS-1 active
52 * color attachements."
54 for (unsigned i
= ctx
->Const
.MaxDualSourceDrawBuffers
;
55 i
< ctx
->DrawBuffer
->_NumColorDrawBuffers
;
57 if (ctx
->Color
.Blend
[i
]._UsesDualSrc
) {
58 _mesa_error(ctx
, GL_INVALID_OPERATION
,
59 "dual source blend on illegal attachment");
64 if (ctx
->Color
.BlendEnabled
&& ctx
->Color
._AdvancedBlendMode
) {
65 /* The KHR_blend_equation_advanced spec says:
67 * "If any non-NONE draw buffer uses a blend equation found in table
68 * X.1 or X.2, the error INVALID_OPERATION is generated by Begin or
69 * any operation that implicitly calls Begin (such as DrawElements)
72 * * the draw buffer for color output zero selects multiple color
73 * buffers (e.g., FRONT_AND_BACK in the default framebuffer); or
75 * * the draw buffer for any other color output is not NONE."
77 if (ctx
->DrawBuffer
->ColorDrawBuffer
[0] == GL_FRONT_AND_BACK
) {
78 _mesa_error(ctx
, GL_INVALID_OPERATION
,
79 "advanced blending is active and draw buffer for color "
80 "output zero selects multiple color buffers");
84 for (unsigned i
= 1; i
< ctx
->DrawBuffer
->_NumColorDrawBuffers
; i
++) {
85 if (ctx
->DrawBuffer
->ColorDrawBuffer
[i
] != GL_NONE
) {
86 _mesa_error(ctx
, GL_INVALID_OPERATION
,
87 "advanced blending is active with multiple color "
93 /* The KHR_blend_equation_advanced spec says:
95 * "Advanced blending equations require the use of a fragment shader
96 * with a matching "blend_support" layout qualifier. If the current
97 * blend equation is found in table X.1 or X.2, and the active
98 * fragment shader does not include the layout qualifier matching
99 * the blend equation or "blend_support_all_equations", the error
100 * INVALID_OPERATION is generated [...]"
102 const struct gl_shader_program
*sh_prog
=
103 ctx
->_Shader
->_CurrentFragmentProgram
;
104 const GLbitfield blend_support
= !sh_prog
? 0 :
105 sh_prog
->_LinkedShaders
[MESA_SHADER_FRAGMENT
]->info
.BlendSupport
;
107 if ((blend_support
& ctx
->Color
._AdvancedBlendMode
) == 0) {
108 _mesa_error(ctx
, GL_INVALID_OPERATION
,
109 "fragment shader does not allow advanced blending mode "
111 _mesa_enum_to_string(ctx
->Color
.Blend
[0].EquationRGB
));
120 * Prior to drawing anything with glBegin, glDrawArrays, etc. this function
121 * is called to see if it's valid to render. This involves checking that
122 * the current shader is valid and the framebuffer is complete.
123 * It also check the current pipeline object is valid if any.
124 * If an error is detected it'll be recorded here.
125 * \return GL_TRUE if OK to render, GL_FALSE if not
128 _mesa_valid_to_render(struct gl_context
*ctx
, const char *where
)
130 /* This depends on having up to date derived state (shaders) */
132 _mesa_update_state(ctx
);
134 if (ctx
->API
== API_OPENGL_COMPAT
) {
135 /* Any shader stages that are not supplied by the GLSL shader and have
136 * assembly shaders enabled must now be validated.
138 if (!ctx
->_Shader
->CurrentProgram
[MESA_SHADER_VERTEX
]
139 && ctx
->VertexProgram
.Enabled
&& !ctx
->VertexProgram
._Enabled
) {
140 _mesa_error(ctx
, GL_INVALID_OPERATION
,
141 "%s(vertex program not valid)", where
);
145 if (!ctx
->_Shader
->CurrentProgram
[MESA_SHADER_FRAGMENT
]) {
146 if (ctx
->FragmentProgram
.Enabled
&& !ctx
->FragmentProgram
._Enabled
) {
147 _mesa_error(ctx
, GL_INVALID_OPERATION
,
148 "%s(fragment program not valid)", where
);
152 /* If drawing to integer-valued color buffers, there must be an
153 * active fragment shader (GL_EXT_texture_integer).
155 if (ctx
->DrawBuffer
&& ctx
->DrawBuffer
->_IntegerBuffers
) {
156 _mesa_error(ctx
, GL_INVALID_OPERATION
,
157 "%s(integer format but no fragment shader)", where
);
163 /* A pipeline object is bound */
164 if (ctx
->_Shader
->Name
&& !ctx
->_Shader
->Validated
) {
165 if (!_mesa_validate_program_pipeline(ctx
, ctx
->_Shader
)) {
166 _mesa_error(ctx
, GL_INVALID_OPERATION
,
167 "glValidateProgramPipeline failed to validate the "
173 /* If a program is active and SSO not in use, check if validation of
174 * samplers succeeded for the active program. */
175 if (ctx
->_Shader
->ActiveProgram
&& ctx
->_Shader
!= ctx
->Pipeline
.Current
) {
177 if (!_mesa_sampler_uniforms_are_valid(ctx
->_Shader
->ActiveProgram
,
179 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s", errMsg
);
184 if (ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
185 _mesa_error(ctx
, GL_INVALID_FRAMEBUFFER_OPERATION_EXT
,
186 "%s(incomplete framebuffer)", where
);
190 if (!check_blend_func_error(ctx
)) {
195 if (ctx
->_Shader
->Flags
& GLSL_LOG
) {
196 struct gl_shader_program
**shProg
= ctx
->_Shader
->CurrentProgram
;
199 for (i
= 0; i
< MESA_SHADER_STAGES
; i
++) {
200 if (shProg
[i
] == NULL
|| shProg
[i
]->_Used
201 || shProg
[i
]->_LinkedShaders
[i
] == NULL
)
204 /* This is the first time this shader is being used.
205 * Append shader's constants/uniforms to log file.
207 * Only log data for the program target that matches the shader
208 * target. It's possible to have a program bound to the vertex
209 * shader target that also supplied a fragment shader. If that
210 * program isn't also bound to the fragment shader target we don't
211 * want to log its fragment data.
213 _mesa_append_uniforms_to_file(shProg
[i
]->_LinkedShaders
[i
]);
216 for (i
= 0; i
< MESA_SHADER_STAGES
; i
++) {
217 if (shProg
[i
] != NULL
)
218 shProg
[i
]->_Used
= GL_TRUE
;
228 * Check if OK to draw arrays/elements.
231 check_valid_to_render(struct gl_context
*ctx
, const char *function
)
233 if (!_mesa_valid_to_render(ctx
, function
)) {
237 if (!_mesa_all_buffers_are_unmapped(ctx
->Array
.VAO
)) {
238 _mesa_error(ctx
, GL_INVALID_OPERATION
,
239 "%s(vertex buffers are mapped)", function
);
245 /* For ES2, we can draw if we have a vertex program/shader). */
246 return ctx
->VertexProgram
._Current
!= NULL
;
249 /* For OpenGL ES, only draw if we have vertex positions
251 if (!ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
)
255 case API_OPENGL_CORE
:
256 /* Section 10.4 (Drawing Commands Using Vertex Arrays) of the OpenGL 4.5
257 * Core Profile spec says:
259 * "An INVALID_OPERATION error is generated if no vertex array
260 * object is bound (see section 10.3.1)."
262 if (ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
263 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(no VAO bound)", function
);
267 /* The spec argues that this is allowed because a tess ctrl shader
268 * without a tess eval shader can be used with transform feedback.
269 * However, glBeginTransformFeedback doesn't allow GL_PATCHES and
270 * therefore doesn't allow tessellation.
272 * Further investigation showed that this is indeed a spec bug and
273 * a tess ctrl shader without a tess eval shader shouldn't have been
274 * allowed, because there is no API in GL 4.0 that can make use this
275 * to produce something useful.
277 * Also, all vendors except one don't support a tess ctrl shader without
278 * a tess eval shader anyway.
280 if (ctx
->TessCtrlProgram
._Current
&& !ctx
->TessEvalProgram
._Current
) {
281 _mesa_error(ctx
, GL_INVALID_OPERATION
,
282 "%s(tess eval shader is missing)", function
);
286 /* Section 7.3 (Program Objects) of the OpenGL 4.5 Core Profile spec
289 * "If there is no active program for the vertex or fragment shader
290 * stages, the results of vertex and/or fragment processing will be
291 * undefined. However, this is not an error."
293 * The fragment shader is not tested here because other state (e.g.,
294 * GL_RASTERIZER_DISCARD) affects whether or not we actually care.
296 return ctx
->VertexProgram
._Current
!= NULL
;
298 case API_OPENGL_COMPAT
:
299 if (ctx
->VertexProgram
._Current
!= NULL
) {
300 /* Draw regardless of whether or not we have any vertex arrays.
301 * (Ex: could draw a point using a constant vertex pos)
305 /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic
308 return (ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
||
309 ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
);
314 unreachable("Invalid API value in check_valid_to_render()");
322 * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
323 * etc? The set of legal values depends on whether geometry shaders/programs
325 * Note: This may be called during display list compilation.
328 _mesa_is_valid_prim_mode(struct gl_context
*ctx
, GLenum mode
)
330 /* The overwhelmingly common case is (mode <= GL_TRIANGLE_FAN). Test that
331 * first and exit. You would think that a switch-statement would be the
332 * right approach, but at least GCC 4.7.2 generates some pretty dire code
333 * for the common case.
335 if (likely(mode
<= GL_TRIANGLE_FAN
))
338 if (mode
<= GL_POLYGON
)
339 return (ctx
->API
== API_OPENGL_COMPAT
);
341 if (mode
<= GL_TRIANGLE_STRIP_ADJACENCY
)
342 return _mesa_has_geometry_shaders(ctx
);
344 if (mode
== GL_PATCHES
)
345 return _mesa_has_tessellation(ctx
);
352 * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
353 * etc? Also, do additional checking related to transformation feedback.
354 * Note: this function cannot be called during glNewList(GL_COMPILE) because
355 * this code depends on current transform feedback state.
356 * Also, do additional checking related to tessellation shaders.
359 _mesa_valid_prim_mode(struct gl_context
*ctx
, GLenum mode
, const char *name
)
361 bool valid_enum
= _mesa_is_valid_prim_mode(ctx
, mode
);
364 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(mode=%x)", name
, mode
);
368 /* From the OpenGL 4.5 specification, section 11.3.1:
370 * The error INVALID_OPERATION is generated if Begin, or any command that
371 * implicitly calls Begin, is called when a geometry shader is active and:
373 * * the input primitive type of the current geometry shader is
374 * POINTS and <mode> is not POINTS,
376 * * the input primitive type of the current geometry shader is
377 * LINES and <mode> is not LINES, LINE_STRIP, or LINE_LOOP,
379 * * the input primitive type of the current geometry shader is
380 * TRIANGLES and <mode> is not TRIANGLES, TRIANGLE_STRIP or
383 * * the input primitive type of the current geometry shader is
384 * LINES_ADJACENCY_ARB and <mode> is not LINES_ADJACENCY_ARB or
385 * LINE_STRIP_ADJACENCY_ARB, or
387 * * the input primitive type of the current geometry shader is
388 * TRIANGLES_ADJACENCY_ARB and <mode> is not
389 * TRIANGLES_ADJACENCY_ARB or TRIANGLE_STRIP_ADJACENCY_ARB.
391 * The GL spec doesn't mention any interaction with tessellation, which
392 * is clearly a spec bug. The same rule should apply, but instead of
393 * the draw primitive mode, the tessellation evaluation shader primitive
394 * mode should be used for the checking.
396 if (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]) {
397 const GLenum geom_mode
=
398 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]->
399 _LinkedShaders
[MESA_SHADER_GEOMETRY
]->info
.Geom
.InputType
;
400 struct gl_shader_program
*tes
=
401 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_EVAL
];
402 GLenum mode_before_gs
= mode
;
405 struct gl_linked_shader
*tes_sh
=
406 tes
->_LinkedShaders
[MESA_SHADER_TESS_EVAL
];
407 if (tes_sh
->info
.TessEval
.PointMode
)
408 mode_before_gs
= GL_POINTS
;
409 else if (tes_sh
->info
.TessEval
.PrimitiveMode
== GL_ISOLINES
)
410 mode_before_gs
= GL_LINES
;
412 /* the GL_QUADS mode generates triangles too */
413 mode_before_gs
= GL_TRIANGLES
;
416 switch (mode_before_gs
) {
418 valid_enum
= (geom_mode
== GL_POINTS
);
423 valid_enum
= (geom_mode
== GL_LINES
);
426 case GL_TRIANGLE_STRIP
:
427 case GL_TRIANGLE_FAN
:
428 valid_enum
= (geom_mode
== GL_TRIANGLES
);
435 case GL_LINES_ADJACENCY
:
436 case GL_LINE_STRIP_ADJACENCY
:
437 valid_enum
= (geom_mode
== GL_LINES_ADJACENCY
);
439 case GL_TRIANGLES_ADJACENCY
:
440 case GL_TRIANGLE_STRIP_ADJACENCY
:
441 valid_enum
= (geom_mode
== GL_TRIANGLES_ADJACENCY
);
448 _mesa_error(ctx
, GL_INVALID_OPERATION
,
449 "%s(mode=%s vs geometry shader input %s)",
451 _mesa_lookup_prim_by_nr(mode_before_gs
),
452 _mesa_lookup_prim_by_nr(geom_mode
));
457 /* From the OpenGL 4.0 (Core Profile) spec (section 2.12):
459 * "Tessellation operates only on patch primitives. If tessellation is
460 * active, any command that transfers vertices to the GL will
461 * generate an INVALID_OPERATION error if the primitive mode is not
463 * Patch primitives are not supported by pipeline stages below the
464 * tessellation evaluation shader. If there is no active program
465 * object or the active program object does not contain a tessellation
466 * evaluation shader, the error INVALID_OPERATION is generated by any
467 * command that transfers vertices to the GL if the primitive mode is
471 if (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_EVAL
] ||
472 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_CTRL
]) {
473 if (mode
!= GL_PATCHES
) {
474 _mesa_error(ctx
, GL_INVALID_OPERATION
,
475 "only GL_PATCHES valid with tessellation");
480 if (mode
== GL_PATCHES
) {
481 _mesa_error(ctx
, GL_INVALID_OPERATION
,
482 "GL_PATCHES only valid with tessellation");
487 /* From the GL_EXT_transform_feedback spec:
489 * "The error INVALID_OPERATION is generated if Begin, or any command
490 * that performs an explicit Begin, is called when:
492 * * a geometry shader is not active and <mode> does not match the
493 * allowed begin modes for the current transform feedback state as
494 * given by table X.1.
496 * * a geometry shader is active and the output primitive type of the
497 * geometry shader does not match the allowed begin modes for the
498 * current transform feedback state as given by table X.1.
501 if (_mesa_is_xfb_active_and_unpaused(ctx
)) {
502 GLboolean pass
= GL_TRUE
;
504 if(ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]) {
505 switch (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_GEOMETRY
]->
506 _LinkedShaders
[MESA_SHADER_GEOMETRY
]->
507 info
.Geom
.OutputType
) {
509 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
512 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
514 case GL_TRIANGLE_STRIP
:
515 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
521 else if (ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_EVAL
]) {
522 struct gl_shader_program
*tes
=
523 ctx
->_Shader
->CurrentProgram
[MESA_SHADER_TESS_EVAL
];
524 struct gl_linked_shader
*tes_sh
=
525 tes
->_LinkedShaders
[MESA_SHADER_TESS_EVAL
];
526 if (tes_sh
->info
.TessEval
.PointMode
)
527 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
528 else if (tes_sh
->info
.TessEval
.PrimitiveMode
== GL_ISOLINES
)
529 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
531 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
536 pass
= ctx
->TransformFeedback
.Mode
== GL_POINTS
;
541 pass
= ctx
->TransformFeedback
.Mode
== GL_LINES
;
544 pass
= ctx
->TransformFeedback
.Mode
== GL_TRIANGLES
;
549 _mesa_error(ctx
, GL_INVALID_OPERATION
,
550 "%s(mode=%s vs transform feedback %s)",
552 _mesa_lookup_prim_by_nr(mode
),
553 _mesa_lookup_prim_by_nr(ctx
->TransformFeedback
.Mode
));
562 * Verify that the element type is valid.
564 * Generates \c GL_INVALID_ENUM and returns \c false if it is not.
567 valid_elements_type(struct gl_context
*ctx
, GLenum type
, const char *name
)
570 case GL_UNSIGNED_BYTE
:
571 case GL_UNSIGNED_SHORT
:
572 case GL_UNSIGNED_INT
:
576 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(type = %s)", name
,
577 _mesa_enum_to_string(type
));
583 validate_DrawElements_common(struct gl_context
*ctx
,
584 GLenum mode
, GLsizei count
, GLenum type
,
585 const GLvoid
*indices
,
588 /* Section 2.14.2 (Transform Feedback Primitive Capture) of the OpenGL ES
591 * The error INVALID_OPERATION is also generated by DrawElements,
592 * DrawElementsInstanced, and DrawRangeElements while transform feedback
593 * is active and not paused, regardless of mode.
595 * The OES_geometry_shader_spec says:
601 * (13) Does this extension change how transform feedback operates
602 * compared to unextended OpenGL ES 3.0 or 3.1?
604 * RESOLVED: Yes... Since we no longer require being able to predict how
605 * much geometry will be generated, we also lift the restriction that
606 * only DrawArray* commands are supported and also support the
607 * DrawElements* commands for transform feedback.
609 * This should also be reflected in the body of the spec, but that appears
610 * to have been overlooked. The body of the spec only explicitly allows
611 * the indirect versions.
613 if (_mesa_is_gles3(ctx
) && !ctx
->Extensions
.OES_geometry_shader
&&
614 _mesa_is_xfb_active_and_unpaused(ctx
)) {
615 _mesa_error(ctx
, GL_INVALID_OPERATION
,
616 "%s(transform feedback active)", caller
);
621 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(count)", caller
);
625 if (!_mesa_valid_prim_mode(ctx
, mode
, caller
)) {
629 if (!valid_elements_type(ctx
, type
, caller
))
632 if (!check_valid_to_render(ctx
, caller
))
635 /* Not using a VBO for indices, so avoid NULL pointer derefs later.
637 if (!_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
) && indices
== NULL
)
647 * Error checking for glDrawElements(). Includes parameter checking
648 * and VBO bounds checking.
649 * \return GL_TRUE if OK to render, GL_FALSE if error found
652 _mesa_validate_DrawElements(struct gl_context
*ctx
,
653 GLenum mode
, GLsizei count
, GLenum type
,
654 const GLvoid
*indices
)
656 FLUSH_CURRENT(ctx
, 0);
658 return validate_DrawElements_common(ctx
, mode
, count
, type
, indices
,
664 * Error checking for glMultiDrawElements(). Includes parameter checking
665 * and VBO bounds checking.
666 * \return GL_TRUE if OK to render, GL_FALSE if error found
669 _mesa_validate_MultiDrawElements(struct gl_context
*ctx
,
670 GLenum mode
, const GLsizei
*count
,
671 GLenum type
, const GLvoid
* const *indices
,
676 FLUSH_CURRENT(ctx
, 0);
678 for (i
= 0; i
< primcount
; i
++) {
680 _mesa_error(ctx
, GL_INVALID_VALUE
,
681 "glMultiDrawElements(count)" );
686 if (!_mesa_valid_prim_mode(ctx
, mode
, "glMultiDrawElements")) {
690 if (!valid_elements_type(ctx
, type
, "glMultiDrawElements"))
693 if (!check_valid_to_render(ctx
, "glMultiDrawElements"))
696 /* Not using a VBO for indices, so avoid NULL pointer derefs later.
698 if (!_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
699 for (i
= 0; i
< primcount
; i
++) {
710 * Error checking for glDrawRangeElements(). Includes parameter checking
711 * and VBO bounds checking.
712 * \return GL_TRUE if OK to render, GL_FALSE if error found
715 _mesa_validate_DrawRangeElements(struct gl_context
*ctx
, GLenum mode
,
716 GLuint start
, GLuint end
,
717 GLsizei count
, GLenum type
,
718 const GLvoid
*indices
)
720 FLUSH_CURRENT(ctx
, 0);
723 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawRangeElements(end<start)");
727 return validate_DrawElements_common(ctx
, mode
, count
, type
, indices
,
728 "glDrawRangeElements");
732 validate_draw_arrays(struct gl_context
*ctx
, const char *func
,
733 GLenum mode
, GLsizei count
, GLsizei numInstances
)
735 struct gl_transform_feedback_object
*xfb_obj
736 = ctx
->TransformFeedback
.CurrentObject
;
737 FLUSH_CURRENT(ctx
, 0);
740 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(count)", func
);
744 if (!_mesa_valid_prim_mode(ctx
, mode
, func
))
747 if (!check_valid_to_render(ctx
, func
))
750 /* From the GLES3 specification, section 2.14.2 (Transform Feedback
751 * Primitive Capture):
753 * The error INVALID_OPERATION is generated by DrawArrays and
754 * DrawArraysInstanced if recording the vertices of a primitive to the
755 * buffer objects being used for transform feedback purposes would result
756 * in either exceeding the limits of any buffer object’s size, or in
757 * exceeding the end position offset + size − 1, as set by
760 * This is in contrast to the behaviour of desktop GL, where the extra
761 * primitives are silently dropped from the transform feedback buffer.
763 * This text is removed in ES 3.2, presumably because it's not really
764 * implementable with geometry and tessellation shaders. In fact,
765 * the OES_geometry_shader spec says:
767 * "(13) Does this extension change how transform feedback operates
768 * compared to unextended OpenGL ES 3.0 or 3.1?
770 * RESOLVED: Yes. Because dynamic geometry amplification in a geometry
771 * shader can make it difficult if not impossible to predict the amount
772 * of geometry that may be generated in advance of executing the shader,
773 * the draw-time error for transform feedback buffer overflow conditions
774 * is removed and replaced with the GL behavior (primitives are not
775 * written and the corresponding counter is not updated)..."
777 if (_mesa_is_gles3(ctx
) && _mesa_is_xfb_active_and_unpaused(ctx
) &&
778 !_mesa_has_OES_geometry_shader(ctx
) &&
779 !_mesa_has_OES_tessellation_shader(ctx
)) {
780 size_t prim_count
= vbo_count_tessellated_primitives(mode
, count
, 1);
781 if (xfb_obj
->GlesRemainingPrims
< prim_count
) {
782 _mesa_error(ctx
, GL_INVALID_OPERATION
,
783 "%s(exceeds transform feedback size)", func
);
786 xfb_obj
->GlesRemainingPrims
-= prim_count
;
796 * Called from the tnl module to error check the function parameters and
797 * verify that we really can draw something.
798 * \return GL_TRUE if OK to render, GL_FALSE if error found
801 _mesa_validate_DrawArrays(struct gl_context
*ctx
, GLenum mode
, GLsizei count
)
803 return validate_draw_arrays(ctx
, "glDrawArrays", mode
, count
, 1);
808 _mesa_validate_DrawArraysInstanced(struct gl_context
*ctx
, GLenum mode
, GLint first
,
809 GLsizei count
, GLsizei numInstances
)
812 _mesa_error(ctx
, GL_INVALID_VALUE
,
813 "glDrawArraysInstanced(start=%d)", first
);
817 if (numInstances
<= 0) {
818 if (numInstances
< 0)
819 _mesa_error(ctx
, GL_INVALID_VALUE
,
820 "glDrawArraysInstanced(numInstances=%d)", numInstances
);
824 return validate_draw_arrays(ctx
, "glDrawArraysInstanced", mode
, count
, 1);
829 _mesa_validate_DrawElementsInstanced(struct gl_context
*ctx
,
830 GLenum mode
, GLsizei count
, GLenum type
,
831 const GLvoid
*indices
, GLsizei numInstances
)
833 FLUSH_CURRENT(ctx
, 0);
835 if (numInstances
< 0) {
836 _mesa_error(ctx
, GL_INVALID_VALUE
,
837 "glDrawElementsInstanced(numInstances=%d)", numInstances
);
841 return validate_DrawElements_common(ctx
, mode
, count
, type
, indices
,
842 "glDrawElementsInstanced")
843 && (numInstances
> 0);
848 _mesa_validate_DrawTransformFeedback(struct gl_context
*ctx
,
850 struct gl_transform_feedback_object
*obj
,
852 GLsizei numInstances
)
854 FLUSH_CURRENT(ctx
, 0);
856 if (!_mesa_valid_prim_mode(ctx
, mode
, "glDrawTransformFeedback*(mode)")) {
861 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawTransformFeedback*(name)");
865 /* From the GL 4.5 specification, page 429:
866 * "An INVALID_VALUE error is generated if id is not the name of a
867 * transform feedback object."
869 if (!obj
->EverBound
) {
870 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawTransformFeedback*(name)");
874 if (stream
>= ctx
->Const
.MaxVertexStreams
) {
875 _mesa_error(ctx
, GL_INVALID_VALUE
,
876 "glDrawTransformFeedbackStream*(index>=MaxVertexStream)");
880 if (!obj
->EndedAnytime
) {
881 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawTransformFeedback*");
885 if (numInstances
<= 0) {
886 if (numInstances
< 0)
887 _mesa_error(ctx
, GL_INVALID_VALUE
,
888 "glDrawTransformFeedback*Instanced(numInstances=%d)",
893 if (!check_valid_to_render(ctx
, "glDrawTransformFeedback*")) {
901 valid_draw_indirect(struct gl_context
*ctx
,
902 GLenum mode
, const GLvoid
*indirect
,
903 GLsizei size
, const char *name
)
905 const uint64_t end
= (uint64_t) (uintptr_t) indirect
+ size
;
907 /* OpenGL ES 3.1 spec. section 10.5:
909 * "DrawArraysIndirect requires that all data sourced for the
910 * command, including the DrawArraysIndirectCommand
911 * structure, be in buffer objects, and may not be called when
912 * the default vertex array object is bound."
914 if (ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
915 _mesa_error(ctx
, GL_INVALID_OPERATION
, "(no VAO bound)");
919 /* From OpenGL ES 3.1 spec. section 10.5:
920 * "An INVALID_OPERATION error is generated if zero is bound to
921 * VERTEX_ARRAY_BINDING, DRAW_INDIRECT_BUFFER or to any enabled
924 * Here we check that for each enabled vertex array we have a vertex
927 if (_mesa_is_gles31(ctx
) &&
928 ctx
->Array
.VAO
->_Enabled
& ~ctx
->Array
.VAO
->VertexAttribBufferMask
) {
929 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(No VBO bound)", name
);
933 if (!_mesa_valid_prim_mode(ctx
, mode
, name
))
936 /* OpenGL ES 3.1 specification, section 10.5:
938 * "An INVALID_OPERATION error is generated if
939 * transform feedback is active and not paused."
941 * The OES_geometry_shader spec says:
943 * On p. 250 in the errors section for the DrawArraysIndirect command,
944 * and on p. 254 in the errors section for the DrawElementsIndirect
945 * command, delete the errors which state:
947 * "An INVALID_OPERATION error is generated if transform feedback is
948 * active and not paused."
950 * (thus allowing transform feedback to work with indirect draw commands).
952 if (_mesa_is_gles31(ctx
) && !ctx
->Extensions
.OES_geometry_shader
&&
953 _mesa_is_xfb_active_and_unpaused(ctx
)) {
954 _mesa_error(ctx
, GL_INVALID_OPERATION
,
955 "%s(TransformFeedback is active and not paused)", name
);
958 /* From OpenGL version 4.4. section 10.5
959 * and OpenGL ES 3.1, section 10.6:
961 * "An INVALID_VALUE error is generated if indirect is not a
962 * multiple of the size, in basic machine units, of uint."
964 if ((GLsizeiptr
)indirect
& (sizeof(GLuint
) - 1)) {
965 _mesa_error(ctx
, GL_INVALID_VALUE
,
966 "%s(indirect is not aligned)", name
);
970 if (!_mesa_is_bufferobj(ctx
->DrawIndirectBuffer
)) {
971 _mesa_error(ctx
, GL_INVALID_OPERATION
,
972 "%s: no buffer bound to DRAW_INDIRECT_BUFFER", name
);
976 if (_mesa_check_disallowed_mapping(ctx
->DrawIndirectBuffer
)) {
977 _mesa_error(ctx
, GL_INVALID_OPERATION
,
978 "%s(DRAW_INDIRECT_BUFFER is mapped)", name
);
982 /* From the ARB_draw_indirect specification:
983 * "An INVALID_OPERATION error is generated if the commands source data
984 * beyond the end of the buffer object [...]"
986 if (ctx
->DrawIndirectBuffer
->Size
< end
) {
987 _mesa_error(ctx
, GL_INVALID_OPERATION
,
988 "%s(DRAW_INDIRECT_BUFFER too small)", name
);
992 if (!check_valid_to_render(ctx
, name
))
998 static inline GLboolean
999 valid_draw_indirect_elements(struct gl_context
*ctx
,
1000 GLenum mode
, GLenum type
, const GLvoid
*indirect
,
1001 GLsizeiptr size
, const char *name
)
1003 if (!valid_elements_type(ctx
, type
, name
))
1007 * Unlike regular DrawElementsInstancedBaseVertex commands, the indices
1008 * may not come from a client array and must come from an index buffer.
1009 * If no element array buffer is bound, an INVALID_OPERATION error is
1012 if (!_mesa_is_bufferobj(ctx
->Array
.VAO
->IndexBufferObj
)) {
1013 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1014 "%s(no buffer bound to GL_ELEMENT_ARRAY_BUFFER)", name
);
1018 return valid_draw_indirect(ctx
, mode
, indirect
, size
, name
);
1021 static inline GLboolean
1022 valid_draw_indirect_multi(struct gl_context
*ctx
,
1023 GLsizei primcount
, GLsizei stride
,
1027 /* From the ARB_multi_draw_indirect specification:
1028 * "INVALID_VALUE is generated by MultiDrawArraysIndirect or
1029 * MultiDrawElementsIndirect if <primcount> is negative."
1031 * "<primcount> must be positive, otherwise an INVALID_VALUE error will
1034 if (primcount
< 0) {
1035 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(primcount < 0)", name
);
1040 /* From the ARB_multi_draw_indirect specification:
1041 * "<stride> must be a multiple of four, otherwise an INVALID_VALUE
1042 * error is generated."
1045 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(stride %% 4)", name
);
1053 _mesa_validate_DrawArraysIndirect(struct gl_context
*ctx
,
1055 const GLvoid
*indirect
)
1057 const unsigned drawArraysNumParams
= 4;
1059 FLUSH_CURRENT(ctx
, 0);
1061 return valid_draw_indirect(ctx
, mode
,
1062 indirect
, drawArraysNumParams
* sizeof(GLuint
),
1063 "glDrawArraysIndirect");
1067 _mesa_validate_DrawElementsIndirect(struct gl_context
*ctx
,
1068 GLenum mode
, GLenum type
,
1069 const GLvoid
*indirect
)
1071 const unsigned drawElementsNumParams
= 5;
1073 FLUSH_CURRENT(ctx
, 0);
1075 return valid_draw_indirect_elements(ctx
, mode
, type
,
1076 indirect
, drawElementsNumParams
* sizeof(GLuint
),
1077 "glDrawElementsIndirect");
1081 _mesa_validate_MultiDrawArraysIndirect(struct gl_context
*ctx
,
1083 const GLvoid
*indirect
,
1084 GLsizei primcount
, GLsizei stride
)
1086 GLsizeiptr size
= 0;
1087 const unsigned drawArraysNumParams
= 4;
1089 FLUSH_CURRENT(ctx
, 0);
1091 /* caller has converted stride==0 to drawArraysNumParams * sizeof(GLuint) */
1092 assert(stride
!= 0);
1094 if (!valid_draw_indirect_multi(ctx
, primcount
, stride
,
1095 "glMultiDrawArraysIndirect"))
1098 /* number of bytes of the indirect buffer which will be read */
1100 ? (primcount
- 1) * stride
+ drawArraysNumParams
* sizeof(GLuint
)
1103 if (!valid_draw_indirect(ctx
, mode
, indirect
, size
,
1104 "glMultiDrawArraysIndirect"))
1111 _mesa_validate_MultiDrawElementsIndirect(struct gl_context
*ctx
,
1112 GLenum mode
, GLenum type
,
1113 const GLvoid
*indirect
,
1114 GLsizei primcount
, GLsizei stride
)
1116 GLsizeiptr size
= 0;
1117 const unsigned drawElementsNumParams
= 5;
1119 FLUSH_CURRENT(ctx
, 0);
1121 /* caller has converted stride==0 to drawElementsNumParams * sizeof(GLuint) */
1122 assert(stride
!= 0);
1124 if (!valid_draw_indirect_multi(ctx
, primcount
, stride
,
1125 "glMultiDrawElementsIndirect"))
1128 /* number of bytes of the indirect buffer which will be read */
1130 ? (primcount
- 1) * stride
+ drawElementsNumParams
* sizeof(GLuint
)
1133 if (!valid_draw_indirect_elements(ctx
, mode
, type
,
1135 "glMultiDrawElementsIndirect"))
1142 valid_draw_indirect_parameters(struct gl_context
*ctx
,
1146 /* From the ARB_indirect_parameters specification:
1147 * "INVALID_VALUE is generated by MultiDrawArraysIndirectCountARB or
1148 * MultiDrawElementsIndirectCountARB if <drawcount> is not a multiple of
1151 if (drawcount
& 3) {
1152 _mesa_error(ctx
, GL_INVALID_VALUE
,
1153 "%s(drawcount is not a multiple of 4)", name
);
1157 /* From the ARB_indirect_parameters specification:
1158 * "INVALID_OPERATION is generated by MultiDrawArraysIndirectCountARB or
1159 * MultiDrawElementsIndirectCountARB if no buffer is bound to the
1160 * PARAMETER_BUFFER_ARB binding point."
1162 if (!_mesa_is_bufferobj(ctx
->ParameterBuffer
)) {
1163 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1164 "%s: no buffer bound to PARAMETER_BUFFER", name
);
1168 if (_mesa_check_disallowed_mapping(ctx
->ParameterBuffer
)) {
1169 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1170 "%s(PARAMETER_BUFFER is mapped)", name
);
1174 /* From the ARB_indirect_parameters specification:
1175 * "INVALID_OPERATION is generated by MultiDrawArraysIndirectCountARB or
1176 * MultiDrawElementsIndirectCountARB if reading a <sizei> typed value
1177 * from the buffer bound to the PARAMETER_BUFFER_ARB target at the offset
1178 * specified by <drawcount> would result in an out-of-bounds access."
1180 if (ctx
->ParameterBuffer
->Size
< drawcount
+ sizeof(GLsizei
)) {
1181 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1182 "%s(PARAMETER_BUFFER too small)", name
);
1190 _mesa_validate_MultiDrawArraysIndirectCount(struct gl_context
*ctx
,
1194 GLsizei maxdrawcount
,
1197 GLsizeiptr size
= 0;
1198 const unsigned drawArraysNumParams
= 4;
1200 FLUSH_CURRENT(ctx
, 0);
1202 /* caller has converted stride==0 to drawArraysNumParams * sizeof(GLuint) */
1203 assert(stride
!= 0);
1205 if (!valid_draw_indirect_multi(ctx
, maxdrawcount
, stride
,
1206 "glMultiDrawArraysIndirectCountARB"))
1209 /* number of bytes of the indirect buffer which will be read */
1211 ? (maxdrawcount
- 1) * stride
+ drawArraysNumParams
* sizeof(GLuint
)
1214 if (!valid_draw_indirect(ctx
, mode
, (void *)indirect
, size
,
1215 "glMultiDrawArraysIndirectCountARB"))
1218 return valid_draw_indirect_parameters(
1219 ctx
, "glMultiDrawArraysIndirectCountARB", drawcount
);
1223 _mesa_validate_MultiDrawElementsIndirectCount(struct gl_context
*ctx
,
1224 GLenum mode
, GLenum type
,
1227 GLsizei maxdrawcount
,
1230 GLsizeiptr size
= 0;
1231 const unsigned drawElementsNumParams
= 5;
1233 FLUSH_CURRENT(ctx
, 0);
1235 /* caller has converted stride==0 to drawElementsNumParams * sizeof(GLuint) */
1236 assert(stride
!= 0);
1238 if (!valid_draw_indirect_multi(ctx
, maxdrawcount
, stride
,
1239 "glMultiDrawElementsIndirectCountARB"))
1242 /* number of bytes of the indirect buffer which will be read */
1244 ? (maxdrawcount
- 1) * stride
+ drawElementsNumParams
* sizeof(GLuint
)
1247 if (!valid_draw_indirect_elements(ctx
, mode
, type
,
1248 (void *)indirect
, size
,
1249 "glMultiDrawElementsIndirectCountARB"))
1252 return valid_draw_indirect_parameters(
1253 ctx
, "glMultiDrawElementsIndirectCountARB", drawcount
);
1257 check_valid_to_compute(struct gl_context
*ctx
, const char *function
)
1259 struct gl_shader_program
*prog
;
1261 if (!_mesa_has_compute_shaders(ctx
)) {
1262 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1263 "unsupported function (%s) called",
1268 /* From the OpenGL 4.3 Core Specification, Chapter 19, Compute Shaders:
1270 * "An INVALID_OPERATION error is generated if there is no active program
1271 * for the compute shader stage."
1273 prog
= ctx
->_Shader
->CurrentProgram
[MESA_SHADER_COMPUTE
];
1274 if (prog
== NULL
|| prog
->_LinkedShaders
[MESA_SHADER_COMPUTE
] == NULL
) {
1275 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1276 "%s(no active compute shader)",
1285 _mesa_validate_DispatchCompute(struct gl_context
*ctx
,
1286 const GLuint
*num_groups
)
1288 struct gl_shader_program
*prog
;
1290 FLUSH_CURRENT(ctx
, 0);
1292 if (!check_valid_to_compute(ctx
, "glDispatchCompute"))
1295 for (i
= 0; i
< 3; i
++) {
1296 /* From the OpenGL 4.3 Core Specification, Chapter 19, Compute Shaders:
1298 * "An INVALID_VALUE error is generated if any of num_groups_x,
1299 * num_groups_y and num_groups_z are greater than or equal to the
1300 * maximum work group count for the corresponding dimension."
1302 * However, the "or equal to" portions appears to be a specification
1303 * bug. In all other areas, the specification appears to indicate that
1304 * the number of workgroups can match the MAX_COMPUTE_WORK_GROUP_COUNT
1305 * value. For example, under DispatchComputeIndirect:
1307 * "If any of num_groups_x, num_groups_y or num_groups_z is greater than
1308 * the value of MAX_COMPUTE_WORK_GROUP_COUNT for the corresponding
1309 * dimension then the results are undefined."
1311 * Additionally, the OpenGLES 3.1 specification does not contain "or
1312 * equal to" as an error condition.
1314 if (num_groups
[i
] > ctx
->Const
.MaxComputeWorkGroupCount
[i
]) {
1315 _mesa_error(ctx
, GL_INVALID_VALUE
,
1316 "glDispatchCompute(num_groups_%c)", 'x' + i
);
1321 /* The ARB_compute_variable_group_size spec says:
1323 * "An INVALID_OPERATION error is generated by DispatchCompute if the active
1324 * program for the compute shader stage has a variable work group size."
1326 prog
= ctx
->_Shader
->CurrentProgram
[MESA_SHADER_COMPUTE
];
1327 if (prog
->Comp
.LocalSizeVariable
) {
1328 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1329 "glDispatchCompute(variable work group size forbidden)");
1337 _mesa_validate_DispatchComputeGroupSizeARB(struct gl_context
*ctx
,
1338 const GLuint
*num_groups
,
1339 const GLuint
*group_size
)
1341 struct gl_shader_program
*prog
;
1342 GLuint total_invocations
= 1;
1345 FLUSH_CURRENT(ctx
, 0);
1347 if (!check_valid_to_compute(ctx
, "glDispatchComputeGroupSizeARB"))
1350 /* The ARB_compute_variable_group_size spec says:
1352 * "An INVALID_OPERATION error is generated by
1353 * DispatchComputeGroupSizeARB if the active program for the compute
1354 * shader stage has a fixed work group size."
1356 prog
= ctx
->_Shader
->CurrentProgram
[MESA_SHADER_COMPUTE
];
1357 if (!prog
->Comp
.LocalSizeVariable
) {
1358 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1359 "glDispatchComputeGroupSizeARB(fixed work group size "
1364 for (i
= 0; i
< 3; i
++) {
1365 /* The ARB_compute_variable_group_size spec says:
1367 * "An INVALID_VALUE error is generated if any of num_groups_x,
1368 * num_groups_y and num_groups_z are greater than or equal to the
1369 * maximum work group count for the corresponding dimension."
1371 if (num_groups
[i
] > ctx
->Const
.MaxComputeWorkGroupCount
[i
]) {
1372 _mesa_error(ctx
, GL_INVALID_VALUE
,
1373 "glDispatchComputeGroupSizeARB(num_groups_%c)", 'x' + i
);
1377 /* The ARB_compute_variable_group_size spec says:
1379 * "An INVALID_VALUE error is generated by DispatchComputeGroupSizeARB if
1380 * any of <group_size_x>, <group_size_y>, or <group_size_z> is less than
1381 * or equal to zero or greater than the maximum local work group size
1382 * for compute shaders with variable group size
1383 * (MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB) in the corresponding
1386 * However, the "less than" is a spec bug because they are declared as
1387 * unsigned integers.
1389 if (group_size
[i
] == 0 ||
1390 group_size
[i
] > ctx
->Const
.MaxComputeVariableGroupSize
[i
]) {
1391 _mesa_error(ctx
, GL_INVALID_VALUE
,
1392 "glDispatchComputeGroupSizeARB(group_size_%c)", 'x' + i
);
1396 total_invocations
*= group_size
[i
];
1399 /* The ARB_compute_variable_group_size spec says:
1401 * "An INVALID_VALUE error is generated by DispatchComputeGroupSizeARB if
1402 * the product of <group_size_x>, <group_size_y>, and <group_size_z> exceeds
1403 * the implementation-dependent maximum local work group invocation count
1404 * for compute shaders with variable group size
1405 * (MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB)."
1407 if (total_invocations
> ctx
->Const
.MaxComputeVariableGroupInvocations
) {
1408 _mesa_error(ctx
, GL_INVALID_VALUE
,
1409 "glDispatchComputeGroupSizeARB(product of local_sizes "
1410 "exceeds MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB "
1411 "(%d > %d))", total_invocations
,
1412 ctx
->Const
.MaxComputeVariableGroupInvocations
);
1420 valid_dispatch_indirect(struct gl_context
*ctx
,
1422 GLsizei size
, const char *name
)
1424 const uint64_t end
= (uint64_t) indirect
+ size
;
1425 struct gl_shader_program
*prog
;
1427 if (!check_valid_to_compute(ctx
, name
))
1430 /* From the OpenGL 4.3 Core Specification, Chapter 19, Compute Shaders:
1432 * "An INVALID_VALUE error is generated if indirect is negative or is not a
1433 * multiple of four."
1435 if (indirect
& (sizeof(GLuint
) - 1)) {
1436 _mesa_error(ctx
, GL_INVALID_VALUE
,
1437 "%s(indirect is not aligned)", name
);
1442 _mesa_error(ctx
, GL_INVALID_VALUE
,
1443 "%s(indirect is less than zero)", name
);
1447 /* From the OpenGL 4.3 Core Specification, Chapter 19, Compute Shaders:
1449 * "An INVALID_OPERATION error is generated if no buffer is bound to the
1450 * DRAW_INDIRECT_BUFFER binding, or if the command would source data
1451 * beyond the end of the buffer object."
1453 if (!_mesa_is_bufferobj(ctx
->DispatchIndirectBuffer
)) {
1454 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1455 "%s: no buffer bound to DISPATCH_INDIRECT_BUFFER", name
);
1459 if (_mesa_check_disallowed_mapping(ctx
->DispatchIndirectBuffer
)) {
1460 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1461 "%s(DISPATCH_INDIRECT_BUFFER is mapped)", name
);
1465 if (ctx
->DispatchIndirectBuffer
->Size
< end
) {
1466 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1467 "%s(DISPATCH_INDIRECT_BUFFER too small)", name
);
1471 /* The ARB_compute_variable_group_size spec says:
1473 * "An INVALID_OPERATION error is generated if the active program for the
1474 * compute shader stage has a variable work group size."
1476 prog
= ctx
->_Shader
->CurrentProgram
[MESA_SHADER_COMPUTE
];
1477 if (prog
->Comp
.LocalSizeVariable
) {
1478 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1479 "%s(variable work group size forbidden)", name
);
1487 _mesa_validate_DispatchComputeIndirect(struct gl_context
*ctx
,
1490 FLUSH_CURRENT(ctx
, 0);
1492 return valid_dispatch_indirect(ctx
, indirect
, 3 * sizeof(GLuint
),
1493 "glDispatchComputeIndirect");