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 update_derived_primitive_restart_state(struct gl_context
*ctx
)
50 /* Update derived primitive restart state.
52 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
53 || ctx
->Array
.PrimitiveRestartFixedIndex
;
58 * Helper to enable/disable VAO client-side state.
61 vao_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
62 gl_vert_attrib attr
, GLboolean state
)
65 _mesa_enable_vertex_array_attrib(ctx
, vao
, attr
);
67 _mesa_disable_vertex_array_attrib(ctx
, vao
, attr
);
72 * Helper to enable/disable client-side state.
75 client_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
76 GLenum cap
, GLboolean state
)
80 vao_state(ctx
, vao
, VERT_ATTRIB_POS
, state
);
83 vao_state(ctx
, vao
, VERT_ATTRIB_NORMAL
, state
);
86 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR0
, state
);
89 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR_INDEX
, state
);
91 case GL_TEXTURE_COORD_ARRAY
:
92 vao_state(ctx
, vao
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
94 case GL_EDGE_FLAG_ARRAY
:
95 vao_state(ctx
, vao
, VERT_ATTRIB_EDGEFLAG
, state
);
97 case GL_FOG_COORDINATE_ARRAY_EXT
:
98 vao_state(ctx
, vao
, VERT_ATTRIB_FOG
, state
);
100 case GL_SECONDARY_COLOR_ARRAY_EXT
:
101 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR1
, state
);
104 case GL_POINT_SIZE_ARRAY_OES
:
105 if (ctx
->VertexProgram
.PointSizeEnabled
!= state
) {
106 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
107 ctx
->VertexProgram
.PointSizeEnabled
= state
;
109 vao_state(ctx
, vao
, VERT_ATTRIB_POINT_SIZE
, state
);
112 /* GL_NV_primitive_restart */
113 case GL_PRIMITIVE_RESTART_NV
:
114 if (!_mesa_has_NV_primitive_restart(ctx
))
115 goto invalid_enum_error
;
116 if (ctx
->Array
.PrimitiveRestart
== state
)
119 FLUSH_VERTICES(ctx
, 0);
120 ctx
->Array
.PrimitiveRestart
= state
;
121 update_derived_primitive_restart_state(ctx
);
125 goto invalid_enum_error
;
128 if (ctx
->Driver
.Enable
) {
129 ctx
->Driver
.Enable( ctx
, cap
, state
);
135 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
136 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
140 /* Helper for GL_EXT_direct_state_access following functions:
141 * - EnableClientStateIndexedEXT
142 * - EnableClientStateiEXT
143 * - DisableClientStateIndexedEXT
144 * - DisableClientStateiEXT
147 client_state_i(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
148 GLenum cap
, GLuint index
, GLboolean state
)
152 if (cap
!= GL_TEXTURE_COORD_ARRAY
) {
153 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientStateiEXT(cap=%s)",
154 state
? "Enable" : "Disable",
155 _mesa_enum_to_string(cap
));
159 if (index
>= ctx
->Const
.MaxTextureCoordUnits
) {
160 _mesa_error(ctx
, GL_INVALID_VALUE
, "gl%sClientStateiEXT(index=%d)",
161 state
? "Enable" : "Disable",
166 saved_active
= ctx
->Array
.ActiveTexture
;
167 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
168 client_state(ctx
, vao
, cap
, state
);
169 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
174 * Enable GL capability.
175 * \param cap state to enable/disable.
177 * Get's the current context, assures that we're outside glBegin()/glEnd() and
178 * calls client_state().
181 _mesa_EnableClientState( GLenum cap
)
183 GET_CURRENT_CONTEXT(ctx
);
184 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_TRUE
);
189 _mesa_EnableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
191 GET_CURRENT_CONTEXT(ctx
);
192 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
194 "glEnableVertexArrayEXT");
198 /* The EXT_direct_state_access spec says:
199 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
200 * the tokens TEXTURE0 through TEXTUREn where n is less than the
201 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
202 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
203 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
204 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
205 * as if the active client texture is set to texture coordinate set i
206 * based on the token TEXTUREi indicated by array."
208 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
209 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
210 _mesa_ClientActiveTexture(cap
);
211 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_TRUE
);
212 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
214 client_state(ctx
, vao
, cap
, GL_TRUE
);
220 _mesa_EnableClientStateiEXT( GLenum cap
, GLuint index
)
222 GET_CURRENT_CONTEXT(ctx
);
223 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_TRUE
);
228 * Disable GL capability.
229 * \param cap state to enable/disable.
231 * Get's the current context, assures that we're outside glBegin()/glEnd() and
232 * calls client_state().
235 _mesa_DisableClientState( GLenum cap
)
237 GET_CURRENT_CONTEXT(ctx
);
238 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_FALSE
);
242 _mesa_DisableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
244 GET_CURRENT_CONTEXT(ctx
);
245 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
247 "glDisableVertexArrayEXT");
251 /* The EXT_direct_state_access spec says:
252 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
253 * the tokens TEXTURE0 through TEXTUREn where n is less than the
254 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
255 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
256 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
257 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
258 * as if the active client texture is set to texture coordinate set i
259 * based on the token TEXTUREi indicated by array."
261 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
262 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
263 _mesa_ClientActiveTexture(cap
);
264 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_FALSE
);
265 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
267 client_state(ctx
, vao
, cap
, GL_FALSE
);
272 _mesa_DisableClientStateiEXT( GLenum cap
, GLuint index
)
274 GET_CURRENT_CONTEXT(ctx
);
275 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_FALSE
);
278 #define CHECK_EXTENSION(EXTNAME) \
279 if (!ctx->Extensions.EXTNAME) { \
280 goto invalid_enum_error; \
284 * Return pointer to current texture unit for setting/getting coordinate
286 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
287 * texture unit is higher than the number of supported coordinate units.
289 static struct gl_fixedfunc_texture_unit
*
290 get_texcoord_unit(struct gl_context
*ctx
)
292 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
293 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
297 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
303 * Helper function to enable or disable a texture target.
304 * \param bit one of the TEXTURE_x_BIT values
305 * \return GL_TRUE if state is changing or GL_FALSE if no change
308 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
310 struct gl_fixedfunc_texture_unit
*texUnit
=
311 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
315 const GLbitfield newenabled
= state
316 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
318 if (texUnit
->Enabled
== newenabled
)
321 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
322 texUnit
->Enabled
= newenabled
;
328 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
329 * whether the API supports it (GLES doesn't).
332 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
334 if (ctx
->Multisample
.Enabled
== state
)
337 /* GL compatibility needs Multisample.Enable to determine program state
340 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
341 !ctx
->DriverFlags
.NewMultisampleEnable
) {
342 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
344 FLUSH_VERTICES(ctx
, 0);
347 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
348 ctx
->Multisample
.Enabled
= state
;
350 if (ctx
->Driver
.Enable
) {
351 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
356 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
357 * check for whether the API supports it (GLES doesn't).
360 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
362 if (ctx
->Color
.sRGBEnabled
== state
)
365 /* TODO: Switch i965 to the new flag and remove the conditional */
366 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
367 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
368 ctx
->Color
.sRGBEnabled
= state
;
370 if (ctx
->Driver
.Enable
) {
371 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
376 * Helper function to enable or disable state.
378 * \param ctx GL context.
379 * \param cap the state to enable/disable
380 * \param state whether to enable or disable the specified capability.
382 * Updates the current context and flushes the vertices as needed. For
383 * capabilities associated with extensions it verifies that those extensions
384 * are effectivly present before updating. Notifies the driver via
385 * dd_function_table::Enable.
388 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
390 if (MESA_VERBOSE
& VERBOSE_API
)
391 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
392 state
? "glEnable" : "glDisable",
393 _mesa_enum_to_string(cap
),
398 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
399 goto invalid_enum_error
;
400 if (ctx
->Color
.AlphaEnabled
== state
)
402 /* AlphaEnabled is used by the fixed-func fragment program */
403 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
404 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
405 ctx
->Color
.AlphaEnabled
= state
;
408 if (ctx
->API
!= API_OPENGL_COMPAT
)
409 goto invalid_enum_error
;
410 if (ctx
->Eval
.AutoNormal
== state
)
412 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
413 ctx
->Eval
.AutoNormal
= state
;
417 GLbitfield newEnabled
=
418 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
419 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
420 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
421 ctx
->Color
._AdvancedBlendMode
);
422 ctx
->Color
.BlendEnabled
= newEnabled
;
423 _mesa_update_allow_draw_out_of_order(ctx
);
427 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
428 case GL_CLIP_DISTANCE1
:
429 case GL_CLIP_DISTANCE2
:
430 case GL_CLIP_DISTANCE3
:
431 case GL_CLIP_DISTANCE4
:
432 case GL_CLIP_DISTANCE5
:
433 case GL_CLIP_DISTANCE6
:
434 case GL_CLIP_DISTANCE7
:
436 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
438 if (p
>= ctx
->Const
.MaxClipPlanes
)
439 goto invalid_enum_error
;
441 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
442 == ((GLuint
) state
<< p
))
445 /* The compatibility profile needs _NEW_TRANSFORM to transform
446 * clip planes according to the projection matrix.
448 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
449 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
450 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
452 FLUSH_VERTICES(ctx
, 0);
454 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
457 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
459 /* The projection matrix transforms the clip plane. */
460 /* TODO: glEnable might not be the best place to do it. */
461 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
462 _mesa_update_clip_plane(ctx
, p
);
463 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
467 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
471 case GL_COLOR_MATERIAL
:
472 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
473 goto invalid_enum_error
;
474 if (ctx
->Light
.ColorMaterialEnabled
== state
)
476 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
477 FLUSH_CURRENT(ctx
, 0);
478 ctx
->Light
.ColorMaterialEnabled
= state
;
480 _mesa_update_color_material( ctx
,
481 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
485 if (ctx
->Polygon
.CullFlag
== state
)
488 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
489 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
490 ctx
->Polygon
.CullFlag
= state
;
493 if (ctx
->Depth
.Test
== state
)
495 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
496 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
497 ctx
->Depth
.Test
= state
;
498 _mesa_update_allow_draw_out_of_order(ctx
);
500 case GL_DEBUG_OUTPUT
:
501 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
502 _mesa_set_debug_state_int(ctx
, cap
, state
);
505 if (ctx
->Color
.DitherFlag
== state
)
507 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
508 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
509 ctx
->Color
.DitherFlag
= state
;
512 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
513 goto invalid_enum_error
;
514 if (ctx
->Fog
.Enabled
== state
)
516 FLUSH_VERTICES(ctx
, _NEW_FOG
);
517 ctx
->Fog
.Enabled
= state
;
518 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
528 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
529 goto invalid_enum_error
;
530 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
532 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
533 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
535 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
538 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
542 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
543 goto invalid_enum_error
;
544 if (ctx
->Light
.Enabled
== state
)
546 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
547 ctx
->Light
.Enabled
= state
;
550 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
551 goto invalid_enum_error
;
552 if (ctx
->Line
.SmoothFlag
== state
)
554 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
555 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
556 ctx
->Line
.SmoothFlag
= state
;
558 case GL_LINE_STIPPLE
:
559 if (ctx
->API
!= API_OPENGL_COMPAT
)
560 goto invalid_enum_error
;
561 if (ctx
->Line
.StippleFlag
== state
)
563 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
564 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
565 ctx
->Line
.StippleFlag
= state
;
567 case GL_INDEX_LOGIC_OP
:
568 if (ctx
->API
!= API_OPENGL_COMPAT
)
569 goto invalid_enum_error
;
570 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
572 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
573 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
574 ctx
->Color
.IndexLogicOpEnabled
= state
;
576 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
577 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
578 goto invalid_enum_error
;
579 if (ctx
->IntelConservativeRasterization
== state
)
581 FLUSH_VERTICES(ctx
, 0);
582 ctx
->NewDriverState
|=
583 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
584 ctx
->IntelConservativeRasterization
= state
;
586 case GL_CONSERVATIVE_RASTERIZATION_NV
:
587 if (!_mesa_has_NV_conservative_raster(ctx
))
588 goto invalid_enum_error
;
589 if (ctx
->ConservativeRasterization
== state
)
591 FLUSH_VERTICES(ctx
, 0);
592 ctx
->NewDriverState
|=
593 ctx
->DriverFlags
.NewNvConservativeRasterization
;
594 ctx
->ConservativeRasterization
= state
;
596 case GL_COLOR_LOGIC_OP
:
597 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
598 goto invalid_enum_error
;
599 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
601 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
602 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
603 ctx
->Color
.ColorLogicOpEnabled
= state
;
604 _mesa_update_allow_draw_out_of_order(ctx
);
606 case GL_MAP1_COLOR_4
:
607 if (ctx
->API
!= API_OPENGL_COMPAT
)
608 goto invalid_enum_error
;
609 if (ctx
->Eval
.Map1Color4
== state
)
611 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
612 ctx
->Eval
.Map1Color4
= state
;
615 if (ctx
->API
!= API_OPENGL_COMPAT
)
616 goto invalid_enum_error
;
617 if (ctx
->Eval
.Map1Index
== state
)
619 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
620 ctx
->Eval
.Map1Index
= state
;
623 if (ctx
->API
!= API_OPENGL_COMPAT
)
624 goto invalid_enum_error
;
625 if (ctx
->Eval
.Map1Normal
== state
)
627 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
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
, _NEW_EVAL
);
636 ctx
->Eval
.Map1TextureCoord1
= state
;
638 case GL_MAP1_TEXTURE_COORD_2
:
639 if (ctx
->API
!= API_OPENGL_COMPAT
)
640 goto invalid_enum_error
;
641 if (ctx
->Eval
.Map1TextureCoord2
== state
)
643 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
644 ctx
->Eval
.Map1TextureCoord2
= state
;
646 case GL_MAP1_TEXTURE_COORD_3
:
647 if (ctx
->API
!= API_OPENGL_COMPAT
)
648 goto invalid_enum_error
;
649 if (ctx
->Eval
.Map1TextureCoord3
== state
)
651 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
652 ctx
->Eval
.Map1TextureCoord3
= state
;
654 case GL_MAP1_TEXTURE_COORD_4
:
655 if (ctx
->API
!= API_OPENGL_COMPAT
)
656 goto invalid_enum_error
;
657 if (ctx
->Eval
.Map1TextureCoord4
== state
)
659 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
660 ctx
->Eval
.Map1TextureCoord4
= state
;
662 case GL_MAP1_VERTEX_3
:
663 if (ctx
->API
!= API_OPENGL_COMPAT
)
664 goto invalid_enum_error
;
665 if (ctx
->Eval
.Map1Vertex3
== state
)
667 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
668 ctx
->Eval
.Map1Vertex3
= state
;
670 case GL_MAP1_VERTEX_4
:
671 if (ctx
->API
!= API_OPENGL_COMPAT
)
672 goto invalid_enum_error
;
673 if (ctx
->Eval
.Map1Vertex4
== state
)
675 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
676 ctx
->Eval
.Map1Vertex4
= state
;
678 case GL_MAP2_COLOR_4
:
679 if (ctx
->API
!= API_OPENGL_COMPAT
)
680 goto invalid_enum_error
;
681 if (ctx
->Eval
.Map2Color4
== state
)
683 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
684 ctx
->Eval
.Map2Color4
= state
;
687 if (ctx
->API
!= API_OPENGL_COMPAT
)
688 goto invalid_enum_error
;
689 if (ctx
->Eval
.Map2Index
== state
)
691 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
692 ctx
->Eval
.Map2Index
= state
;
695 if (ctx
->API
!= API_OPENGL_COMPAT
)
696 goto invalid_enum_error
;
697 if (ctx
->Eval
.Map2Normal
== state
)
699 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
700 ctx
->Eval
.Map2Normal
= state
;
702 case GL_MAP2_TEXTURE_COORD_1
:
703 if (ctx
->API
!= API_OPENGL_COMPAT
)
704 goto invalid_enum_error
;
705 if (ctx
->Eval
.Map2TextureCoord1
== state
)
707 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
708 ctx
->Eval
.Map2TextureCoord1
= state
;
710 case GL_MAP2_TEXTURE_COORD_2
:
711 if (ctx
->API
!= API_OPENGL_COMPAT
)
712 goto invalid_enum_error
;
713 if (ctx
->Eval
.Map2TextureCoord2
== state
)
715 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
716 ctx
->Eval
.Map2TextureCoord2
= state
;
718 case GL_MAP2_TEXTURE_COORD_3
:
719 if (ctx
->API
!= API_OPENGL_COMPAT
)
720 goto invalid_enum_error
;
721 if (ctx
->Eval
.Map2TextureCoord3
== state
)
723 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
724 ctx
->Eval
.Map2TextureCoord3
= state
;
726 case GL_MAP2_TEXTURE_COORD_4
:
727 if (ctx
->API
!= API_OPENGL_COMPAT
)
728 goto invalid_enum_error
;
729 if (ctx
->Eval
.Map2TextureCoord4
== state
)
731 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
732 ctx
->Eval
.Map2TextureCoord4
= state
;
734 case GL_MAP2_VERTEX_3
:
735 if (ctx
->API
!= API_OPENGL_COMPAT
)
736 goto invalid_enum_error
;
737 if (ctx
->Eval
.Map2Vertex3
== state
)
739 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
740 ctx
->Eval
.Map2Vertex3
= state
;
742 case GL_MAP2_VERTEX_4
:
743 if (ctx
->API
!= API_OPENGL_COMPAT
)
744 goto invalid_enum_error
;
745 if (ctx
->Eval
.Map2Vertex4
== state
)
747 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
748 ctx
->Eval
.Map2Vertex4
= state
;
751 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
752 goto invalid_enum_error
;
753 if (ctx
->Transform
.Normalize
== state
)
755 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
756 ctx
->Transform
.Normalize
= state
;
758 case GL_POINT_SMOOTH
:
759 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
760 goto invalid_enum_error
;
761 if (ctx
->Point
.SmoothFlag
== state
)
763 FLUSH_VERTICES(ctx
, _NEW_POINT
);
764 ctx
->Point
.SmoothFlag
= state
;
766 case GL_POLYGON_SMOOTH
:
767 if (!_mesa_is_desktop_gl(ctx
))
768 goto invalid_enum_error
;
769 if (ctx
->Polygon
.SmoothFlag
== state
)
772 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
773 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
774 ctx
->Polygon
.SmoothFlag
= state
;
776 case GL_POLYGON_STIPPLE
:
777 if (ctx
->API
!= API_OPENGL_COMPAT
)
778 goto invalid_enum_error
;
779 if (ctx
->Polygon
.StippleFlag
== state
)
782 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
783 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
784 ctx
->Polygon
.StippleFlag
= state
;
786 case GL_POLYGON_OFFSET_POINT
:
787 if (!_mesa_is_desktop_gl(ctx
))
788 goto invalid_enum_error
;
789 if (ctx
->Polygon
.OffsetPoint
== state
)
792 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
793 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
794 ctx
->Polygon
.OffsetPoint
= state
;
796 case GL_POLYGON_OFFSET_LINE
:
797 if (!_mesa_is_desktop_gl(ctx
))
798 goto invalid_enum_error
;
799 if (ctx
->Polygon
.OffsetLine
== state
)
802 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
803 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
804 ctx
->Polygon
.OffsetLine
= state
;
806 case GL_POLYGON_OFFSET_FILL
:
807 if (ctx
->Polygon
.OffsetFill
== state
)
810 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
811 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
812 ctx
->Polygon
.OffsetFill
= state
;
814 case GL_RESCALE_NORMAL_EXT
:
815 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
816 goto invalid_enum_error
;
817 if (ctx
->Transform
.RescaleNormals
== state
)
819 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
820 ctx
->Transform
.RescaleNormals
= state
;
822 case GL_SCISSOR_TEST
:
824 /* Must expand glEnable to all scissors */
825 GLbitfield newEnabled
=
826 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
827 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
828 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
830 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
831 ctx
->Scissor
.EnableFlags
= newEnabled
;
835 case GL_STENCIL_TEST
:
836 if (ctx
->Stencil
.Enabled
== state
)
838 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
839 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
840 ctx
->Stencil
.Enabled
= state
;
841 _mesa_update_allow_draw_out_of_order(ctx
);
844 if (ctx
->API
!= API_OPENGL_COMPAT
)
845 goto invalid_enum_error
;
846 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
851 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
852 goto invalid_enum_error
;
853 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
858 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
859 goto invalid_enum_error
;
860 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
864 case GL_TEXTURE_GEN_S
:
865 case GL_TEXTURE_GEN_T
:
866 case GL_TEXTURE_GEN_R
:
867 case GL_TEXTURE_GEN_Q
:
869 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
871 if (ctx
->API
!= API_OPENGL_COMPAT
)
872 goto invalid_enum_error
;
875 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
876 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
878 newenabled
|= coordBit
;
879 if (texUnit
->TexGenEnabled
== newenabled
)
881 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
882 texUnit
->TexGenEnabled
= newenabled
;
887 case GL_TEXTURE_GEN_STR_OES
:
888 /* disable S, T, and R at the same time */
890 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
892 if (ctx
->API
!= API_OPENGLES
)
893 goto invalid_enum_error
;
897 texUnit
->TexGenEnabled
& ~STR_BITS
;
899 newenabled
|= STR_BITS
;
900 if (texUnit
->TexGenEnabled
== newenabled
)
902 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
903 texUnit
->TexGenEnabled
= newenabled
;
908 /* client-side state */
909 case GL_VERTEX_ARRAY
:
910 case GL_NORMAL_ARRAY
:
912 case GL_TEXTURE_COORD_ARRAY
:
913 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
914 goto invalid_enum_error
;
915 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
918 case GL_EDGE_FLAG_ARRAY
:
919 case GL_FOG_COORDINATE_ARRAY_EXT
:
920 case GL_SECONDARY_COLOR_ARRAY_EXT
:
921 if (ctx
->API
!= API_OPENGL_COMPAT
)
922 goto invalid_enum_error
;
923 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
925 case GL_POINT_SIZE_ARRAY_OES
:
926 if (ctx
->API
!= API_OPENGLES
)
927 goto invalid_enum_error
;
928 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
931 /* GL_ARB_texture_cube_map */
932 case GL_TEXTURE_CUBE_MAP
:
933 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
934 !_mesa_has_OES_texture_cube_map(ctx
))
935 goto invalid_enum_error
;
936 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
941 /* GL_EXT_secondary_color */
942 case GL_COLOR_SUM_EXT
:
943 if (ctx
->API
!= API_OPENGL_COMPAT
)
944 goto invalid_enum_error
;
945 if (ctx
->Fog
.ColorSumEnabled
== state
)
947 FLUSH_VERTICES(ctx
, _NEW_FOG
);
948 ctx
->Fog
.ColorSumEnabled
= state
;
951 /* GL_ARB_multisample */
952 case GL_MULTISAMPLE_ARB
:
953 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
954 goto invalid_enum_error
;
955 _mesa_set_multisample(ctx
, state
);
957 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
958 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
960 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
962 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
963 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
965 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
966 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
967 goto invalid_enum_error
;
968 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
970 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
972 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
973 ctx
->Multisample
.SampleAlphaToOne
= state
;
975 case GL_SAMPLE_COVERAGE_ARB
:
976 if (ctx
->Multisample
.SampleCoverage
== state
)
978 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
980 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
981 ctx
->Multisample
.SampleCoverage
= state
;
983 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
984 if (!_mesa_is_desktop_gl(ctx
))
985 goto invalid_enum_error
;
986 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
988 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
990 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
991 ctx
->Multisample
.SampleCoverageInvert
= state
;
994 /* GL_ARB_sample_shading */
995 case GL_SAMPLE_SHADING
:
996 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
997 goto invalid_enum_error
;
998 if (ctx
->Multisample
.SampleShading
== state
)
1000 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
1002 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
1003 ctx
->Multisample
.SampleShading
= state
;
1006 /* GL_IBM_rasterpos_clip */
1007 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1008 if (ctx
->API
!= API_OPENGL_COMPAT
)
1009 goto invalid_enum_error
;
1010 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
1012 FLUSH_VERTICES(ctx
, 0);
1013 ctx
->Transform
.RasterPositionUnclipped
= state
;
1016 /* GL_NV_point_sprite */
1017 case GL_POINT_SPRITE_NV
:
1018 if (!(ctx
->API
== API_OPENGL_COMPAT
&&
1019 (_mesa_has_ARB_point_sprite(ctx
) ||
1020 _mesa_has_NV_point_sprite(ctx
))) &&
1021 !_mesa_has_OES_point_sprite(ctx
))
1022 goto invalid_enum_error
;
1023 if (ctx
->Point
.PointSprite
== state
)
1025 FLUSH_VERTICES(ctx
, _NEW_POINT
);
1026 ctx
->Point
.PointSprite
= state
;
1029 case GL_VERTEX_PROGRAM_ARB
:
1030 if (!_mesa_has_ARB_vertex_program(ctx
))
1031 goto invalid_enum_error
;
1032 if (ctx
->VertexProgram
.Enabled
== state
)
1034 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1035 ctx
->VertexProgram
.Enabled
= state
;
1036 _mesa_update_vertex_processing_mode(ctx
);
1038 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1039 /* This was added with ARB_vertex_program, but it is also used with
1040 * GLSL vertex shaders on desktop.
1042 if (!_mesa_has_ARB_vertex_program(ctx
) &&
1043 ctx
->API
!= API_OPENGL_CORE
)
1044 goto invalid_enum_error
;
1045 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
1047 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1048 ctx
->VertexProgram
.PointSizeEnabled
= state
;
1050 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1051 if (!_mesa_has_ARB_vertex_program(ctx
))
1052 goto invalid_enum_error
;
1053 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
1055 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1056 ctx
->VertexProgram
.TwoSideEnabled
= state
;
1059 /* GL_NV_texture_rectangle */
1060 case GL_TEXTURE_RECTANGLE_NV
:
1061 if (!_mesa_has_NV_texture_rectangle(ctx
))
1062 goto invalid_enum_error
;
1063 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
1068 /* GL_EXT_stencil_two_side */
1069 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1070 if (!_mesa_has_EXT_stencil_two_side(ctx
))
1071 goto invalid_enum_error
;
1072 if (ctx
->Stencil
.TestTwoSide
== state
)
1074 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
1075 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
1076 ctx
->Stencil
.TestTwoSide
= state
;
1078 ctx
->Stencil
._BackFace
= 2;
1080 ctx
->Stencil
._BackFace
= 1;
1084 case GL_FRAGMENT_PROGRAM_ARB
:
1085 if (!_mesa_has_ARB_fragment_program(ctx
))
1086 goto invalid_enum_error
;
1087 if (ctx
->FragmentProgram
.Enabled
== state
)
1089 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1090 ctx
->FragmentProgram
.Enabled
= state
;
1093 /* GL_EXT_depth_bounds_test */
1094 case GL_DEPTH_BOUNDS_TEST_EXT
:
1095 if (!_mesa_has_EXT_depth_bounds_test(ctx
))
1096 goto invalid_enum_error
;
1097 if (ctx
->Depth
.BoundsTest
== state
)
1099 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
1100 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
1101 ctx
->Depth
.BoundsTest
= state
;
1104 case GL_DEPTH_CLAMP
:
1105 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1106 !_mesa_has_EXT_depth_clamp(ctx
))
1107 goto invalid_enum_error
;
1108 if (ctx
->Transform
.DepthClampNear
== state
&&
1109 ctx
->Transform
.DepthClampFar
== state
)
1111 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1113 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1114 ctx
->Transform
.DepthClampNear
= state
;
1115 ctx
->Transform
.DepthClampFar
= state
;
1118 case GL_DEPTH_CLAMP_NEAR_AMD
:
1119 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1120 goto invalid_enum_error
;
1121 if (ctx
->Transform
.DepthClampNear
== state
)
1123 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1125 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1126 ctx
->Transform
.DepthClampNear
= state
;
1129 case GL_DEPTH_CLAMP_FAR_AMD
:
1130 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1131 goto invalid_enum_error
;
1132 if (ctx
->Transform
.DepthClampFar
== state
)
1134 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1136 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1137 ctx
->Transform
.DepthClampFar
= state
;
1140 case GL_FRAGMENT_SHADER_ATI
:
1141 if (ctx
->API
!= API_OPENGL_COMPAT
)
1142 goto invalid_enum_error
;
1143 CHECK_EXTENSION(ATI_fragment_shader
);
1144 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1146 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1147 ctx
->ATIFragmentShader
.Enabled
= state
;
1150 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1151 if (!_mesa_is_desktop_gl(ctx
))
1152 goto invalid_enum_error
;
1153 CHECK_EXTENSION(ARB_seamless_cube_map
);
1154 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1155 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1156 ctx
->Texture
.CubeMapSeamless
= state
;
1160 case GL_RASTERIZER_DISCARD
:
1161 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1162 goto invalid_enum_error
;
1163 CHECK_EXTENSION(EXT_transform_feedback
);
1164 if (ctx
->RasterDiscard
!= state
) {
1165 FLUSH_VERTICES(ctx
, 0);
1166 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1167 ctx
->RasterDiscard
= state
;
1171 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1172 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1173 goto invalid_enum_error
;
1174 if (ctx
->TileRasterOrderFixed
!= state
) {
1175 FLUSH_VERTICES(ctx
, 0);
1176 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1177 ctx
->TileRasterOrderFixed
= state
;
1181 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1182 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1183 goto invalid_enum_error
;
1184 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1185 FLUSH_VERTICES(ctx
, 0);
1186 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1187 ctx
->TileRasterOrderIncreasingX
= state
;
1191 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1192 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1193 goto invalid_enum_error
;
1194 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1195 FLUSH_VERTICES(ctx
, 0);
1196 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1197 ctx
->TileRasterOrderIncreasingY
= state
;
1201 /* GL 3.1 primitive restart. Note: this enum is different from
1202 * GL_PRIMITIVE_RESTART_NV (which is client state).
1204 case GL_PRIMITIVE_RESTART
:
1205 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1206 goto invalid_enum_error
;
1208 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1209 FLUSH_VERTICES(ctx
, 0);
1210 ctx
->Array
.PrimitiveRestart
= state
;
1211 update_derived_primitive_restart_state(ctx
);
1215 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1216 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1217 goto invalid_enum_error
;
1218 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1219 FLUSH_VERTICES(ctx
, 0);
1220 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1221 update_derived_primitive_restart_state(ctx
);
1225 /* GL3.0 - GL_framebuffer_sRGB */
1226 case GL_FRAMEBUFFER_SRGB_EXT
:
1227 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1228 !_mesa_has_EXT_sRGB_write_control(ctx
))
1229 goto invalid_enum_error
;
1230 _mesa_set_framebuffer_srgb(ctx
, state
);
1233 /* GL_OES_EGL_image_external */
1234 case GL_TEXTURE_EXTERNAL_OES
:
1235 if (!_mesa_is_gles(ctx
))
1236 goto invalid_enum_error
;
1237 CHECK_EXTENSION(OES_EGL_image_external
);
1238 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1243 /* ARB_texture_multisample */
1244 case GL_SAMPLE_MASK
:
1245 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1246 goto invalid_enum_error
;
1247 if (ctx
->Multisample
.SampleMask
== state
)
1249 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1251 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1252 ctx
->Multisample
.SampleMask
= state
;
1255 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1256 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1257 goto invalid_enum_error
;
1258 if (ctx
->Color
.BlendCoherent
== state
)
1260 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1261 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1262 ctx
->Color
.BlendCoherent
= state
;
1265 case GL_BLACKHOLE_RENDER_INTEL
:
1266 if (!_mesa_has_INTEL_blackhole_render(ctx
))
1267 goto invalid_enum_error
;
1268 if (ctx
->IntelBlackholeRender
== state
)
1270 FLUSH_VERTICES(ctx
, 0);
1271 ctx
->IntelBlackholeRender
= state
;
1275 goto invalid_enum_error
;
1278 if (ctx
->Driver
.Enable
) {
1279 ctx
->Driver
.Enable( ctx
, cap
, state
);
1285 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1286 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1291 * Enable GL capability. Called by glEnable()
1292 * \param cap state to enable.
1295 _mesa_Enable( GLenum cap
)
1297 GET_CURRENT_CONTEXT(ctx
);
1299 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1304 * Disable GL capability. Called by glDisable()
1305 * \param cap state to disable.
1308 _mesa_Disable( GLenum cap
)
1310 GET_CURRENT_CONTEXT(ctx
);
1312 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1318 * Enable/disable an indexed state var.
1321 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1322 GLuint index
, GLboolean state
)
1324 assert(state
== 0 || state
== 1);
1327 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1328 goto invalid_enum_error
;
1330 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1331 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1332 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1335 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1336 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1339 enabled
|= (1 << index
);
1341 enabled
&= ~(1 << index
);
1343 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1344 ctx
->Color
._AdvancedBlendMode
);
1345 ctx
->Color
.BlendEnabled
= enabled
;
1346 _mesa_update_allow_draw_out_of_order(ctx
);
1349 case GL_SCISSOR_TEST
:
1350 if (index
>= ctx
->Const
.MaxViewports
) {
1351 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1352 state
? "glEnablei" : "glDisablei", index
);
1355 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1357 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1358 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1360 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1362 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1365 /* EXT_direct_state_access */
1369 case GL_TEXTURE_CUBE_MAP
:
1370 case GL_TEXTURE_GEN_S
:
1371 case GL_TEXTURE_GEN_T
:
1372 case GL_TEXTURE_GEN_R
:
1373 case GL_TEXTURE_GEN_Q
:
1374 case GL_TEXTURE_RECTANGLE_ARB
: {
1375 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1376 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1377 ctx
->Const
.MaxTextureCoordUnits
)) {
1378 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1379 state
? "glEnablei" : "glDisablei", index
);
1382 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1383 _mesa_set_enable( ctx
, cap
, state
);
1384 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1388 goto invalid_enum_error
;
1393 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1394 state
? "glEnablei" : "glDisablei",
1395 _mesa_enum_to_string(cap
));
1400 _mesa_Disablei( GLenum cap
, GLuint index
)
1402 GET_CURRENT_CONTEXT(ctx
);
1403 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1408 _mesa_Enablei( GLenum cap
, GLuint index
)
1410 GET_CURRENT_CONTEXT(ctx
);
1411 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1415 GLboolean GLAPIENTRY
1416 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1418 GET_CURRENT_CONTEXT(ctx
);
1419 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1422 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1423 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1427 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1428 case GL_SCISSOR_TEST
:
1429 if (index
>= ctx
->Const
.MaxViewports
) {
1430 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1434 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1435 /* EXT_direct_state_access */
1439 case GL_TEXTURE_CUBE_MAP
:
1440 case GL_TEXTURE_GEN_S
:
1441 case GL_TEXTURE_GEN_T
:
1442 case GL_TEXTURE_GEN_R
:
1443 case GL_TEXTURE_GEN_Q
:
1444 case GL_TEXTURE_RECTANGLE_ARB
: {
1446 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1447 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1448 ctx
->Const
.MaxTextureCoordUnits
)) {
1449 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1453 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1454 state
= _mesa_IsEnabled(cap
);
1455 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1459 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1460 _mesa_enum_to_string(cap
));
1468 * Helper function to determine whether a texture target is enabled.
1471 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1473 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1474 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
1479 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1484 * Return simple enable/disable state.
1486 * \param cap state variable to query.
1488 * Returns the state of the specified capability from the current GL context.
1489 * For the capabilities associated with extensions verifies that those
1490 * extensions are effectively present before reporting.
1492 GLboolean GLAPIENTRY
1493 _mesa_IsEnabled( GLenum cap
)
1495 GET_CURRENT_CONTEXT(ctx
);
1496 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1500 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1501 goto invalid_enum_error
;
1502 return ctx
->Color
.AlphaEnabled
;
1503 case GL_AUTO_NORMAL
:
1504 if (ctx
->API
!= API_OPENGL_COMPAT
)
1505 goto invalid_enum_error
;
1506 return ctx
->Eval
.AutoNormal
;
1508 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1509 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1510 case GL_CLIP_DISTANCE1
:
1511 case GL_CLIP_DISTANCE2
:
1512 case GL_CLIP_DISTANCE3
:
1513 case GL_CLIP_DISTANCE4
:
1514 case GL_CLIP_DISTANCE5
:
1515 case GL_CLIP_DISTANCE6
:
1516 case GL_CLIP_DISTANCE7
: {
1517 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1519 if (p
>= ctx
->Const
.MaxClipPlanes
)
1520 goto invalid_enum_error
;
1522 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1524 case GL_COLOR_MATERIAL
:
1525 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1526 goto invalid_enum_error
;
1527 return ctx
->Light
.ColorMaterialEnabled
;
1529 return ctx
->Polygon
.CullFlag
;
1530 case GL_DEBUG_OUTPUT
:
1531 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1532 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1534 return ctx
->Depth
.Test
;
1536 return ctx
->Color
.DitherFlag
;
1538 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1539 goto invalid_enum_error
;
1540 return ctx
->Fog
.Enabled
;
1542 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1543 goto invalid_enum_error
;
1544 return ctx
->Light
.Enabled
;
1553 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1554 goto invalid_enum_error
;
1555 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1556 case GL_LINE_SMOOTH
:
1557 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1558 goto invalid_enum_error
;
1559 return ctx
->Line
.SmoothFlag
;
1560 case GL_LINE_STIPPLE
:
1561 if (ctx
->API
!= API_OPENGL_COMPAT
)
1562 goto invalid_enum_error
;
1563 return ctx
->Line
.StippleFlag
;
1564 case GL_INDEX_LOGIC_OP
:
1565 if (ctx
->API
!= API_OPENGL_COMPAT
)
1566 goto invalid_enum_error
;
1567 return ctx
->Color
.IndexLogicOpEnabled
;
1568 case GL_COLOR_LOGIC_OP
:
1569 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1570 goto invalid_enum_error
;
1571 return ctx
->Color
.ColorLogicOpEnabled
;
1572 case GL_MAP1_COLOR_4
:
1573 if (ctx
->API
!= API_OPENGL_COMPAT
)
1574 goto invalid_enum_error
;
1575 return ctx
->Eval
.Map1Color4
;
1577 if (ctx
->API
!= API_OPENGL_COMPAT
)
1578 goto invalid_enum_error
;
1579 return ctx
->Eval
.Map1Index
;
1580 case GL_MAP1_NORMAL
:
1581 if (ctx
->API
!= API_OPENGL_COMPAT
)
1582 goto invalid_enum_error
;
1583 return ctx
->Eval
.Map1Normal
;
1584 case GL_MAP1_TEXTURE_COORD_1
:
1585 if (ctx
->API
!= API_OPENGL_COMPAT
)
1586 goto invalid_enum_error
;
1587 return ctx
->Eval
.Map1TextureCoord1
;
1588 case GL_MAP1_TEXTURE_COORD_2
:
1589 if (ctx
->API
!= API_OPENGL_COMPAT
)
1590 goto invalid_enum_error
;
1591 return ctx
->Eval
.Map1TextureCoord2
;
1592 case GL_MAP1_TEXTURE_COORD_3
:
1593 if (ctx
->API
!= API_OPENGL_COMPAT
)
1594 goto invalid_enum_error
;
1595 return ctx
->Eval
.Map1TextureCoord3
;
1596 case GL_MAP1_TEXTURE_COORD_4
:
1597 if (ctx
->API
!= API_OPENGL_COMPAT
)
1598 goto invalid_enum_error
;
1599 return ctx
->Eval
.Map1TextureCoord4
;
1600 case GL_MAP1_VERTEX_3
:
1601 if (ctx
->API
!= API_OPENGL_COMPAT
)
1602 goto invalid_enum_error
;
1603 return ctx
->Eval
.Map1Vertex3
;
1604 case GL_MAP1_VERTEX_4
:
1605 if (ctx
->API
!= API_OPENGL_COMPAT
)
1606 goto invalid_enum_error
;
1607 return ctx
->Eval
.Map1Vertex4
;
1608 case GL_MAP2_COLOR_4
:
1609 if (ctx
->API
!= API_OPENGL_COMPAT
)
1610 goto invalid_enum_error
;
1611 return ctx
->Eval
.Map2Color4
;
1613 if (ctx
->API
!= API_OPENGL_COMPAT
)
1614 goto invalid_enum_error
;
1615 return ctx
->Eval
.Map2Index
;
1616 case GL_MAP2_NORMAL
:
1617 if (ctx
->API
!= API_OPENGL_COMPAT
)
1618 goto invalid_enum_error
;
1619 return ctx
->Eval
.Map2Normal
;
1620 case GL_MAP2_TEXTURE_COORD_1
:
1621 if (ctx
->API
!= API_OPENGL_COMPAT
)
1622 goto invalid_enum_error
;
1623 return ctx
->Eval
.Map2TextureCoord1
;
1624 case GL_MAP2_TEXTURE_COORD_2
:
1625 if (ctx
->API
!= API_OPENGL_COMPAT
)
1626 goto invalid_enum_error
;
1627 return ctx
->Eval
.Map2TextureCoord2
;
1628 case GL_MAP2_TEXTURE_COORD_3
:
1629 if (ctx
->API
!= API_OPENGL_COMPAT
)
1630 goto invalid_enum_error
;
1631 return ctx
->Eval
.Map2TextureCoord3
;
1632 case GL_MAP2_TEXTURE_COORD_4
:
1633 if (ctx
->API
!= API_OPENGL_COMPAT
)
1634 goto invalid_enum_error
;
1635 return ctx
->Eval
.Map2TextureCoord4
;
1636 case GL_MAP2_VERTEX_3
:
1637 if (ctx
->API
!= API_OPENGL_COMPAT
)
1638 goto invalid_enum_error
;
1639 return ctx
->Eval
.Map2Vertex3
;
1640 case GL_MAP2_VERTEX_4
:
1641 if (ctx
->API
!= API_OPENGL_COMPAT
)
1642 goto invalid_enum_error
;
1643 return ctx
->Eval
.Map2Vertex4
;
1645 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1646 goto invalid_enum_error
;
1647 return ctx
->Transform
.Normalize
;
1648 case GL_POINT_SMOOTH
:
1649 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1650 goto invalid_enum_error
;
1651 return ctx
->Point
.SmoothFlag
;
1652 case GL_POLYGON_SMOOTH
:
1653 if (!_mesa_is_desktop_gl(ctx
))
1654 goto invalid_enum_error
;
1655 return ctx
->Polygon
.SmoothFlag
;
1656 case GL_POLYGON_STIPPLE
:
1657 if (ctx
->API
!= API_OPENGL_COMPAT
)
1658 goto invalid_enum_error
;
1659 return ctx
->Polygon
.StippleFlag
;
1660 case GL_POLYGON_OFFSET_POINT
:
1661 if (!_mesa_is_desktop_gl(ctx
))
1662 goto invalid_enum_error
;
1663 return ctx
->Polygon
.OffsetPoint
;
1664 case GL_POLYGON_OFFSET_LINE
:
1665 if (!_mesa_is_desktop_gl(ctx
))
1666 goto invalid_enum_error
;
1667 return ctx
->Polygon
.OffsetLine
;
1668 case GL_POLYGON_OFFSET_FILL
:
1669 return ctx
->Polygon
.OffsetFill
;
1670 case GL_RESCALE_NORMAL_EXT
:
1671 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1672 goto invalid_enum_error
;
1673 return ctx
->Transform
.RescaleNormals
;
1674 case GL_SCISSOR_TEST
:
1675 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1676 case GL_STENCIL_TEST
:
1677 return ctx
->Stencil
.Enabled
;
1679 if (ctx
->API
!= API_OPENGL_COMPAT
)
1680 goto invalid_enum_error
;
1681 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1683 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1684 goto invalid_enum_error
;
1685 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1687 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1688 goto invalid_enum_error
;
1689 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1690 case GL_TEXTURE_GEN_S
:
1691 case GL_TEXTURE_GEN_T
:
1692 case GL_TEXTURE_GEN_R
:
1693 case GL_TEXTURE_GEN_Q
:
1695 const struct gl_fixedfunc_texture_unit
*texUnit
=
1696 get_texcoord_unit(ctx
);
1698 if (ctx
->API
!= API_OPENGL_COMPAT
)
1699 goto invalid_enum_error
;
1702 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1703 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1707 case GL_TEXTURE_GEN_STR_OES
:
1709 const struct gl_fixedfunc_texture_unit
*texUnit
=
1710 get_texcoord_unit(ctx
);
1712 if (ctx
->API
!= API_OPENGLES
)
1713 goto invalid_enum_error
;
1716 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1717 ? GL_TRUE
: GL_FALSE
;
1721 /* client-side state */
1722 case GL_VERTEX_ARRAY
:
1723 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1724 goto invalid_enum_error
;
1725 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
1726 case GL_NORMAL_ARRAY
:
1727 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1728 goto invalid_enum_error
;
1729 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
1730 case GL_COLOR_ARRAY
:
1731 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1732 goto invalid_enum_error
;
1733 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
1734 case GL_INDEX_ARRAY
:
1735 if (ctx
->API
!= API_OPENGL_COMPAT
)
1736 goto invalid_enum_error
;
1737 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
1738 case GL_TEXTURE_COORD_ARRAY
:
1739 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1740 goto invalid_enum_error
;
1741 return !!(ctx
->Array
.VAO
->Enabled
&
1742 VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
1743 case GL_EDGE_FLAG_ARRAY
:
1744 if (ctx
->API
!= API_OPENGL_COMPAT
)
1745 goto invalid_enum_error
;
1746 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
1747 case GL_FOG_COORDINATE_ARRAY_EXT
:
1748 if (ctx
->API
!= API_OPENGL_COMPAT
)
1749 goto invalid_enum_error
;
1750 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
1751 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1752 if (ctx
->API
!= API_OPENGL_COMPAT
)
1753 goto invalid_enum_error
;
1754 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
1755 case GL_POINT_SIZE_ARRAY_OES
:
1756 if (ctx
->API
!= API_OPENGLES
)
1757 goto invalid_enum_error
;
1758 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
1760 /* GL_ARB_texture_cube_map */
1761 case GL_TEXTURE_CUBE_MAP
:
1762 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
1763 !_mesa_has_OES_texture_cube_map(ctx
))
1764 goto invalid_enum_error
;
1765 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1767 /* GL_EXT_secondary_color */
1768 case GL_COLOR_SUM_EXT
:
1769 if (ctx
->API
!= API_OPENGL_COMPAT
)
1770 goto invalid_enum_error
;
1771 return ctx
->Fog
.ColorSumEnabled
;
1773 /* GL_ARB_multisample */
1774 case GL_MULTISAMPLE_ARB
:
1775 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1776 goto invalid_enum_error
;
1777 return ctx
->Multisample
.Enabled
;
1778 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1779 return ctx
->Multisample
.SampleAlphaToCoverage
;
1780 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1781 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1782 goto invalid_enum_error
;
1783 return ctx
->Multisample
.SampleAlphaToOne
;
1784 case GL_SAMPLE_COVERAGE_ARB
:
1785 return ctx
->Multisample
.SampleCoverage
;
1786 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1787 if (!_mesa_is_desktop_gl(ctx
))
1788 goto invalid_enum_error
;
1789 return ctx
->Multisample
.SampleCoverageInvert
;
1791 /* GL_IBM_rasterpos_clip */
1792 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1793 if (ctx
->API
!= API_OPENGL_COMPAT
)
1794 goto invalid_enum_error
;
1795 return ctx
->Transform
.RasterPositionUnclipped
;
1797 /* GL_NV_point_sprite */
1798 case GL_POINT_SPRITE_NV
:
1799 if (!(ctx
->API
== API_OPENGL_COMPAT
&&
1800 (_mesa_has_ARB_point_sprite(ctx
) ||
1801 _mesa_has_NV_point_sprite(ctx
))) &&
1802 !_mesa_has_OES_point_sprite(ctx
))
1803 goto invalid_enum_error
;
1804 return ctx
->Point
.PointSprite
;
1806 case GL_VERTEX_PROGRAM_ARB
:
1807 if (!_mesa_has_ARB_vertex_program(ctx
))
1808 goto invalid_enum_error
;
1809 return ctx
->VertexProgram
.Enabled
;
1810 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1811 /* This was added with ARB_vertex_program, but it is also used with
1812 * GLSL vertex shaders on desktop.
1814 if (!_mesa_has_ARB_vertex_program(ctx
) &&
1815 ctx
->API
!= API_OPENGL_CORE
)
1816 goto invalid_enum_error
;
1817 return ctx
->VertexProgram
.PointSizeEnabled
;
1818 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1819 if (!_mesa_has_ARB_vertex_program(ctx
))
1820 goto invalid_enum_error
;
1821 return ctx
->VertexProgram
.TwoSideEnabled
;
1823 /* GL_NV_texture_rectangle */
1824 case GL_TEXTURE_RECTANGLE_NV
:
1825 if (!_mesa_has_NV_texture_rectangle(ctx
))
1826 goto invalid_enum_error
;
1827 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1829 /* GL_EXT_stencil_two_side */
1830 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1831 if (!_mesa_has_EXT_stencil_two_side(ctx
))
1832 goto invalid_enum_error
;
1833 return ctx
->Stencil
.TestTwoSide
;
1835 case GL_FRAGMENT_PROGRAM_ARB
:
1836 if (!_mesa_has_ARB_fragment_program(ctx
))
1837 goto invalid_enum_error
;
1838 return ctx
->FragmentProgram
.Enabled
;
1840 /* GL_EXT_depth_bounds_test */
1841 case GL_DEPTH_BOUNDS_TEST_EXT
:
1842 if (!_mesa_has_EXT_depth_bounds_test(ctx
))
1843 goto invalid_enum_error
;
1844 return ctx
->Depth
.BoundsTest
;
1846 /* GL_ARB_depth_clamp */
1847 case GL_DEPTH_CLAMP
:
1848 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1849 !_mesa_has_EXT_depth_clamp(ctx
))
1850 goto invalid_enum_error
;
1851 return ctx
->Transform
.DepthClampNear
||
1852 ctx
->Transform
.DepthClampFar
;
1854 case GL_DEPTH_CLAMP_NEAR_AMD
:
1855 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1856 goto invalid_enum_error
;
1857 return ctx
->Transform
.DepthClampNear
;
1859 case GL_DEPTH_CLAMP_FAR_AMD
:
1860 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1861 goto invalid_enum_error
;
1862 return ctx
->Transform
.DepthClampFar
;
1864 case GL_FRAGMENT_SHADER_ATI
:
1865 if (ctx
->API
!= API_OPENGL_COMPAT
)
1866 goto invalid_enum_error
;
1867 CHECK_EXTENSION(ATI_fragment_shader
);
1868 return ctx
->ATIFragmentShader
.Enabled
;
1870 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1871 if (!_mesa_is_desktop_gl(ctx
))
1872 goto invalid_enum_error
;
1873 CHECK_EXTENSION(ARB_seamless_cube_map
);
1874 return ctx
->Texture
.CubeMapSeamless
;
1876 case GL_RASTERIZER_DISCARD
:
1877 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1878 goto invalid_enum_error
;
1879 CHECK_EXTENSION(EXT_transform_feedback
);
1880 return ctx
->RasterDiscard
;
1882 /* GL_NV_primitive_restart */
1883 case GL_PRIMITIVE_RESTART_NV
:
1884 if (!_mesa_has_NV_primitive_restart(ctx
))
1885 goto invalid_enum_error
;
1886 return ctx
->Array
.PrimitiveRestart
;
1888 /* GL 3.1 primitive restart */
1889 case GL_PRIMITIVE_RESTART
:
1890 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1891 goto invalid_enum_error
;
1893 return ctx
->Array
.PrimitiveRestart
;
1895 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1896 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1897 goto invalid_enum_error
;
1898 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1900 /* GL3.0 - GL_framebuffer_sRGB */
1901 case GL_FRAMEBUFFER_SRGB_EXT
:
1902 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1903 !_mesa_has_EXT_sRGB_write_control(ctx
))
1904 goto invalid_enum_error
;
1905 return ctx
->Color
.sRGBEnabled
;
1907 /* GL_OES_EGL_image_external */
1908 case GL_TEXTURE_EXTERNAL_OES
:
1909 if (!_mesa_is_gles(ctx
))
1910 goto invalid_enum_error
;
1911 CHECK_EXTENSION(OES_EGL_image_external
);
1912 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1914 /* ARB_texture_multisample */
1915 case GL_SAMPLE_MASK
:
1916 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1917 goto invalid_enum_error
;
1918 return ctx
->Multisample
.SampleMask
;
1920 /* ARB_sample_shading */
1921 case GL_SAMPLE_SHADING
:
1922 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
1923 goto invalid_enum_error
;
1924 return ctx
->Multisample
.SampleShading
;
1926 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1927 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1928 goto invalid_enum_error
;
1929 return ctx
->Color
.BlendCoherent
;
1931 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1932 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
1933 goto invalid_enum_error
;
1934 return ctx
->IntelConservativeRasterization
;
1936 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1937 if (!_mesa_has_NV_conservative_raster(ctx
))
1938 goto invalid_enum_error
;
1939 return ctx
->ConservativeRasterization
;
1941 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1942 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1943 goto invalid_enum_error
;
1944 return ctx
->TileRasterOrderFixed
;
1946 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1947 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1948 goto invalid_enum_error
;
1949 return ctx
->TileRasterOrderIncreasingX
;
1951 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1952 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1953 goto invalid_enum_error
;
1954 return ctx
->TileRasterOrderIncreasingY
;
1956 case GL_BLACKHOLE_RENDER_INTEL
:
1957 if (!_mesa_has_INTEL_blackhole_render(ctx
))
1958 goto invalid_enum_error
;
1959 return ctx
->IntelBlackholeRender
;
1962 goto invalid_enum_error
;
1968 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1969 _mesa_enum_to_string(cap
));