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 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
106 ctx
->VertexProgram
.PointSizeEnabled
= state
;
107 vao_state(ctx
, vao
, VERT_ATTRIB_POINT_SIZE
, state
);
110 /* GL_NV_primitive_restart */
111 case GL_PRIMITIVE_RESTART_NV
:
112 if (!_mesa_has_NV_primitive_restart(ctx
))
113 goto invalid_enum_error
;
114 if (ctx
->Array
.PrimitiveRestart
== state
)
117 FLUSH_VERTICES(ctx
, 0);
118 ctx
->Array
.PrimitiveRestart
= state
;
119 update_derived_primitive_restart_state(ctx
);
123 goto invalid_enum_error
;
126 if (ctx
->Driver
.Enable
) {
127 ctx
->Driver
.Enable( ctx
, cap
, state
);
133 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
134 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
138 /* Helper for GL_EXT_direct_state_access following functions:
139 * - EnableClientStateIndexedEXT
140 * - EnableClientStateiEXT
141 * - DisableClientStateIndexedEXT
142 * - DisableClientStateiEXT
145 client_state_i(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
146 GLenum cap
, GLuint index
, GLboolean state
)
150 if (cap
!= GL_TEXTURE_COORD_ARRAY
) {
151 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientStateiEXT(cap=%s)",
152 state
? "Enable" : "Disable",
153 _mesa_enum_to_string(cap
));
157 if (index
>= ctx
->Const
.MaxTextureCoordUnits
) {
158 _mesa_error(ctx
, GL_INVALID_VALUE
, "gl%sClientStateiEXT(index=%d)",
159 state
? "Enable" : "Disable",
164 saved_active
= ctx
->Array
.ActiveTexture
;
165 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
166 client_state(ctx
, vao
, cap
, state
);
167 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
172 * Enable GL capability.
173 * \param cap state to enable/disable.
175 * Get's the current context, assures that we're outside glBegin()/glEnd() and
176 * calls client_state().
179 _mesa_EnableClientState( GLenum cap
)
181 GET_CURRENT_CONTEXT(ctx
);
182 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_TRUE
);
187 _mesa_EnableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
189 GET_CURRENT_CONTEXT(ctx
);
190 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
192 "glEnableVertexArrayEXT");
196 /* The EXT_direct_state_access spec says:
197 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
198 * the tokens TEXTURE0 through TEXTUREn where n is less than the
199 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
200 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
201 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
202 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
203 * as if the active client texture is set to texture coordinate set i
204 * based on the token TEXTUREi indicated by array."
206 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
207 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
208 _mesa_ClientActiveTexture(cap
);
209 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_TRUE
);
210 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
212 client_state(ctx
, vao
, cap
, GL_TRUE
);
218 _mesa_EnableClientStateiEXT( GLenum cap
, GLuint index
)
220 GET_CURRENT_CONTEXT(ctx
);
221 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_TRUE
);
226 * Disable GL capability.
227 * \param cap state to enable/disable.
229 * Get's the current context, assures that we're outside glBegin()/glEnd() and
230 * calls client_state().
233 _mesa_DisableClientState( GLenum cap
)
235 GET_CURRENT_CONTEXT(ctx
);
236 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_FALSE
);
240 _mesa_DisableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
242 GET_CURRENT_CONTEXT(ctx
);
243 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
245 "glDisableVertexArrayEXT");
249 /* The EXT_direct_state_access spec says:
250 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
251 * the tokens TEXTURE0 through TEXTUREn where n is less than the
252 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
253 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
254 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
255 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
256 * as if the active client texture is set to texture coordinate set i
257 * based on the token TEXTUREi indicated by array."
259 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
260 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
261 _mesa_ClientActiveTexture(cap
);
262 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_FALSE
);
263 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
265 client_state(ctx
, vao
, cap
, GL_FALSE
);
270 _mesa_DisableClientStateiEXT( GLenum cap
, GLuint index
)
272 GET_CURRENT_CONTEXT(ctx
);
273 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_FALSE
);
276 #define CHECK_EXTENSION(EXTNAME) \
277 if (!ctx->Extensions.EXTNAME) { \
278 goto invalid_enum_error; \
281 #define CHECK_EXTENSION2(EXT1, EXT2) \
282 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
283 goto invalid_enum_error; \
287 * Return pointer to current texture unit for setting/getting coordinate
289 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
290 * texture unit is higher than the number of supported coordinate units.
292 static struct gl_fixedfunc_texture_unit
*
293 get_texcoord_unit(struct gl_context
*ctx
)
295 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
296 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
300 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
306 * Helper function to enable or disable a texture target.
307 * \param bit one of the TEXTURE_x_BIT values
308 * \return GL_TRUE if state is changing or GL_FALSE if no change
311 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
313 struct gl_fixedfunc_texture_unit
*texUnit
=
314 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
318 const GLbitfield newenabled
= state
319 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
321 if (texUnit
->Enabled
== newenabled
)
324 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
325 texUnit
->Enabled
= newenabled
;
331 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
332 * whether the API supports it (GLES doesn't).
335 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
337 if (ctx
->Multisample
.Enabled
== state
)
340 /* GL compatibility needs Multisample.Enable to determine program state
343 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
344 !ctx
->DriverFlags
.NewMultisampleEnable
) {
345 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
347 FLUSH_VERTICES(ctx
, 0);
350 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
351 ctx
->Multisample
.Enabled
= state
;
353 if (ctx
->Driver
.Enable
) {
354 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
359 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
360 * check for whether the API supports it (GLES doesn't).
363 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
365 if (ctx
->Color
.sRGBEnabled
== state
)
368 /* TODO: Switch i965 to the new flag and remove the conditional */
369 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
370 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
371 ctx
->Color
.sRGBEnabled
= state
;
373 if (ctx
->Driver
.Enable
) {
374 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
379 * Helper function to enable or disable state.
381 * \param ctx GL context.
382 * \param cap the state to enable/disable
383 * \param state whether to enable or disable the specified capability.
385 * Updates the current context and flushes the vertices as needed. For
386 * capabilities associated with extensions it verifies that those extensions
387 * are effectivly present before updating. Notifies the driver via
388 * dd_function_table::Enable.
391 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
393 if (MESA_VERBOSE
& VERBOSE_API
)
394 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
395 state
? "glEnable" : "glDisable",
396 _mesa_enum_to_string(cap
),
401 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
402 goto invalid_enum_error
;
403 if (ctx
->Color
.AlphaEnabled
== state
)
405 /* AlphaEnabled is used by the fixed-func fragment program */
406 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
407 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
408 ctx
->Color
.AlphaEnabled
= state
;
411 if (ctx
->API
!= API_OPENGL_COMPAT
)
412 goto invalid_enum_error
;
413 if (ctx
->Eval
.AutoNormal
== state
)
415 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
416 ctx
->Eval
.AutoNormal
= state
;
420 GLbitfield newEnabled
=
421 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
422 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
423 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
424 ctx
->Color
._AdvancedBlendMode
);
425 ctx
->Color
.BlendEnabled
= newEnabled
;
429 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
430 case GL_CLIP_DISTANCE1
:
431 case GL_CLIP_DISTANCE2
:
432 case GL_CLIP_DISTANCE3
:
433 case GL_CLIP_DISTANCE4
:
434 case GL_CLIP_DISTANCE5
:
435 case GL_CLIP_DISTANCE6
:
436 case GL_CLIP_DISTANCE7
:
438 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
440 if (p
>= ctx
->Const
.MaxClipPlanes
)
441 goto invalid_enum_error
;
443 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
444 == ((GLuint
) state
<< p
))
447 /* The compatibility profile needs _NEW_TRANSFORM to transform
448 * clip planes according to the projection matrix.
450 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
451 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
452 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
454 FLUSH_VERTICES(ctx
, 0);
456 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
459 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
461 /* The projection matrix transforms the clip plane. */
462 /* TODO: glEnable might not be the best place to do it. */
463 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
464 _mesa_update_clip_plane(ctx
, p
);
465 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
469 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
473 case GL_COLOR_MATERIAL
:
474 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
475 goto invalid_enum_error
;
476 if (ctx
->Light
.ColorMaterialEnabled
== state
)
478 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
479 FLUSH_CURRENT(ctx
, 0);
480 ctx
->Light
.ColorMaterialEnabled
= state
;
482 _mesa_update_color_material( ctx
,
483 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
487 if (ctx
->Polygon
.CullFlag
== state
)
490 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
491 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
492 ctx
->Polygon
.CullFlag
= state
;
495 if (ctx
->Depth
.Test
== state
)
497 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
498 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
499 ctx
->Depth
.Test
= state
;
501 case GL_DEBUG_OUTPUT
:
502 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
503 _mesa_set_debug_state_int(ctx
, cap
, state
);
506 if (ctx
->Color
.DitherFlag
== state
)
508 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
509 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
510 ctx
->Color
.DitherFlag
= state
;
513 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
514 goto invalid_enum_error
;
515 if (ctx
->Fog
.Enabled
== state
)
517 FLUSH_VERTICES(ctx
, _NEW_FOG
);
518 ctx
->Fog
.Enabled
= state
;
519 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
529 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
530 goto invalid_enum_error
;
531 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
533 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
534 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
536 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
539 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
543 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
544 goto invalid_enum_error
;
545 if (ctx
->Light
.Enabled
== state
)
547 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
548 ctx
->Light
.Enabled
= state
;
551 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
552 goto invalid_enum_error
;
553 if (ctx
->Line
.SmoothFlag
== state
)
555 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
556 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
557 ctx
->Line
.SmoothFlag
= state
;
559 case GL_LINE_STIPPLE
:
560 if (ctx
->API
!= API_OPENGL_COMPAT
)
561 goto invalid_enum_error
;
562 if (ctx
->Line
.StippleFlag
== state
)
564 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
565 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
566 ctx
->Line
.StippleFlag
= state
;
568 case GL_INDEX_LOGIC_OP
:
569 if (ctx
->API
!= API_OPENGL_COMPAT
)
570 goto invalid_enum_error
;
571 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
573 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
574 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
575 ctx
->Color
.IndexLogicOpEnabled
= state
;
577 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
578 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
579 goto invalid_enum_error
;
580 if (ctx
->IntelConservativeRasterization
== state
)
582 FLUSH_VERTICES(ctx
, 0);
583 ctx
->NewDriverState
|=
584 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
585 ctx
->IntelConservativeRasterization
= state
;
587 case GL_CONSERVATIVE_RASTERIZATION_NV
:
588 if (!_mesa_has_NV_conservative_raster(ctx
))
589 goto invalid_enum_error
;
590 if (ctx
->ConservativeRasterization
== state
)
592 FLUSH_VERTICES(ctx
, 0);
593 ctx
->NewDriverState
|=
594 ctx
->DriverFlags
.NewNvConservativeRasterization
;
595 ctx
->ConservativeRasterization
= state
;
597 case GL_COLOR_LOGIC_OP
:
598 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
599 goto invalid_enum_error
;
600 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
602 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
603 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
604 ctx
->Color
.ColorLogicOpEnabled
= state
;
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
;
843 if (ctx
->API
!= API_OPENGL_COMPAT
)
844 goto invalid_enum_error
;
845 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
850 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
851 goto invalid_enum_error
;
852 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
857 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
858 goto invalid_enum_error
;
859 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
863 case GL_TEXTURE_GEN_S
:
864 case GL_TEXTURE_GEN_T
:
865 case GL_TEXTURE_GEN_R
:
866 case GL_TEXTURE_GEN_Q
:
868 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
870 if (ctx
->API
!= API_OPENGL_COMPAT
)
871 goto invalid_enum_error
;
874 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
875 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
877 newenabled
|= coordBit
;
878 if (texUnit
->TexGenEnabled
== newenabled
)
880 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
881 texUnit
->TexGenEnabled
= newenabled
;
886 case GL_TEXTURE_GEN_STR_OES
:
887 /* disable S, T, and R at the same time */
889 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
891 if (ctx
->API
!= API_OPENGLES
)
892 goto invalid_enum_error
;
896 texUnit
->TexGenEnabled
& ~STR_BITS
;
898 newenabled
|= STR_BITS
;
899 if (texUnit
->TexGenEnabled
== newenabled
)
901 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
902 texUnit
->TexGenEnabled
= newenabled
;
907 /* client-side state */
908 case GL_VERTEX_ARRAY
:
909 case GL_NORMAL_ARRAY
:
911 case GL_TEXTURE_COORD_ARRAY
:
912 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
913 goto invalid_enum_error
;
914 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
917 case GL_EDGE_FLAG_ARRAY
:
918 case GL_FOG_COORDINATE_ARRAY_EXT
:
919 case GL_SECONDARY_COLOR_ARRAY_EXT
:
920 if (ctx
->API
!= API_OPENGL_COMPAT
)
921 goto invalid_enum_error
;
922 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
924 case GL_POINT_SIZE_ARRAY_OES
:
925 if (ctx
->API
!= API_OPENGLES
)
926 goto invalid_enum_error
;
927 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
930 /* GL_ARB_texture_cube_map */
931 case GL_TEXTURE_CUBE_MAP
:
932 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
933 !_mesa_has_OES_texture_cube_map(ctx
))
934 goto invalid_enum_error
;
935 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
940 /* GL_EXT_secondary_color */
941 case GL_COLOR_SUM_EXT
:
942 if (ctx
->API
!= API_OPENGL_COMPAT
)
943 goto invalid_enum_error
;
944 if (ctx
->Fog
.ColorSumEnabled
== state
)
946 FLUSH_VERTICES(ctx
, _NEW_FOG
);
947 ctx
->Fog
.ColorSumEnabled
= state
;
950 /* GL_ARB_multisample */
951 case GL_MULTISAMPLE_ARB
:
952 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
953 goto invalid_enum_error
;
954 _mesa_set_multisample(ctx
, state
);
956 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
957 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
959 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
961 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
962 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
964 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
965 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
966 goto invalid_enum_error
;
967 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
969 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
971 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
972 ctx
->Multisample
.SampleAlphaToOne
= state
;
974 case GL_SAMPLE_COVERAGE_ARB
:
975 if (ctx
->Multisample
.SampleCoverage
== state
)
977 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
979 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
980 ctx
->Multisample
.SampleCoverage
= state
;
982 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
983 if (!_mesa_is_desktop_gl(ctx
))
984 goto invalid_enum_error
;
985 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
987 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
989 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
990 ctx
->Multisample
.SampleCoverageInvert
= state
;
993 /* GL_ARB_sample_shading */
994 case GL_SAMPLE_SHADING
:
995 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
996 goto invalid_enum_error
;
997 if (ctx
->Multisample
.SampleShading
== state
)
999 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
1001 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
1002 ctx
->Multisample
.SampleShading
= state
;
1005 /* GL_IBM_rasterpos_clip */
1006 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1007 if (ctx
->API
!= API_OPENGL_COMPAT
)
1008 goto invalid_enum_error
;
1009 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
1011 FLUSH_VERTICES(ctx
, 0);
1012 ctx
->Transform
.RasterPositionUnclipped
= state
;
1015 /* GL_NV_point_sprite */
1016 case GL_POINT_SPRITE_NV
:
1017 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1018 goto invalid_enum_error
;
1019 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
);
1020 if (ctx
->Point
.PointSprite
== state
)
1022 FLUSH_VERTICES(ctx
, _NEW_POINT
);
1023 ctx
->Point
.PointSprite
= state
;
1026 case GL_VERTEX_PROGRAM_ARB
:
1027 if (ctx
->API
!= API_OPENGL_COMPAT
)
1028 goto invalid_enum_error
;
1029 CHECK_EXTENSION(ARB_vertex_program
);
1030 if (ctx
->VertexProgram
.Enabled
== state
)
1032 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1033 ctx
->VertexProgram
.Enabled
= state
;
1034 _mesa_update_vertex_processing_mode(ctx
);
1036 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1037 /* This was added with ARB_vertex_program, but it is also used with
1038 * GLSL vertex shaders on desktop.
1040 if (!_mesa_is_desktop_gl(ctx
))
1041 goto invalid_enum_error
;
1042 CHECK_EXTENSION(ARB_vertex_program
);
1043 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
1045 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1046 ctx
->VertexProgram
.PointSizeEnabled
= state
;
1048 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1049 if (ctx
->API
!= API_OPENGL_COMPAT
)
1050 goto invalid_enum_error
;
1051 CHECK_EXTENSION(ARB_vertex_program
);
1052 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
1054 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1055 ctx
->VertexProgram
.TwoSideEnabled
= state
;
1058 /* GL_NV_texture_rectangle */
1059 case GL_TEXTURE_RECTANGLE_NV
:
1060 if (ctx
->API
!= API_OPENGL_COMPAT
)
1061 goto invalid_enum_error
;
1062 CHECK_EXTENSION(NV_texture_rectangle
);
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 (ctx
->API
!= API_OPENGL_COMPAT
)
1071 goto invalid_enum_error
;
1072 CHECK_EXTENSION(EXT_stencil_two_side
);
1073 if (ctx
->Stencil
.TestTwoSide
== state
)
1075 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
1076 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
1077 ctx
->Stencil
.TestTwoSide
= state
;
1079 ctx
->Stencil
._BackFace
= 2;
1081 ctx
->Stencil
._BackFace
= 1;
1085 case GL_FRAGMENT_PROGRAM_ARB
:
1086 if (!_mesa_has_ARB_fragment_program(ctx
))
1087 goto invalid_enum_error
;
1088 if (ctx
->FragmentProgram
.Enabled
== state
)
1090 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1091 ctx
->FragmentProgram
.Enabled
= state
;
1094 /* GL_EXT_depth_bounds_test */
1095 case GL_DEPTH_BOUNDS_TEST_EXT
:
1096 if (!_mesa_is_desktop_gl(ctx
))
1097 goto invalid_enum_error
;
1098 CHECK_EXTENSION(EXT_depth_bounds_test
);
1099 if (ctx
->Depth
.BoundsTest
== state
)
1101 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
1102 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
1103 ctx
->Depth
.BoundsTest
= state
;
1106 case GL_DEPTH_CLAMP
:
1107 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1108 !_mesa_has_EXT_depth_clamp(ctx
))
1109 goto invalid_enum_error
;
1110 if (ctx
->Transform
.DepthClampNear
== state
&&
1111 ctx
->Transform
.DepthClampFar
== state
)
1113 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1115 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1116 ctx
->Transform
.DepthClampNear
= state
;
1117 ctx
->Transform
.DepthClampFar
= state
;
1120 case GL_DEPTH_CLAMP_NEAR_AMD
:
1121 if (!_mesa_is_desktop_gl(ctx
))
1122 goto invalid_enum_error
;
1123 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1124 if (ctx
->Transform
.DepthClampNear
== state
)
1126 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1128 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1129 ctx
->Transform
.DepthClampNear
= state
;
1132 case GL_DEPTH_CLAMP_FAR_AMD
:
1133 if (!_mesa_is_desktop_gl(ctx
))
1134 goto invalid_enum_error
;
1135 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1136 if (ctx
->Transform
.DepthClampFar
== state
)
1138 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1140 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1141 ctx
->Transform
.DepthClampFar
= state
;
1144 case GL_FRAGMENT_SHADER_ATI
:
1145 if (ctx
->API
!= API_OPENGL_COMPAT
)
1146 goto invalid_enum_error
;
1147 CHECK_EXTENSION(ATI_fragment_shader
);
1148 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1150 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1151 ctx
->ATIFragmentShader
.Enabled
= state
;
1154 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1155 if (!_mesa_is_desktop_gl(ctx
))
1156 goto invalid_enum_error
;
1157 CHECK_EXTENSION(ARB_seamless_cube_map
);
1158 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1159 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1160 ctx
->Texture
.CubeMapSeamless
= state
;
1164 case GL_RASTERIZER_DISCARD
:
1165 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1166 goto invalid_enum_error
;
1167 CHECK_EXTENSION(EXT_transform_feedback
);
1168 if (ctx
->RasterDiscard
!= state
) {
1169 FLUSH_VERTICES(ctx
, 0);
1170 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1171 ctx
->RasterDiscard
= state
;
1175 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1176 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1177 goto invalid_enum_error
;
1178 if (ctx
->TileRasterOrderFixed
!= state
) {
1179 FLUSH_VERTICES(ctx
, 0);
1180 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1181 ctx
->TileRasterOrderFixed
= state
;
1185 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1186 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1187 goto invalid_enum_error
;
1188 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1189 FLUSH_VERTICES(ctx
, 0);
1190 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1191 ctx
->TileRasterOrderIncreasingX
= state
;
1195 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1196 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1197 goto invalid_enum_error
;
1198 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1199 FLUSH_VERTICES(ctx
, 0);
1200 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1201 ctx
->TileRasterOrderIncreasingY
= state
;
1205 /* GL 3.1 primitive restart. Note: this enum is different from
1206 * GL_PRIMITIVE_RESTART_NV (which is client state).
1208 case GL_PRIMITIVE_RESTART
:
1209 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1210 goto invalid_enum_error
;
1212 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1213 FLUSH_VERTICES(ctx
, 0);
1214 ctx
->Array
.PrimitiveRestart
= state
;
1215 update_derived_primitive_restart_state(ctx
);
1219 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1220 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1221 goto invalid_enum_error
;
1222 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1223 FLUSH_VERTICES(ctx
, 0);
1224 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1225 update_derived_primitive_restart_state(ctx
);
1229 /* GL3.0 - GL_framebuffer_sRGB */
1230 case GL_FRAMEBUFFER_SRGB_EXT
:
1231 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1232 !_mesa_has_EXT_sRGB_write_control(ctx
))
1233 goto invalid_enum_error
;
1234 _mesa_set_framebuffer_srgb(ctx
, state
);
1237 /* GL_OES_EGL_image_external */
1238 case GL_TEXTURE_EXTERNAL_OES
:
1239 if (!_mesa_is_gles(ctx
))
1240 goto invalid_enum_error
;
1241 CHECK_EXTENSION(OES_EGL_image_external
);
1242 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1247 /* ARB_texture_multisample */
1248 case GL_SAMPLE_MASK
:
1249 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1250 goto invalid_enum_error
;
1251 if (ctx
->Multisample
.SampleMask
== state
)
1253 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1255 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1256 ctx
->Multisample
.SampleMask
= state
;
1259 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1260 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1261 goto invalid_enum_error
;
1262 if (ctx
->Color
.BlendCoherent
== state
)
1264 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1265 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1266 ctx
->Color
.BlendCoherent
= state
;
1270 goto invalid_enum_error
;
1273 if (ctx
->Driver
.Enable
) {
1274 ctx
->Driver
.Enable( ctx
, cap
, state
);
1280 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1281 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1286 * Enable GL capability. Called by glEnable()
1287 * \param cap state to enable.
1290 _mesa_Enable( GLenum cap
)
1292 GET_CURRENT_CONTEXT(ctx
);
1294 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1299 * Disable GL capability. Called by glDisable()
1300 * \param cap state to disable.
1303 _mesa_Disable( GLenum cap
)
1305 GET_CURRENT_CONTEXT(ctx
);
1307 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1313 * Enable/disable an indexed state var.
1316 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1317 GLuint index
, GLboolean state
)
1319 assert(state
== 0 || state
== 1);
1322 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1323 goto invalid_enum_error
;
1325 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1326 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1327 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1330 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1331 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1334 enabled
|= (1 << index
);
1336 enabled
&= ~(1 << index
);
1338 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1339 ctx
->Color
._AdvancedBlendMode
);
1340 ctx
->Color
.BlendEnabled
= enabled
;
1343 case GL_SCISSOR_TEST
:
1344 if (index
>= ctx
->Const
.MaxViewports
) {
1345 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1346 state
? "glEnablei" : "glDisablei", index
);
1349 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1351 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1352 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1354 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1356 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1359 /* EXT_direct_state_access */
1363 case GL_TEXTURE_CUBE_MAP
:
1364 case GL_TEXTURE_GEN_S
:
1365 case GL_TEXTURE_GEN_T
:
1366 case GL_TEXTURE_GEN_R
:
1367 case GL_TEXTURE_GEN_Q
:
1368 case GL_TEXTURE_RECTANGLE_ARB
: {
1369 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1370 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1371 ctx
->Const
.MaxTextureCoordUnits
)) {
1372 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1373 state
? "glEnablei" : "glDisablei", index
);
1376 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1377 _mesa_set_enable( ctx
, cap
, state
);
1378 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1382 goto invalid_enum_error
;
1387 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1388 state
? "glEnablei" : "glDisablei",
1389 _mesa_enum_to_string(cap
));
1394 _mesa_Disablei( GLenum cap
, GLuint index
)
1396 GET_CURRENT_CONTEXT(ctx
);
1397 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1402 _mesa_Enablei( GLenum cap
, GLuint index
)
1404 GET_CURRENT_CONTEXT(ctx
);
1405 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1409 GLboolean GLAPIENTRY
1410 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1412 GET_CURRENT_CONTEXT(ctx
);
1413 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1416 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1417 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1421 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1422 case GL_SCISSOR_TEST
:
1423 if (index
>= ctx
->Const
.MaxViewports
) {
1424 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1428 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1429 /* EXT_direct_state_access */
1433 case GL_TEXTURE_CUBE_MAP
:
1434 case GL_TEXTURE_GEN_S
:
1435 case GL_TEXTURE_GEN_T
:
1436 case GL_TEXTURE_GEN_R
:
1437 case GL_TEXTURE_GEN_Q
:
1438 case GL_TEXTURE_RECTANGLE_ARB
: {
1440 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1441 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1442 ctx
->Const
.MaxTextureCoordUnits
)) {
1443 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1447 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1448 state
= _mesa_IsEnabled(cap
);
1449 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1453 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1454 _mesa_enum_to_string(cap
));
1462 * Helper function to determine whether a texture target is enabled.
1465 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1467 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1468 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
1473 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1478 * Return simple enable/disable state.
1480 * \param cap state variable to query.
1482 * Returns the state of the specified capability from the current GL context.
1483 * For the capabilities associated with extensions verifies that those
1484 * extensions are effectively present before reporting.
1486 GLboolean GLAPIENTRY
1487 _mesa_IsEnabled( GLenum cap
)
1489 GET_CURRENT_CONTEXT(ctx
);
1490 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1494 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1495 goto invalid_enum_error
;
1496 return ctx
->Color
.AlphaEnabled
;
1497 case GL_AUTO_NORMAL
:
1498 if (ctx
->API
!= API_OPENGL_COMPAT
)
1499 goto invalid_enum_error
;
1500 return ctx
->Eval
.AutoNormal
;
1502 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1503 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1504 case GL_CLIP_DISTANCE1
:
1505 case GL_CLIP_DISTANCE2
:
1506 case GL_CLIP_DISTANCE3
:
1507 case GL_CLIP_DISTANCE4
:
1508 case GL_CLIP_DISTANCE5
:
1509 case GL_CLIP_DISTANCE6
:
1510 case GL_CLIP_DISTANCE7
: {
1511 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1513 if (p
>= ctx
->Const
.MaxClipPlanes
)
1514 goto invalid_enum_error
;
1516 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1518 case GL_COLOR_MATERIAL
:
1519 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1520 goto invalid_enum_error
;
1521 return ctx
->Light
.ColorMaterialEnabled
;
1523 return ctx
->Polygon
.CullFlag
;
1524 case GL_DEBUG_OUTPUT
:
1525 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1526 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1528 return ctx
->Depth
.Test
;
1530 return ctx
->Color
.DitherFlag
;
1532 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1533 goto invalid_enum_error
;
1534 return ctx
->Fog
.Enabled
;
1536 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1537 goto invalid_enum_error
;
1538 return ctx
->Light
.Enabled
;
1547 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1548 goto invalid_enum_error
;
1549 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1550 case GL_LINE_SMOOTH
:
1551 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1552 goto invalid_enum_error
;
1553 return ctx
->Line
.SmoothFlag
;
1554 case GL_LINE_STIPPLE
:
1555 if (ctx
->API
!= API_OPENGL_COMPAT
)
1556 goto invalid_enum_error
;
1557 return ctx
->Line
.StippleFlag
;
1558 case GL_INDEX_LOGIC_OP
:
1559 if (ctx
->API
!= API_OPENGL_COMPAT
)
1560 goto invalid_enum_error
;
1561 return ctx
->Color
.IndexLogicOpEnabled
;
1562 case GL_COLOR_LOGIC_OP
:
1563 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1564 goto invalid_enum_error
;
1565 return ctx
->Color
.ColorLogicOpEnabled
;
1566 case GL_MAP1_COLOR_4
:
1567 if (ctx
->API
!= API_OPENGL_COMPAT
)
1568 goto invalid_enum_error
;
1569 return ctx
->Eval
.Map1Color4
;
1571 if (ctx
->API
!= API_OPENGL_COMPAT
)
1572 goto invalid_enum_error
;
1573 return ctx
->Eval
.Map1Index
;
1574 case GL_MAP1_NORMAL
:
1575 if (ctx
->API
!= API_OPENGL_COMPAT
)
1576 goto invalid_enum_error
;
1577 return ctx
->Eval
.Map1Normal
;
1578 case GL_MAP1_TEXTURE_COORD_1
:
1579 if (ctx
->API
!= API_OPENGL_COMPAT
)
1580 goto invalid_enum_error
;
1581 return ctx
->Eval
.Map1TextureCoord1
;
1582 case GL_MAP1_TEXTURE_COORD_2
:
1583 if (ctx
->API
!= API_OPENGL_COMPAT
)
1584 goto invalid_enum_error
;
1585 return ctx
->Eval
.Map1TextureCoord2
;
1586 case GL_MAP1_TEXTURE_COORD_3
:
1587 if (ctx
->API
!= API_OPENGL_COMPAT
)
1588 goto invalid_enum_error
;
1589 return ctx
->Eval
.Map1TextureCoord3
;
1590 case GL_MAP1_TEXTURE_COORD_4
:
1591 if (ctx
->API
!= API_OPENGL_COMPAT
)
1592 goto invalid_enum_error
;
1593 return ctx
->Eval
.Map1TextureCoord4
;
1594 case GL_MAP1_VERTEX_3
:
1595 if (ctx
->API
!= API_OPENGL_COMPAT
)
1596 goto invalid_enum_error
;
1597 return ctx
->Eval
.Map1Vertex3
;
1598 case GL_MAP1_VERTEX_4
:
1599 if (ctx
->API
!= API_OPENGL_COMPAT
)
1600 goto invalid_enum_error
;
1601 return ctx
->Eval
.Map1Vertex4
;
1602 case GL_MAP2_COLOR_4
:
1603 if (ctx
->API
!= API_OPENGL_COMPAT
)
1604 goto invalid_enum_error
;
1605 return ctx
->Eval
.Map2Color4
;
1607 if (ctx
->API
!= API_OPENGL_COMPAT
)
1608 goto invalid_enum_error
;
1609 return ctx
->Eval
.Map2Index
;
1610 case GL_MAP2_NORMAL
:
1611 if (ctx
->API
!= API_OPENGL_COMPAT
)
1612 goto invalid_enum_error
;
1613 return ctx
->Eval
.Map2Normal
;
1614 case GL_MAP2_TEXTURE_COORD_1
:
1615 if (ctx
->API
!= API_OPENGL_COMPAT
)
1616 goto invalid_enum_error
;
1617 return ctx
->Eval
.Map2TextureCoord1
;
1618 case GL_MAP2_TEXTURE_COORD_2
:
1619 if (ctx
->API
!= API_OPENGL_COMPAT
)
1620 goto invalid_enum_error
;
1621 return ctx
->Eval
.Map2TextureCoord2
;
1622 case GL_MAP2_TEXTURE_COORD_3
:
1623 if (ctx
->API
!= API_OPENGL_COMPAT
)
1624 goto invalid_enum_error
;
1625 return ctx
->Eval
.Map2TextureCoord3
;
1626 case GL_MAP2_TEXTURE_COORD_4
:
1627 if (ctx
->API
!= API_OPENGL_COMPAT
)
1628 goto invalid_enum_error
;
1629 return ctx
->Eval
.Map2TextureCoord4
;
1630 case GL_MAP2_VERTEX_3
:
1631 if (ctx
->API
!= API_OPENGL_COMPAT
)
1632 goto invalid_enum_error
;
1633 return ctx
->Eval
.Map2Vertex3
;
1634 case GL_MAP2_VERTEX_4
:
1635 if (ctx
->API
!= API_OPENGL_COMPAT
)
1636 goto invalid_enum_error
;
1637 return ctx
->Eval
.Map2Vertex4
;
1639 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1640 goto invalid_enum_error
;
1641 return ctx
->Transform
.Normalize
;
1642 case GL_POINT_SMOOTH
:
1643 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1644 goto invalid_enum_error
;
1645 return ctx
->Point
.SmoothFlag
;
1646 case GL_POLYGON_SMOOTH
:
1647 if (!_mesa_is_desktop_gl(ctx
))
1648 goto invalid_enum_error
;
1649 return ctx
->Polygon
.SmoothFlag
;
1650 case GL_POLYGON_STIPPLE
:
1651 if (ctx
->API
!= API_OPENGL_COMPAT
)
1652 goto invalid_enum_error
;
1653 return ctx
->Polygon
.StippleFlag
;
1654 case GL_POLYGON_OFFSET_POINT
:
1655 if (!_mesa_is_desktop_gl(ctx
))
1656 goto invalid_enum_error
;
1657 return ctx
->Polygon
.OffsetPoint
;
1658 case GL_POLYGON_OFFSET_LINE
:
1659 if (!_mesa_is_desktop_gl(ctx
))
1660 goto invalid_enum_error
;
1661 return ctx
->Polygon
.OffsetLine
;
1662 case GL_POLYGON_OFFSET_FILL
:
1663 return ctx
->Polygon
.OffsetFill
;
1664 case GL_RESCALE_NORMAL_EXT
:
1665 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1666 goto invalid_enum_error
;
1667 return ctx
->Transform
.RescaleNormals
;
1668 case GL_SCISSOR_TEST
:
1669 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1670 case GL_STENCIL_TEST
:
1671 return ctx
->Stencil
.Enabled
;
1673 if (ctx
->API
!= API_OPENGL_COMPAT
)
1674 goto invalid_enum_error
;
1675 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1677 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1678 goto invalid_enum_error
;
1679 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1681 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1682 goto invalid_enum_error
;
1683 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1684 case GL_TEXTURE_GEN_S
:
1685 case GL_TEXTURE_GEN_T
:
1686 case GL_TEXTURE_GEN_R
:
1687 case GL_TEXTURE_GEN_Q
:
1689 const struct gl_fixedfunc_texture_unit
*texUnit
=
1690 get_texcoord_unit(ctx
);
1692 if (ctx
->API
!= API_OPENGL_COMPAT
)
1693 goto invalid_enum_error
;
1696 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1697 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1701 case GL_TEXTURE_GEN_STR_OES
:
1703 const struct gl_fixedfunc_texture_unit
*texUnit
=
1704 get_texcoord_unit(ctx
);
1706 if (ctx
->API
!= API_OPENGLES
)
1707 goto invalid_enum_error
;
1710 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1711 ? GL_TRUE
: GL_FALSE
;
1715 /* client-side state */
1716 case GL_VERTEX_ARRAY
:
1717 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1718 goto invalid_enum_error
;
1719 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
1720 case GL_NORMAL_ARRAY
:
1721 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1722 goto invalid_enum_error
;
1723 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
1724 case GL_COLOR_ARRAY
:
1725 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1726 goto invalid_enum_error
;
1727 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
1728 case GL_INDEX_ARRAY
:
1729 if (ctx
->API
!= API_OPENGL_COMPAT
)
1730 goto invalid_enum_error
;
1731 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
1732 case GL_TEXTURE_COORD_ARRAY
:
1733 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1734 goto invalid_enum_error
;
1735 return !!(ctx
->Array
.VAO
->Enabled
&
1736 VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
1737 case GL_EDGE_FLAG_ARRAY
:
1738 if (ctx
->API
!= API_OPENGL_COMPAT
)
1739 goto invalid_enum_error
;
1740 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
1741 case GL_FOG_COORDINATE_ARRAY_EXT
:
1742 if (ctx
->API
!= API_OPENGL_COMPAT
)
1743 goto invalid_enum_error
;
1744 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
1745 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1746 if (ctx
->API
!= API_OPENGL_COMPAT
)
1747 goto invalid_enum_error
;
1748 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
1749 case GL_POINT_SIZE_ARRAY_OES
:
1750 if (ctx
->API
!= API_OPENGLES
)
1751 goto invalid_enum_error
;
1752 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
1754 /* GL_ARB_texture_cube_map */
1755 case GL_TEXTURE_CUBE_MAP
:
1756 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
1757 !_mesa_has_OES_texture_cube_map(ctx
))
1758 goto invalid_enum_error
;
1759 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1761 /* GL_EXT_secondary_color */
1762 case GL_COLOR_SUM_EXT
:
1763 if (ctx
->API
!= API_OPENGL_COMPAT
)
1764 goto invalid_enum_error
;
1765 return ctx
->Fog
.ColorSumEnabled
;
1767 /* GL_ARB_multisample */
1768 case GL_MULTISAMPLE_ARB
:
1769 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1770 goto invalid_enum_error
;
1771 return ctx
->Multisample
.Enabled
;
1772 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1773 return ctx
->Multisample
.SampleAlphaToCoverage
;
1774 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1775 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1776 goto invalid_enum_error
;
1777 return ctx
->Multisample
.SampleAlphaToOne
;
1778 case GL_SAMPLE_COVERAGE_ARB
:
1779 return ctx
->Multisample
.SampleCoverage
;
1780 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1781 if (!_mesa_is_desktop_gl(ctx
))
1782 goto invalid_enum_error
;
1783 return ctx
->Multisample
.SampleCoverageInvert
;
1785 /* GL_IBM_rasterpos_clip */
1786 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1787 if (ctx
->API
!= API_OPENGL_COMPAT
)
1788 goto invalid_enum_error
;
1789 return ctx
->Transform
.RasterPositionUnclipped
;
1791 /* GL_NV_point_sprite */
1792 case GL_POINT_SPRITE_NV
:
1793 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1794 goto invalid_enum_error
;
1795 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1796 return ctx
->Point
.PointSprite
;
1798 case GL_VERTEX_PROGRAM_ARB
:
1799 if (ctx
->API
!= API_OPENGL_COMPAT
)
1800 goto invalid_enum_error
;
1801 CHECK_EXTENSION(ARB_vertex_program
);
1802 return ctx
->VertexProgram
.Enabled
;
1803 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1804 /* This was added with ARB_vertex_program, but it is also used with
1805 * GLSL vertex shaders on desktop.
1807 if (!_mesa_is_desktop_gl(ctx
))
1808 goto invalid_enum_error
;
1809 CHECK_EXTENSION(ARB_vertex_program
);
1810 return ctx
->VertexProgram
.PointSizeEnabled
;
1811 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1812 if (ctx
->API
!= API_OPENGL_COMPAT
)
1813 goto invalid_enum_error
;
1814 CHECK_EXTENSION(ARB_vertex_program
);
1815 return ctx
->VertexProgram
.TwoSideEnabled
;
1817 /* GL_NV_texture_rectangle */
1818 case GL_TEXTURE_RECTANGLE_NV
:
1819 if (ctx
->API
!= API_OPENGL_COMPAT
)
1820 goto invalid_enum_error
;
1821 CHECK_EXTENSION(NV_texture_rectangle
);
1822 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1824 /* GL_EXT_stencil_two_side */
1825 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1826 if (ctx
->API
!= API_OPENGL_COMPAT
)
1827 goto invalid_enum_error
;
1828 CHECK_EXTENSION(EXT_stencil_two_side
);
1829 return ctx
->Stencil
.TestTwoSide
;
1831 case GL_FRAGMENT_PROGRAM_ARB
:
1832 if (!_mesa_has_ARB_fragment_program(ctx
))
1833 goto invalid_enum_error
;
1834 return ctx
->FragmentProgram
.Enabled
;
1836 /* GL_EXT_depth_bounds_test */
1837 case GL_DEPTH_BOUNDS_TEST_EXT
:
1838 if (!_mesa_is_desktop_gl(ctx
))
1839 goto invalid_enum_error
;
1840 CHECK_EXTENSION(EXT_depth_bounds_test
);
1841 return ctx
->Depth
.BoundsTest
;
1843 /* GL_ARB_depth_clamp */
1844 case GL_DEPTH_CLAMP
:
1845 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1846 !_mesa_has_EXT_depth_clamp(ctx
))
1847 goto invalid_enum_error
;
1848 return ctx
->Transform
.DepthClampNear
||
1849 ctx
->Transform
.DepthClampFar
;
1851 case GL_DEPTH_CLAMP_NEAR_AMD
:
1852 if (!_mesa_is_desktop_gl(ctx
))
1853 goto invalid_enum_error
;
1854 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1855 return ctx
->Transform
.DepthClampNear
;
1857 case GL_DEPTH_CLAMP_FAR_AMD
:
1858 if (!_mesa_is_desktop_gl(ctx
))
1859 goto invalid_enum_error
;
1860 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1861 return ctx
->Transform
.DepthClampFar
;
1863 case GL_FRAGMENT_SHADER_ATI
:
1864 if (ctx
->API
!= API_OPENGL_COMPAT
)
1865 goto invalid_enum_error
;
1866 CHECK_EXTENSION(ATI_fragment_shader
);
1867 return ctx
->ATIFragmentShader
.Enabled
;
1869 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1870 if (!_mesa_is_desktop_gl(ctx
))
1871 goto invalid_enum_error
;
1872 CHECK_EXTENSION(ARB_seamless_cube_map
);
1873 return ctx
->Texture
.CubeMapSeamless
;
1875 case GL_RASTERIZER_DISCARD
:
1876 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1877 goto invalid_enum_error
;
1878 CHECK_EXTENSION(EXT_transform_feedback
);
1879 return ctx
->RasterDiscard
;
1881 /* GL_NV_primitive_restart */
1882 case GL_PRIMITIVE_RESTART_NV
:
1883 if (!_mesa_has_NV_primitive_restart(ctx
))
1884 goto invalid_enum_error
;
1885 return ctx
->Array
.PrimitiveRestart
;
1887 /* GL 3.1 primitive restart */
1888 case GL_PRIMITIVE_RESTART
:
1889 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1890 goto invalid_enum_error
;
1892 return ctx
->Array
.PrimitiveRestart
;
1894 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1895 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1896 goto invalid_enum_error
;
1897 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1899 /* GL3.0 - GL_framebuffer_sRGB */
1900 case GL_FRAMEBUFFER_SRGB_EXT
:
1901 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1902 !_mesa_has_EXT_sRGB_write_control(ctx
))
1903 goto invalid_enum_error
;
1904 return ctx
->Color
.sRGBEnabled
;
1906 /* GL_OES_EGL_image_external */
1907 case GL_TEXTURE_EXTERNAL_OES
:
1908 if (!_mesa_is_gles(ctx
))
1909 goto invalid_enum_error
;
1910 CHECK_EXTENSION(OES_EGL_image_external
);
1911 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1913 /* ARB_texture_multisample */
1914 case GL_SAMPLE_MASK
:
1915 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1916 goto invalid_enum_error
;
1917 return ctx
->Multisample
.SampleMask
;
1919 /* ARB_sample_shading */
1920 case GL_SAMPLE_SHADING
:
1921 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
1922 goto invalid_enum_error
;
1923 return ctx
->Multisample
.SampleShading
;
1925 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1926 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1927 goto invalid_enum_error
;
1928 return ctx
->Color
.BlendCoherent
;
1930 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1931 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
1932 goto invalid_enum_error
;
1933 return ctx
->IntelConservativeRasterization
;
1935 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1936 if (!_mesa_has_NV_conservative_raster(ctx
))
1937 goto invalid_enum_error
;
1938 return ctx
->ConservativeRasterization
;
1940 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1941 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1942 goto invalid_enum_error
;
1943 return ctx
->TileRasterOrderFixed
;
1945 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1946 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1947 goto invalid_enum_error
;
1948 return ctx
->TileRasterOrderIncreasingX
;
1950 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1951 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1952 goto invalid_enum_error
;
1953 return ctx
->TileRasterOrderIncreasingY
;
1956 goto invalid_enum_error
;
1962 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1963 _mesa_enum_to_string(cap
));