3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
36 #include "debug_output.h"
48 update_derived_primitive_restart_state(struct gl_context
*ctx
)
50 /* Update derived primitive restart state.
52 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
53 || ctx
->Array
.PrimitiveRestartFixedIndex
;
58 * Helper to enable/disable VAO client-side state.
61 vao_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
62 gl_vert_attrib attr
, GLboolean state
)
65 _mesa_enable_vertex_array_attrib(ctx
, vao
, attr
);
67 _mesa_disable_vertex_array_attrib(ctx
, vao
, attr
);
72 * Helper to enable/disable client-side state.
75 client_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
76 GLenum cap
, GLboolean state
)
80 vao_state(ctx
, vao
, VERT_ATTRIB_POS
, state
);
83 vao_state(ctx
, vao
, VERT_ATTRIB_NORMAL
, state
);
86 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR0
, state
);
89 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR_INDEX
, state
);
91 case GL_TEXTURE_COORD_ARRAY
:
92 vao_state(ctx
, vao
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
94 case GL_EDGE_FLAG_ARRAY
:
95 vao_state(ctx
, vao
, VERT_ATTRIB_EDGEFLAG
, state
);
97 case GL_FOG_COORDINATE_ARRAY_EXT
:
98 vao_state(ctx
, vao
, VERT_ATTRIB_FOG
, state
);
100 case GL_SECONDARY_COLOR_ARRAY_EXT
:
101 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR1
, state
);
104 case GL_POINT_SIZE_ARRAY_OES
:
105 if (ctx
->VertexProgram
.PointSizeEnabled
!= state
) {
106 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
107 ctx
->VertexProgram
.PointSizeEnabled
= state
;
109 vao_state(ctx
, vao
, VERT_ATTRIB_POINT_SIZE
, state
);
112 /* GL_NV_primitive_restart */
113 case GL_PRIMITIVE_RESTART_NV
:
114 if (!_mesa_has_NV_primitive_restart(ctx
))
115 goto invalid_enum_error
;
116 if (ctx
->Array
.PrimitiveRestart
== state
)
119 FLUSH_VERTICES(ctx
, 0);
120 ctx
->Array
.PrimitiveRestart
= state
;
121 update_derived_primitive_restart_state(ctx
);
125 goto invalid_enum_error
;
128 if (ctx
->Driver
.Enable
) {
129 ctx
->Driver
.Enable( ctx
, cap
, state
);
135 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
136 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
140 /* Helper for GL_EXT_direct_state_access following functions:
141 * - EnableClientStateIndexedEXT
142 * - EnableClientStateiEXT
143 * - DisableClientStateIndexedEXT
144 * - DisableClientStateiEXT
147 client_state_i(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
148 GLenum cap
, GLuint index
, GLboolean state
)
152 if (cap
!= GL_TEXTURE_COORD_ARRAY
) {
153 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientStateiEXT(cap=%s)",
154 state
? "Enable" : "Disable",
155 _mesa_enum_to_string(cap
));
159 if (index
>= ctx
->Const
.MaxTextureCoordUnits
) {
160 _mesa_error(ctx
, GL_INVALID_VALUE
, "gl%sClientStateiEXT(index=%d)",
161 state
? "Enable" : "Disable",
166 saved_active
= ctx
->Array
.ActiveTexture
;
167 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
168 client_state(ctx
, vao
, cap
, state
);
169 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
174 * Enable GL capability.
175 * \param cap state to enable/disable.
177 * Get's the current context, assures that we're outside glBegin()/glEnd() and
178 * calls client_state().
181 _mesa_EnableClientState( GLenum cap
)
183 GET_CURRENT_CONTEXT(ctx
);
184 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_TRUE
);
189 _mesa_EnableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
191 GET_CURRENT_CONTEXT(ctx
);
192 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
194 "glEnableVertexArrayEXT");
198 /* The EXT_direct_state_access spec says:
199 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
200 * the tokens TEXTURE0 through TEXTUREn where n is less than the
201 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
202 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
203 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
204 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
205 * as if the active client texture is set to texture coordinate set i
206 * based on the token TEXTUREi indicated by array."
208 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
209 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
210 _mesa_ClientActiveTexture(cap
);
211 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_TRUE
);
212 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
214 client_state(ctx
, vao
, cap
, GL_TRUE
);
220 _mesa_EnableClientStateiEXT( GLenum cap
, GLuint index
)
222 GET_CURRENT_CONTEXT(ctx
);
223 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_TRUE
);
228 * Disable GL capability.
229 * \param cap state to enable/disable.
231 * Get's the current context, assures that we're outside glBegin()/glEnd() and
232 * calls client_state().
235 _mesa_DisableClientState( GLenum cap
)
237 GET_CURRENT_CONTEXT(ctx
);
238 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_FALSE
);
242 _mesa_DisableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
244 GET_CURRENT_CONTEXT(ctx
);
245 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
247 "glDisableVertexArrayEXT");
251 /* The EXT_direct_state_access spec says:
252 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
253 * the tokens TEXTURE0 through TEXTUREn where n is less than the
254 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
255 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
256 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
257 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
258 * as if the active client texture is set to texture coordinate set i
259 * based on the token TEXTUREi indicated by array."
261 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
262 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
263 _mesa_ClientActiveTexture(cap
);
264 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_FALSE
);
265 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
267 client_state(ctx
, vao
, cap
, GL_FALSE
);
272 _mesa_DisableClientStateiEXT( GLenum cap
, GLuint index
)
274 GET_CURRENT_CONTEXT(ctx
);
275 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_FALSE
);
279 * Return pointer to current texture unit for setting/getting coordinate
281 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
282 * texture unit is higher than the number of supported coordinate units.
284 static struct gl_fixedfunc_texture_unit
*
285 get_texcoord_unit(struct gl_context
*ctx
)
287 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
288 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
292 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
298 * Helper function to enable or disable a texture target.
299 * \param bit one of the TEXTURE_x_BIT values
300 * \return GL_TRUE if state is changing or GL_FALSE if no change
303 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
305 struct gl_fixedfunc_texture_unit
*texUnit
=
306 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
310 const GLbitfield newenabled
= state
311 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
313 if (texUnit
->Enabled
== newenabled
)
316 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
317 texUnit
->Enabled
= newenabled
;
323 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
324 * whether the API supports it (GLES doesn't).
327 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
329 if (ctx
->Multisample
.Enabled
== state
)
332 /* GL compatibility needs Multisample.Enable to determine program state
335 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
336 !ctx
->DriverFlags
.NewMultisampleEnable
) {
337 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
339 FLUSH_VERTICES(ctx
, 0);
342 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
343 ctx
->Multisample
.Enabled
= state
;
345 if (ctx
->Driver
.Enable
) {
346 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
351 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
352 * check for whether the API supports it (GLES doesn't).
355 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
357 if (ctx
->Color
.sRGBEnabled
== state
)
360 /* TODO: Switch i965 to the new flag and remove the conditional */
361 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
362 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
363 ctx
->Color
.sRGBEnabled
= state
;
365 if (ctx
->Driver
.Enable
) {
366 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
371 * Helper function to enable or disable state.
373 * \param ctx GL context.
374 * \param cap the state to enable/disable
375 * \param state whether to enable or disable the specified capability.
377 * Updates the current context and flushes the vertices as needed. For
378 * capabilities associated with extensions it verifies that those extensions
379 * are effectivly present before updating. Notifies the driver via
380 * dd_function_table::Enable.
383 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
385 if (MESA_VERBOSE
& VERBOSE_API
)
386 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
387 state
? "glEnable" : "glDisable",
388 _mesa_enum_to_string(cap
),
393 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
394 goto invalid_enum_error
;
395 if (ctx
->Color
.AlphaEnabled
== state
)
397 /* AlphaEnabled is used by the fixed-func fragment program */
398 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
399 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
400 ctx
->Color
.AlphaEnabled
= state
;
403 if (ctx
->API
!= API_OPENGL_COMPAT
)
404 goto invalid_enum_error
;
405 if (ctx
->Eval
.AutoNormal
== state
)
407 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
408 ctx
->Eval
.AutoNormal
= state
;
412 GLbitfield newEnabled
=
413 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
414 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
415 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
416 ctx
->Color
._AdvancedBlendMode
);
417 ctx
->Color
.BlendEnabled
= newEnabled
;
418 _mesa_update_allow_draw_out_of_order(ctx
);
422 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
423 case GL_CLIP_DISTANCE1
:
424 case GL_CLIP_DISTANCE2
:
425 case GL_CLIP_DISTANCE3
:
426 case GL_CLIP_DISTANCE4
:
427 case GL_CLIP_DISTANCE5
:
428 case GL_CLIP_DISTANCE6
:
429 case GL_CLIP_DISTANCE7
:
431 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
433 if (p
>= ctx
->Const
.MaxClipPlanes
)
434 goto invalid_enum_error
;
436 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
437 == ((GLuint
) state
<< p
))
440 /* The compatibility profile needs _NEW_TRANSFORM to transform
441 * clip planes according to the projection matrix.
443 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
444 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
445 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
447 FLUSH_VERTICES(ctx
, 0);
449 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
452 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
454 /* The projection matrix transforms the clip plane. */
455 /* TODO: glEnable might not be the best place to do it. */
456 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
457 _mesa_update_clip_plane(ctx
, p
);
458 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
462 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
466 case GL_COLOR_MATERIAL
:
467 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
468 goto invalid_enum_error
;
469 if (ctx
->Light
.ColorMaterialEnabled
== state
)
471 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
472 FLUSH_CURRENT(ctx
, 0);
473 ctx
->Light
.ColorMaterialEnabled
= state
;
475 _mesa_update_color_material( ctx
,
476 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
480 if (ctx
->Polygon
.CullFlag
== state
)
483 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
484 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
485 ctx
->Polygon
.CullFlag
= state
;
488 if (ctx
->Depth
.Test
== state
)
490 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
491 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
492 ctx
->Depth
.Test
= state
;
493 _mesa_update_allow_draw_out_of_order(ctx
);
495 case GL_DEBUG_OUTPUT
:
496 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
497 _mesa_set_debug_state_int(ctx
, cap
, state
);
500 if (ctx
->Color
.DitherFlag
== state
)
502 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
503 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
504 ctx
->Color
.DitherFlag
= state
;
507 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
508 goto invalid_enum_error
;
509 if (ctx
->Fog
.Enabled
== state
)
511 FLUSH_VERTICES(ctx
, _NEW_FOG
);
512 ctx
->Fog
.Enabled
= state
;
513 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
523 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
524 goto invalid_enum_error
;
525 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
527 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
528 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
530 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
533 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
537 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
538 goto invalid_enum_error
;
539 if (ctx
->Light
.Enabled
== state
)
541 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
542 ctx
->Light
.Enabled
= state
;
545 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
546 goto invalid_enum_error
;
547 if (ctx
->Line
.SmoothFlag
== state
)
549 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
550 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
551 ctx
->Line
.SmoothFlag
= state
;
553 case GL_LINE_STIPPLE
:
554 if (ctx
->API
!= API_OPENGL_COMPAT
)
555 goto invalid_enum_error
;
556 if (ctx
->Line
.StippleFlag
== state
)
558 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
559 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
560 ctx
->Line
.StippleFlag
= state
;
562 case GL_INDEX_LOGIC_OP
:
563 if (ctx
->API
!= API_OPENGL_COMPAT
)
564 goto invalid_enum_error
;
565 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
567 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
568 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
569 ctx
->Color
.IndexLogicOpEnabled
= state
;
571 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
572 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
573 goto invalid_enum_error
;
574 if (ctx
->IntelConservativeRasterization
== state
)
576 FLUSH_VERTICES(ctx
, 0);
577 ctx
->NewDriverState
|=
578 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
579 ctx
->IntelConservativeRasterization
= state
;
581 case GL_CONSERVATIVE_RASTERIZATION_NV
:
582 if (!_mesa_has_NV_conservative_raster(ctx
))
583 goto invalid_enum_error
;
584 if (ctx
->ConservativeRasterization
== state
)
586 FLUSH_VERTICES(ctx
, 0);
587 ctx
->NewDriverState
|=
588 ctx
->DriverFlags
.NewNvConservativeRasterization
;
589 ctx
->ConservativeRasterization
= state
;
591 case GL_COLOR_LOGIC_OP
:
592 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
593 goto invalid_enum_error
;
594 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
596 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
597 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
598 ctx
->Color
.ColorLogicOpEnabled
= state
;
599 _mesa_update_allow_draw_out_of_order(ctx
);
601 case GL_MAP1_COLOR_4
:
602 if (ctx
->API
!= API_OPENGL_COMPAT
)
603 goto invalid_enum_error
;
604 if (ctx
->Eval
.Map1Color4
== state
)
606 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
607 ctx
->Eval
.Map1Color4
= state
;
610 if (ctx
->API
!= API_OPENGL_COMPAT
)
611 goto invalid_enum_error
;
612 if (ctx
->Eval
.Map1Index
== state
)
614 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
615 ctx
->Eval
.Map1Index
= state
;
618 if (ctx
->API
!= API_OPENGL_COMPAT
)
619 goto invalid_enum_error
;
620 if (ctx
->Eval
.Map1Normal
== state
)
622 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
623 ctx
->Eval
.Map1Normal
= state
;
625 case GL_MAP1_TEXTURE_COORD_1
:
626 if (ctx
->API
!= API_OPENGL_COMPAT
)
627 goto invalid_enum_error
;
628 if (ctx
->Eval
.Map1TextureCoord1
== state
)
630 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
631 ctx
->Eval
.Map1TextureCoord1
= state
;
633 case GL_MAP1_TEXTURE_COORD_2
:
634 if (ctx
->API
!= API_OPENGL_COMPAT
)
635 goto invalid_enum_error
;
636 if (ctx
->Eval
.Map1TextureCoord2
== state
)
638 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
639 ctx
->Eval
.Map1TextureCoord2
= state
;
641 case GL_MAP1_TEXTURE_COORD_3
:
642 if (ctx
->API
!= API_OPENGL_COMPAT
)
643 goto invalid_enum_error
;
644 if (ctx
->Eval
.Map1TextureCoord3
== state
)
646 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
647 ctx
->Eval
.Map1TextureCoord3
= state
;
649 case GL_MAP1_TEXTURE_COORD_4
:
650 if (ctx
->API
!= API_OPENGL_COMPAT
)
651 goto invalid_enum_error
;
652 if (ctx
->Eval
.Map1TextureCoord4
== state
)
654 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
655 ctx
->Eval
.Map1TextureCoord4
= state
;
657 case GL_MAP1_VERTEX_3
:
658 if (ctx
->API
!= API_OPENGL_COMPAT
)
659 goto invalid_enum_error
;
660 if (ctx
->Eval
.Map1Vertex3
== state
)
662 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
663 ctx
->Eval
.Map1Vertex3
= state
;
665 case GL_MAP1_VERTEX_4
:
666 if (ctx
->API
!= API_OPENGL_COMPAT
)
667 goto invalid_enum_error
;
668 if (ctx
->Eval
.Map1Vertex4
== state
)
670 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
671 ctx
->Eval
.Map1Vertex4
= state
;
673 case GL_MAP2_COLOR_4
:
674 if (ctx
->API
!= API_OPENGL_COMPAT
)
675 goto invalid_enum_error
;
676 if (ctx
->Eval
.Map2Color4
== state
)
678 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
679 ctx
->Eval
.Map2Color4
= state
;
682 if (ctx
->API
!= API_OPENGL_COMPAT
)
683 goto invalid_enum_error
;
684 if (ctx
->Eval
.Map2Index
== state
)
686 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
687 ctx
->Eval
.Map2Index
= state
;
690 if (ctx
->API
!= API_OPENGL_COMPAT
)
691 goto invalid_enum_error
;
692 if (ctx
->Eval
.Map2Normal
== state
)
694 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
695 ctx
->Eval
.Map2Normal
= state
;
697 case GL_MAP2_TEXTURE_COORD_1
:
698 if (ctx
->API
!= API_OPENGL_COMPAT
)
699 goto invalid_enum_error
;
700 if (ctx
->Eval
.Map2TextureCoord1
== state
)
702 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
703 ctx
->Eval
.Map2TextureCoord1
= state
;
705 case GL_MAP2_TEXTURE_COORD_2
:
706 if (ctx
->API
!= API_OPENGL_COMPAT
)
707 goto invalid_enum_error
;
708 if (ctx
->Eval
.Map2TextureCoord2
== state
)
710 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
711 ctx
->Eval
.Map2TextureCoord2
= state
;
713 case GL_MAP2_TEXTURE_COORD_3
:
714 if (ctx
->API
!= API_OPENGL_COMPAT
)
715 goto invalid_enum_error
;
716 if (ctx
->Eval
.Map2TextureCoord3
== state
)
718 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
719 ctx
->Eval
.Map2TextureCoord3
= state
;
721 case GL_MAP2_TEXTURE_COORD_4
:
722 if (ctx
->API
!= API_OPENGL_COMPAT
)
723 goto invalid_enum_error
;
724 if (ctx
->Eval
.Map2TextureCoord4
== state
)
726 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
727 ctx
->Eval
.Map2TextureCoord4
= state
;
729 case GL_MAP2_VERTEX_3
:
730 if (ctx
->API
!= API_OPENGL_COMPAT
)
731 goto invalid_enum_error
;
732 if (ctx
->Eval
.Map2Vertex3
== state
)
734 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
735 ctx
->Eval
.Map2Vertex3
= state
;
737 case GL_MAP2_VERTEX_4
:
738 if (ctx
->API
!= API_OPENGL_COMPAT
)
739 goto invalid_enum_error
;
740 if (ctx
->Eval
.Map2Vertex4
== state
)
742 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
743 ctx
->Eval
.Map2Vertex4
= state
;
746 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
747 goto invalid_enum_error
;
748 if (ctx
->Transform
.Normalize
== state
)
750 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
751 ctx
->Transform
.Normalize
= state
;
753 case GL_POINT_SMOOTH
:
754 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
755 goto invalid_enum_error
;
756 if (ctx
->Point
.SmoothFlag
== state
)
758 FLUSH_VERTICES(ctx
, _NEW_POINT
);
759 ctx
->Point
.SmoothFlag
= state
;
761 case GL_POLYGON_SMOOTH
:
762 if (!_mesa_is_desktop_gl(ctx
))
763 goto invalid_enum_error
;
764 if (ctx
->Polygon
.SmoothFlag
== state
)
767 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
768 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
769 ctx
->Polygon
.SmoothFlag
= state
;
771 case GL_POLYGON_STIPPLE
:
772 if (ctx
->API
!= API_OPENGL_COMPAT
)
773 goto invalid_enum_error
;
774 if (ctx
->Polygon
.StippleFlag
== state
)
777 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
778 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
779 ctx
->Polygon
.StippleFlag
= state
;
781 case GL_POLYGON_OFFSET_POINT
:
782 if (!_mesa_is_desktop_gl(ctx
))
783 goto invalid_enum_error
;
784 if (ctx
->Polygon
.OffsetPoint
== state
)
787 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
788 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
789 ctx
->Polygon
.OffsetPoint
= state
;
791 case GL_POLYGON_OFFSET_LINE
:
792 if (!_mesa_is_desktop_gl(ctx
))
793 goto invalid_enum_error
;
794 if (ctx
->Polygon
.OffsetLine
== state
)
797 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
798 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
799 ctx
->Polygon
.OffsetLine
= state
;
801 case GL_POLYGON_OFFSET_FILL
:
802 if (ctx
->Polygon
.OffsetFill
== state
)
805 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
806 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
807 ctx
->Polygon
.OffsetFill
= state
;
809 case GL_RESCALE_NORMAL_EXT
:
810 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
811 goto invalid_enum_error
;
812 if (ctx
->Transform
.RescaleNormals
== state
)
814 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
815 ctx
->Transform
.RescaleNormals
= state
;
817 case GL_SCISSOR_TEST
:
819 /* Must expand glEnable to all scissors */
820 GLbitfield newEnabled
=
821 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
822 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
823 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
825 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
826 ctx
->Scissor
.EnableFlags
= newEnabled
;
830 case GL_STENCIL_TEST
:
831 if (ctx
->Stencil
.Enabled
== state
)
833 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
834 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
835 ctx
->Stencil
.Enabled
= state
;
836 _mesa_update_allow_draw_out_of_order(ctx
);
839 if (ctx
->API
!= API_OPENGL_COMPAT
)
840 goto invalid_enum_error
;
841 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
846 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
847 goto invalid_enum_error
;
848 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
853 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
854 goto invalid_enum_error
;
855 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
859 case GL_TEXTURE_GEN_S
:
860 case GL_TEXTURE_GEN_T
:
861 case GL_TEXTURE_GEN_R
:
862 case GL_TEXTURE_GEN_Q
:
864 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
866 if (ctx
->API
!= API_OPENGL_COMPAT
)
867 goto invalid_enum_error
;
870 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
871 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
873 newenabled
|= coordBit
;
874 if (texUnit
->TexGenEnabled
== newenabled
)
876 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
877 texUnit
->TexGenEnabled
= newenabled
;
882 case GL_TEXTURE_GEN_STR_OES
:
883 /* disable S, T, and R at the same time */
885 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
887 if (ctx
->API
!= API_OPENGLES
)
888 goto invalid_enum_error
;
892 texUnit
->TexGenEnabled
& ~STR_BITS
;
894 newenabled
|= STR_BITS
;
895 if (texUnit
->TexGenEnabled
== newenabled
)
897 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
898 texUnit
->TexGenEnabled
= newenabled
;
903 /* client-side state */
904 case GL_VERTEX_ARRAY
:
905 case GL_NORMAL_ARRAY
:
907 case GL_TEXTURE_COORD_ARRAY
:
908 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
909 goto invalid_enum_error
;
910 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
913 case GL_EDGE_FLAG_ARRAY
:
914 case GL_FOG_COORDINATE_ARRAY_EXT
:
915 case GL_SECONDARY_COLOR_ARRAY_EXT
:
916 if (ctx
->API
!= API_OPENGL_COMPAT
)
917 goto invalid_enum_error
;
918 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
920 case GL_POINT_SIZE_ARRAY_OES
:
921 if (ctx
->API
!= API_OPENGLES
)
922 goto invalid_enum_error
;
923 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
926 /* GL_ARB_texture_cube_map */
927 case GL_TEXTURE_CUBE_MAP
:
928 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
929 !_mesa_has_OES_texture_cube_map(ctx
))
930 goto invalid_enum_error
;
931 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
936 /* GL_EXT_secondary_color */
937 case GL_COLOR_SUM_EXT
:
938 if (ctx
->API
!= API_OPENGL_COMPAT
)
939 goto invalid_enum_error
;
940 if (ctx
->Fog
.ColorSumEnabled
== state
)
942 FLUSH_VERTICES(ctx
, _NEW_FOG
);
943 ctx
->Fog
.ColorSumEnabled
= state
;
946 /* GL_ARB_multisample */
947 case GL_MULTISAMPLE_ARB
:
948 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
949 goto invalid_enum_error
;
950 _mesa_set_multisample(ctx
, state
);
952 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
953 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
955 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
957 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
958 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
960 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
961 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
962 goto invalid_enum_error
;
963 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
965 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
967 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
968 ctx
->Multisample
.SampleAlphaToOne
= state
;
970 case GL_SAMPLE_COVERAGE_ARB
:
971 if (ctx
->Multisample
.SampleCoverage
== state
)
973 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
975 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
976 ctx
->Multisample
.SampleCoverage
= state
;
978 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
979 if (!_mesa_is_desktop_gl(ctx
))
980 goto invalid_enum_error
;
981 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
983 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
985 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
986 ctx
->Multisample
.SampleCoverageInvert
= state
;
989 /* GL_ARB_sample_shading */
990 case GL_SAMPLE_SHADING
:
991 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
992 goto invalid_enum_error
;
993 if (ctx
->Multisample
.SampleShading
== state
)
995 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
997 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
998 ctx
->Multisample
.SampleShading
= state
;
1001 /* GL_IBM_rasterpos_clip */
1002 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1003 if (ctx
->API
!= API_OPENGL_COMPAT
)
1004 goto invalid_enum_error
;
1005 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
1007 FLUSH_VERTICES(ctx
, 0);
1008 ctx
->Transform
.RasterPositionUnclipped
= state
;
1011 /* GL_NV_point_sprite */
1012 case GL_POINT_SPRITE_NV
:
1013 if (!(ctx
->API
== API_OPENGL_COMPAT
&&
1014 (_mesa_has_ARB_point_sprite(ctx
) ||
1015 _mesa_has_NV_point_sprite(ctx
))) &&
1016 !_mesa_has_OES_point_sprite(ctx
))
1017 goto invalid_enum_error
;
1018 if (ctx
->Point
.PointSprite
== state
)
1020 FLUSH_VERTICES(ctx
, _NEW_POINT
);
1021 ctx
->Point
.PointSprite
= state
;
1024 case GL_VERTEX_PROGRAM_ARB
:
1025 if (!_mesa_has_ARB_vertex_program(ctx
))
1026 goto invalid_enum_error
;
1027 if (ctx
->VertexProgram
.Enabled
== state
)
1029 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1030 ctx
->VertexProgram
.Enabled
= state
;
1031 _mesa_update_vertex_processing_mode(ctx
);
1033 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1034 /* This was added with ARB_vertex_program, but it is also used with
1035 * GLSL vertex shaders on desktop.
1037 if (!_mesa_has_ARB_vertex_program(ctx
) &&
1038 ctx
->API
!= API_OPENGL_CORE
)
1039 goto invalid_enum_error
;
1040 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
1042 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1043 ctx
->VertexProgram
.PointSizeEnabled
= state
;
1045 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1046 if (!_mesa_has_ARB_vertex_program(ctx
))
1047 goto invalid_enum_error
;
1048 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
1050 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1051 ctx
->VertexProgram
.TwoSideEnabled
= state
;
1054 /* GL_NV_texture_rectangle */
1055 case GL_TEXTURE_RECTANGLE_NV
:
1056 if (!_mesa_has_NV_texture_rectangle(ctx
))
1057 goto invalid_enum_error
;
1058 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
1063 /* GL_EXT_stencil_two_side */
1064 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1065 if (!_mesa_has_EXT_stencil_two_side(ctx
))
1066 goto invalid_enum_error
;
1067 if (ctx
->Stencil
.TestTwoSide
== state
)
1069 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
1070 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
1071 ctx
->Stencil
.TestTwoSide
= state
;
1073 ctx
->Stencil
._BackFace
= 2;
1075 ctx
->Stencil
._BackFace
= 1;
1079 case GL_FRAGMENT_PROGRAM_ARB
:
1080 if (!_mesa_has_ARB_fragment_program(ctx
))
1081 goto invalid_enum_error
;
1082 if (ctx
->FragmentProgram
.Enabled
== state
)
1084 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1085 ctx
->FragmentProgram
.Enabled
= state
;
1088 /* GL_EXT_depth_bounds_test */
1089 case GL_DEPTH_BOUNDS_TEST_EXT
:
1090 if (!_mesa_has_EXT_depth_bounds_test(ctx
))
1091 goto invalid_enum_error
;
1092 if (ctx
->Depth
.BoundsTest
== state
)
1094 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
1095 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
1096 ctx
->Depth
.BoundsTest
= state
;
1099 case GL_DEPTH_CLAMP
:
1100 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1101 !_mesa_has_EXT_depth_clamp(ctx
))
1102 goto invalid_enum_error
;
1103 if (ctx
->Transform
.DepthClampNear
== state
&&
1104 ctx
->Transform
.DepthClampFar
== state
)
1106 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1108 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1109 ctx
->Transform
.DepthClampNear
= state
;
1110 ctx
->Transform
.DepthClampFar
= state
;
1113 case GL_DEPTH_CLAMP_NEAR_AMD
:
1114 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1115 goto invalid_enum_error
;
1116 if (ctx
->Transform
.DepthClampNear
== state
)
1118 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1120 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1121 ctx
->Transform
.DepthClampNear
= state
;
1124 case GL_DEPTH_CLAMP_FAR_AMD
:
1125 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1126 goto invalid_enum_error
;
1127 if (ctx
->Transform
.DepthClampFar
== state
)
1129 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1131 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1132 ctx
->Transform
.DepthClampFar
= state
;
1135 case GL_FRAGMENT_SHADER_ATI
:
1136 if (!_mesa_has_ATI_fragment_shader(ctx
))
1137 goto invalid_enum_error
;
1138 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1140 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1141 ctx
->ATIFragmentShader
.Enabled
= state
;
1144 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1145 if (!_mesa_has_ARB_seamless_cube_map(ctx
))
1146 goto invalid_enum_error
;
1147 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1148 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1149 ctx
->Texture
.CubeMapSeamless
= state
;
1153 case GL_RASTERIZER_DISCARD
:
1154 if (!(_mesa_has_EXT_transform_feedback(ctx
) || _mesa_is_gles3(ctx
)))
1155 goto invalid_enum_error
;
1156 if (ctx
->RasterDiscard
!= state
) {
1157 FLUSH_VERTICES(ctx
, 0);
1158 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1159 ctx
->RasterDiscard
= state
;
1163 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1164 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1165 goto invalid_enum_error
;
1166 if (ctx
->TileRasterOrderFixed
!= state
) {
1167 FLUSH_VERTICES(ctx
, 0);
1168 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1169 ctx
->TileRasterOrderFixed
= state
;
1173 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1174 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1175 goto invalid_enum_error
;
1176 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1177 FLUSH_VERTICES(ctx
, 0);
1178 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1179 ctx
->TileRasterOrderIncreasingX
= state
;
1183 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1184 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1185 goto invalid_enum_error
;
1186 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1187 FLUSH_VERTICES(ctx
, 0);
1188 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1189 ctx
->TileRasterOrderIncreasingY
= state
;
1193 /* GL 3.1 primitive restart. Note: this enum is different from
1194 * GL_PRIMITIVE_RESTART_NV (which is client state).
1196 case GL_PRIMITIVE_RESTART
:
1197 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1198 goto invalid_enum_error
;
1200 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1201 FLUSH_VERTICES(ctx
, 0);
1202 ctx
->Array
.PrimitiveRestart
= state
;
1203 update_derived_primitive_restart_state(ctx
);
1207 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1208 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1209 goto invalid_enum_error
;
1210 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1211 FLUSH_VERTICES(ctx
, 0);
1212 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1213 update_derived_primitive_restart_state(ctx
);
1217 /* GL3.0 - GL_framebuffer_sRGB */
1218 case GL_FRAMEBUFFER_SRGB_EXT
:
1219 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1220 !_mesa_has_EXT_sRGB_write_control(ctx
))
1221 goto invalid_enum_error
;
1222 _mesa_set_framebuffer_srgb(ctx
, state
);
1225 /* GL_OES_EGL_image_external */
1226 case GL_TEXTURE_EXTERNAL_OES
:
1227 if (!_mesa_has_OES_EGL_image_external(ctx
))
1228 goto invalid_enum_error
;
1229 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1234 /* ARB_texture_multisample */
1235 case GL_SAMPLE_MASK
:
1236 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1237 goto invalid_enum_error
;
1238 if (ctx
->Multisample
.SampleMask
== state
)
1240 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1242 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1243 ctx
->Multisample
.SampleMask
= state
;
1246 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1247 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1248 goto invalid_enum_error
;
1249 if (ctx
->Color
.BlendCoherent
== state
)
1251 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1252 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1253 ctx
->Color
.BlendCoherent
= state
;
1256 case GL_BLACKHOLE_RENDER_INTEL
:
1257 if (!_mesa_has_INTEL_blackhole_render(ctx
))
1258 goto invalid_enum_error
;
1259 if (ctx
->IntelBlackholeRender
== state
)
1261 FLUSH_VERTICES(ctx
, 0);
1262 ctx
->IntelBlackholeRender
= state
;
1266 goto invalid_enum_error
;
1269 if (ctx
->Driver
.Enable
) {
1270 ctx
->Driver
.Enable( ctx
, cap
, state
);
1276 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1277 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1282 * Enable GL capability. Called by glEnable()
1283 * \param cap state to enable.
1286 _mesa_Enable( GLenum cap
)
1288 GET_CURRENT_CONTEXT(ctx
);
1290 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1295 * Disable GL capability. Called by glDisable()
1296 * \param cap state to disable.
1299 _mesa_Disable( GLenum cap
)
1301 GET_CURRENT_CONTEXT(ctx
);
1303 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1309 * Enable/disable an indexed state var.
1312 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1313 GLuint index
, GLboolean state
)
1315 assert(state
== 0 || state
== 1);
1318 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1319 goto invalid_enum_error
;
1321 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1322 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1323 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1326 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1327 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1330 enabled
|= (1 << index
);
1332 enabled
&= ~(1 << index
);
1334 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1335 ctx
->Color
._AdvancedBlendMode
);
1336 ctx
->Color
.BlendEnabled
= enabled
;
1337 _mesa_update_allow_draw_out_of_order(ctx
);
1340 case GL_SCISSOR_TEST
:
1341 if (index
>= ctx
->Const
.MaxViewports
) {
1342 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1343 state
? "glEnablei" : "glDisablei", index
);
1346 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1348 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1349 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1351 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1353 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1356 /* EXT_direct_state_access */
1360 case GL_TEXTURE_CUBE_MAP
:
1361 case GL_TEXTURE_GEN_S
:
1362 case GL_TEXTURE_GEN_T
:
1363 case GL_TEXTURE_GEN_R
:
1364 case GL_TEXTURE_GEN_Q
:
1365 case GL_TEXTURE_RECTANGLE_ARB
: {
1366 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1367 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1368 ctx
->Const
.MaxTextureCoordUnits
)) {
1369 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1370 state
? "glEnablei" : "glDisablei", index
);
1373 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1374 _mesa_set_enable( ctx
, cap
, state
);
1375 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1379 goto invalid_enum_error
;
1384 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1385 state
? "glEnablei" : "glDisablei",
1386 _mesa_enum_to_string(cap
));
1391 _mesa_Disablei( GLenum cap
, GLuint index
)
1393 GET_CURRENT_CONTEXT(ctx
);
1394 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1399 _mesa_Enablei( GLenum cap
, GLuint index
)
1401 GET_CURRENT_CONTEXT(ctx
);
1402 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1406 GLboolean GLAPIENTRY
1407 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1409 GET_CURRENT_CONTEXT(ctx
);
1410 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1413 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1414 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1418 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1419 case GL_SCISSOR_TEST
:
1420 if (index
>= ctx
->Const
.MaxViewports
) {
1421 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1425 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1426 /* EXT_direct_state_access */
1430 case GL_TEXTURE_CUBE_MAP
:
1431 case GL_TEXTURE_GEN_S
:
1432 case GL_TEXTURE_GEN_T
:
1433 case GL_TEXTURE_GEN_R
:
1434 case GL_TEXTURE_GEN_Q
:
1435 case GL_TEXTURE_RECTANGLE_ARB
: {
1437 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1438 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1439 ctx
->Const
.MaxTextureCoordUnits
)) {
1440 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1444 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1445 state
= _mesa_IsEnabled(cap
);
1446 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1450 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1451 _mesa_enum_to_string(cap
));
1459 * Helper function to determine whether a texture target is enabled.
1462 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1464 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1465 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
1470 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1475 * Return simple enable/disable state.
1477 * \param cap state variable to query.
1479 * Returns the state of the specified capability from the current GL context.
1480 * For the capabilities associated with extensions verifies that those
1481 * extensions are effectively present before reporting.
1483 GLboolean GLAPIENTRY
1484 _mesa_IsEnabled( GLenum cap
)
1486 GET_CURRENT_CONTEXT(ctx
);
1487 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1491 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1492 goto invalid_enum_error
;
1493 return ctx
->Color
.AlphaEnabled
;
1494 case GL_AUTO_NORMAL
:
1495 if (ctx
->API
!= API_OPENGL_COMPAT
)
1496 goto invalid_enum_error
;
1497 return ctx
->Eval
.AutoNormal
;
1499 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1500 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1501 case GL_CLIP_DISTANCE1
:
1502 case GL_CLIP_DISTANCE2
:
1503 case GL_CLIP_DISTANCE3
:
1504 case GL_CLIP_DISTANCE4
:
1505 case GL_CLIP_DISTANCE5
:
1506 case GL_CLIP_DISTANCE6
:
1507 case GL_CLIP_DISTANCE7
: {
1508 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1510 if (p
>= ctx
->Const
.MaxClipPlanes
)
1511 goto invalid_enum_error
;
1513 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1515 case GL_COLOR_MATERIAL
:
1516 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1517 goto invalid_enum_error
;
1518 return ctx
->Light
.ColorMaterialEnabled
;
1520 return ctx
->Polygon
.CullFlag
;
1521 case GL_DEBUG_OUTPUT
:
1522 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1523 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1525 return ctx
->Depth
.Test
;
1527 return ctx
->Color
.DitherFlag
;
1529 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1530 goto invalid_enum_error
;
1531 return ctx
->Fog
.Enabled
;
1533 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1534 goto invalid_enum_error
;
1535 return ctx
->Light
.Enabled
;
1544 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1545 goto invalid_enum_error
;
1546 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1547 case GL_LINE_SMOOTH
:
1548 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1549 goto invalid_enum_error
;
1550 return ctx
->Line
.SmoothFlag
;
1551 case GL_LINE_STIPPLE
:
1552 if (ctx
->API
!= API_OPENGL_COMPAT
)
1553 goto invalid_enum_error
;
1554 return ctx
->Line
.StippleFlag
;
1555 case GL_INDEX_LOGIC_OP
:
1556 if (ctx
->API
!= API_OPENGL_COMPAT
)
1557 goto invalid_enum_error
;
1558 return ctx
->Color
.IndexLogicOpEnabled
;
1559 case GL_COLOR_LOGIC_OP
:
1560 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1561 goto invalid_enum_error
;
1562 return ctx
->Color
.ColorLogicOpEnabled
;
1563 case GL_MAP1_COLOR_4
:
1564 if (ctx
->API
!= API_OPENGL_COMPAT
)
1565 goto invalid_enum_error
;
1566 return ctx
->Eval
.Map1Color4
;
1568 if (ctx
->API
!= API_OPENGL_COMPAT
)
1569 goto invalid_enum_error
;
1570 return ctx
->Eval
.Map1Index
;
1571 case GL_MAP1_NORMAL
:
1572 if (ctx
->API
!= API_OPENGL_COMPAT
)
1573 goto invalid_enum_error
;
1574 return ctx
->Eval
.Map1Normal
;
1575 case GL_MAP1_TEXTURE_COORD_1
:
1576 if (ctx
->API
!= API_OPENGL_COMPAT
)
1577 goto invalid_enum_error
;
1578 return ctx
->Eval
.Map1TextureCoord1
;
1579 case GL_MAP1_TEXTURE_COORD_2
:
1580 if (ctx
->API
!= API_OPENGL_COMPAT
)
1581 goto invalid_enum_error
;
1582 return ctx
->Eval
.Map1TextureCoord2
;
1583 case GL_MAP1_TEXTURE_COORD_3
:
1584 if (ctx
->API
!= API_OPENGL_COMPAT
)
1585 goto invalid_enum_error
;
1586 return ctx
->Eval
.Map1TextureCoord3
;
1587 case GL_MAP1_TEXTURE_COORD_4
:
1588 if (ctx
->API
!= API_OPENGL_COMPAT
)
1589 goto invalid_enum_error
;
1590 return ctx
->Eval
.Map1TextureCoord4
;
1591 case GL_MAP1_VERTEX_3
:
1592 if (ctx
->API
!= API_OPENGL_COMPAT
)
1593 goto invalid_enum_error
;
1594 return ctx
->Eval
.Map1Vertex3
;
1595 case GL_MAP1_VERTEX_4
:
1596 if (ctx
->API
!= API_OPENGL_COMPAT
)
1597 goto invalid_enum_error
;
1598 return ctx
->Eval
.Map1Vertex4
;
1599 case GL_MAP2_COLOR_4
:
1600 if (ctx
->API
!= API_OPENGL_COMPAT
)
1601 goto invalid_enum_error
;
1602 return ctx
->Eval
.Map2Color4
;
1604 if (ctx
->API
!= API_OPENGL_COMPAT
)
1605 goto invalid_enum_error
;
1606 return ctx
->Eval
.Map2Index
;
1607 case GL_MAP2_NORMAL
:
1608 if (ctx
->API
!= API_OPENGL_COMPAT
)
1609 goto invalid_enum_error
;
1610 return ctx
->Eval
.Map2Normal
;
1611 case GL_MAP2_TEXTURE_COORD_1
:
1612 if (ctx
->API
!= API_OPENGL_COMPAT
)
1613 goto invalid_enum_error
;
1614 return ctx
->Eval
.Map2TextureCoord1
;
1615 case GL_MAP2_TEXTURE_COORD_2
:
1616 if (ctx
->API
!= API_OPENGL_COMPAT
)
1617 goto invalid_enum_error
;
1618 return ctx
->Eval
.Map2TextureCoord2
;
1619 case GL_MAP2_TEXTURE_COORD_3
:
1620 if (ctx
->API
!= API_OPENGL_COMPAT
)
1621 goto invalid_enum_error
;
1622 return ctx
->Eval
.Map2TextureCoord3
;
1623 case GL_MAP2_TEXTURE_COORD_4
:
1624 if (ctx
->API
!= API_OPENGL_COMPAT
)
1625 goto invalid_enum_error
;
1626 return ctx
->Eval
.Map2TextureCoord4
;
1627 case GL_MAP2_VERTEX_3
:
1628 if (ctx
->API
!= API_OPENGL_COMPAT
)
1629 goto invalid_enum_error
;
1630 return ctx
->Eval
.Map2Vertex3
;
1631 case GL_MAP2_VERTEX_4
:
1632 if (ctx
->API
!= API_OPENGL_COMPAT
)
1633 goto invalid_enum_error
;
1634 return ctx
->Eval
.Map2Vertex4
;
1636 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1637 goto invalid_enum_error
;
1638 return ctx
->Transform
.Normalize
;
1639 case GL_POINT_SMOOTH
:
1640 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1641 goto invalid_enum_error
;
1642 return ctx
->Point
.SmoothFlag
;
1643 case GL_POLYGON_SMOOTH
:
1644 if (!_mesa_is_desktop_gl(ctx
))
1645 goto invalid_enum_error
;
1646 return ctx
->Polygon
.SmoothFlag
;
1647 case GL_POLYGON_STIPPLE
:
1648 if (ctx
->API
!= API_OPENGL_COMPAT
)
1649 goto invalid_enum_error
;
1650 return ctx
->Polygon
.StippleFlag
;
1651 case GL_POLYGON_OFFSET_POINT
:
1652 if (!_mesa_is_desktop_gl(ctx
))
1653 goto invalid_enum_error
;
1654 return ctx
->Polygon
.OffsetPoint
;
1655 case GL_POLYGON_OFFSET_LINE
:
1656 if (!_mesa_is_desktop_gl(ctx
))
1657 goto invalid_enum_error
;
1658 return ctx
->Polygon
.OffsetLine
;
1659 case GL_POLYGON_OFFSET_FILL
:
1660 return ctx
->Polygon
.OffsetFill
;
1661 case GL_RESCALE_NORMAL_EXT
:
1662 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1663 goto invalid_enum_error
;
1664 return ctx
->Transform
.RescaleNormals
;
1665 case GL_SCISSOR_TEST
:
1666 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1667 case GL_STENCIL_TEST
:
1668 return ctx
->Stencil
.Enabled
;
1670 if (ctx
->API
!= API_OPENGL_COMPAT
)
1671 goto invalid_enum_error
;
1672 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1674 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1675 goto invalid_enum_error
;
1676 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1678 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1679 goto invalid_enum_error
;
1680 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1681 case GL_TEXTURE_GEN_S
:
1682 case GL_TEXTURE_GEN_T
:
1683 case GL_TEXTURE_GEN_R
:
1684 case GL_TEXTURE_GEN_Q
:
1686 const struct gl_fixedfunc_texture_unit
*texUnit
=
1687 get_texcoord_unit(ctx
);
1689 if (ctx
->API
!= API_OPENGL_COMPAT
)
1690 goto invalid_enum_error
;
1693 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1694 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1698 case GL_TEXTURE_GEN_STR_OES
:
1700 const struct gl_fixedfunc_texture_unit
*texUnit
=
1701 get_texcoord_unit(ctx
);
1703 if (ctx
->API
!= API_OPENGLES
)
1704 goto invalid_enum_error
;
1707 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1708 ? GL_TRUE
: GL_FALSE
;
1712 /* client-side state */
1713 case GL_VERTEX_ARRAY
:
1714 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1715 goto invalid_enum_error
;
1716 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
1717 case GL_NORMAL_ARRAY
:
1718 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1719 goto invalid_enum_error
;
1720 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
1721 case GL_COLOR_ARRAY
:
1722 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1723 goto invalid_enum_error
;
1724 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
1725 case GL_INDEX_ARRAY
:
1726 if (ctx
->API
!= API_OPENGL_COMPAT
)
1727 goto invalid_enum_error
;
1728 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
1729 case GL_TEXTURE_COORD_ARRAY
:
1730 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1731 goto invalid_enum_error
;
1732 return !!(ctx
->Array
.VAO
->Enabled
&
1733 VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
1734 case GL_EDGE_FLAG_ARRAY
:
1735 if (ctx
->API
!= API_OPENGL_COMPAT
)
1736 goto invalid_enum_error
;
1737 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
1738 case GL_FOG_COORDINATE_ARRAY_EXT
:
1739 if (ctx
->API
!= API_OPENGL_COMPAT
)
1740 goto invalid_enum_error
;
1741 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
1742 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1743 if (ctx
->API
!= API_OPENGL_COMPAT
)
1744 goto invalid_enum_error
;
1745 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
1746 case GL_POINT_SIZE_ARRAY_OES
:
1747 if (ctx
->API
!= API_OPENGLES
)
1748 goto invalid_enum_error
;
1749 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
1751 /* GL_ARB_texture_cube_map */
1752 case GL_TEXTURE_CUBE_MAP
:
1753 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
1754 !_mesa_has_OES_texture_cube_map(ctx
))
1755 goto invalid_enum_error
;
1756 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1758 /* GL_EXT_secondary_color */
1759 case GL_COLOR_SUM_EXT
:
1760 if (ctx
->API
!= API_OPENGL_COMPAT
)
1761 goto invalid_enum_error
;
1762 return ctx
->Fog
.ColorSumEnabled
;
1764 /* GL_ARB_multisample */
1765 case GL_MULTISAMPLE_ARB
:
1766 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1767 goto invalid_enum_error
;
1768 return ctx
->Multisample
.Enabled
;
1769 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1770 return ctx
->Multisample
.SampleAlphaToCoverage
;
1771 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1772 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1773 goto invalid_enum_error
;
1774 return ctx
->Multisample
.SampleAlphaToOne
;
1775 case GL_SAMPLE_COVERAGE_ARB
:
1776 return ctx
->Multisample
.SampleCoverage
;
1777 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1778 if (!_mesa_is_desktop_gl(ctx
))
1779 goto invalid_enum_error
;
1780 return ctx
->Multisample
.SampleCoverageInvert
;
1782 /* GL_IBM_rasterpos_clip */
1783 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1784 if (ctx
->API
!= API_OPENGL_COMPAT
)
1785 goto invalid_enum_error
;
1786 return ctx
->Transform
.RasterPositionUnclipped
;
1788 /* GL_NV_point_sprite */
1789 case GL_POINT_SPRITE_NV
:
1790 if (!(ctx
->API
== API_OPENGL_COMPAT
&&
1791 (_mesa_has_ARB_point_sprite(ctx
) ||
1792 _mesa_has_NV_point_sprite(ctx
))) &&
1793 !_mesa_has_OES_point_sprite(ctx
))
1794 goto invalid_enum_error
;
1795 return ctx
->Point
.PointSprite
;
1797 case GL_VERTEX_PROGRAM_ARB
:
1798 if (!_mesa_has_ARB_vertex_program(ctx
))
1799 goto invalid_enum_error
;
1800 return ctx
->VertexProgram
.Enabled
;
1801 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1802 /* This was added with ARB_vertex_program, but it is also used with
1803 * GLSL vertex shaders on desktop.
1805 if (!_mesa_has_ARB_vertex_program(ctx
) &&
1806 ctx
->API
!= API_OPENGL_CORE
)
1807 goto invalid_enum_error
;
1808 return ctx
->VertexProgram
.PointSizeEnabled
;
1809 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1810 if (!_mesa_has_ARB_vertex_program(ctx
))
1811 goto invalid_enum_error
;
1812 return ctx
->VertexProgram
.TwoSideEnabled
;
1814 /* GL_NV_texture_rectangle */
1815 case GL_TEXTURE_RECTANGLE_NV
:
1816 if (!_mesa_has_NV_texture_rectangle(ctx
))
1817 goto invalid_enum_error
;
1818 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1820 /* GL_EXT_stencil_two_side */
1821 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1822 if (!_mesa_has_EXT_stencil_two_side(ctx
))
1823 goto invalid_enum_error
;
1824 return ctx
->Stencil
.TestTwoSide
;
1826 case GL_FRAGMENT_PROGRAM_ARB
:
1827 if (!_mesa_has_ARB_fragment_program(ctx
))
1828 goto invalid_enum_error
;
1829 return ctx
->FragmentProgram
.Enabled
;
1831 /* GL_EXT_depth_bounds_test */
1832 case GL_DEPTH_BOUNDS_TEST_EXT
:
1833 if (!_mesa_has_EXT_depth_bounds_test(ctx
))
1834 goto invalid_enum_error
;
1835 return ctx
->Depth
.BoundsTest
;
1837 /* GL_ARB_depth_clamp */
1838 case GL_DEPTH_CLAMP
:
1839 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1840 !_mesa_has_EXT_depth_clamp(ctx
))
1841 goto invalid_enum_error
;
1842 return ctx
->Transform
.DepthClampNear
||
1843 ctx
->Transform
.DepthClampFar
;
1845 case GL_DEPTH_CLAMP_NEAR_AMD
:
1846 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1847 goto invalid_enum_error
;
1848 return ctx
->Transform
.DepthClampNear
;
1850 case GL_DEPTH_CLAMP_FAR_AMD
:
1851 if (!_mesa_has_AMD_depth_clamp_separate(ctx
))
1852 goto invalid_enum_error
;
1853 return ctx
->Transform
.DepthClampFar
;
1855 case GL_FRAGMENT_SHADER_ATI
:
1856 if (!_mesa_has_ATI_fragment_shader(ctx
))
1857 goto invalid_enum_error
;
1858 return ctx
->ATIFragmentShader
.Enabled
;
1860 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1861 if (!_mesa_has_ARB_seamless_cube_map(ctx
))
1862 goto invalid_enum_error
;
1863 return ctx
->Texture
.CubeMapSeamless
;
1865 case GL_RASTERIZER_DISCARD
:
1866 if (!(_mesa_has_EXT_transform_feedback(ctx
) || _mesa_is_gles3(ctx
)))
1867 goto invalid_enum_error
;
1868 return ctx
->RasterDiscard
;
1870 /* GL_NV_primitive_restart */
1871 case GL_PRIMITIVE_RESTART_NV
:
1872 if (!_mesa_has_NV_primitive_restart(ctx
))
1873 goto invalid_enum_error
;
1874 return ctx
->Array
.PrimitiveRestart
;
1876 /* GL 3.1 primitive restart */
1877 case GL_PRIMITIVE_RESTART
:
1878 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1879 goto invalid_enum_error
;
1881 return ctx
->Array
.PrimitiveRestart
;
1883 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1884 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1885 goto invalid_enum_error
;
1886 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1888 /* GL3.0 - GL_framebuffer_sRGB */
1889 case GL_FRAMEBUFFER_SRGB_EXT
:
1890 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1891 !_mesa_has_EXT_sRGB_write_control(ctx
))
1892 goto invalid_enum_error
;
1893 return ctx
->Color
.sRGBEnabled
;
1895 /* GL_OES_EGL_image_external */
1896 case GL_TEXTURE_EXTERNAL_OES
:
1897 if (!_mesa_has_OES_EGL_image_external(ctx
))
1898 goto invalid_enum_error
;
1899 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1901 /* ARB_texture_multisample */
1902 case GL_SAMPLE_MASK
:
1903 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1904 goto invalid_enum_error
;
1905 return ctx
->Multisample
.SampleMask
;
1907 /* ARB_sample_shading */
1908 case GL_SAMPLE_SHADING
:
1909 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
1910 goto invalid_enum_error
;
1911 return ctx
->Multisample
.SampleShading
;
1913 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1914 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1915 goto invalid_enum_error
;
1916 return ctx
->Color
.BlendCoherent
;
1918 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1919 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
1920 goto invalid_enum_error
;
1921 return ctx
->IntelConservativeRasterization
;
1923 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1924 if (!_mesa_has_NV_conservative_raster(ctx
))
1925 goto invalid_enum_error
;
1926 return ctx
->ConservativeRasterization
;
1928 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1929 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1930 goto invalid_enum_error
;
1931 return ctx
->TileRasterOrderFixed
;
1933 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1934 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1935 goto invalid_enum_error
;
1936 return ctx
->TileRasterOrderIncreasingX
;
1938 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1939 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1940 goto invalid_enum_error
;
1941 return ctx
->TileRasterOrderIncreasingY
;
1943 case GL_BLACKHOLE_RENDER_INTEL
:
1944 if (!_mesa_has_INTEL_blackhole_render(ctx
))
1945 goto invalid_enum_error
;
1946 return ctx
->IntelBlackholeRender
;
1949 goto invalid_enum_error
;
1955 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1956 _mesa_enum_to_string(cap
));