3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
36 #include "debug_output.h"
48 _mesa_update_derived_primitive_restart_state(struct gl_context
*ctx
)
50 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
||
51 ctx
->Array
.PrimitiveRestartFixedIndex
;
52 ctx
->Array
._RestartIndex
[0] = _mesa_primitive_restart_index(ctx
, 1);
53 ctx
->Array
._RestartIndex
[1] = _mesa_primitive_restart_index(ctx
, 2);
54 ctx
->Array
._RestartIndex
[3] = _mesa_primitive_restart_index(ctx
, 4);
59 * Helper to enable/disable VAO client-side state.
62 vao_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
63 gl_vert_attrib attr
, GLboolean state
)
66 _mesa_enable_vertex_array_attrib(ctx
, vao
, attr
);
68 _mesa_disable_vertex_array_attrib(ctx
, vao
, attr
);
73 * Helper to enable/disable client-side state.
76 client_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
77 GLenum cap
, GLboolean state
)
81 vao_state(ctx
, vao
, VERT_ATTRIB_POS
, state
);
84 vao_state(ctx
, vao
, VERT_ATTRIB_NORMAL
, state
);
87 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR0
, state
);
90 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR_INDEX
, state
);
92 case GL_TEXTURE_COORD_ARRAY
:
93 vao_state(ctx
, vao
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
95 case GL_EDGE_FLAG_ARRAY
:
96 vao_state(ctx
, vao
, VERT_ATTRIB_EDGEFLAG
, state
);
98 case GL_FOG_COORDINATE_ARRAY_EXT
:
99 vao_state(ctx
, vao
, VERT_ATTRIB_FOG
, state
);
101 case GL_SECONDARY_COLOR_ARRAY_EXT
:
102 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR1
, state
);
105 case GL_POINT_SIZE_ARRAY_OES
:
106 if (ctx
->VertexProgram
.PointSizeEnabled
!= state
) {
107 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
108 ctx
->VertexProgram
.PointSizeEnabled
= state
;
110 vao_state(ctx
, vao
, VERT_ATTRIB_POINT_SIZE
, state
);
113 /* GL_NV_primitive_restart */
114 case GL_PRIMITIVE_RESTART_NV
:
115 if (!_mesa_has_NV_primitive_restart(ctx
))
116 goto invalid_enum_error
;
117 if (ctx
->Array
.PrimitiveRestart
== state
)
120 FLUSH_VERTICES(ctx
, 0);
121 ctx
->Array
.PrimitiveRestart
= state
;
122 _mesa_update_derived_primitive_restart_state(ctx
);
126 goto invalid_enum_error
;
129 if (ctx
->Driver
.Enable
) {
130 ctx
->Driver
.Enable( ctx
, cap
, state
);
136 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
137 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
141 /* Helper for GL_EXT_direct_state_access following functions:
142 * - EnableClientStateIndexedEXT
143 * - EnableClientStateiEXT
144 * - DisableClientStateIndexedEXT
145 * - DisableClientStateiEXT
148 client_state_i(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
149 GLenum cap
, GLuint index
, GLboolean state
)
153 if (cap
!= GL_TEXTURE_COORD_ARRAY
) {
154 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientStateiEXT(cap=%s)",
155 state
? "Enable" : "Disable",
156 _mesa_enum_to_string(cap
));
160 if (index
>= ctx
->Const
.MaxTextureCoordUnits
) {
161 _mesa_error(ctx
, GL_INVALID_VALUE
, "gl%sClientStateiEXT(index=%d)",
162 state
? "Enable" : "Disable",
167 saved_active
= ctx
->Array
.ActiveTexture
;
168 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
169 client_state(ctx
, vao
, cap
, state
);
170 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
175 * Enable GL capability.
176 * \param cap state to enable/disable.
178 * Get's the current context, assures that we're outside glBegin()/glEnd() and
179 * calls client_state().
182 _mesa_EnableClientState( GLenum cap
)
184 GET_CURRENT_CONTEXT(ctx
);
185 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_TRUE
);
190 _mesa_EnableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
192 GET_CURRENT_CONTEXT(ctx
);
193 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
195 "glEnableVertexArrayEXT");
199 /* The EXT_direct_state_access spec says:
200 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
201 * the tokens TEXTURE0 through TEXTUREn where n is less than the
202 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
203 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
204 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
205 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
206 * as if the active client texture is set to texture coordinate set i
207 * based on the token TEXTUREi indicated by array."
209 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
210 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
211 _mesa_ClientActiveTexture(cap
);
212 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_TRUE
);
213 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
215 client_state(ctx
, vao
, cap
, GL_TRUE
);
221 _mesa_EnableClientStateiEXT( GLenum cap
, GLuint index
)
223 GET_CURRENT_CONTEXT(ctx
);
224 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_TRUE
);
229 * Disable GL capability.
230 * \param cap state to enable/disable.
232 * Get's the current context, assures that we're outside glBegin()/glEnd() and
233 * calls client_state().
236 _mesa_DisableClientState( GLenum cap
)
238 GET_CURRENT_CONTEXT(ctx
);
239 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_FALSE
);
243 _mesa_DisableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
245 GET_CURRENT_CONTEXT(ctx
);
246 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
248 "glDisableVertexArrayEXT");
252 /* The EXT_direct_state_access spec says:
253 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
254 * the tokens TEXTURE0 through TEXTUREn where n is less than the
255 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
256 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
257 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
258 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
259 * as if the active client texture is set to texture coordinate set i
260 * based on the token TEXTUREi indicated by array."
262 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
263 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
264 _mesa_ClientActiveTexture(cap
);
265 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_FALSE
);
266 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
268 client_state(ctx
, vao
, cap
, GL_FALSE
);
273 _mesa_DisableClientStateiEXT( GLenum cap
, GLuint index
)
275 GET_CURRENT_CONTEXT(ctx
);
276 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_FALSE
);
280 * Return pointer to current texture unit for setting/getting coordinate
282 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
283 * texture unit is higher than the number of supported coordinate units.
285 static struct gl_fixedfunc_texture_unit
*
286 get_texcoord_unit(struct gl_context
*ctx
)
288 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
289 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
293 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
299 * Helper function to enable or disable a texture target.
300 * \param bit one of the TEXTURE_x_BIT values
301 * \return GL_TRUE if state is changing or GL_FALSE if no change
304 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
306 struct gl_fixedfunc_texture_unit
*texUnit
=
307 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
311 const GLbitfield newenabled
= state
312 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
314 if (texUnit
->Enabled
== newenabled
)
317 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
318 texUnit
->Enabled
= newenabled
;
324 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
325 * whether the API supports it (GLES doesn't).
328 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
330 if (ctx
->Multisample
.Enabled
== state
)
333 /* GL compatibility needs Multisample.Enable to determine program state
336 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
337 !ctx
->DriverFlags
.NewMultisampleEnable
) {
338 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
340 FLUSH_VERTICES(ctx
, 0);
343 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
344 ctx
->Multisample
.Enabled
= state
;
346 if (ctx
->Driver
.Enable
) {
347 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
352 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
353 * check for whether the API supports it (GLES doesn't).
356 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
358 if (ctx
->Color
.sRGBEnabled
== state
)
361 /* TODO: Switch i965 to the new flag and remove the conditional */
362 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
363 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
364 ctx
->Color
.sRGBEnabled
= state
;
366 if (ctx
->Driver
.Enable
) {
367 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
372 * Helper function to enable or disable state.
374 * \param ctx GL context.
375 * \param cap the state to enable/disable
376 * \param state whether to enable or disable the specified capability.
378 * Updates the current context and flushes the vertices as needed. For
379 * capabilities associated with extensions it verifies that those extensions
380 * are effectivly present before updating. Notifies the driver via
381 * dd_function_table::Enable.
384 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
386 if (MESA_VERBOSE
& VERBOSE_API
)
387 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
388 state
? "glEnable" : "glDisable",
389 _mesa_enum_to_string(cap
),
394 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
395 goto invalid_enum_error
;
396 if (ctx
->Color
.AlphaEnabled
== state
)
398 /* AlphaEnabled is used by the fixed-func fragment program */
399 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
400 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
401 ctx
->Color
.AlphaEnabled
= state
;
404 if (ctx
->API
!= API_OPENGL_COMPAT
)
405 goto invalid_enum_error
;
406 if (ctx
->Eval
.AutoNormal
== state
)
408 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
409 ctx
->Eval
.AutoNormal
= state
;
413 GLbitfield newEnabled
=
414 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
415 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
416 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
417 ctx
->Color
._AdvancedBlendMode
);
418 ctx
->Color
.BlendEnabled
= newEnabled
;
419 _mesa_update_allow_draw_out_of_order(ctx
);
423 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
424 case GL_CLIP_DISTANCE1
:
425 case GL_CLIP_DISTANCE2
:
426 case GL_CLIP_DISTANCE3
:
427 case GL_CLIP_DISTANCE4
:
428 case GL_CLIP_DISTANCE5
:
429 case GL_CLIP_DISTANCE6
:
430 case GL_CLIP_DISTANCE7
:
432 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
434 if (p
>= ctx
->Const
.MaxClipPlanes
)
435 goto invalid_enum_error
;
437 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
438 == ((GLuint
) state
<< p
))
441 /* The compatibility profile needs _NEW_TRANSFORM to transform
442 * clip planes according to the projection matrix.
444 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
445 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
446 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
448 FLUSH_VERTICES(ctx
, 0);
450 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
453 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
455 /* The projection matrix transforms the clip plane. */
456 /* TODO: glEnable might not be the best place to do it. */
457 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
458 _mesa_update_clip_plane(ctx
, p
);
459 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
463 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
467 case GL_COLOR_MATERIAL
:
468 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
469 goto invalid_enum_error
;
470 if (ctx
->Light
.ColorMaterialEnabled
== state
)
472 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
473 FLUSH_CURRENT(ctx
, 0);
474 ctx
->Light
.ColorMaterialEnabled
= state
;
476 _mesa_update_color_material( ctx
,
477 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
481 if (ctx
->Polygon
.CullFlag
== state
)
484 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
485 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
486 ctx
->Polygon
.CullFlag
= state
;
489 if (ctx
->Depth
.Test
== state
)
491 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
492 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
493 ctx
->Depth
.Test
= state
;
494 _mesa_update_allow_draw_out_of_order(ctx
);
496 case GL_DEBUG_OUTPUT
:
497 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
498 _mesa_set_debug_state_int(ctx
, cap
, state
);
501 if (ctx
->Color
.DitherFlag
== state
)
503 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
504 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
505 ctx
->Color
.DitherFlag
= state
;
508 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
509 goto invalid_enum_error
;
510 if (ctx
->Fog
.Enabled
== state
)
512 FLUSH_VERTICES(ctx
, _NEW_FOG
);
513 ctx
->Fog
.Enabled
= state
;
514 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
524 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
525 goto invalid_enum_error
;
526 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
528 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
529 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
531 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
534 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
538 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
539 goto invalid_enum_error
;
540 if (ctx
->Light
.Enabled
== state
)
542 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
543 ctx
->Light
.Enabled
= state
;
546 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
547 goto invalid_enum_error
;
548 if (ctx
->Line
.SmoothFlag
== state
)
550 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
551 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
552 ctx
->Line
.SmoothFlag
= state
;
554 case GL_LINE_STIPPLE
:
555 if (ctx
->API
!= API_OPENGL_COMPAT
)
556 goto invalid_enum_error
;
557 if (ctx
->Line
.StippleFlag
== state
)
559 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
560 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
561 ctx
->Line
.StippleFlag
= state
;
563 case GL_INDEX_LOGIC_OP
:
564 if (ctx
->API
!= API_OPENGL_COMPAT
)
565 goto invalid_enum_error
;
566 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
568 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
569 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
570 ctx
->Color
.IndexLogicOpEnabled
= state
;
572 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
573 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
574 goto invalid_enum_error
;
575 if (ctx
->IntelConservativeRasterization
== state
)
577 FLUSH_VERTICES(ctx
, 0);
578 ctx
->NewDriverState
|=
579 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
580 ctx
->IntelConservativeRasterization
= state
;
582 case GL_CONSERVATIVE_RASTERIZATION_NV
:
583 if (!_mesa_has_NV_conservative_raster(ctx
))
584 goto invalid_enum_error
;
585 if (ctx
->ConservativeRasterization
== state
)
587 FLUSH_VERTICES(ctx
, 0);
588 ctx
->NewDriverState
|=
589 ctx
->DriverFlags
.NewNvConservativeRasterization
;
590 ctx
->ConservativeRasterization
= state
;
592 case GL_COLOR_LOGIC_OP
:
593 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
594 goto invalid_enum_error
;
595 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
597 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
598 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
599 ctx
->Color
.ColorLogicOpEnabled
= state
;
600 _mesa_update_allow_draw_out_of_order(ctx
);
602 case GL_MAP1_COLOR_4
:
603 if (ctx
->API
!= API_OPENGL_COMPAT
)
604 goto invalid_enum_error
;
605 if (ctx
->Eval
.Map1Color4
== state
)
607 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
608 ctx
->Eval
.Map1Color4
= state
;
611 if (ctx
->API
!= API_OPENGL_COMPAT
)
612 goto invalid_enum_error
;
613 if (ctx
->Eval
.Map1Index
== state
)
615 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
616 ctx
->Eval
.Map1Index
= state
;
619 if (ctx
->API
!= API_OPENGL_COMPAT
)
620 goto invalid_enum_error
;
621 if (ctx
->Eval
.Map1Normal
== state
)
623 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
624 ctx
->Eval
.Map1Normal
= state
;
626 case GL_MAP1_TEXTURE_COORD_1
:
627 if (ctx
->API
!= API_OPENGL_COMPAT
)
628 goto invalid_enum_error
;
629 if (ctx
->Eval
.Map1TextureCoord1
== state
)
631 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
632 ctx
->Eval
.Map1TextureCoord1
= state
;
634 case GL_MAP1_TEXTURE_COORD_2
:
635 if (ctx
->API
!= API_OPENGL_COMPAT
)
636 goto invalid_enum_error
;
637 if (ctx
->Eval
.Map1TextureCoord2
== state
)
639 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
640 ctx
->Eval
.Map1TextureCoord2
= state
;
642 case GL_MAP1_TEXTURE_COORD_3
:
643 if (ctx
->API
!= API_OPENGL_COMPAT
)
644 goto invalid_enum_error
;
645 if (ctx
->Eval
.Map1TextureCoord3
== state
)
647 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
648 ctx
->Eval
.Map1TextureCoord3
= state
;
650 case GL_MAP1_TEXTURE_COORD_4
:
651 if (ctx
->API
!= API_OPENGL_COMPAT
)
652 goto invalid_enum_error
;
653 if (ctx
->Eval
.Map1TextureCoord4
== state
)
655 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
656 ctx
->Eval
.Map1TextureCoord4
= state
;
658 case GL_MAP1_VERTEX_3
:
659 if (ctx
->API
!= API_OPENGL_COMPAT
)
660 goto invalid_enum_error
;
661 if (ctx
->Eval
.Map1Vertex3
== state
)
663 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
664 ctx
->Eval
.Map1Vertex3
= state
;
666 case GL_MAP1_VERTEX_4
:
667 if (ctx
->API
!= API_OPENGL_COMPAT
)
668 goto invalid_enum_error
;
669 if (ctx
->Eval
.Map1Vertex4
== state
)
671 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
672 ctx
->Eval
.Map1Vertex4
= state
;
674 case GL_MAP2_COLOR_4
:
675 if (ctx
->API
!= API_OPENGL_COMPAT
)
676 goto invalid_enum_error
;
677 if (ctx
->Eval
.Map2Color4
== state
)
679 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
680 ctx
->Eval
.Map2Color4
= state
;
683 if (ctx
->API
!= API_OPENGL_COMPAT
)
684 goto invalid_enum_error
;
685 if (ctx
->Eval
.Map2Index
== state
)
687 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
688 ctx
->Eval
.Map2Index
= state
;
691 if (ctx
->API
!= API_OPENGL_COMPAT
)
692 goto invalid_enum_error
;
693 if (ctx
->Eval
.Map2Normal
== state
)
695 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
696 ctx
->Eval
.Map2Normal
= state
;
698 case GL_MAP2_TEXTURE_COORD_1
:
699 if (ctx
->API
!= API_OPENGL_COMPAT
)
700 goto invalid_enum_error
;
701 if (ctx
->Eval
.Map2TextureCoord1
== state
)
703 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
704 ctx
->Eval
.Map2TextureCoord1
= state
;
706 case GL_MAP2_TEXTURE_COORD_2
:
707 if (ctx
->API
!= API_OPENGL_COMPAT
)
708 goto invalid_enum_error
;
709 if (ctx
->Eval
.Map2TextureCoord2
== state
)
711 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
712 ctx
->Eval
.Map2TextureCoord2
= state
;
714 case GL_MAP2_TEXTURE_COORD_3
:
715 if (ctx
->API
!= API_OPENGL_COMPAT
)
716 goto invalid_enum_error
;
717 if (ctx
->Eval
.Map2TextureCoord3
== state
)
719 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
720 ctx
->Eval
.Map2TextureCoord3
= state
;
722 case GL_MAP2_TEXTURE_COORD_4
:
723 if (ctx
->API
!= API_OPENGL_COMPAT
)
724 goto invalid_enum_error
;
725 if (ctx
->Eval
.Map2TextureCoord4
== state
)
727 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
728 ctx
->Eval
.Map2TextureCoord4
= state
;
730 case GL_MAP2_VERTEX_3
:
731 if (ctx
->API
!= API_OPENGL_COMPAT
)
732 goto invalid_enum_error
;
733 if (ctx
->Eval
.Map2Vertex3
== state
)
735 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
736 ctx
->Eval
.Map2Vertex3
= state
;
738 case GL_MAP2_VERTEX_4
:
739 if (ctx
->API
!= API_OPENGL_COMPAT
)
740 goto invalid_enum_error
;
741 if (ctx
->Eval
.Map2Vertex4
== state
)
743 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
744 ctx
->Eval
.Map2Vertex4
= state
;
747 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
748 goto invalid_enum_error
;
749 if (ctx
->Transform
.Normalize
== state
)
751 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
752 ctx
->Transform
.Normalize
= state
;
754 case GL_POINT_SMOOTH
:
755 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
756 goto invalid_enum_error
;
757 if (ctx
->Point
.SmoothFlag
== state
)
759 FLUSH_VERTICES(ctx
, _NEW_POINT
);
760 ctx
->Point
.SmoothFlag
= state
;
762 case GL_POLYGON_SMOOTH
:
763 if (!_mesa_is_desktop_gl(ctx
))
764 goto invalid_enum_error
;
765 if (ctx
->Polygon
.SmoothFlag
== state
)
768 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
769 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
770 ctx
->Polygon
.SmoothFlag
= state
;
772 case GL_POLYGON_STIPPLE
:
773 if (ctx
->API
!= API_OPENGL_COMPAT
)
774 goto invalid_enum_error
;
775 if (ctx
->Polygon
.StippleFlag
== state
)
778 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
779 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
780 ctx
->Polygon
.StippleFlag
= state
;
782 case GL_POLYGON_OFFSET_POINT
:
783 if (!_mesa_is_desktop_gl(ctx
))
784 goto invalid_enum_error
;
785 if (ctx
->Polygon
.OffsetPoint
== state
)
788 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
789 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
790 ctx
->Polygon
.OffsetPoint
= state
;
792 case GL_POLYGON_OFFSET_LINE
:
793 if (!_mesa_is_desktop_gl(ctx
))
794 goto invalid_enum_error
;
795 if (ctx
->Polygon
.OffsetLine
== state
)
798 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
799 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
800 ctx
->Polygon
.OffsetLine
= state
;
802 case GL_POLYGON_OFFSET_FILL
:
803 if (ctx
->Polygon
.OffsetFill
== state
)
806 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
807 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
808 ctx
->Polygon
.OffsetFill
= state
;
810 case GL_RESCALE_NORMAL_EXT
:
811 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
812 goto invalid_enum_error
;
813 if (ctx
->Transform
.RescaleNormals
== state
)
815 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
816 ctx
->Transform
.RescaleNormals
= state
;
818 case GL_SCISSOR_TEST
:
820 /* Must expand glEnable to all scissors */
821 GLbitfield newEnabled
=
822 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
823 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
824 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
826 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
827 ctx
->Scissor
.EnableFlags
= newEnabled
;
831 case GL_STENCIL_TEST
:
832 if (ctx
->Stencil
.Enabled
== state
)
834 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
835 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
836 ctx
->Stencil
.Enabled
= state
;
837 _mesa_update_allow_draw_out_of_order(ctx
);
840 if (ctx
->API
!= API_OPENGL_COMPAT
)
841 goto invalid_enum_error
;
842 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
847 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
848 goto invalid_enum_error
;
849 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
854 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
855 goto invalid_enum_error
;
856 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
860 case GL_TEXTURE_GEN_S
:
861 case GL_TEXTURE_GEN_T
:
862 case GL_TEXTURE_GEN_R
:
863 case GL_TEXTURE_GEN_Q
:
865 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
867 if (ctx
->API
!= API_OPENGL_COMPAT
)
868 goto invalid_enum_error
;
871 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
872 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
874 newenabled
|= coordBit
;
875 if (texUnit
->TexGenEnabled
== newenabled
)
877 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
878 texUnit
->TexGenEnabled
= newenabled
;
883 case GL_TEXTURE_GEN_STR_OES
:
884 /* disable S, T, and R at the same time */
886 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
888 if (ctx
->API
!= API_OPENGLES
)
889 goto invalid_enum_error
;
893 texUnit
->TexGenEnabled
& ~STR_BITS
;
895 newenabled
|= STR_BITS
;
896 if (texUnit
->TexGenEnabled
== newenabled
)
898 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
899 texUnit
->TexGenEnabled
= newenabled
;
904 /* client-side state */
905 case GL_VERTEX_ARRAY
:
906 case GL_NORMAL_ARRAY
:
908 case GL_TEXTURE_COORD_ARRAY
:
909 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
910 goto invalid_enum_error
;
911 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
914 case GL_EDGE_FLAG_ARRAY
:
915 case GL_FOG_COORDINATE_ARRAY_EXT
:
916 case GL_SECONDARY_COLOR_ARRAY_EXT
:
917 if (ctx
->API
!= API_OPENGL_COMPAT
)
918 goto invalid_enum_error
;
919 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
921 case GL_POINT_SIZE_ARRAY_OES
:
922 if (ctx
->API
!= API_OPENGLES
)
923 goto invalid_enum_error
;
924 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
927 /* GL_ARB_texture_cube_map */
928 case GL_TEXTURE_CUBE_MAP
:
929 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
930 !_mesa_has_OES_texture_cube_map(ctx
))
931 goto invalid_enum_error
;
932 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
937 /* GL_EXT_secondary_color */
938 case GL_COLOR_SUM_EXT
:
939 if (ctx
->API
!= API_OPENGL_COMPAT
)
940 goto invalid_enum_error
;
941 if (ctx
->Fog
.ColorSumEnabled
== state
)
943 FLUSH_VERTICES(ctx
, _NEW_FOG
);
944 ctx
->Fog
.ColorSumEnabled
= state
;
947 /* GL_ARB_multisample */
948 case GL_MULTISAMPLE_ARB
:
949 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
950 goto invalid_enum_error
;
951 _mesa_set_multisample(ctx
, state
);
953 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
954 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
956 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
958 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
959 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
961 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
962 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
963 goto invalid_enum_error
;
964 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
966 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
968 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
969 ctx
->Multisample
.SampleAlphaToOne
= state
;
971 case GL_SAMPLE_COVERAGE_ARB
:
972 if (ctx
->Multisample
.SampleCoverage
== state
)
974 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
976 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
977 ctx
->Multisample
.SampleCoverage
= state
;
979 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
980 if (!_mesa_is_desktop_gl(ctx
))
981 goto invalid_enum_error
;
982 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
984 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
986 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
987 ctx
->Multisample
.SampleCoverageInvert
= state
;
990 /* GL_ARB_sample_shading */
991 case GL_SAMPLE_SHADING
:
992 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
993 goto invalid_enum_error
;
994 if (ctx
->Multisample
.SampleShading
== state
)
996 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
998 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
999 ctx
->Multisample
.SampleShading
= state
;
1002 /* GL_IBM_rasterpos_clip */
1003 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1004 if (ctx
->API
!= API_OPENGL_COMPAT
)
1005 goto invalid_enum_error
;
1006 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
1008 FLUSH_VERTICES(ctx
, 0);
1009 ctx
->Transform
.RasterPositionUnclipped
= state
;
1012 /* GL_NV_point_sprite */
1013 case GL_POINT_SPRITE_NV
:
1014 if (!(ctx
->API
== API_OPENGL_COMPAT
&&
1015 (_mesa_has_ARB_point_sprite(ctx
) ||
1016 _mesa_has_NV_point_sprite(ctx
))) &&
1017 !_mesa_has_OES_point_sprite(ctx
))
1018 goto invalid_enum_error
;
1019 if (ctx
->Point
.PointSprite
== state
)
1021 FLUSH_VERTICES(ctx
, _NEW_POINT
);
1022 ctx
->Point
.PointSprite
= state
;
1025 case GL_VERTEX_PROGRAM_ARB
:
1026 if (!_mesa_has_ARB_vertex_program(ctx
))
1027 goto invalid_enum_error
;
1028 if (ctx
->VertexProgram
.Enabled
== state
)
1030 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1031 ctx
->VertexProgram
.Enabled
= state
;
1032 _mesa_update_vertex_processing_mode(ctx
);
1034 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1035 /* This was added with ARB_vertex_program, but it is also used with
1036 * GLSL vertex shaders on desktop.
1038 if (!_mesa_has_ARB_vertex_program(ctx
) &&
1039 ctx
->API
!= API_OPENGL_CORE
)
1040 goto invalid_enum_error
;
1041 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
1043 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1044 ctx
->VertexProgram
.PointSizeEnabled
= state
;
1046 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1047 if (!_mesa_has_ARB_vertex_program(ctx
))
1048 goto invalid_enum_error
;
1049 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
1051 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1052 ctx
->VertexProgram
.TwoSideEnabled
= state
;
1055 /* GL_NV_texture_rectangle */
1056 case GL_TEXTURE_RECTANGLE_NV
:
1057 if (!_mesa_has_NV_texture_rectangle(ctx
))
1058 goto invalid_enum_error
;
1059 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
1064 /* GL_EXT_stencil_two_side */
1065 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1066 if (!_mesa_has_EXT_stencil_two_side(ctx
))
1067 goto invalid_enum_error
;
1068 if (ctx
->Stencil
.TestTwoSide
== state
)
1070 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
1071 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
1072 ctx
->Stencil
.TestTwoSide
= state
;
1074 ctx
->Stencil
._BackFace
= 2;
1076 ctx
->Stencil
._BackFace
= 1;
1080 case GL_FRAGMENT_PROGRAM_ARB
:
1081 if (!_mesa_has_ARB_fragment_program(ctx
))
1082 goto invalid_enum_error
;
1083 if (ctx
->FragmentProgram
.Enabled
== state
)
1085 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1086 ctx
->FragmentProgram
.Enabled
= state
;
1089 /* GL_EXT_depth_bounds_test */
1090 case GL_DEPTH_BOUNDS_TEST_EXT
:
1091 if (!_mesa_has_EXT_depth_bounds_test(ctx
))
1092 goto invalid_enum_error
;
1093 if (ctx
->Depth
.BoundsTest
== state
)
1095 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
1096 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
1097 ctx
->Depth
.BoundsTest
= state
;
1100 case GL_DEPTH_CLAMP
:
1101 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1102 !_mesa_has_EXT_depth_clamp(ctx
))
1103 goto invalid_enum_error
;
1104 if (ctx
->Transform
.DepthClampNear
== state
&&
1105 ctx
->Transform
.DepthClampFar
== state
)
1107 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1109 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1110 ctx
->Transform
.DepthClampNear
= state
;
1111 ctx
->Transform
.DepthClampFar
= state
;
1114 case GL_DEPTH_CLAMP_NEAR_AMD
:
1115 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1116 goto invalid_enum_error
;
1117 if (ctx
->Transform
.DepthClampNear
== state
)
1119 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1121 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1122 ctx
->Transform
.DepthClampNear
= state
;
1125 case GL_DEPTH_CLAMP_FAR_AMD
:
1126 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1127 goto invalid_enum_error
;
1128 if (ctx
->Transform
.DepthClampFar
== state
)
1130 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1132 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1133 ctx
->Transform
.DepthClampFar
= state
;
1136 case GL_FRAGMENT_SHADER_ATI
:
1137 if (!_mesa_has_ATI_fragment_shader(ctx
))
1138 goto invalid_enum_error
;
1139 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1141 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1142 ctx
->ATIFragmentShader
.Enabled
= state
;
1145 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1146 if (!_mesa_has_ARB_seamless_cube_map(ctx
))
1147 goto invalid_enum_error
;
1148 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1149 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1150 ctx
->Texture
.CubeMapSeamless
= state
;
1154 case GL_RASTERIZER_DISCARD
:
1155 if (!(_mesa_has_EXT_transform_feedback(ctx
) || _mesa_is_gles3(ctx
)))
1156 goto invalid_enum_error
;
1157 if (ctx
->RasterDiscard
!= state
) {
1158 FLUSH_VERTICES(ctx
, 0);
1159 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1160 ctx
->RasterDiscard
= state
;
1164 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1165 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1166 goto invalid_enum_error
;
1167 if (ctx
->TileRasterOrderFixed
!= state
) {
1168 FLUSH_VERTICES(ctx
, 0);
1169 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1170 ctx
->TileRasterOrderFixed
= state
;
1174 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1175 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1176 goto invalid_enum_error
;
1177 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1178 FLUSH_VERTICES(ctx
, 0);
1179 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1180 ctx
->TileRasterOrderIncreasingX
= state
;
1184 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1185 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1186 goto invalid_enum_error
;
1187 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1188 FLUSH_VERTICES(ctx
, 0);
1189 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1190 ctx
->TileRasterOrderIncreasingY
= state
;
1194 /* GL 3.1 primitive restart. Note: this enum is different from
1195 * GL_PRIMITIVE_RESTART_NV (which is client state).
1197 case GL_PRIMITIVE_RESTART
:
1198 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1199 goto invalid_enum_error
;
1201 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1202 FLUSH_VERTICES(ctx
, 0);
1203 ctx
->Array
.PrimitiveRestart
= state
;
1204 _mesa_update_derived_primitive_restart_state(ctx
);
1208 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1209 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1210 goto invalid_enum_error
;
1211 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1212 FLUSH_VERTICES(ctx
, 0);
1213 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1214 _mesa_update_derived_primitive_restart_state(ctx
);
1218 /* GL3.0 - GL_framebuffer_sRGB */
1219 case GL_FRAMEBUFFER_SRGB_EXT
:
1220 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1221 !_mesa_has_EXT_sRGB_write_control(ctx
))
1222 goto invalid_enum_error
;
1223 _mesa_set_framebuffer_srgb(ctx
, state
);
1226 /* GL_OES_EGL_image_external */
1227 case GL_TEXTURE_EXTERNAL_OES
:
1228 if (!_mesa_has_OES_EGL_image_external(ctx
))
1229 goto invalid_enum_error
;
1230 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1235 /* ARB_texture_multisample */
1236 case GL_SAMPLE_MASK
:
1237 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1238 goto invalid_enum_error
;
1239 if (ctx
->Multisample
.SampleMask
== state
)
1241 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1243 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1244 ctx
->Multisample
.SampleMask
= state
;
1247 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1248 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1249 goto invalid_enum_error
;
1250 if (ctx
->Color
.BlendCoherent
== state
)
1252 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1253 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1254 ctx
->Color
.BlendCoherent
= state
;
1257 case GL_BLACKHOLE_RENDER_INTEL
:
1258 if (!_mesa_has_INTEL_blackhole_render(ctx
))
1259 goto invalid_enum_error
;
1260 if (ctx
->IntelBlackholeRender
== state
)
1262 FLUSH_VERTICES(ctx
, 0);
1263 ctx
->IntelBlackholeRender
= state
;
1267 goto invalid_enum_error
;
1270 if (ctx
->Driver
.Enable
) {
1271 ctx
->Driver
.Enable( ctx
, cap
, state
);
1277 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1278 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1283 * Enable GL capability. Called by glEnable()
1284 * \param cap state to enable.
1287 _mesa_Enable( GLenum cap
)
1289 GET_CURRENT_CONTEXT(ctx
);
1291 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1296 * Disable GL capability. Called by glDisable()
1297 * \param cap state to disable.
1300 _mesa_Disable( GLenum cap
)
1302 GET_CURRENT_CONTEXT(ctx
);
1304 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1310 * Enable/disable an indexed state var.
1313 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1314 GLuint index
, GLboolean state
)
1316 assert(state
== 0 || state
== 1);
1319 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1320 goto invalid_enum_error
;
1322 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1323 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1324 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1327 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1328 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1331 enabled
|= (1 << index
);
1333 enabled
&= ~(1 << index
);
1335 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1336 ctx
->Color
._AdvancedBlendMode
);
1337 ctx
->Color
.BlendEnabled
= enabled
;
1338 _mesa_update_allow_draw_out_of_order(ctx
);
1341 case GL_SCISSOR_TEST
:
1342 if (index
>= ctx
->Const
.MaxViewports
) {
1343 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1344 state
? "glEnablei" : "glDisablei", index
);
1347 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1349 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1350 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1352 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1354 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1357 /* EXT_direct_state_access */
1361 case GL_TEXTURE_CUBE_MAP
:
1362 case GL_TEXTURE_GEN_S
:
1363 case GL_TEXTURE_GEN_T
:
1364 case GL_TEXTURE_GEN_R
:
1365 case GL_TEXTURE_GEN_Q
:
1366 case GL_TEXTURE_RECTANGLE_ARB
: {
1367 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1368 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1369 ctx
->Const
.MaxTextureCoordUnits
)) {
1370 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1371 state
? "glEnablei" : "glDisablei", index
);
1374 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1375 _mesa_set_enable( ctx
, cap
, state
);
1376 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1380 goto invalid_enum_error
;
1385 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1386 state
? "glEnablei" : "glDisablei",
1387 _mesa_enum_to_string(cap
));
1392 _mesa_Disablei( GLenum cap
, GLuint index
)
1394 GET_CURRENT_CONTEXT(ctx
);
1395 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1400 _mesa_Enablei( GLenum cap
, GLuint index
)
1402 GET_CURRENT_CONTEXT(ctx
);
1403 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1407 GLboolean GLAPIENTRY
1408 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1410 GET_CURRENT_CONTEXT(ctx
);
1411 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1414 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1415 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1419 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1420 case GL_SCISSOR_TEST
:
1421 if (index
>= ctx
->Const
.MaxViewports
) {
1422 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1426 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1427 /* EXT_direct_state_access */
1431 case GL_TEXTURE_CUBE_MAP
:
1432 case GL_TEXTURE_GEN_S
:
1433 case GL_TEXTURE_GEN_T
:
1434 case GL_TEXTURE_GEN_R
:
1435 case GL_TEXTURE_GEN_Q
:
1436 case GL_TEXTURE_RECTANGLE_ARB
: {
1438 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1439 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1440 ctx
->Const
.MaxTextureCoordUnits
)) {
1441 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1445 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1446 state
= _mesa_IsEnabled(cap
);
1447 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1451 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1452 _mesa_enum_to_string(cap
));
1460 * Helper function to determine whether a texture target is enabled.
1463 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1465 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1466 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
1471 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1476 * Return simple enable/disable state.
1478 * \param cap state variable to query.
1480 * Returns the state of the specified capability from the current GL context.
1481 * For the capabilities associated with extensions verifies that those
1482 * extensions are effectively present before reporting.
1484 GLboolean GLAPIENTRY
1485 _mesa_IsEnabled( GLenum cap
)
1487 GET_CURRENT_CONTEXT(ctx
);
1488 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1492 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1493 goto invalid_enum_error
;
1494 return ctx
->Color
.AlphaEnabled
;
1495 case GL_AUTO_NORMAL
:
1496 if (ctx
->API
!= API_OPENGL_COMPAT
)
1497 goto invalid_enum_error
;
1498 return ctx
->Eval
.AutoNormal
;
1500 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1501 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1502 case GL_CLIP_DISTANCE1
:
1503 case GL_CLIP_DISTANCE2
:
1504 case GL_CLIP_DISTANCE3
:
1505 case GL_CLIP_DISTANCE4
:
1506 case GL_CLIP_DISTANCE5
:
1507 case GL_CLIP_DISTANCE6
:
1508 case GL_CLIP_DISTANCE7
: {
1509 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1511 if (p
>= ctx
->Const
.MaxClipPlanes
)
1512 goto invalid_enum_error
;
1514 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1516 case GL_COLOR_MATERIAL
:
1517 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1518 goto invalid_enum_error
;
1519 return ctx
->Light
.ColorMaterialEnabled
;
1521 return ctx
->Polygon
.CullFlag
;
1522 case GL_DEBUG_OUTPUT
:
1523 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1524 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1526 return ctx
->Depth
.Test
;
1528 return ctx
->Color
.DitherFlag
;
1530 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1531 goto invalid_enum_error
;
1532 return ctx
->Fog
.Enabled
;
1534 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1535 goto invalid_enum_error
;
1536 return ctx
->Light
.Enabled
;
1545 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1546 goto invalid_enum_error
;
1547 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1548 case GL_LINE_SMOOTH
:
1549 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1550 goto invalid_enum_error
;
1551 return ctx
->Line
.SmoothFlag
;
1552 case GL_LINE_STIPPLE
:
1553 if (ctx
->API
!= API_OPENGL_COMPAT
)
1554 goto invalid_enum_error
;
1555 return ctx
->Line
.StippleFlag
;
1556 case GL_INDEX_LOGIC_OP
:
1557 if (ctx
->API
!= API_OPENGL_COMPAT
)
1558 goto invalid_enum_error
;
1559 return ctx
->Color
.IndexLogicOpEnabled
;
1560 case GL_COLOR_LOGIC_OP
:
1561 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1562 goto invalid_enum_error
;
1563 return ctx
->Color
.ColorLogicOpEnabled
;
1564 case GL_MAP1_COLOR_4
:
1565 if (ctx
->API
!= API_OPENGL_COMPAT
)
1566 goto invalid_enum_error
;
1567 return ctx
->Eval
.Map1Color4
;
1569 if (ctx
->API
!= API_OPENGL_COMPAT
)
1570 goto invalid_enum_error
;
1571 return ctx
->Eval
.Map1Index
;
1572 case GL_MAP1_NORMAL
:
1573 if (ctx
->API
!= API_OPENGL_COMPAT
)
1574 goto invalid_enum_error
;
1575 return ctx
->Eval
.Map1Normal
;
1576 case GL_MAP1_TEXTURE_COORD_1
:
1577 if (ctx
->API
!= API_OPENGL_COMPAT
)
1578 goto invalid_enum_error
;
1579 return ctx
->Eval
.Map1TextureCoord1
;
1580 case GL_MAP1_TEXTURE_COORD_2
:
1581 if (ctx
->API
!= API_OPENGL_COMPAT
)
1582 goto invalid_enum_error
;
1583 return ctx
->Eval
.Map1TextureCoord2
;
1584 case GL_MAP1_TEXTURE_COORD_3
:
1585 if (ctx
->API
!= API_OPENGL_COMPAT
)
1586 goto invalid_enum_error
;
1587 return ctx
->Eval
.Map1TextureCoord3
;
1588 case GL_MAP1_TEXTURE_COORD_4
:
1589 if (ctx
->API
!= API_OPENGL_COMPAT
)
1590 goto invalid_enum_error
;
1591 return ctx
->Eval
.Map1TextureCoord4
;
1592 case GL_MAP1_VERTEX_3
:
1593 if (ctx
->API
!= API_OPENGL_COMPAT
)
1594 goto invalid_enum_error
;
1595 return ctx
->Eval
.Map1Vertex3
;
1596 case GL_MAP1_VERTEX_4
:
1597 if (ctx
->API
!= API_OPENGL_COMPAT
)
1598 goto invalid_enum_error
;
1599 return ctx
->Eval
.Map1Vertex4
;
1600 case GL_MAP2_COLOR_4
:
1601 if (ctx
->API
!= API_OPENGL_COMPAT
)
1602 goto invalid_enum_error
;
1603 return ctx
->Eval
.Map2Color4
;
1605 if (ctx
->API
!= API_OPENGL_COMPAT
)
1606 goto invalid_enum_error
;
1607 return ctx
->Eval
.Map2Index
;
1608 case GL_MAP2_NORMAL
:
1609 if (ctx
->API
!= API_OPENGL_COMPAT
)
1610 goto invalid_enum_error
;
1611 return ctx
->Eval
.Map2Normal
;
1612 case GL_MAP2_TEXTURE_COORD_1
:
1613 if (ctx
->API
!= API_OPENGL_COMPAT
)
1614 goto invalid_enum_error
;
1615 return ctx
->Eval
.Map2TextureCoord1
;
1616 case GL_MAP2_TEXTURE_COORD_2
:
1617 if (ctx
->API
!= API_OPENGL_COMPAT
)
1618 goto invalid_enum_error
;
1619 return ctx
->Eval
.Map2TextureCoord2
;
1620 case GL_MAP2_TEXTURE_COORD_3
:
1621 if (ctx
->API
!= API_OPENGL_COMPAT
)
1622 goto invalid_enum_error
;
1623 return ctx
->Eval
.Map2TextureCoord3
;
1624 case GL_MAP2_TEXTURE_COORD_4
:
1625 if (ctx
->API
!= API_OPENGL_COMPAT
)
1626 goto invalid_enum_error
;
1627 return ctx
->Eval
.Map2TextureCoord4
;
1628 case GL_MAP2_VERTEX_3
:
1629 if (ctx
->API
!= API_OPENGL_COMPAT
)
1630 goto invalid_enum_error
;
1631 return ctx
->Eval
.Map2Vertex3
;
1632 case GL_MAP2_VERTEX_4
:
1633 if (ctx
->API
!= API_OPENGL_COMPAT
)
1634 goto invalid_enum_error
;
1635 return ctx
->Eval
.Map2Vertex4
;
1637 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1638 goto invalid_enum_error
;
1639 return ctx
->Transform
.Normalize
;
1640 case GL_POINT_SMOOTH
:
1641 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1642 goto invalid_enum_error
;
1643 return ctx
->Point
.SmoothFlag
;
1644 case GL_POLYGON_SMOOTH
:
1645 if (!_mesa_is_desktop_gl(ctx
))
1646 goto invalid_enum_error
;
1647 return ctx
->Polygon
.SmoothFlag
;
1648 case GL_POLYGON_STIPPLE
:
1649 if (ctx
->API
!= API_OPENGL_COMPAT
)
1650 goto invalid_enum_error
;
1651 return ctx
->Polygon
.StippleFlag
;
1652 case GL_POLYGON_OFFSET_POINT
:
1653 if (!_mesa_is_desktop_gl(ctx
))
1654 goto invalid_enum_error
;
1655 return ctx
->Polygon
.OffsetPoint
;
1656 case GL_POLYGON_OFFSET_LINE
:
1657 if (!_mesa_is_desktop_gl(ctx
))
1658 goto invalid_enum_error
;
1659 return ctx
->Polygon
.OffsetLine
;
1660 case GL_POLYGON_OFFSET_FILL
:
1661 return ctx
->Polygon
.OffsetFill
;
1662 case GL_RESCALE_NORMAL_EXT
:
1663 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1664 goto invalid_enum_error
;
1665 return ctx
->Transform
.RescaleNormals
;
1666 case GL_SCISSOR_TEST
:
1667 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1668 case GL_STENCIL_TEST
:
1669 return ctx
->Stencil
.Enabled
;
1671 if (ctx
->API
!= API_OPENGL_COMPAT
)
1672 goto invalid_enum_error
;
1673 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1675 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1676 goto invalid_enum_error
;
1677 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1679 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1680 goto invalid_enum_error
;
1681 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1682 case GL_TEXTURE_GEN_S
:
1683 case GL_TEXTURE_GEN_T
:
1684 case GL_TEXTURE_GEN_R
:
1685 case GL_TEXTURE_GEN_Q
:
1687 const struct gl_fixedfunc_texture_unit
*texUnit
=
1688 get_texcoord_unit(ctx
);
1690 if (ctx
->API
!= API_OPENGL_COMPAT
)
1691 goto invalid_enum_error
;
1694 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1695 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1699 case GL_TEXTURE_GEN_STR_OES
:
1701 const struct gl_fixedfunc_texture_unit
*texUnit
=
1702 get_texcoord_unit(ctx
);
1704 if (ctx
->API
!= API_OPENGLES
)
1705 goto invalid_enum_error
;
1708 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1709 ? GL_TRUE
: GL_FALSE
;
1713 /* client-side state */
1714 case GL_VERTEX_ARRAY
:
1715 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1716 goto invalid_enum_error
;
1717 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
1718 case GL_NORMAL_ARRAY
:
1719 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1720 goto invalid_enum_error
;
1721 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
1722 case GL_COLOR_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_COLOR0
);
1726 case GL_INDEX_ARRAY
:
1727 if (ctx
->API
!= API_OPENGL_COMPAT
)
1728 goto invalid_enum_error
;
1729 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
1730 case GL_TEXTURE_COORD_ARRAY
:
1731 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1732 goto invalid_enum_error
;
1733 return !!(ctx
->Array
.VAO
->Enabled
&
1734 VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
1735 case GL_EDGE_FLAG_ARRAY
:
1736 if (ctx
->API
!= API_OPENGL_COMPAT
)
1737 goto invalid_enum_error
;
1738 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
1739 case GL_FOG_COORDINATE_ARRAY_EXT
:
1740 if (ctx
->API
!= API_OPENGL_COMPAT
)
1741 goto invalid_enum_error
;
1742 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
1743 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1744 if (ctx
->API
!= API_OPENGL_COMPAT
)
1745 goto invalid_enum_error
;
1746 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
1747 case GL_POINT_SIZE_ARRAY_OES
:
1748 if (ctx
->API
!= API_OPENGLES
)
1749 goto invalid_enum_error
;
1750 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
1752 /* GL_ARB_texture_cube_map */
1753 case GL_TEXTURE_CUBE_MAP
:
1754 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
1755 !_mesa_has_OES_texture_cube_map(ctx
))
1756 goto invalid_enum_error
;
1757 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1759 /* GL_EXT_secondary_color */
1760 case GL_COLOR_SUM_EXT
:
1761 if (ctx
->API
!= API_OPENGL_COMPAT
)
1762 goto invalid_enum_error
;
1763 return ctx
->Fog
.ColorSumEnabled
;
1765 /* GL_ARB_multisample */
1766 case GL_MULTISAMPLE_ARB
:
1767 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1768 goto invalid_enum_error
;
1769 return ctx
->Multisample
.Enabled
;
1770 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1771 return ctx
->Multisample
.SampleAlphaToCoverage
;
1772 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1773 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1774 goto invalid_enum_error
;
1775 return ctx
->Multisample
.SampleAlphaToOne
;
1776 case GL_SAMPLE_COVERAGE_ARB
:
1777 return ctx
->Multisample
.SampleCoverage
;
1778 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1779 if (!_mesa_is_desktop_gl(ctx
))
1780 goto invalid_enum_error
;
1781 return ctx
->Multisample
.SampleCoverageInvert
;
1783 /* GL_IBM_rasterpos_clip */
1784 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1785 if (ctx
->API
!= API_OPENGL_COMPAT
)
1786 goto invalid_enum_error
;
1787 return ctx
->Transform
.RasterPositionUnclipped
;
1789 /* GL_NV_point_sprite */
1790 case GL_POINT_SPRITE_NV
:
1791 if (!(ctx
->API
== API_OPENGL_COMPAT
&&
1792 (_mesa_has_ARB_point_sprite(ctx
) ||
1793 _mesa_has_NV_point_sprite(ctx
))) &&
1794 !_mesa_has_OES_point_sprite(ctx
))
1795 goto invalid_enum_error
;
1796 return ctx
->Point
.PointSprite
;
1798 case GL_VERTEX_PROGRAM_ARB
:
1799 if (!_mesa_has_ARB_vertex_program(ctx
))
1800 goto invalid_enum_error
;
1801 return ctx
->VertexProgram
.Enabled
;
1802 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1803 /* This was added with ARB_vertex_program, but it is also used with
1804 * GLSL vertex shaders on desktop.
1806 if (!_mesa_has_ARB_vertex_program(ctx
) &&
1807 ctx
->API
!= API_OPENGL_CORE
)
1808 goto invalid_enum_error
;
1809 return ctx
->VertexProgram
.PointSizeEnabled
;
1810 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1811 if (!_mesa_has_ARB_vertex_program(ctx
))
1812 goto invalid_enum_error
;
1813 return ctx
->VertexProgram
.TwoSideEnabled
;
1815 /* GL_NV_texture_rectangle */
1816 case GL_TEXTURE_RECTANGLE_NV
:
1817 if (!_mesa_has_NV_texture_rectangle(ctx
))
1818 goto invalid_enum_error
;
1819 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1821 /* GL_EXT_stencil_two_side */
1822 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1823 if (!_mesa_has_EXT_stencil_two_side(ctx
))
1824 goto invalid_enum_error
;
1825 return ctx
->Stencil
.TestTwoSide
;
1827 case GL_FRAGMENT_PROGRAM_ARB
:
1828 if (!_mesa_has_ARB_fragment_program(ctx
))
1829 goto invalid_enum_error
;
1830 return ctx
->FragmentProgram
.Enabled
;
1832 /* GL_EXT_depth_bounds_test */
1833 case GL_DEPTH_BOUNDS_TEST_EXT
:
1834 if (!_mesa_has_EXT_depth_bounds_test(ctx
))
1835 goto invalid_enum_error
;
1836 return ctx
->Depth
.BoundsTest
;
1838 /* GL_ARB_depth_clamp */
1839 case GL_DEPTH_CLAMP
:
1840 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1841 !_mesa_has_EXT_depth_clamp(ctx
))
1842 goto invalid_enum_error
;
1843 return ctx
->Transform
.DepthClampNear
||
1844 ctx
->Transform
.DepthClampFar
;
1846 case GL_DEPTH_CLAMP_NEAR_AMD
:
1847 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1848 goto invalid_enum_error
;
1849 return ctx
->Transform
.DepthClampNear
;
1851 case GL_DEPTH_CLAMP_FAR_AMD
:
1852 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1853 goto invalid_enum_error
;
1854 return ctx
->Transform
.DepthClampFar
;
1856 case GL_FRAGMENT_SHADER_ATI
:
1857 if (!_mesa_has_ATI_fragment_shader(ctx
))
1858 goto invalid_enum_error
;
1859 return ctx
->ATIFragmentShader
.Enabled
;
1861 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1862 if (!_mesa_has_ARB_seamless_cube_map(ctx
))
1863 goto invalid_enum_error
;
1864 return ctx
->Texture
.CubeMapSeamless
;
1866 case GL_RASTERIZER_DISCARD
:
1867 if (!(_mesa_has_EXT_transform_feedback(ctx
) || _mesa_is_gles3(ctx
)))
1868 goto invalid_enum_error
;
1869 return ctx
->RasterDiscard
;
1871 /* GL_NV_primitive_restart */
1872 case GL_PRIMITIVE_RESTART_NV
:
1873 if (!_mesa_has_NV_primitive_restart(ctx
))
1874 goto invalid_enum_error
;
1875 return ctx
->Array
.PrimitiveRestart
;
1877 /* GL 3.1 primitive restart */
1878 case GL_PRIMITIVE_RESTART
:
1879 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1880 goto invalid_enum_error
;
1882 return ctx
->Array
.PrimitiveRestart
;
1884 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1885 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1886 goto invalid_enum_error
;
1887 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1889 /* GL3.0 - GL_framebuffer_sRGB */
1890 case GL_FRAMEBUFFER_SRGB_EXT
:
1891 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1892 !_mesa_has_EXT_sRGB_write_control(ctx
))
1893 goto invalid_enum_error
;
1894 return ctx
->Color
.sRGBEnabled
;
1896 /* GL_OES_EGL_image_external */
1897 case GL_TEXTURE_EXTERNAL_OES
:
1898 if (!_mesa_has_OES_EGL_image_external(ctx
))
1899 goto invalid_enum_error
;
1900 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1902 /* ARB_texture_multisample */
1903 case GL_SAMPLE_MASK
:
1904 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1905 goto invalid_enum_error
;
1906 return ctx
->Multisample
.SampleMask
;
1908 /* ARB_sample_shading */
1909 case GL_SAMPLE_SHADING
:
1910 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
1911 goto invalid_enum_error
;
1912 return ctx
->Multisample
.SampleShading
;
1914 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1915 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1916 goto invalid_enum_error
;
1917 return ctx
->Color
.BlendCoherent
;
1919 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1920 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
1921 goto invalid_enum_error
;
1922 return ctx
->IntelConservativeRasterization
;
1924 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1925 if (!_mesa_has_NV_conservative_raster(ctx
))
1926 goto invalid_enum_error
;
1927 return ctx
->ConservativeRasterization
;
1929 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1930 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1931 goto invalid_enum_error
;
1932 return ctx
->TileRasterOrderFixed
;
1934 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1935 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1936 goto invalid_enum_error
;
1937 return ctx
->TileRasterOrderIncreasingX
;
1939 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1940 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1941 goto invalid_enum_error
;
1942 return ctx
->TileRasterOrderIncreasingY
;
1944 case GL_BLACKHOLE_RENDER_INTEL
:
1945 if (!_mesa_has_INTEL_blackhole_render(ctx
))
1946 goto invalid_enum_error
;
1947 return ctx
->IntelBlackholeRender
;
1950 goto invalid_enum_error
;
1956 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1957 _mesa_enum_to_string(cap
));