3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
36 #include "debug_output.h"
48 _mesa_update_derived_primitive_restart_state(struct gl_context
*ctx
)
50 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
||
51 ctx
->Array
.PrimitiveRestartFixedIndex
;
52 ctx
->Array
._RestartIndex
[0] = _mesa_primitive_restart_index(ctx
, 1);
53 ctx
->Array
._RestartIndex
[1] = _mesa_primitive_restart_index(ctx
, 2);
54 ctx
->Array
._RestartIndex
[3] = _mesa_primitive_restart_index(ctx
, 4);
59 * Helper to enable/disable VAO client-side state.
62 vao_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
63 gl_vert_attrib attr
, GLboolean state
)
66 _mesa_enable_vertex_array_attrib(ctx
, vao
, attr
);
68 _mesa_disable_vertex_array_attrib(ctx
, vao
, attr
);
73 * Helper to enable/disable client-side state.
76 client_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
77 GLenum cap
, GLboolean state
)
81 vao_state(ctx
, vao
, VERT_ATTRIB_POS
, state
);
84 vao_state(ctx
, vao
, VERT_ATTRIB_NORMAL
, state
);
87 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR0
, state
);
90 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR_INDEX
, state
);
92 case GL_TEXTURE_COORD_ARRAY
:
93 vao_state(ctx
, vao
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
95 case GL_EDGE_FLAG_ARRAY
:
96 vao_state(ctx
, vao
, VERT_ATTRIB_EDGEFLAG
, state
);
98 case GL_FOG_COORDINATE_ARRAY_EXT
:
99 vao_state(ctx
, vao
, VERT_ATTRIB_FOG
, state
);
101 case GL_SECONDARY_COLOR_ARRAY_EXT
:
102 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR1
, state
);
105 case GL_POINT_SIZE_ARRAY_OES
:
106 if (ctx
->VertexProgram
.PointSizeEnabled
!= state
) {
107 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
108 ctx
->VertexProgram
.PointSizeEnabled
= state
;
110 vao_state(ctx
, vao
, VERT_ATTRIB_POINT_SIZE
, state
);
113 /* GL_NV_primitive_restart */
114 case GL_PRIMITIVE_RESTART_NV
:
115 if (!_mesa_has_NV_primitive_restart(ctx
))
116 goto invalid_enum_error
;
117 if (ctx
->Array
.PrimitiveRestart
== state
)
120 FLUSH_VERTICES(ctx
, 0);
121 ctx
->Array
.PrimitiveRestart
= state
;
122 _mesa_update_derived_primitive_restart_state(ctx
);
126 goto invalid_enum_error
;
129 if (ctx
->Driver
.Enable
) {
130 ctx
->Driver
.Enable( ctx
, cap
, state
);
136 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
137 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
141 /* Helper for GL_EXT_direct_state_access following functions:
142 * - EnableClientStateIndexedEXT
143 * - EnableClientStateiEXT
144 * - DisableClientStateIndexedEXT
145 * - DisableClientStateiEXT
148 client_state_i(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
149 GLenum cap
, GLuint index
, GLboolean state
)
153 if (cap
!= GL_TEXTURE_COORD_ARRAY
) {
154 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientStateiEXT(cap=%s)",
155 state
? "Enable" : "Disable",
156 _mesa_enum_to_string(cap
));
160 if (index
>= ctx
->Const
.MaxTextureCoordUnits
) {
161 _mesa_error(ctx
, GL_INVALID_VALUE
, "gl%sClientStateiEXT(index=%d)",
162 state
? "Enable" : "Disable",
167 saved_active
= ctx
->Array
.ActiveTexture
;
168 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
169 client_state(ctx
, vao
, cap
, state
);
170 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
175 * Enable GL capability.
176 * \param cap state to enable/disable.
178 * Get's the current context, assures that we're outside glBegin()/glEnd() and
179 * calls client_state().
182 _mesa_EnableClientState( GLenum cap
)
184 GET_CURRENT_CONTEXT(ctx
);
185 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_TRUE
);
190 _mesa_EnableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
192 GET_CURRENT_CONTEXT(ctx
);
193 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
195 "glEnableVertexArrayEXT");
199 /* The EXT_direct_state_access spec says:
200 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
201 * the tokens TEXTURE0 through TEXTUREn where n is less than the
202 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
203 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
204 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
205 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
206 * as if the active client texture is set to texture coordinate set i
207 * based on the token TEXTUREi indicated by array."
209 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
210 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
211 _mesa_ClientActiveTexture(cap
);
212 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_TRUE
);
213 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
215 client_state(ctx
, vao
, cap
, GL_TRUE
);
221 _mesa_EnableClientStateiEXT( GLenum cap
, GLuint index
)
223 GET_CURRENT_CONTEXT(ctx
);
224 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_TRUE
);
229 * Disable GL capability.
230 * \param cap state to enable/disable.
232 * Get's the current context, assures that we're outside glBegin()/glEnd() and
233 * calls client_state().
236 _mesa_DisableClientState( GLenum cap
)
238 GET_CURRENT_CONTEXT(ctx
);
239 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_FALSE
);
243 _mesa_DisableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
245 GET_CURRENT_CONTEXT(ctx
);
246 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
248 "glDisableVertexArrayEXT");
252 /* The EXT_direct_state_access spec says:
253 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
254 * the tokens TEXTURE0 through TEXTUREn where n is less than the
255 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
256 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
257 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
258 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
259 * as if the active client texture is set to texture coordinate set i
260 * based on the token TEXTUREi indicated by array."
262 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
263 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
264 _mesa_ClientActiveTexture(cap
);
265 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_FALSE
);
266 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
268 client_state(ctx
, vao
, cap
, GL_FALSE
);
273 _mesa_DisableClientStateiEXT( GLenum cap
, GLuint index
)
275 GET_CURRENT_CONTEXT(ctx
);
276 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_FALSE
);
280 * Return pointer to current texture unit for setting/getting coordinate
282 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
283 * texture unit is higher than the number of supported coordinate units.
285 static struct gl_fixedfunc_texture_unit
*
286 get_texcoord_unit(struct gl_context
*ctx
)
288 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
289 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
293 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
299 * Helper function to enable or disable a texture target.
300 * \param bit one of the TEXTURE_x_BIT values
301 * \return GL_TRUE if state is changing or GL_FALSE if no change
304 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
306 struct gl_fixedfunc_texture_unit
*texUnit
=
307 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
311 const GLbitfield newenabled
= state
312 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
314 if (texUnit
->Enabled
== newenabled
)
317 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
318 texUnit
->Enabled
= newenabled
;
324 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
325 * whether the API supports it (GLES doesn't).
328 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
330 if (ctx
->Multisample
.Enabled
== state
)
333 /* GL compatibility needs Multisample.Enable to determine program state
336 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
337 !ctx
->DriverFlags
.NewMultisampleEnable
) {
338 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
340 FLUSH_VERTICES(ctx
, 0);
343 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
344 ctx
->Multisample
.Enabled
= state
;
346 if (ctx
->Driver
.Enable
) {
347 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
352 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
353 * check for whether the API supports it (GLES doesn't).
356 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
358 if (ctx
->Color
.sRGBEnabled
== state
)
361 /* TODO: Switch i965 to the new flag and remove the conditional */
362 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
363 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
364 ctx
->Color
.sRGBEnabled
= state
;
366 if (ctx
->Driver
.Enable
) {
367 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
372 * Helper function to enable or disable state.
374 * \param ctx GL context.
375 * \param cap the state to enable/disable
376 * \param state whether to enable or disable the specified capability.
378 * Updates the current context and flushes the vertices as needed. For
379 * capabilities associated with extensions it verifies that those extensions
380 * are effectivly present before updating. Notifies the driver via
381 * dd_function_table::Enable.
384 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
386 if (MESA_VERBOSE
& VERBOSE_API
)
387 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
388 state
? "glEnable" : "glDisable",
389 _mesa_enum_to_string(cap
),
394 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
395 goto invalid_enum_error
;
396 if (ctx
->Color
.AlphaEnabled
== state
)
398 /* AlphaEnabled is used by the fixed-func fragment program */
399 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
400 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
401 ctx
->Color
.AlphaEnabled
= state
;
404 if (ctx
->API
!= API_OPENGL_COMPAT
)
405 goto invalid_enum_error
;
406 if (ctx
->Eval
.AutoNormal
== state
)
408 FLUSH_VERTICES(ctx
, 0);
409 vbo_exec_update_eval_maps(ctx
);
410 ctx
->Eval
.AutoNormal
= state
;
414 GLbitfield newEnabled
=
415 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
416 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
417 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
418 ctx
->Color
._AdvancedBlendMode
);
419 ctx
->Color
.BlendEnabled
= newEnabled
;
420 _mesa_update_allow_draw_out_of_order(ctx
);
424 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
425 case GL_CLIP_DISTANCE1
:
426 case GL_CLIP_DISTANCE2
:
427 case GL_CLIP_DISTANCE3
:
428 case GL_CLIP_DISTANCE4
:
429 case GL_CLIP_DISTANCE5
:
430 case GL_CLIP_DISTANCE6
:
431 case GL_CLIP_DISTANCE7
:
433 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
435 if (p
>= ctx
->Const
.MaxClipPlanes
)
436 goto invalid_enum_error
;
438 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
439 == ((GLuint
) state
<< p
))
442 /* The compatibility profile needs _NEW_TRANSFORM to transform
443 * clip planes according to the projection matrix.
445 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
446 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
447 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
449 FLUSH_VERTICES(ctx
, 0);
451 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
454 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
456 /* The projection matrix transforms the clip plane. */
457 /* TODO: glEnable might not be the best place to do it. */
458 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
459 _mesa_update_clip_plane(ctx
, p
);
460 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
464 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
468 case GL_COLOR_MATERIAL
:
469 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
470 goto invalid_enum_error
;
471 if (ctx
->Light
.ColorMaterialEnabled
== state
)
473 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
474 FLUSH_CURRENT(ctx
, 0);
475 ctx
->Light
.ColorMaterialEnabled
= state
;
477 _mesa_update_color_material( ctx
,
478 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
482 if (ctx
->Polygon
.CullFlag
== state
)
485 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
486 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
487 ctx
->Polygon
.CullFlag
= state
;
490 if (ctx
->Depth
.Test
== state
)
492 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
493 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
494 ctx
->Depth
.Test
= state
;
495 _mesa_update_allow_draw_out_of_order(ctx
);
497 case GL_DEBUG_OUTPUT
:
498 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
499 _mesa_set_debug_state_int(ctx
, cap
, state
);
502 if (ctx
->Color
.DitherFlag
== state
)
504 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
505 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
506 ctx
->Color
.DitherFlag
= state
;
509 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
510 goto invalid_enum_error
;
511 if (ctx
->Fog
.Enabled
== state
)
513 FLUSH_VERTICES(ctx
, _NEW_FOG
);
514 ctx
->Fog
.Enabled
= state
;
515 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
525 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
526 goto invalid_enum_error
;
527 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
529 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
530 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
532 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
535 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
539 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
540 goto invalid_enum_error
;
541 if (ctx
->Light
.Enabled
== state
)
543 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
544 ctx
->Light
.Enabled
= state
;
547 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
548 goto invalid_enum_error
;
549 if (ctx
->Line
.SmoothFlag
== state
)
551 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
552 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
553 ctx
->Line
.SmoothFlag
= state
;
555 case GL_LINE_STIPPLE
:
556 if (ctx
->API
!= API_OPENGL_COMPAT
)
557 goto invalid_enum_error
;
558 if (ctx
->Line
.StippleFlag
== state
)
560 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
561 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
562 ctx
->Line
.StippleFlag
= state
;
564 case GL_INDEX_LOGIC_OP
:
565 if (ctx
->API
!= API_OPENGL_COMPAT
)
566 goto invalid_enum_error
;
567 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
569 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
570 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
571 ctx
->Color
.IndexLogicOpEnabled
= state
;
573 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
574 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
575 goto invalid_enum_error
;
576 if (ctx
->IntelConservativeRasterization
== state
)
578 FLUSH_VERTICES(ctx
, 0);
579 ctx
->NewDriverState
|=
580 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
581 ctx
->IntelConservativeRasterization
= state
;
583 case GL_CONSERVATIVE_RASTERIZATION_NV
:
584 if (!_mesa_has_NV_conservative_raster(ctx
))
585 goto invalid_enum_error
;
586 if (ctx
->ConservativeRasterization
== state
)
588 FLUSH_VERTICES(ctx
, 0);
589 ctx
->NewDriverState
|=
590 ctx
->DriverFlags
.NewNvConservativeRasterization
;
591 ctx
->ConservativeRasterization
= state
;
593 case GL_COLOR_LOGIC_OP
:
594 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
595 goto invalid_enum_error
;
596 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
598 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
599 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
600 ctx
->Color
.ColorLogicOpEnabled
= state
;
601 _mesa_update_allow_draw_out_of_order(ctx
);
603 case GL_MAP1_COLOR_4
:
604 if (ctx
->API
!= API_OPENGL_COMPAT
)
605 goto invalid_enum_error
;
606 if (ctx
->Eval
.Map1Color4
== state
)
608 FLUSH_VERTICES(ctx
, 0);
609 vbo_exec_update_eval_maps(ctx
);
610 ctx
->Eval
.Map1Color4
= state
;
613 if (ctx
->API
!= API_OPENGL_COMPAT
)
614 goto invalid_enum_error
;
615 if (ctx
->Eval
.Map1Index
== state
)
617 FLUSH_VERTICES(ctx
, 0);
618 vbo_exec_update_eval_maps(ctx
);
619 ctx
->Eval
.Map1Index
= state
;
622 if (ctx
->API
!= API_OPENGL_COMPAT
)
623 goto invalid_enum_error
;
624 if (ctx
->Eval
.Map1Normal
== state
)
626 FLUSH_VERTICES(ctx
, 0);
627 vbo_exec_update_eval_maps(ctx
);
628 ctx
->Eval
.Map1Normal
= state
;
630 case GL_MAP1_TEXTURE_COORD_1
:
631 if (ctx
->API
!= API_OPENGL_COMPAT
)
632 goto invalid_enum_error
;
633 if (ctx
->Eval
.Map1TextureCoord1
== state
)
635 FLUSH_VERTICES(ctx
, 0);
636 vbo_exec_update_eval_maps(ctx
);
637 ctx
->Eval
.Map1TextureCoord1
= state
;
639 case GL_MAP1_TEXTURE_COORD_2
:
640 if (ctx
->API
!= API_OPENGL_COMPAT
)
641 goto invalid_enum_error
;
642 if (ctx
->Eval
.Map1TextureCoord2
== state
)
644 FLUSH_VERTICES(ctx
, 0);
645 vbo_exec_update_eval_maps(ctx
);
646 ctx
->Eval
.Map1TextureCoord2
= state
;
648 case GL_MAP1_TEXTURE_COORD_3
:
649 if (ctx
->API
!= API_OPENGL_COMPAT
)
650 goto invalid_enum_error
;
651 if (ctx
->Eval
.Map1TextureCoord3
== state
)
653 FLUSH_VERTICES(ctx
, 0);
654 vbo_exec_update_eval_maps(ctx
);
655 ctx
->Eval
.Map1TextureCoord3
= state
;
657 case GL_MAP1_TEXTURE_COORD_4
:
658 if (ctx
->API
!= API_OPENGL_COMPAT
)
659 goto invalid_enum_error
;
660 if (ctx
->Eval
.Map1TextureCoord4
== state
)
662 FLUSH_VERTICES(ctx
, 0);
663 vbo_exec_update_eval_maps(ctx
);
664 ctx
->Eval
.Map1TextureCoord4
= state
;
666 case GL_MAP1_VERTEX_3
:
667 if (ctx
->API
!= API_OPENGL_COMPAT
)
668 goto invalid_enum_error
;
669 if (ctx
->Eval
.Map1Vertex3
== state
)
671 FLUSH_VERTICES(ctx
, 0);
672 vbo_exec_update_eval_maps(ctx
);
673 ctx
->Eval
.Map1Vertex3
= state
;
675 case GL_MAP1_VERTEX_4
:
676 if (ctx
->API
!= API_OPENGL_COMPAT
)
677 goto invalid_enum_error
;
678 if (ctx
->Eval
.Map1Vertex4
== state
)
680 FLUSH_VERTICES(ctx
, 0);
681 vbo_exec_update_eval_maps(ctx
);
682 ctx
->Eval
.Map1Vertex4
= state
;
684 case GL_MAP2_COLOR_4
:
685 if (ctx
->API
!= API_OPENGL_COMPAT
)
686 goto invalid_enum_error
;
687 if (ctx
->Eval
.Map2Color4
== state
)
689 FLUSH_VERTICES(ctx
, 0);
690 vbo_exec_update_eval_maps(ctx
);
691 ctx
->Eval
.Map2Color4
= state
;
694 if (ctx
->API
!= API_OPENGL_COMPAT
)
695 goto invalid_enum_error
;
696 if (ctx
->Eval
.Map2Index
== state
)
698 FLUSH_VERTICES(ctx
, 0);
699 vbo_exec_update_eval_maps(ctx
);
700 ctx
->Eval
.Map2Index
= state
;
703 if (ctx
->API
!= API_OPENGL_COMPAT
)
704 goto invalid_enum_error
;
705 if (ctx
->Eval
.Map2Normal
== state
)
707 FLUSH_VERTICES(ctx
, 0);
708 vbo_exec_update_eval_maps(ctx
);
709 ctx
->Eval
.Map2Normal
= state
;
711 case GL_MAP2_TEXTURE_COORD_1
:
712 if (ctx
->API
!= API_OPENGL_COMPAT
)
713 goto invalid_enum_error
;
714 if (ctx
->Eval
.Map2TextureCoord1
== state
)
716 FLUSH_VERTICES(ctx
, 0);
717 vbo_exec_update_eval_maps(ctx
);
718 ctx
->Eval
.Map2TextureCoord1
= state
;
720 case GL_MAP2_TEXTURE_COORD_2
:
721 if (ctx
->API
!= API_OPENGL_COMPAT
)
722 goto invalid_enum_error
;
723 if (ctx
->Eval
.Map2TextureCoord2
== state
)
725 FLUSH_VERTICES(ctx
, 0);
726 vbo_exec_update_eval_maps(ctx
);
727 ctx
->Eval
.Map2TextureCoord2
= state
;
729 case GL_MAP2_TEXTURE_COORD_3
:
730 if (ctx
->API
!= API_OPENGL_COMPAT
)
731 goto invalid_enum_error
;
732 if (ctx
->Eval
.Map2TextureCoord3
== state
)
734 FLUSH_VERTICES(ctx
, 0);
735 vbo_exec_update_eval_maps(ctx
);
736 ctx
->Eval
.Map2TextureCoord3
= state
;
738 case GL_MAP2_TEXTURE_COORD_4
:
739 if (ctx
->API
!= API_OPENGL_COMPAT
)
740 goto invalid_enum_error
;
741 if (ctx
->Eval
.Map2TextureCoord4
== state
)
743 FLUSH_VERTICES(ctx
, 0);
744 vbo_exec_update_eval_maps(ctx
);
745 ctx
->Eval
.Map2TextureCoord4
= state
;
747 case GL_MAP2_VERTEX_3
:
748 if (ctx
->API
!= API_OPENGL_COMPAT
)
749 goto invalid_enum_error
;
750 if (ctx
->Eval
.Map2Vertex3
== state
)
752 FLUSH_VERTICES(ctx
, 0);
753 vbo_exec_update_eval_maps(ctx
);
754 ctx
->Eval
.Map2Vertex3
= state
;
756 case GL_MAP2_VERTEX_4
:
757 if (ctx
->API
!= API_OPENGL_COMPAT
)
758 goto invalid_enum_error
;
759 if (ctx
->Eval
.Map2Vertex4
== state
)
761 FLUSH_VERTICES(ctx
, 0);
762 vbo_exec_update_eval_maps(ctx
);
763 ctx
->Eval
.Map2Vertex4
= state
;
766 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
767 goto invalid_enum_error
;
768 if (ctx
->Transform
.Normalize
== state
)
770 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
771 ctx
->Transform
.Normalize
= state
;
773 case GL_POINT_SMOOTH
:
774 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
775 goto invalid_enum_error
;
776 if (ctx
->Point
.SmoothFlag
== state
)
778 FLUSH_VERTICES(ctx
, _NEW_POINT
);
779 ctx
->Point
.SmoothFlag
= state
;
781 case GL_POLYGON_SMOOTH
:
782 if (!_mesa_is_desktop_gl(ctx
))
783 goto invalid_enum_error
;
784 if (ctx
->Polygon
.SmoothFlag
== state
)
787 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
788 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
789 ctx
->Polygon
.SmoothFlag
= state
;
791 case GL_POLYGON_STIPPLE
:
792 if (ctx
->API
!= API_OPENGL_COMPAT
)
793 goto invalid_enum_error
;
794 if (ctx
->Polygon
.StippleFlag
== state
)
797 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
798 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
799 ctx
->Polygon
.StippleFlag
= state
;
801 case GL_POLYGON_OFFSET_POINT
:
802 if (!_mesa_is_desktop_gl(ctx
))
803 goto invalid_enum_error
;
804 if (ctx
->Polygon
.OffsetPoint
== state
)
807 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
808 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
809 ctx
->Polygon
.OffsetPoint
= state
;
811 case GL_POLYGON_OFFSET_LINE
:
812 if (!_mesa_is_desktop_gl(ctx
))
813 goto invalid_enum_error
;
814 if (ctx
->Polygon
.OffsetLine
== state
)
817 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
818 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
819 ctx
->Polygon
.OffsetLine
= state
;
821 case GL_POLYGON_OFFSET_FILL
:
822 if (ctx
->Polygon
.OffsetFill
== state
)
825 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
826 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
827 ctx
->Polygon
.OffsetFill
= state
;
829 case GL_RESCALE_NORMAL_EXT
:
830 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
831 goto invalid_enum_error
;
832 if (ctx
->Transform
.RescaleNormals
== state
)
834 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
835 ctx
->Transform
.RescaleNormals
= state
;
837 case GL_SCISSOR_TEST
:
839 /* Must expand glEnable to all scissors */
840 GLbitfield newEnabled
=
841 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
842 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
843 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
845 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
846 ctx
->Scissor
.EnableFlags
= newEnabled
;
850 case GL_STENCIL_TEST
:
851 if (ctx
->Stencil
.Enabled
== state
)
853 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
854 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
855 ctx
->Stencil
.Enabled
= state
;
856 _mesa_update_allow_draw_out_of_order(ctx
);
859 if (ctx
->API
!= API_OPENGL_COMPAT
)
860 goto invalid_enum_error
;
861 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
866 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
867 goto invalid_enum_error
;
868 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
873 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
874 goto invalid_enum_error
;
875 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
879 case GL_TEXTURE_GEN_S
:
880 case GL_TEXTURE_GEN_T
:
881 case GL_TEXTURE_GEN_R
:
882 case GL_TEXTURE_GEN_Q
:
884 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
886 if (ctx
->API
!= API_OPENGL_COMPAT
)
887 goto invalid_enum_error
;
890 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
891 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
893 newenabled
|= coordBit
;
894 if (texUnit
->TexGenEnabled
== newenabled
)
896 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
897 texUnit
->TexGenEnabled
= newenabled
;
902 case GL_TEXTURE_GEN_STR_OES
:
903 /* disable S, T, and R at the same time */
905 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
907 if (ctx
->API
!= API_OPENGLES
)
908 goto invalid_enum_error
;
912 texUnit
->TexGenEnabled
& ~STR_BITS
;
914 newenabled
|= STR_BITS
;
915 if (texUnit
->TexGenEnabled
== newenabled
)
917 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
918 texUnit
->TexGenEnabled
= newenabled
;
923 /* client-side state */
924 case GL_VERTEX_ARRAY
:
925 case GL_NORMAL_ARRAY
:
927 case GL_TEXTURE_COORD_ARRAY
:
928 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
929 goto invalid_enum_error
;
930 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
933 case GL_EDGE_FLAG_ARRAY
:
934 case GL_FOG_COORDINATE_ARRAY_EXT
:
935 case GL_SECONDARY_COLOR_ARRAY_EXT
:
936 if (ctx
->API
!= API_OPENGL_COMPAT
)
937 goto invalid_enum_error
;
938 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
940 case GL_POINT_SIZE_ARRAY_OES
:
941 if (ctx
->API
!= API_OPENGLES
)
942 goto invalid_enum_error
;
943 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
946 /* GL_ARB_texture_cube_map */
947 case GL_TEXTURE_CUBE_MAP
:
948 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
949 !_mesa_has_OES_texture_cube_map(ctx
))
950 goto invalid_enum_error
;
951 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
956 /* GL_EXT_secondary_color */
957 case GL_COLOR_SUM_EXT
:
958 if (ctx
->API
!= API_OPENGL_COMPAT
)
959 goto invalid_enum_error
;
960 if (ctx
->Fog
.ColorSumEnabled
== state
)
962 FLUSH_VERTICES(ctx
, _NEW_FOG
);
963 ctx
->Fog
.ColorSumEnabled
= state
;
966 /* GL_ARB_multisample */
967 case GL_MULTISAMPLE_ARB
:
968 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
969 goto invalid_enum_error
;
970 _mesa_set_multisample(ctx
, state
);
972 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
973 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
975 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
977 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
978 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
980 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
981 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
982 goto invalid_enum_error
;
983 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
985 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
987 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
988 ctx
->Multisample
.SampleAlphaToOne
= state
;
990 case GL_SAMPLE_COVERAGE_ARB
:
991 if (ctx
->Multisample
.SampleCoverage
== state
)
993 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
995 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
996 ctx
->Multisample
.SampleCoverage
= state
;
998 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
999 if (!_mesa_is_desktop_gl(ctx
))
1000 goto invalid_enum_error
;
1001 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
1003 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1005 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1006 ctx
->Multisample
.SampleCoverageInvert
= state
;
1009 /* GL_ARB_sample_shading */
1010 case GL_SAMPLE_SHADING
:
1011 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
1012 goto invalid_enum_error
;
1013 if (ctx
->Multisample
.SampleShading
== state
)
1015 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
1017 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
1018 ctx
->Multisample
.SampleShading
= state
;
1021 /* GL_IBM_rasterpos_clip */
1022 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1023 if (ctx
->API
!= API_OPENGL_COMPAT
)
1024 goto invalid_enum_error
;
1025 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
1027 FLUSH_VERTICES(ctx
, 0);
1028 ctx
->Transform
.RasterPositionUnclipped
= state
;
1031 /* GL_NV_point_sprite */
1032 case GL_POINT_SPRITE_NV
:
1033 if (!(ctx
->API
== API_OPENGL_COMPAT
&&
1034 (_mesa_has_ARB_point_sprite(ctx
) ||
1035 _mesa_has_NV_point_sprite(ctx
))) &&
1036 !_mesa_has_OES_point_sprite(ctx
))
1037 goto invalid_enum_error
;
1038 if (ctx
->Point
.PointSprite
== state
)
1040 FLUSH_VERTICES(ctx
, _NEW_POINT
);
1041 ctx
->Point
.PointSprite
= state
;
1044 case GL_VERTEX_PROGRAM_ARB
:
1045 if (!_mesa_has_ARB_vertex_program(ctx
))
1046 goto invalid_enum_error
;
1047 if (ctx
->VertexProgram
.Enabled
== state
)
1049 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1050 ctx
->VertexProgram
.Enabled
= state
;
1051 _mesa_update_vertex_processing_mode(ctx
);
1053 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1054 /* This was added with ARB_vertex_program, but it is also used with
1055 * GLSL vertex shaders on desktop.
1057 if (!_mesa_has_ARB_vertex_program(ctx
) &&
1058 ctx
->API
!= API_OPENGL_CORE
)
1059 goto invalid_enum_error
;
1060 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
1062 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1063 ctx
->VertexProgram
.PointSizeEnabled
= state
;
1065 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1066 if (!_mesa_has_ARB_vertex_program(ctx
))
1067 goto invalid_enum_error
;
1068 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
1070 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1071 ctx
->VertexProgram
.TwoSideEnabled
= state
;
1074 /* GL_NV_texture_rectangle */
1075 case GL_TEXTURE_RECTANGLE_NV
:
1076 if (!_mesa_has_NV_texture_rectangle(ctx
))
1077 goto invalid_enum_error
;
1078 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
1083 /* GL_EXT_stencil_two_side */
1084 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1085 if (!_mesa_has_EXT_stencil_two_side(ctx
))
1086 goto invalid_enum_error
;
1087 if (ctx
->Stencil
.TestTwoSide
== state
)
1089 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
1090 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
1091 ctx
->Stencil
.TestTwoSide
= state
;
1093 ctx
->Stencil
._BackFace
= 2;
1095 ctx
->Stencil
._BackFace
= 1;
1099 case GL_FRAGMENT_PROGRAM_ARB
:
1100 if (!_mesa_has_ARB_fragment_program(ctx
))
1101 goto invalid_enum_error
;
1102 if (ctx
->FragmentProgram
.Enabled
== state
)
1104 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1105 ctx
->FragmentProgram
.Enabled
= state
;
1108 /* GL_EXT_depth_bounds_test */
1109 case GL_DEPTH_BOUNDS_TEST_EXT
:
1110 if (!_mesa_has_EXT_depth_bounds_test(ctx
))
1111 goto invalid_enum_error
;
1112 if (ctx
->Depth
.BoundsTest
== state
)
1114 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
1115 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
1116 ctx
->Depth
.BoundsTest
= state
;
1119 case GL_DEPTH_CLAMP
:
1120 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1121 !_mesa_has_EXT_depth_clamp(ctx
))
1122 goto invalid_enum_error
;
1123 if (ctx
->Transform
.DepthClampNear
== state
&&
1124 ctx
->Transform
.DepthClampFar
== state
)
1126 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1128 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1129 ctx
->Transform
.DepthClampNear
= state
;
1130 ctx
->Transform
.DepthClampFar
= state
;
1133 case GL_DEPTH_CLAMP_NEAR_AMD
:
1134 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1135 goto invalid_enum_error
;
1136 if (ctx
->Transform
.DepthClampNear
== state
)
1138 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1140 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1141 ctx
->Transform
.DepthClampNear
= state
;
1144 case GL_DEPTH_CLAMP_FAR_AMD
:
1145 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1146 goto invalid_enum_error
;
1147 if (ctx
->Transform
.DepthClampFar
== state
)
1149 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1151 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1152 ctx
->Transform
.DepthClampFar
= state
;
1155 case GL_FRAGMENT_SHADER_ATI
:
1156 if (!_mesa_has_ATI_fragment_shader(ctx
))
1157 goto invalid_enum_error
;
1158 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1160 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1161 ctx
->ATIFragmentShader
.Enabled
= state
;
1164 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1165 if (!_mesa_has_ARB_seamless_cube_map(ctx
))
1166 goto invalid_enum_error
;
1167 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1168 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1169 ctx
->Texture
.CubeMapSeamless
= state
;
1173 case GL_RASTERIZER_DISCARD
:
1174 if (!(_mesa_has_EXT_transform_feedback(ctx
) || _mesa_is_gles3(ctx
)))
1175 goto invalid_enum_error
;
1176 if (ctx
->RasterDiscard
!= state
) {
1177 FLUSH_VERTICES(ctx
, 0);
1178 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1179 ctx
->RasterDiscard
= state
;
1183 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1184 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1185 goto invalid_enum_error
;
1186 if (ctx
->TileRasterOrderFixed
!= state
) {
1187 FLUSH_VERTICES(ctx
, 0);
1188 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1189 ctx
->TileRasterOrderFixed
= state
;
1193 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1194 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1195 goto invalid_enum_error
;
1196 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1197 FLUSH_VERTICES(ctx
, 0);
1198 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1199 ctx
->TileRasterOrderIncreasingX
= state
;
1203 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1204 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1205 goto invalid_enum_error
;
1206 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1207 FLUSH_VERTICES(ctx
, 0);
1208 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1209 ctx
->TileRasterOrderIncreasingY
= state
;
1213 /* GL 3.1 primitive restart. Note: this enum is different from
1214 * GL_PRIMITIVE_RESTART_NV (which is client state).
1216 case GL_PRIMITIVE_RESTART
:
1217 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1218 goto invalid_enum_error
;
1220 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1221 FLUSH_VERTICES(ctx
, 0);
1222 ctx
->Array
.PrimitiveRestart
= state
;
1223 _mesa_update_derived_primitive_restart_state(ctx
);
1227 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1228 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1229 goto invalid_enum_error
;
1230 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1231 FLUSH_VERTICES(ctx
, 0);
1232 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1233 _mesa_update_derived_primitive_restart_state(ctx
);
1237 /* GL3.0 - GL_framebuffer_sRGB */
1238 case GL_FRAMEBUFFER_SRGB_EXT
:
1239 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1240 !_mesa_has_EXT_sRGB_write_control(ctx
))
1241 goto invalid_enum_error
;
1242 _mesa_set_framebuffer_srgb(ctx
, state
);
1245 /* GL_OES_EGL_image_external */
1246 case GL_TEXTURE_EXTERNAL_OES
:
1247 if (!_mesa_has_OES_EGL_image_external(ctx
))
1248 goto invalid_enum_error
;
1249 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1254 /* ARB_texture_multisample */
1255 case GL_SAMPLE_MASK
:
1256 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1257 goto invalid_enum_error
;
1258 if (ctx
->Multisample
.SampleMask
== state
)
1260 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1262 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1263 ctx
->Multisample
.SampleMask
= state
;
1266 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1267 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1268 goto invalid_enum_error
;
1269 if (ctx
->Color
.BlendCoherent
== state
)
1271 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1272 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1273 ctx
->Color
.BlendCoherent
= state
;
1276 case GL_BLACKHOLE_RENDER_INTEL
:
1277 if (!_mesa_has_INTEL_blackhole_render(ctx
))
1278 goto invalid_enum_error
;
1279 if (ctx
->IntelBlackholeRender
== state
)
1281 FLUSH_VERTICES(ctx
, 0);
1282 ctx
->IntelBlackholeRender
= state
;
1286 goto invalid_enum_error
;
1289 if (ctx
->Driver
.Enable
) {
1290 ctx
->Driver
.Enable( ctx
, cap
, state
);
1296 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1297 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1302 * Enable GL capability. Called by glEnable()
1303 * \param cap state to enable.
1306 _mesa_Enable( GLenum cap
)
1308 GET_CURRENT_CONTEXT(ctx
);
1310 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1315 * Disable GL capability. Called by glDisable()
1316 * \param cap state to disable.
1319 _mesa_Disable( GLenum cap
)
1321 GET_CURRENT_CONTEXT(ctx
);
1323 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1329 * Enable/disable an indexed state var.
1332 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1333 GLuint index
, GLboolean state
)
1335 assert(state
== 0 || state
== 1);
1338 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1339 goto invalid_enum_error
;
1341 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1342 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1343 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1346 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1347 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1350 enabled
|= (1 << index
);
1352 enabled
&= ~(1 << index
);
1354 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1355 ctx
->Color
._AdvancedBlendMode
);
1356 ctx
->Color
.BlendEnabled
= enabled
;
1357 _mesa_update_allow_draw_out_of_order(ctx
);
1360 case GL_SCISSOR_TEST
:
1361 if (index
>= ctx
->Const
.MaxViewports
) {
1362 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1363 state
? "glEnablei" : "glDisablei", index
);
1366 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1368 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1369 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1371 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1373 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1376 /* EXT_direct_state_access */
1380 case GL_TEXTURE_CUBE_MAP
:
1381 case GL_TEXTURE_GEN_S
:
1382 case GL_TEXTURE_GEN_T
:
1383 case GL_TEXTURE_GEN_R
:
1384 case GL_TEXTURE_GEN_Q
:
1385 case GL_TEXTURE_RECTANGLE_ARB
: {
1386 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1387 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1388 ctx
->Const
.MaxTextureCoordUnits
)) {
1389 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1390 state
? "glEnablei" : "glDisablei", index
);
1393 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1394 _mesa_set_enable( ctx
, cap
, state
);
1395 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1399 goto invalid_enum_error
;
1404 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1405 state
? "glEnablei" : "glDisablei",
1406 _mesa_enum_to_string(cap
));
1411 _mesa_Disablei( GLenum cap
, GLuint index
)
1413 GET_CURRENT_CONTEXT(ctx
);
1414 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1419 _mesa_Enablei( GLenum cap
, GLuint index
)
1421 GET_CURRENT_CONTEXT(ctx
);
1422 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1426 GLboolean GLAPIENTRY
1427 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1429 GET_CURRENT_CONTEXT(ctx
);
1430 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1433 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1434 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1438 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1439 case GL_SCISSOR_TEST
:
1440 if (index
>= ctx
->Const
.MaxViewports
) {
1441 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1445 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1446 /* EXT_direct_state_access */
1450 case GL_TEXTURE_CUBE_MAP
:
1451 case GL_TEXTURE_GEN_S
:
1452 case GL_TEXTURE_GEN_T
:
1453 case GL_TEXTURE_GEN_R
:
1454 case GL_TEXTURE_GEN_Q
:
1455 case GL_TEXTURE_RECTANGLE_ARB
: {
1457 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1458 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1459 ctx
->Const
.MaxTextureCoordUnits
)) {
1460 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1464 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1465 state
= _mesa_IsEnabled(cap
);
1466 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1470 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1471 _mesa_enum_to_string(cap
));
1479 * Helper function to determine whether a texture target is enabled.
1482 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1484 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1485 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
1490 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1495 * Return simple enable/disable state.
1497 * \param cap state variable to query.
1499 * Returns the state of the specified capability from the current GL context.
1500 * For the capabilities associated with extensions verifies that those
1501 * extensions are effectively present before reporting.
1503 GLboolean GLAPIENTRY
1504 _mesa_IsEnabled( GLenum cap
)
1506 GET_CURRENT_CONTEXT(ctx
);
1507 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1511 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1512 goto invalid_enum_error
;
1513 return ctx
->Color
.AlphaEnabled
;
1514 case GL_AUTO_NORMAL
:
1515 if (ctx
->API
!= API_OPENGL_COMPAT
)
1516 goto invalid_enum_error
;
1517 return ctx
->Eval
.AutoNormal
;
1519 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1520 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1521 case GL_CLIP_DISTANCE1
:
1522 case GL_CLIP_DISTANCE2
:
1523 case GL_CLIP_DISTANCE3
:
1524 case GL_CLIP_DISTANCE4
:
1525 case GL_CLIP_DISTANCE5
:
1526 case GL_CLIP_DISTANCE6
:
1527 case GL_CLIP_DISTANCE7
: {
1528 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1530 if (p
>= ctx
->Const
.MaxClipPlanes
)
1531 goto invalid_enum_error
;
1533 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1535 case GL_COLOR_MATERIAL
:
1536 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1537 goto invalid_enum_error
;
1538 return ctx
->Light
.ColorMaterialEnabled
;
1540 return ctx
->Polygon
.CullFlag
;
1541 case GL_DEBUG_OUTPUT
:
1542 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1543 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1545 return ctx
->Depth
.Test
;
1547 return ctx
->Color
.DitherFlag
;
1549 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1550 goto invalid_enum_error
;
1551 return ctx
->Fog
.Enabled
;
1553 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1554 goto invalid_enum_error
;
1555 return ctx
->Light
.Enabled
;
1564 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1565 goto invalid_enum_error
;
1566 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1567 case GL_LINE_SMOOTH
:
1568 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1569 goto invalid_enum_error
;
1570 return ctx
->Line
.SmoothFlag
;
1571 case GL_LINE_STIPPLE
:
1572 if (ctx
->API
!= API_OPENGL_COMPAT
)
1573 goto invalid_enum_error
;
1574 return ctx
->Line
.StippleFlag
;
1575 case GL_INDEX_LOGIC_OP
:
1576 if (ctx
->API
!= API_OPENGL_COMPAT
)
1577 goto invalid_enum_error
;
1578 return ctx
->Color
.IndexLogicOpEnabled
;
1579 case GL_COLOR_LOGIC_OP
:
1580 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1581 goto invalid_enum_error
;
1582 return ctx
->Color
.ColorLogicOpEnabled
;
1583 case GL_MAP1_COLOR_4
:
1584 if (ctx
->API
!= API_OPENGL_COMPAT
)
1585 goto invalid_enum_error
;
1586 return ctx
->Eval
.Map1Color4
;
1588 if (ctx
->API
!= API_OPENGL_COMPAT
)
1589 goto invalid_enum_error
;
1590 return ctx
->Eval
.Map1Index
;
1591 case GL_MAP1_NORMAL
:
1592 if (ctx
->API
!= API_OPENGL_COMPAT
)
1593 goto invalid_enum_error
;
1594 return ctx
->Eval
.Map1Normal
;
1595 case GL_MAP1_TEXTURE_COORD_1
:
1596 if (ctx
->API
!= API_OPENGL_COMPAT
)
1597 goto invalid_enum_error
;
1598 return ctx
->Eval
.Map1TextureCoord1
;
1599 case GL_MAP1_TEXTURE_COORD_2
:
1600 if (ctx
->API
!= API_OPENGL_COMPAT
)
1601 goto invalid_enum_error
;
1602 return ctx
->Eval
.Map1TextureCoord2
;
1603 case GL_MAP1_TEXTURE_COORD_3
:
1604 if (ctx
->API
!= API_OPENGL_COMPAT
)
1605 goto invalid_enum_error
;
1606 return ctx
->Eval
.Map1TextureCoord3
;
1607 case GL_MAP1_TEXTURE_COORD_4
:
1608 if (ctx
->API
!= API_OPENGL_COMPAT
)
1609 goto invalid_enum_error
;
1610 return ctx
->Eval
.Map1TextureCoord4
;
1611 case GL_MAP1_VERTEX_3
:
1612 if (ctx
->API
!= API_OPENGL_COMPAT
)
1613 goto invalid_enum_error
;
1614 return ctx
->Eval
.Map1Vertex3
;
1615 case GL_MAP1_VERTEX_4
:
1616 if (ctx
->API
!= API_OPENGL_COMPAT
)
1617 goto invalid_enum_error
;
1618 return ctx
->Eval
.Map1Vertex4
;
1619 case GL_MAP2_COLOR_4
:
1620 if (ctx
->API
!= API_OPENGL_COMPAT
)
1621 goto invalid_enum_error
;
1622 return ctx
->Eval
.Map2Color4
;
1624 if (ctx
->API
!= API_OPENGL_COMPAT
)
1625 goto invalid_enum_error
;
1626 return ctx
->Eval
.Map2Index
;
1627 case GL_MAP2_NORMAL
:
1628 if (ctx
->API
!= API_OPENGL_COMPAT
)
1629 goto invalid_enum_error
;
1630 return ctx
->Eval
.Map2Normal
;
1631 case GL_MAP2_TEXTURE_COORD_1
:
1632 if (ctx
->API
!= API_OPENGL_COMPAT
)
1633 goto invalid_enum_error
;
1634 return ctx
->Eval
.Map2TextureCoord1
;
1635 case GL_MAP2_TEXTURE_COORD_2
:
1636 if (ctx
->API
!= API_OPENGL_COMPAT
)
1637 goto invalid_enum_error
;
1638 return ctx
->Eval
.Map2TextureCoord2
;
1639 case GL_MAP2_TEXTURE_COORD_3
:
1640 if (ctx
->API
!= API_OPENGL_COMPAT
)
1641 goto invalid_enum_error
;
1642 return ctx
->Eval
.Map2TextureCoord3
;
1643 case GL_MAP2_TEXTURE_COORD_4
:
1644 if (ctx
->API
!= API_OPENGL_COMPAT
)
1645 goto invalid_enum_error
;
1646 return ctx
->Eval
.Map2TextureCoord4
;
1647 case GL_MAP2_VERTEX_3
:
1648 if (ctx
->API
!= API_OPENGL_COMPAT
)
1649 goto invalid_enum_error
;
1650 return ctx
->Eval
.Map2Vertex3
;
1651 case GL_MAP2_VERTEX_4
:
1652 if (ctx
->API
!= API_OPENGL_COMPAT
)
1653 goto invalid_enum_error
;
1654 return ctx
->Eval
.Map2Vertex4
;
1656 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1657 goto invalid_enum_error
;
1658 return ctx
->Transform
.Normalize
;
1659 case GL_POINT_SMOOTH
:
1660 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1661 goto invalid_enum_error
;
1662 return ctx
->Point
.SmoothFlag
;
1663 case GL_POLYGON_SMOOTH
:
1664 if (!_mesa_is_desktop_gl(ctx
))
1665 goto invalid_enum_error
;
1666 return ctx
->Polygon
.SmoothFlag
;
1667 case GL_POLYGON_STIPPLE
:
1668 if (ctx
->API
!= API_OPENGL_COMPAT
)
1669 goto invalid_enum_error
;
1670 return ctx
->Polygon
.StippleFlag
;
1671 case GL_POLYGON_OFFSET_POINT
:
1672 if (!_mesa_is_desktop_gl(ctx
))
1673 goto invalid_enum_error
;
1674 return ctx
->Polygon
.OffsetPoint
;
1675 case GL_POLYGON_OFFSET_LINE
:
1676 if (!_mesa_is_desktop_gl(ctx
))
1677 goto invalid_enum_error
;
1678 return ctx
->Polygon
.OffsetLine
;
1679 case GL_POLYGON_OFFSET_FILL
:
1680 return ctx
->Polygon
.OffsetFill
;
1681 case GL_RESCALE_NORMAL_EXT
:
1682 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1683 goto invalid_enum_error
;
1684 return ctx
->Transform
.RescaleNormals
;
1685 case GL_SCISSOR_TEST
:
1686 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1687 case GL_STENCIL_TEST
:
1688 return ctx
->Stencil
.Enabled
;
1690 if (ctx
->API
!= API_OPENGL_COMPAT
)
1691 goto invalid_enum_error
;
1692 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1694 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1695 goto invalid_enum_error
;
1696 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1698 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1699 goto invalid_enum_error
;
1700 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1701 case GL_TEXTURE_GEN_S
:
1702 case GL_TEXTURE_GEN_T
:
1703 case GL_TEXTURE_GEN_R
:
1704 case GL_TEXTURE_GEN_Q
:
1706 const struct gl_fixedfunc_texture_unit
*texUnit
=
1707 get_texcoord_unit(ctx
);
1709 if (ctx
->API
!= API_OPENGL_COMPAT
)
1710 goto invalid_enum_error
;
1713 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1714 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1718 case GL_TEXTURE_GEN_STR_OES
:
1720 const struct gl_fixedfunc_texture_unit
*texUnit
=
1721 get_texcoord_unit(ctx
);
1723 if (ctx
->API
!= API_OPENGLES
)
1724 goto invalid_enum_error
;
1727 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1728 ? GL_TRUE
: GL_FALSE
;
1732 /* client-side state */
1733 case GL_VERTEX_ARRAY
:
1734 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1735 goto invalid_enum_error
;
1736 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
1737 case GL_NORMAL_ARRAY
:
1738 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1739 goto invalid_enum_error
;
1740 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
1741 case GL_COLOR_ARRAY
:
1742 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1743 goto invalid_enum_error
;
1744 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
1745 case GL_INDEX_ARRAY
:
1746 if (ctx
->API
!= API_OPENGL_COMPAT
)
1747 goto invalid_enum_error
;
1748 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
1749 case GL_TEXTURE_COORD_ARRAY
:
1750 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1751 goto invalid_enum_error
;
1752 return !!(ctx
->Array
.VAO
->Enabled
&
1753 VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
1754 case GL_EDGE_FLAG_ARRAY
:
1755 if (ctx
->API
!= API_OPENGL_COMPAT
)
1756 goto invalid_enum_error
;
1757 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
1758 case GL_FOG_COORDINATE_ARRAY_EXT
:
1759 if (ctx
->API
!= API_OPENGL_COMPAT
)
1760 goto invalid_enum_error
;
1761 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
1762 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1763 if (ctx
->API
!= API_OPENGL_COMPAT
)
1764 goto invalid_enum_error
;
1765 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
1766 case GL_POINT_SIZE_ARRAY_OES
:
1767 if (ctx
->API
!= API_OPENGLES
)
1768 goto invalid_enum_error
;
1769 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
1771 /* GL_ARB_texture_cube_map */
1772 case GL_TEXTURE_CUBE_MAP
:
1773 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
1774 !_mesa_has_OES_texture_cube_map(ctx
))
1775 goto invalid_enum_error
;
1776 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1778 /* GL_EXT_secondary_color */
1779 case GL_COLOR_SUM_EXT
:
1780 if (ctx
->API
!= API_OPENGL_COMPAT
)
1781 goto invalid_enum_error
;
1782 return ctx
->Fog
.ColorSumEnabled
;
1784 /* GL_ARB_multisample */
1785 case GL_MULTISAMPLE_ARB
:
1786 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1787 goto invalid_enum_error
;
1788 return ctx
->Multisample
.Enabled
;
1789 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1790 return ctx
->Multisample
.SampleAlphaToCoverage
;
1791 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1792 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1793 goto invalid_enum_error
;
1794 return ctx
->Multisample
.SampleAlphaToOne
;
1795 case GL_SAMPLE_COVERAGE_ARB
:
1796 return ctx
->Multisample
.SampleCoverage
;
1797 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1798 if (!_mesa_is_desktop_gl(ctx
))
1799 goto invalid_enum_error
;
1800 return ctx
->Multisample
.SampleCoverageInvert
;
1802 /* GL_IBM_rasterpos_clip */
1803 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1804 if (ctx
->API
!= API_OPENGL_COMPAT
)
1805 goto invalid_enum_error
;
1806 return ctx
->Transform
.RasterPositionUnclipped
;
1808 /* GL_NV_point_sprite */
1809 case GL_POINT_SPRITE_NV
:
1810 if (!(ctx
->API
== API_OPENGL_COMPAT
&&
1811 (_mesa_has_ARB_point_sprite(ctx
) ||
1812 _mesa_has_NV_point_sprite(ctx
))) &&
1813 !_mesa_has_OES_point_sprite(ctx
))
1814 goto invalid_enum_error
;
1815 return ctx
->Point
.PointSprite
;
1817 case GL_VERTEX_PROGRAM_ARB
:
1818 if (!_mesa_has_ARB_vertex_program(ctx
))
1819 goto invalid_enum_error
;
1820 return ctx
->VertexProgram
.Enabled
;
1821 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1822 /* This was added with ARB_vertex_program, but it is also used with
1823 * GLSL vertex shaders on desktop.
1825 if (!_mesa_has_ARB_vertex_program(ctx
) &&
1826 ctx
->API
!= API_OPENGL_CORE
)
1827 goto invalid_enum_error
;
1828 return ctx
->VertexProgram
.PointSizeEnabled
;
1829 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1830 if (!_mesa_has_ARB_vertex_program(ctx
))
1831 goto invalid_enum_error
;
1832 return ctx
->VertexProgram
.TwoSideEnabled
;
1834 /* GL_NV_texture_rectangle */
1835 case GL_TEXTURE_RECTANGLE_NV
:
1836 if (!_mesa_has_NV_texture_rectangle(ctx
))
1837 goto invalid_enum_error
;
1838 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1840 /* GL_EXT_stencil_two_side */
1841 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1842 if (!_mesa_has_EXT_stencil_two_side(ctx
))
1843 goto invalid_enum_error
;
1844 return ctx
->Stencil
.TestTwoSide
;
1846 case GL_FRAGMENT_PROGRAM_ARB
:
1847 if (!_mesa_has_ARB_fragment_program(ctx
))
1848 goto invalid_enum_error
;
1849 return ctx
->FragmentProgram
.Enabled
;
1851 /* GL_EXT_depth_bounds_test */
1852 case GL_DEPTH_BOUNDS_TEST_EXT
:
1853 if (!_mesa_has_EXT_depth_bounds_test(ctx
))
1854 goto invalid_enum_error
;
1855 return ctx
->Depth
.BoundsTest
;
1857 /* GL_ARB_depth_clamp */
1858 case GL_DEPTH_CLAMP
:
1859 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1860 !_mesa_has_EXT_depth_clamp(ctx
))
1861 goto invalid_enum_error
;
1862 return ctx
->Transform
.DepthClampNear
||
1863 ctx
->Transform
.DepthClampFar
;
1865 case GL_DEPTH_CLAMP_NEAR_AMD
:
1866 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1867 goto invalid_enum_error
;
1868 return ctx
->Transform
.DepthClampNear
;
1870 case GL_DEPTH_CLAMP_FAR_AMD
:
1871 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1872 goto invalid_enum_error
;
1873 return ctx
->Transform
.DepthClampFar
;
1875 case GL_FRAGMENT_SHADER_ATI
:
1876 if (!_mesa_has_ATI_fragment_shader(ctx
))
1877 goto invalid_enum_error
;
1878 return ctx
->ATIFragmentShader
.Enabled
;
1880 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1881 if (!_mesa_has_ARB_seamless_cube_map(ctx
))
1882 goto invalid_enum_error
;
1883 return ctx
->Texture
.CubeMapSeamless
;
1885 case GL_RASTERIZER_DISCARD
:
1886 if (!(_mesa_has_EXT_transform_feedback(ctx
) || _mesa_is_gles3(ctx
)))
1887 goto invalid_enum_error
;
1888 return ctx
->RasterDiscard
;
1890 /* GL_NV_primitive_restart */
1891 case GL_PRIMITIVE_RESTART_NV
:
1892 if (!_mesa_has_NV_primitive_restart(ctx
))
1893 goto invalid_enum_error
;
1894 return ctx
->Array
.PrimitiveRestart
;
1896 /* GL 3.1 primitive restart */
1897 case GL_PRIMITIVE_RESTART
:
1898 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1899 goto invalid_enum_error
;
1901 return ctx
->Array
.PrimitiveRestart
;
1903 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1904 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1905 goto invalid_enum_error
;
1906 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1908 /* GL3.0 - GL_framebuffer_sRGB */
1909 case GL_FRAMEBUFFER_SRGB_EXT
:
1910 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1911 !_mesa_has_EXT_sRGB_write_control(ctx
))
1912 goto invalid_enum_error
;
1913 return ctx
->Color
.sRGBEnabled
;
1915 /* GL_OES_EGL_image_external */
1916 case GL_TEXTURE_EXTERNAL_OES
:
1917 if (!_mesa_has_OES_EGL_image_external(ctx
))
1918 goto invalid_enum_error
;
1919 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1921 /* ARB_texture_multisample */
1922 case GL_SAMPLE_MASK
:
1923 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1924 goto invalid_enum_error
;
1925 return ctx
->Multisample
.SampleMask
;
1927 /* ARB_sample_shading */
1928 case GL_SAMPLE_SHADING
:
1929 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
1930 goto invalid_enum_error
;
1931 return ctx
->Multisample
.SampleShading
;
1933 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1934 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1935 goto invalid_enum_error
;
1936 return ctx
->Color
.BlendCoherent
;
1938 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1939 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
1940 goto invalid_enum_error
;
1941 return ctx
->IntelConservativeRasterization
;
1943 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1944 if (!_mesa_has_NV_conservative_raster(ctx
))
1945 goto invalid_enum_error
;
1946 return ctx
->ConservativeRasterization
;
1948 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1949 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1950 goto invalid_enum_error
;
1951 return ctx
->TileRasterOrderFixed
;
1953 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1954 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1955 goto invalid_enum_error
;
1956 return ctx
->TileRasterOrderIncreasingX
;
1958 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1959 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1960 goto invalid_enum_error
;
1961 return ctx
->TileRasterOrderIncreasingY
;
1963 case GL_BLACKHOLE_RENDER_INTEL
:
1964 if (!_mesa_has_INTEL_blackhole_render(ctx
))
1965 goto invalid_enum_error
;
1966 return ctx
->IntelBlackholeRender
;
1969 goto invalid_enum_error
;
1975 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1976 _mesa_enum_to_string(cap
));