3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
36 #include "debug_output.h"
48 update_derived_primitive_restart_state(struct gl_context
*ctx
)
50 /* Update derived primitive restart state.
52 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
53 || ctx
->Array
.PrimitiveRestartFixedIndex
;
58 * Helper to enable/disable VAO client-side state.
61 vao_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
62 gl_vert_attrib attr
, GLboolean state
)
65 _mesa_enable_vertex_array_attrib(ctx
, vao
, attr
);
67 _mesa_disable_vertex_array_attrib(ctx
, vao
, attr
);
72 * Helper to enable/disable client-side state.
75 client_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
76 GLenum cap
, GLboolean state
)
80 vao_state(ctx
, vao
, VERT_ATTRIB_POS
, state
);
83 vao_state(ctx
, vao
, VERT_ATTRIB_NORMAL
, state
);
86 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR0
, state
);
89 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR_INDEX
, state
);
91 case GL_TEXTURE_COORD_ARRAY
:
92 vao_state(ctx
, vao
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
94 case GL_EDGE_FLAG_ARRAY
:
95 vao_state(ctx
, vao
, VERT_ATTRIB_EDGEFLAG
, state
);
97 case GL_FOG_COORDINATE_ARRAY_EXT
:
98 vao_state(ctx
, vao
, VERT_ATTRIB_FOG
, state
);
100 case GL_SECONDARY_COLOR_ARRAY_EXT
:
101 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR1
, state
);
104 case GL_POINT_SIZE_ARRAY_OES
:
105 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
106 ctx
->VertexProgram
.PointSizeEnabled
= state
;
107 vao_state(ctx
, vao
, VERT_ATTRIB_POINT_SIZE
, state
);
110 /* GL_NV_primitive_restart */
111 case GL_PRIMITIVE_RESTART_NV
:
112 if (!_mesa_has_NV_primitive_restart(ctx
))
113 goto invalid_enum_error
;
114 if (ctx
->Array
.PrimitiveRestart
== state
)
117 FLUSH_VERTICES(ctx
, 0);
118 ctx
->Array
.PrimitiveRestart
= state
;
119 update_derived_primitive_restart_state(ctx
);
123 goto invalid_enum_error
;
126 if (ctx
->Driver
.Enable
) {
127 ctx
->Driver
.Enable( ctx
, cap
, state
);
133 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
134 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
138 /* Helper for GL_EXT_direct_state_access following functions:
139 * - EnableClientStateIndexedEXT
140 * - EnableClientStateiEXT
141 * - DisableClientStateIndexedEXT
142 * - DisableClientStateiEXT
145 client_state_i(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
146 GLenum cap
, GLuint index
, GLboolean state
)
150 if (cap
!= GL_TEXTURE_COORD_ARRAY
) {
151 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientStateiEXT(cap=%s)",
152 state
? "Enable" : "Disable",
153 _mesa_enum_to_string(cap
));
157 if (index
>= ctx
->Const
.MaxTextureCoordUnits
) {
158 _mesa_error(ctx
, GL_INVALID_VALUE
, "gl%sClientStateiEXT(index=%d)",
159 state
? "Enable" : "Disable",
164 saved_active
= ctx
->Array
.ActiveTexture
;
165 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
166 client_state(ctx
, vao
, cap
, state
);
167 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
172 * Enable GL capability.
173 * \param cap state to enable/disable.
175 * Get's the current context, assures that we're outside glBegin()/glEnd() and
176 * calls client_state().
179 _mesa_EnableClientState( GLenum cap
)
181 GET_CURRENT_CONTEXT(ctx
);
182 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_TRUE
);
187 _mesa_EnableClientStateiEXT( GLenum cap
, GLuint index
)
189 GET_CURRENT_CONTEXT(ctx
);
190 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_TRUE
);
195 * Disable GL capability.
196 * \param cap state to enable/disable.
198 * Get's the current context, assures that we're outside glBegin()/glEnd() and
199 * calls client_state().
202 _mesa_DisableClientState( GLenum cap
)
204 GET_CURRENT_CONTEXT(ctx
);
205 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_FALSE
);
209 _mesa_DisableClientStateiEXT( GLenum cap
, GLuint index
)
211 GET_CURRENT_CONTEXT(ctx
);
212 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_FALSE
);
215 #define CHECK_EXTENSION(EXTNAME) \
216 if (!ctx->Extensions.EXTNAME) { \
217 goto invalid_enum_error; \
220 #define CHECK_EXTENSION2(EXT1, EXT2) \
221 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
222 goto invalid_enum_error; \
226 * Return pointer to current texture unit for setting/getting coordinate
228 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
229 * texture unit is higher than the number of supported coordinate units.
231 static struct gl_fixedfunc_texture_unit
*
232 get_texcoord_unit(struct gl_context
*ctx
)
234 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
235 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
239 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
245 * Helper function to enable or disable a texture target.
246 * \param bit one of the TEXTURE_x_BIT values
247 * \return GL_TRUE if state is changing or GL_FALSE if no change
250 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
252 struct gl_fixedfunc_texture_unit
*texUnit
=
253 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
257 const GLbitfield newenabled
= state
258 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
260 if (texUnit
->Enabled
== newenabled
)
263 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
264 texUnit
->Enabled
= newenabled
;
270 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
271 * whether the API supports it (GLES doesn't).
274 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
276 if (ctx
->Multisample
.Enabled
== state
)
279 /* GL compatibility needs Multisample.Enable to determine program state
282 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
283 !ctx
->DriverFlags
.NewMultisampleEnable
) {
284 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
286 FLUSH_VERTICES(ctx
, 0);
289 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
290 ctx
->Multisample
.Enabled
= state
;
292 if (ctx
->Driver
.Enable
) {
293 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
298 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
299 * check for whether the API supports it (GLES doesn't).
302 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
304 if (ctx
->Color
.sRGBEnabled
== state
)
307 /* TODO: Switch i965 to the new flag and remove the conditional */
308 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
309 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
310 ctx
->Color
.sRGBEnabled
= state
;
312 if (ctx
->Driver
.Enable
) {
313 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
318 * Helper function to enable or disable state.
320 * \param ctx GL context.
321 * \param cap the state to enable/disable
322 * \param state whether to enable or disable the specified capability.
324 * Updates the current context and flushes the vertices as needed. For
325 * capabilities associated with extensions it verifies that those extensions
326 * are effectivly present before updating. Notifies the driver via
327 * dd_function_table::Enable.
330 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
332 if (MESA_VERBOSE
& VERBOSE_API
)
333 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
334 state
? "glEnable" : "glDisable",
335 _mesa_enum_to_string(cap
),
340 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
341 goto invalid_enum_error
;
342 if (ctx
->Color
.AlphaEnabled
== state
)
344 /* AlphaEnabled is used by the fixed-func fragment program */
345 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
346 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
347 ctx
->Color
.AlphaEnabled
= state
;
350 if (ctx
->API
!= API_OPENGL_COMPAT
)
351 goto invalid_enum_error
;
352 if (ctx
->Eval
.AutoNormal
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
355 ctx
->Eval
.AutoNormal
= state
;
359 GLbitfield newEnabled
=
360 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
361 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
362 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
363 ctx
->Color
._AdvancedBlendMode
);
364 ctx
->Color
.BlendEnabled
= newEnabled
;
368 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
369 case GL_CLIP_DISTANCE1
:
370 case GL_CLIP_DISTANCE2
:
371 case GL_CLIP_DISTANCE3
:
372 case GL_CLIP_DISTANCE4
:
373 case GL_CLIP_DISTANCE5
:
374 case GL_CLIP_DISTANCE6
:
375 case GL_CLIP_DISTANCE7
:
377 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
379 if (p
>= ctx
->Const
.MaxClipPlanes
)
380 goto invalid_enum_error
;
382 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
383 == ((GLuint
) state
<< p
))
386 /* The compatibility profile needs _NEW_TRANSFORM to transform
387 * clip planes according to the projection matrix.
389 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
390 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
391 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
393 FLUSH_VERTICES(ctx
, 0);
395 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
398 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
400 /* The projection matrix transforms the clip plane. */
401 /* TODO: glEnable might not be the best place to do it. */
402 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
403 _mesa_update_clip_plane(ctx
, p
);
404 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
408 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
412 case GL_COLOR_MATERIAL
:
413 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
414 goto invalid_enum_error
;
415 if (ctx
->Light
.ColorMaterialEnabled
== state
)
417 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
418 FLUSH_CURRENT(ctx
, 0);
419 ctx
->Light
.ColorMaterialEnabled
= state
;
421 _mesa_update_color_material( ctx
,
422 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
426 if (ctx
->Polygon
.CullFlag
== state
)
429 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
430 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
431 ctx
->Polygon
.CullFlag
= state
;
434 if (ctx
->Depth
.Test
== state
)
436 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
437 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
438 ctx
->Depth
.Test
= state
;
440 case GL_DEBUG_OUTPUT
:
441 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
442 _mesa_set_debug_state_int(ctx
, cap
, state
);
445 if (ctx
->Color
.DitherFlag
== state
)
447 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
448 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
449 ctx
->Color
.DitherFlag
= state
;
452 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
453 goto invalid_enum_error
;
454 if (ctx
->Fog
.Enabled
== state
)
456 FLUSH_VERTICES(ctx
, _NEW_FOG
);
457 ctx
->Fog
.Enabled
= state
;
458 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
468 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
469 goto invalid_enum_error
;
470 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
472 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
473 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
475 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
478 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
482 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
483 goto invalid_enum_error
;
484 if (ctx
->Light
.Enabled
== state
)
486 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
487 ctx
->Light
.Enabled
= state
;
490 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
491 goto invalid_enum_error
;
492 if (ctx
->Line
.SmoothFlag
== state
)
494 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
495 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
496 ctx
->Line
.SmoothFlag
= state
;
498 case GL_LINE_STIPPLE
:
499 if (ctx
->API
!= API_OPENGL_COMPAT
)
500 goto invalid_enum_error
;
501 if (ctx
->Line
.StippleFlag
== state
)
503 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
504 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
505 ctx
->Line
.StippleFlag
= state
;
507 case GL_INDEX_LOGIC_OP
:
508 if (ctx
->API
!= API_OPENGL_COMPAT
)
509 goto invalid_enum_error
;
510 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
512 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
513 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
514 ctx
->Color
.IndexLogicOpEnabled
= state
;
516 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
517 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
518 goto invalid_enum_error
;
519 if (ctx
->IntelConservativeRasterization
== state
)
521 FLUSH_VERTICES(ctx
, 0);
522 ctx
->NewDriverState
|=
523 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
524 ctx
->IntelConservativeRasterization
= state
;
526 case GL_CONSERVATIVE_RASTERIZATION_NV
:
527 if (!_mesa_has_NV_conservative_raster(ctx
))
528 goto invalid_enum_error
;
529 if (ctx
->ConservativeRasterization
== state
)
531 FLUSH_VERTICES(ctx
, 0);
532 ctx
->NewDriverState
|=
533 ctx
->DriverFlags
.NewNvConservativeRasterization
;
534 ctx
->ConservativeRasterization
= state
;
536 case GL_COLOR_LOGIC_OP
:
537 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
538 goto invalid_enum_error
;
539 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
541 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
542 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
543 ctx
->Color
.ColorLogicOpEnabled
= state
;
545 case GL_MAP1_COLOR_4
:
546 if (ctx
->API
!= API_OPENGL_COMPAT
)
547 goto invalid_enum_error
;
548 if (ctx
->Eval
.Map1Color4
== state
)
550 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
551 ctx
->Eval
.Map1Color4
= state
;
554 if (ctx
->API
!= API_OPENGL_COMPAT
)
555 goto invalid_enum_error
;
556 if (ctx
->Eval
.Map1Index
== state
)
558 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
559 ctx
->Eval
.Map1Index
= state
;
562 if (ctx
->API
!= API_OPENGL_COMPAT
)
563 goto invalid_enum_error
;
564 if (ctx
->Eval
.Map1Normal
== state
)
566 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
567 ctx
->Eval
.Map1Normal
= state
;
569 case GL_MAP1_TEXTURE_COORD_1
:
570 if (ctx
->API
!= API_OPENGL_COMPAT
)
571 goto invalid_enum_error
;
572 if (ctx
->Eval
.Map1TextureCoord1
== state
)
574 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
575 ctx
->Eval
.Map1TextureCoord1
= state
;
577 case GL_MAP1_TEXTURE_COORD_2
:
578 if (ctx
->API
!= API_OPENGL_COMPAT
)
579 goto invalid_enum_error
;
580 if (ctx
->Eval
.Map1TextureCoord2
== state
)
582 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
583 ctx
->Eval
.Map1TextureCoord2
= state
;
585 case GL_MAP1_TEXTURE_COORD_3
:
586 if (ctx
->API
!= API_OPENGL_COMPAT
)
587 goto invalid_enum_error
;
588 if (ctx
->Eval
.Map1TextureCoord3
== state
)
590 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
591 ctx
->Eval
.Map1TextureCoord3
= state
;
593 case GL_MAP1_TEXTURE_COORD_4
:
594 if (ctx
->API
!= API_OPENGL_COMPAT
)
595 goto invalid_enum_error
;
596 if (ctx
->Eval
.Map1TextureCoord4
== state
)
598 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
599 ctx
->Eval
.Map1TextureCoord4
= state
;
601 case GL_MAP1_VERTEX_3
:
602 if (ctx
->API
!= API_OPENGL_COMPAT
)
603 goto invalid_enum_error
;
604 if (ctx
->Eval
.Map1Vertex3
== state
)
606 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
607 ctx
->Eval
.Map1Vertex3
= state
;
609 case GL_MAP1_VERTEX_4
:
610 if (ctx
->API
!= API_OPENGL_COMPAT
)
611 goto invalid_enum_error
;
612 if (ctx
->Eval
.Map1Vertex4
== state
)
614 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
615 ctx
->Eval
.Map1Vertex4
= state
;
617 case GL_MAP2_COLOR_4
:
618 if (ctx
->API
!= API_OPENGL_COMPAT
)
619 goto invalid_enum_error
;
620 if (ctx
->Eval
.Map2Color4
== state
)
622 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
623 ctx
->Eval
.Map2Color4
= state
;
626 if (ctx
->API
!= API_OPENGL_COMPAT
)
627 goto invalid_enum_error
;
628 if (ctx
->Eval
.Map2Index
== state
)
630 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
631 ctx
->Eval
.Map2Index
= state
;
634 if (ctx
->API
!= API_OPENGL_COMPAT
)
635 goto invalid_enum_error
;
636 if (ctx
->Eval
.Map2Normal
== state
)
638 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
639 ctx
->Eval
.Map2Normal
= state
;
641 case GL_MAP2_TEXTURE_COORD_1
:
642 if (ctx
->API
!= API_OPENGL_COMPAT
)
643 goto invalid_enum_error
;
644 if (ctx
->Eval
.Map2TextureCoord1
== state
)
646 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
647 ctx
->Eval
.Map2TextureCoord1
= state
;
649 case GL_MAP2_TEXTURE_COORD_2
:
650 if (ctx
->API
!= API_OPENGL_COMPAT
)
651 goto invalid_enum_error
;
652 if (ctx
->Eval
.Map2TextureCoord2
== state
)
654 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
655 ctx
->Eval
.Map2TextureCoord2
= state
;
657 case GL_MAP2_TEXTURE_COORD_3
:
658 if (ctx
->API
!= API_OPENGL_COMPAT
)
659 goto invalid_enum_error
;
660 if (ctx
->Eval
.Map2TextureCoord3
== state
)
662 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
663 ctx
->Eval
.Map2TextureCoord3
= state
;
665 case GL_MAP2_TEXTURE_COORD_4
:
666 if (ctx
->API
!= API_OPENGL_COMPAT
)
667 goto invalid_enum_error
;
668 if (ctx
->Eval
.Map2TextureCoord4
== state
)
670 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
671 ctx
->Eval
.Map2TextureCoord4
= state
;
673 case GL_MAP2_VERTEX_3
:
674 if (ctx
->API
!= API_OPENGL_COMPAT
)
675 goto invalid_enum_error
;
676 if (ctx
->Eval
.Map2Vertex3
== state
)
678 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
679 ctx
->Eval
.Map2Vertex3
= state
;
681 case GL_MAP2_VERTEX_4
:
682 if (ctx
->API
!= API_OPENGL_COMPAT
)
683 goto invalid_enum_error
;
684 if (ctx
->Eval
.Map2Vertex4
== state
)
686 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
687 ctx
->Eval
.Map2Vertex4
= state
;
690 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
691 goto invalid_enum_error
;
692 if (ctx
->Transform
.Normalize
== state
)
694 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
695 ctx
->Transform
.Normalize
= state
;
697 case GL_POINT_SMOOTH
:
698 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
699 goto invalid_enum_error
;
700 if (ctx
->Point
.SmoothFlag
== state
)
702 FLUSH_VERTICES(ctx
, _NEW_POINT
);
703 ctx
->Point
.SmoothFlag
= state
;
705 case GL_POLYGON_SMOOTH
:
706 if (!_mesa_is_desktop_gl(ctx
))
707 goto invalid_enum_error
;
708 if (ctx
->Polygon
.SmoothFlag
== state
)
711 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
712 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
713 ctx
->Polygon
.SmoothFlag
= state
;
715 case GL_POLYGON_STIPPLE
:
716 if (ctx
->API
!= API_OPENGL_COMPAT
)
717 goto invalid_enum_error
;
718 if (ctx
->Polygon
.StippleFlag
== state
)
721 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
722 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
723 ctx
->Polygon
.StippleFlag
= state
;
725 case GL_POLYGON_OFFSET_POINT
:
726 if (!_mesa_is_desktop_gl(ctx
))
727 goto invalid_enum_error
;
728 if (ctx
->Polygon
.OffsetPoint
== state
)
731 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
732 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
733 ctx
->Polygon
.OffsetPoint
= state
;
735 case GL_POLYGON_OFFSET_LINE
:
736 if (!_mesa_is_desktop_gl(ctx
))
737 goto invalid_enum_error
;
738 if (ctx
->Polygon
.OffsetLine
== state
)
741 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
742 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
743 ctx
->Polygon
.OffsetLine
= state
;
745 case GL_POLYGON_OFFSET_FILL
:
746 if (ctx
->Polygon
.OffsetFill
== state
)
749 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
750 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
751 ctx
->Polygon
.OffsetFill
= state
;
753 case GL_RESCALE_NORMAL_EXT
:
754 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
755 goto invalid_enum_error
;
756 if (ctx
->Transform
.RescaleNormals
== state
)
758 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
759 ctx
->Transform
.RescaleNormals
= state
;
761 case GL_SCISSOR_TEST
:
763 /* Must expand glEnable to all scissors */
764 GLbitfield newEnabled
=
765 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
766 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
767 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
769 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
770 ctx
->Scissor
.EnableFlags
= newEnabled
;
774 case GL_STENCIL_TEST
:
775 if (ctx
->Stencil
.Enabled
== state
)
777 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
778 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
779 ctx
->Stencil
.Enabled
= state
;
782 if (ctx
->API
!= API_OPENGL_COMPAT
)
783 goto invalid_enum_error
;
784 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
789 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
790 goto invalid_enum_error
;
791 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
796 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
797 goto invalid_enum_error
;
798 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
802 case GL_TEXTURE_GEN_S
:
803 case GL_TEXTURE_GEN_T
:
804 case GL_TEXTURE_GEN_R
:
805 case GL_TEXTURE_GEN_Q
:
807 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
809 if (ctx
->API
!= API_OPENGL_COMPAT
)
810 goto invalid_enum_error
;
813 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
814 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
816 newenabled
|= coordBit
;
817 if (texUnit
->TexGenEnabled
== newenabled
)
819 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
820 texUnit
->TexGenEnabled
= newenabled
;
825 case GL_TEXTURE_GEN_STR_OES
:
826 /* disable S, T, and R at the same time */
828 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
830 if (ctx
->API
!= API_OPENGLES
)
831 goto invalid_enum_error
;
835 texUnit
->TexGenEnabled
& ~STR_BITS
;
837 newenabled
|= STR_BITS
;
838 if (texUnit
->TexGenEnabled
== newenabled
)
840 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
841 texUnit
->TexGenEnabled
= newenabled
;
846 /* client-side state */
847 case GL_VERTEX_ARRAY
:
848 case GL_NORMAL_ARRAY
:
850 case GL_TEXTURE_COORD_ARRAY
:
851 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
852 goto invalid_enum_error
;
853 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
856 case GL_EDGE_FLAG_ARRAY
:
857 case GL_FOG_COORDINATE_ARRAY_EXT
:
858 case GL_SECONDARY_COLOR_ARRAY_EXT
:
859 if (ctx
->API
!= API_OPENGL_COMPAT
)
860 goto invalid_enum_error
;
861 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
863 case GL_POINT_SIZE_ARRAY_OES
:
864 if (ctx
->API
!= API_OPENGLES
)
865 goto invalid_enum_error
;
866 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
869 /* GL_ARB_texture_cube_map */
870 case GL_TEXTURE_CUBE_MAP
:
871 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
872 !_mesa_has_OES_texture_cube_map(ctx
))
873 goto invalid_enum_error
;
874 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
879 /* GL_EXT_secondary_color */
880 case GL_COLOR_SUM_EXT
:
881 if (ctx
->API
!= API_OPENGL_COMPAT
)
882 goto invalid_enum_error
;
883 if (ctx
->Fog
.ColorSumEnabled
== state
)
885 FLUSH_VERTICES(ctx
, _NEW_FOG
);
886 ctx
->Fog
.ColorSumEnabled
= state
;
889 /* GL_ARB_multisample */
890 case GL_MULTISAMPLE_ARB
:
891 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
892 goto invalid_enum_error
;
893 _mesa_set_multisample(ctx
, state
);
895 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
896 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
898 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
900 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
901 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
903 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
904 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
905 goto invalid_enum_error
;
906 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
908 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
910 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
911 ctx
->Multisample
.SampleAlphaToOne
= state
;
913 case GL_SAMPLE_COVERAGE_ARB
:
914 if (ctx
->Multisample
.SampleCoverage
== state
)
916 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
918 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
919 ctx
->Multisample
.SampleCoverage
= state
;
921 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
922 if (!_mesa_is_desktop_gl(ctx
))
923 goto invalid_enum_error
;
924 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
926 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
928 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
929 ctx
->Multisample
.SampleCoverageInvert
= state
;
932 /* GL_ARB_sample_shading */
933 case GL_SAMPLE_SHADING
:
934 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
935 goto invalid_enum_error
;
936 if (ctx
->Multisample
.SampleShading
== state
)
938 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
940 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
941 ctx
->Multisample
.SampleShading
= state
;
944 /* GL_IBM_rasterpos_clip */
945 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
946 if (ctx
->API
!= API_OPENGL_COMPAT
)
947 goto invalid_enum_error
;
948 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
950 FLUSH_VERTICES(ctx
, 0);
951 ctx
->Transform
.RasterPositionUnclipped
= state
;
954 /* GL_NV_point_sprite */
955 case GL_POINT_SPRITE_NV
:
956 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
957 goto invalid_enum_error
;
958 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
);
959 if (ctx
->Point
.PointSprite
== state
)
961 FLUSH_VERTICES(ctx
, _NEW_POINT
);
962 ctx
->Point
.PointSprite
= state
;
965 case GL_VERTEX_PROGRAM_ARB
:
966 if (ctx
->API
!= API_OPENGL_COMPAT
)
967 goto invalid_enum_error
;
968 CHECK_EXTENSION(ARB_vertex_program
);
969 if (ctx
->VertexProgram
.Enabled
== state
)
971 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
972 ctx
->VertexProgram
.Enabled
= state
;
973 _mesa_update_vertex_processing_mode(ctx
);
975 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
976 /* This was added with ARB_vertex_program, but it is also used with
977 * GLSL vertex shaders on desktop.
979 if (!_mesa_is_desktop_gl(ctx
))
980 goto invalid_enum_error
;
981 CHECK_EXTENSION(ARB_vertex_program
);
982 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
984 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
985 ctx
->VertexProgram
.PointSizeEnabled
= state
;
987 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
988 if (ctx
->API
!= API_OPENGL_COMPAT
)
989 goto invalid_enum_error
;
990 CHECK_EXTENSION(ARB_vertex_program
);
991 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
993 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
994 ctx
->VertexProgram
.TwoSideEnabled
= state
;
997 /* GL_NV_texture_rectangle */
998 case GL_TEXTURE_RECTANGLE_NV
:
999 if (ctx
->API
!= API_OPENGL_COMPAT
)
1000 goto invalid_enum_error
;
1001 CHECK_EXTENSION(NV_texture_rectangle
);
1002 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
1007 /* GL_EXT_stencil_two_side */
1008 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1009 if (ctx
->API
!= API_OPENGL_COMPAT
)
1010 goto invalid_enum_error
;
1011 CHECK_EXTENSION(EXT_stencil_two_side
);
1012 if (ctx
->Stencil
.TestTwoSide
== state
)
1014 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
1015 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
1016 ctx
->Stencil
.TestTwoSide
= state
;
1018 ctx
->Stencil
._BackFace
= 2;
1020 ctx
->Stencil
._BackFace
= 1;
1024 case GL_FRAGMENT_PROGRAM_ARB
:
1025 if (!_mesa_has_ARB_fragment_program(ctx
))
1026 goto invalid_enum_error
;
1027 if (ctx
->FragmentProgram
.Enabled
== state
)
1029 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1030 ctx
->FragmentProgram
.Enabled
= state
;
1033 /* GL_EXT_depth_bounds_test */
1034 case GL_DEPTH_BOUNDS_TEST_EXT
:
1035 if (!_mesa_is_desktop_gl(ctx
))
1036 goto invalid_enum_error
;
1037 CHECK_EXTENSION(EXT_depth_bounds_test
);
1038 if (ctx
->Depth
.BoundsTest
== state
)
1040 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
1041 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
1042 ctx
->Depth
.BoundsTest
= state
;
1045 case GL_DEPTH_CLAMP
:
1046 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1047 !_mesa_has_EXT_depth_clamp(ctx
))
1048 goto invalid_enum_error
;
1049 if (ctx
->Transform
.DepthClampNear
== state
&&
1050 ctx
->Transform
.DepthClampFar
== state
)
1052 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1054 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1055 ctx
->Transform
.DepthClampNear
= state
;
1056 ctx
->Transform
.DepthClampFar
= state
;
1059 case GL_DEPTH_CLAMP_NEAR_AMD
:
1060 if (!_mesa_is_desktop_gl(ctx
))
1061 goto invalid_enum_error
;
1062 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1063 if (ctx
->Transform
.DepthClampNear
== state
)
1065 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1067 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1068 ctx
->Transform
.DepthClampNear
= state
;
1071 case GL_DEPTH_CLAMP_FAR_AMD
:
1072 if (!_mesa_is_desktop_gl(ctx
))
1073 goto invalid_enum_error
;
1074 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1075 if (ctx
->Transform
.DepthClampFar
== state
)
1077 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1079 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1080 ctx
->Transform
.DepthClampFar
= state
;
1083 case GL_FRAGMENT_SHADER_ATI
:
1084 if (ctx
->API
!= API_OPENGL_COMPAT
)
1085 goto invalid_enum_error
;
1086 CHECK_EXTENSION(ATI_fragment_shader
);
1087 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1089 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1090 ctx
->ATIFragmentShader
.Enabled
= state
;
1093 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1094 if (!_mesa_is_desktop_gl(ctx
))
1095 goto invalid_enum_error
;
1096 CHECK_EXTENSION(ARB_seamless_cube_map
);
1097 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1098 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1099 ctx
->Texture
.CubeMapSeamless
= state
;
1103 case GL_RASTERIZER_DISCARD
:
1104 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1105 goto invalid_enum_error
;
1106 CHECK_EXTENSION(EXT_transform_feedback
);
1107 if (ctx
->RasterDiscard
!= state
) {
1108 FLUSH_VERTICES(ctx
, 0);
1109 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1110 ctx
->RasterDiscard
= state
;
1114 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1115 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1116 goto invalid_enum_error
;
1117 if (ctx
->TileRasterOrderFixed
!= state
) {
1118 FLUSH_VERTICES(ctx
, 0);
1119 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1120 ctx
->TileRasterOrderFixed
= state
;
1124 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1125 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1126 goto invalid_enum_error
;
1127 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1128 FLUSH_VERTICES(ctx
, 0);
1129 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1130 ctx
->TileRasterOrderIncreasingX
= state
;
1134 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1135 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1136 goto invalid_enum_error
;
1137 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1138 FLUSH_VERTICES(ctx
, 0);
1139 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1140 ctx
->TileRasterOrderIncreasingY
= state
;
1144 /* GL 3.1 primitive restart. Note: this enum is different from
1145 * GL_PRIMITIVE_RESTART_NV (which is client state).
1147 case GL_PRIMITIVE_RESTART
:
1148 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1149 goto invalid_enum_error
;
1151 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1152 FLUSH_VERTICES(ctx
, 0);
1153 ctx
->Array
.PrimitiveRestart
= state
;
1154 update_derived_primitive_restart_state(ctx
);
1158 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1159 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1160 goto invalid_enum_error
;
1161 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1162 FLUSH_VERTICES(ctx
, 0);
1163 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1164 update_derived_primitive_restart_state(ctx
);
1168 /* GL3.0 - GL_framebuffer_sRGB */
1169 case GL_FRAMEBUFFER_SRGB_EXT
:
1170 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1171 !_mesa_has_EXT_sRGB_write_control(ctx
))
1172 goto invalid_enum_error
;
1173 _mesa_set_framebuffer_srgb(ctx
, state
);
1176 /* GL_OES_EGL_image_external */
1177 case GL_TEXTURE_EXTERNAL_OES
:
1178 if (!_mesa_is_gles(ctx
))
1179 goto invalid_enum_error
;
1180 CHECK_EXTENSION(OES_EGL_image_external
);
1181 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1186 /* ARB_texture_multisample */
1187 case GL_SAMPLE_MASK
:
1188 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1189 goto invalid_enum_error
;
1190 if (ctx
->Multisample
.SampleMask
== state
)
1192 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1194 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1195 ctx
->Multisample
.SampleMask
= state
;
1198 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1199 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1200 goto invalid_enum_error
;
1201 if (ctx
->Color
.BlendCoherent
== state
)
1203 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1204 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1205 ctx
->Color
.BlendCoherent
= state
;
1209 goto invalid_enum_error
;
1212 if (ctx
->Driver
.Enable
) {
1213 ctx
->Driver
.Enable( ctx
, cap
, state
);
1219 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1220 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1225 * Enable GL capability. Called by glEnable()
1226 * \param cap state to enable.
1229 _mesa_Enable( GLenum cap
)
1231 GET_CURRENT_CONTEXT(ctx
);
1233 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1238 * Disable GL capability. Called by glDisable()
1239 * \param cap state to disable.
1242 _mesa_Disable( GLenum cap
)
1244 GET_CURRENT_CONTEXT(ctx
);
1246 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1252 * Enable/disable an indexed state var.
1255 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1256 GLuint index
, GLboolean state
)
1258 assert(state
== 0 || state
== 1);
1261 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1262 goto invalid_enum_error
;
1264 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1265 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1266 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1269 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1270 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1273 enabled
|= (1 << index
);
1275 enabled
&= ~(1 << index
);
1277 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1278 ctx
->Color
._AdvancedBlendMode
);
1279 ctx
->Color
.BlendEnabled
= enabled
;
1282 case GL_SCISSOR_TEST
:
1283 if (index
>= ctx
->Const
.MaxViewports
) {
1284 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1285 state
? "glEnablei" : "glDisablei", index
);
1288 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1290 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1291 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1293 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1295 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1298 /* EXT_direct_state_access */
1302 case GL_TEXTURE_CUBE_MAP
:
1303 case GL_TEXTURE_GEN_S
:
1304 case GL_TEXTURE_GEN_T
:
1305 case GL_TEXTURE_GEN_R
:
1306 case GL_TEXTURE_GEN_Q
:
1307 case GL_TEXTURE_RECTANGLE_ARB
: {
1308 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1309 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1310 ctx
->Const
.MaxTextureCoordUnits
)) {
1311 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1312 state
? "glEnablei" : "glDisablei", index
);
1315 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1316 _mesa_set_enable( ctx
, cap
, state
);
1317 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1321 goto invalid_enum_error
;
1326 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1327 state
? "glEnablei" : "glDisablei",
1328 _mesa_enum_to_string(cap
));
1333 _mesa_Disablei( GLenum cap
, GLuint index
)
1335 GET_CURRENT_CONTEXT(ctx
);
1336 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1341 _mesa_Enablei( GLenum cap
, GLuint index
)
1343 GET_CURRENT_CONTEXT(ctx
);
1344 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1348 GLboolean GLAPIENTRY
1349 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1351 GET_CURRENT_CONTEXT(ctx
);
1352 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1355 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1356 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1360 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1361 case GL_SCISSOR_TEST
:
1362 if (index
>= ctx
->Const
.MaxViewports
) {
1363 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1367 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1368 /* EXT_direct_state_access */
1372 case GL_TEXTURE_CUBE_MAP
:
1373 case GL_TEXTURE_GEN_S
:
1374 case GL_TEXTURE_GEN_T
:
1375 case GL_TEXTURE_GEN_R
:
1376 case GL_TEXTURE_GEN_Q
:
1377 case GL_TEXTURE_RECTANGLE_ARB
: {
1379 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1380 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1381 ctx
->Const
.MaxTextureCoordUnits
)) {
1382 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1386 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1387 state
= _mesa_IsEnabled(cap
);
1388 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1392 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1393 _mesa_enum_to_string(cap
));
1401 * Helper function to determine whether a texture target is enabled.
1404 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1406 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1407 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
1412 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1417 * Return simple enable/disable state.
1419 * \param cap state variable to query.
1421 * Returns the state of the specified capability from the current GL context.
1422 * For the capabilities associated with extensions verifies that those
1423 * extensions are effectively present before reporting.
1425 GLboolean GLAPIENTRY
1426 _mesa_IsEnabled( GLenum cap
)
1428 GET_CURRENT_CONTEXT(ctx
);
1429 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1433 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1434 goto invalid_enum_error
;
1435 return ctx
->Color
.AlphaEnabled
;
1436 case GL_AUTO_NORMAL
:
1437 if (ctx
->API
!= API_OPENGL_COMPAT
)
1438 goto invalid_enum_error
;
1439 return ctx
->Eval
.AutoNormal
;
1441 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1442 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1443 case GL_CLIP_DISTANCE1
:
1444 case GL_CLIP_DISTANCE2
:
1445 case GL_CLIP_DISTANCE3
:
1446 case GL_CLIP_DISTANCE4
:
1447 case GL_CLIP_DISTANCE5
:
1448 case GL_CLIP_DISTANCE6
:
1449 case GL_CLIP_DISTANCE7
: {
1450 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1452 if (p
>= ctx
->Const
.MaxClipPlanes
)
1453 goto invalid_enum_error
;
1455 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1457 case GL_COLOR_MATERIAL
:
1458 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1459 goto invalid_enum_error
;
1460 return ctx
->Light
.ColorMaterialEnabled
;
1462 return ctx
->Polygon
.CullFlag
;
1463 case GL_DEBUG_OUTPUT
:
1464 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1465 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1467 return ctx
->Depth
.Test
;
1469 return ctx
->Color
.DitherFlag
;
1471 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1472 goto invalid_enum_error
;
1473 return ctx
->Fog
.Enabled
;
1475 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1476 goto invalid_enum_error
;
1477 return ctx
->Light
.Enabled
;
1486 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1487 goto invalid_enum_error
;
1488 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1489 case GL_LINE_SMOOTH
:
1490 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1491 goto invalid_enum_error
;
1492 return ctx
->Line
.SmoothFlag
;
1493 case GL_LINE_STIPPLE
:
1494 if (ctx
->API
!= API_OPENGL_COMPAT
)
1495 goto invalid_enum_error
;
1496 return ctx
->Line
.StippleFlag
;
1497 case GL_INDEX_LOGIC_OP
:
1498 if (ctx
->API
!= API_OPENGL_COMPAT
)
1499 goto invalid_enum_error
;
1500 return ctx
->Color
.IndexLogicOpEnabled
;
1501 case GL_COLOR_LOGIC_OP
:
1502 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1503 goto invalid_enum_error
;
1504 return ctx
->Color
.ColorLogicOpEnabled
;
1505 case GL_MAP1_COLOR_4
:
1506 if (ctx
->API
!= API_OPENGL_COMPAT
)
1507 goto invalid_enum_error
;
1508 return ctx
->Eval
.Map1Color4
;
1510 if (ctx
->API
!= API_OPENGL_COMPAT
)
1511 goto invalid_enum_error
;
1512 return ctx
->Eval
.Map1Index
;
1513 case GL_MAP1_NORMAL
:
1514 if (ctx
->API
!= API_OPENGL_COMPAT
)
1515 goto invalid_enum_error
;
1516 return ctx
->Eval
.Map1Normal
;
1517 case GL_MAP1_TEXTURE_COORD_1
:
1518 if (ctx
->API
!= API_OPENGL_COMPAT
)
1519 goto invalid_enum_error
;
1520 return ctx
->Eval
.Map1TextureCoord1
;
1521 case GL_MAP1_TEXTURE_COORD_2
:
1522 if (ctx
->API
!= API_OPENGL_COMPAT
)
1523 goto invalid_enum_error
;
1524 return ctx
->Eval
.Map1TextureCoord2
;
1525 case GL_MAP1_TEXTURE_COORD_3
:
1526 if (ctx
->API
!= API_OPENGL_COMPAT
)
1527 goto invalid_enum_error
;
1528 return ctx
->Eval
.Map1TextureCoord3
;
1529 case GL_MAP1_TEXTURE_COORD_4
:
1530 if (ctx
->API
!= API_OPENGL_COMPAT
)
1531 goto invalid_enum_error
;
1532 return ctx
->Eval
.Map1TextureCoord4
;
1533 case GL_MAP1_VERTEX_3
:
1534 if (ctx
->API
!= API_OPENGL_COMPAT
)
1535 goto invalid_enum_error
;
1536 return ctx
->Eval
.Map1Vertex3
;
1537 case GL_MAP1_VERTEX_4
:
1538 if (ctx
->API
!= API_OPENGL_COMPAT
)
1539 goto invalid_enum_error
;
1540 return ctx
->Eval
.Map1Vertex4
;
1541 case GL_MAP2_COLOR_4
:
1542 if (ctx
->API
!= API_OPENGL_COMPAT
)
1543 goto invalid_enum_error
;
1544 return ctx
->Eval
.Map2Color4
;
1546 if (ctx
->API
!= API_OPENGL_COMPAT
)
1547 goto invalid_enum_error
;
1548 return ctx
->Eval
.Map2Index
;
1549 case GL_MAP2_NORMAL
:
1550 if (ctx
->API
!= API_OPENGL_COMPAT
)
1551 goto invalid_enum_error
;
1552 return ctx
->Eval
.Map2Normal
;
1553 case GL_MAP2_TEXTURE_COORD_1
:
1554 if (ctx
->API
!= API_OPENGL_COMPAT
)
1555 goto invalid_enum_error
;
1556 return ctx
->Eval
.Map2TextureCoord1
;
1557 case GL_MAP2_TEXTURE_COORD_2
:
1558 if (ctx
->API
!= API_OPENGL_COMPAT
)
1559 goto invalid_enum_error
;
1560 return ctx
->Eval
.Map2TextureCoord2
;
1561 case GL_MAP2_TEXTURE_COORD_3
:
1562 if (ctx
->API
!= API_OPENGL_COMPAT
)
1563 goto invalid_enum_error
;
1564 return ctx
->Eval
.Map2TextureCoord3
;
1565 case GL_MAP2_TEXTURE_COORD_4
:
1566 if (ctx
->API
!= API_OPENGL_COMPAT
)
1567 goto invalid_enum_error
;
1568 return ctx
->Eval
.Map2TextureCoord4
;
1569 case GL_MAP2_VERTEX_3
:
1570 if (ctx
->API
!= API_OPENGL_COMPAT
)
1571 goto invalid_enum_error
;
1572 return ctx
->Eval
.Map2Vertex3
;
1573 case GL_MAP2_VERTEX_4
:
1574 if (ctx
->API
!= API_OPENGL_COMPAT
)
1575 goto invalid_enum_error
;
1576 return ctx
->Eval
.Map2Vertex4
;
1578 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1579 goto invalid_enum_error
;
1580 return ctx
->Transform
.Normalize
;
1581 case GL_POINT_SMOOTH
:
1582 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1583 goto invalid_enum_error
;
1584 return ctx
->Point
.SmoothFlag
;
1585 case GL_POLYGON_SMOOTH
:
1586 if (!_mesa_is_desktop_gl(ctx
))
1587 goto invalid_enum_error
;
1588 return ctx
->Polygon
.SmoothFlag
;
1589 case GL_POLYGON_STIPPLE
:
1590 if (ctx
->API
!= API_OPENGL_COMPAT
)
1591 goto invalid_enum_error
;
1592 return ctx
->Polygon
.StippleFlag
;
1593 case GL_POLYGON_OFFSET_POINT
:
1594 if (!_mesa_is_desktop_gl(ctx
))
1595 goto invalid_enum_error
;
1596 return ctx
->Polygon
.OffsetPoint
;
1597 case GL_POLYGON_OFFSET_LINE
:
1598 if (!_mesa_is_desktop_gl(ctx
))
1599 goto invalid_enum_error
;
1600 return ctx
->Polygon
.OffsetLine
;
1601 case GL_POLYGON_OFFSET_FILL
:
1602 return ctx
->Polygon
.OffsetFill
;
1603 case GL_RESCALE_NORMAL_EXT
:
1604 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1605 goto invalid_enum_error
;
1606 return ctx
->Transform
.RescaleNormals
;
1607 case GL_SCISSOR_TEST
:
1608 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1609 case GL_STENCIL_TEST
:
1610 return ctx
->Stencil
.Enabled
;
1612 if (ctx
->API
!= API_OPENGL_COMPAT
)
1613 goto invalid_enum_error
;
1614 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1616 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1617 goto invalid_enum_error
;
1618 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1620 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1621 goto invalid_enum_error
;
1622 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1623 case GL_TEXTURE_GEN_S
:
1624 case GL_TEXTURE_GEN_T
:
1625 case GL_TEXTURE_GEN_R
:
1626 case GL_TEXTURE_GEN_Q
:
1628 const struct gl_fixedfunc_texture_unit
*texUnit
=
1629 get_texcoord_unit(ctx
);
1631 if (ctx
->API
!= API_OPENGL_COMPAT
)
1632 goto invalid_enum_error
;
1635 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1636 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1640 case GL_TEXTURE_GEN_STR_OES
:
1642 const struct gl_fixedfunc_texture_unit
*texUnit
=
1643 get_texcoord_unit(ctx
);
1645 if (ctx
->API
!= API_OPENGLES
)
1646 goto invalid_enum_error
;
1649 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1650 ? GL_TRUE
: GL_FALSE
;
1654 /* client-side state */
1655 case GL_VERTEX_ARRAY
:
1656 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1657 goto invalid_enum_error
;
1658 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
1659 case GL_NORMAL_ARRAY
:
1660 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1661 goto invalid_enum_error
;
1662 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
1663 case GL_COLOR_ARRAY
:
1664 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1665 goto invalid_enum_error
;
1666 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
1667 case GL_INDEX_ARRAY
:
1668 if (ctx
->API
!= API_OPENGL_COMPAT
)
1669 goto invalid_enum_error
;
1670 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
1671 case GL_TEXTURE_COORD_ARRAY
:
1672 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1673 goto invalid_enum_error
;
1674 return !!(ctx
->Array
.VAO
->Enabled
&
1675 VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
1676 case GL_EDGE_FLAG_ARRAY
:
1677 if (ctx
->API
!= API_OPENGL_COMPAT
)
1678 goto invalid_enum_error
;
1679 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
1680 case GL_FOG_COORDINATE_ARRAY_EXT
:
1681 if (ctx
->API
!= API_OPENGL_COMPAT
)
1682 goto invalid_enum_error
;
1683 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
1684 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1685 if (ctx
->API
!= API_OPENGL_COMPAT
)
1686 goto invalid_enum_error
;
1687 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
1688 case GL_POINT_SIZE_ARRAY_OES
:
1689 if (ctx
->API
!= API_OPENGLES
)
1690 goto invalid_enum_error
;
1691 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
1693 /* GL_ARB_texture_cube_map */
1694 case GL_TEXTURE_CUBE_MAP
:
1695 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
1696 !_mesa_has_OES_texture_cube_map(ctx
))
1697 goto invalid_enum_error
;
1698 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1700 /* GL_EXT_secondary_color */
1701 case GL_COLOR_SUM_EXT
:
1702 if (ctx
->API
!= API_OPENGL_COMPAT
)
1703 goto invalid_enum_error
;
1704 return ctx
->Fog
.ColorSumEnabled
;
1706 /* GL_ARB_multisample */
1707 case GL_MULTISAMPLE_ARB
:
1708 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1709 goto invalid_enum_error
;
1710 return ctx
->Multisample
.Enabled
;
1711 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1712 return ctx
->Multisample
.SampleAlphaToCoverage
;
1713 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1714 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1715 goto invalid_enum_error
;
1716 return ctx
->Multisample
.SampleAlphaToOne
;
1717 case GL_SAMPLE_COVERAGE_ARB
:
1718 return ctx
->Multisample
.SampleCoverage
;
1719 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1720 if (!_mesa_is_desktop_gl(ctx
))
1721 goto invalid_enum_error
;
1722 return ctx
->Multisample
.SampleCoverageInvert
;
1724 /* GL_IBM_rasterpos_clip */
1725 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1726 if (ctx
->API
!= API_OPENGL_COMPAT
)
1727 goto invalid_enum_error
;
1728 return ctx
->Transform
.RasterPositionUnclipped
;
1730 /* GL_NV_point_sprite */
1731 case GL_POINT_SPRITE_NV
:
1732 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1733 goto invalid_enum_error
;
1734 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1735 return ctx
->Point
.PointSprite
;
1737 case GL_VERTEX_PROGRAM_ARB
:
1738 if (ctx
->API
!= API_OPENGL_COMPAT
)
1739 goto invalid_enum_error
;
1740 CHECK_EXTENSION(ARB_vertex_program
);
1741 return ctx
->VertexProgram
.Enabled
;
1742 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1743 /* This was added with ARB_vertex_program, but it is also used with
1744 * GLSL vertex shaders on desktop.
1746 if (!_mesa_is_desktop_gl(ctx
))
1747 goto invalid_enum_error
;
1748 CHECK_EXTENSION(ARB_vertex_program
);
1749 return ctx
->VertexProgram
.PointSizeEnabled
;
1750 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1751 if (ctx
->API
!= API_OPENGL_COMPAT
)
1752 goto invalid_enum_error
;
1753 CHECK_EXTENSION(ARB_vertex_program
);
1754 return ctx
->VertexProgram
.TwoSideEnabled
;
1756 /* GL_NV_texture_rectangle */
1757 case GL_TEXTURE_RECTANGLE_NV
:
1758 if (ctx
->API
!= API_OPENGL_COMPAT
)
1759 goto invalid_enum_error
;
1760 CHECK_EXTENSION(NV_texture_rectangle
);
1761 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1763 /* GL_EXT_stencil_two_side */
1764 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1765 if (ctx
->API
!= API_OPENGL_COMPAT
)
1766 goto invalid_enum_error
;
1767 CHECK_EXTENSION(EXT_stencil_two_side
);
1768 return ctx
->Stencil
.TestTwoSide
;
1770 case GL_FRAGMENT_PROGRAM_ARB
:
1771 if (!_mesa_has_ARB_fragment_program(ctx
))
1772 goto invalid_enum_error
;
1773 return ctx
->FragmentProgram
.Enabled
;
1775 /* GL_EXT_depth_bounds_test */
1776 case GL_DEPTH_BOUNDS_TEST_EXT
:
1777 if (!_mesa_is_desktop_gl(ctx
))
1778 goto invalid_enum_error
;
1779 CHECK_EXTENSION(EXT_depth_bounds_test
);
1780 return ctx
->Depth
.BoundsTest
;
1782 /* GL_ARB_depth_clamp */
1783 case GL_DEPTH_CLAMP
:
1784 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1785 !_mesa_has_EXT_depth_clamp(ctx
))
1786 goto invalid_enum_error
;
1787 return ctx
->Transform
.DepthClampNear
||
1788 ctx
->Transform
.DepthClampFar
;
1790 case GL_DEPTH_CLAMP_NEAR_AMD
:
1791 if (!_mesa_is_desktop_gl(ctx
))
1792 goto invalid_enum_error
;
1793 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1794 return ctx
->Transform
.DepthClampNear
;
1796 case GL_DEPTH_CLAMP_FAR_AMD
:
1797 if (!_mesa_is_desktop_gl(ctx
))
1798 goto invalid_enum_error
;
1799 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1800 return ctx
->Transform
.DepthClampFar
;
1802 case GL_FRAGMENT_SHADER_ATI
:
1803 if (ctx
->API
!= API_OPENGL_COMPAT
)
1804 goto invalid_enum_error
;
1805 CHECK_EXTENSION(ATI_fragment_shader
);
1806 return ctx
->ATIFragmentShader
.Enabled
;
1808 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1809 if (!_mesa_is_desktop_gl(ctx
))
1810 goto invalid_enum_error
;
1811 CHECK_EXTENSION(ARB_seamless_cube_map
);
1812 return ctx
->Texture
.CubeMapSeamless
;
1814 case GL_RASTERIZER_DISCARD
:
1815 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1816 goto invalid_enum_error
;
1817 CHECK_EXTENSION(EXT_transform_feedback
);
1818 return ctx
->RasterDiscard
;
1820 /* GL_NV_primitive_restart */
1821 case GL_PRIMITIVE_RESTART_NV
:
1822 if (!_mesa_has_NV_primitive_restart(ctx
))
1823 goto invalid_enum_error
;
1824 return ctx
->Array
.PrimitiveRestart
;
1826 /* GL 3.1 primitive restart */
1827 case GL_PRIMITIVE_RESTART
:
1828 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1829 goto invalid_enum_error
;
1831 return ctx
->Array
.PrimitiveRestart
;
1833 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1834 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1835 goto invalid_enum_error
;
1836 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1838 /* GL3.0 - GL_framebuffer_sRGB */
1839 case GL_FRAMEBUFFER_SRGB_EXT
:
1840 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1841 !_mesa_has_EXT_sRGB_write_control(ctx
))
1842 goto invalid_enum_error
;
1843 return ctx
->Color
.sRGBEnabled
;
1845 /* GL_OES_EGL_image_external */
1846 case GL_TEXTURE_EXTERNAL_OES
:
1847 if (!_mesa_is_gles(ctx
))
1848 goto invalid_enum_error
;
1849 CHECK_EXTENSION(OES_EGL_image_external
);
1850 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1852 /* ARB_texture_multisample */
1853 case GL_SAMPLE_MASK
:
1854 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1855 goto invalid_enum_error
;
1856 return ctx
->Multisample
.SampleMask
;
1858 /* ARB_sample_shading */
1859 case GL_SAMPLE_SHADING
:
1860 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
1861 goto invalid_enum_error
;
1862 return ctx
->Multisample
.SampleShading
;
1864 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1865 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1866 goto invalid_enum_error
;
1867 return ctx
->Color
.BlendCoherent
;
1869 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1870 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
1871 goto invalid_enum_error
;
1872 return ctx
->IntelConservativeRasterization
;
1874 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1875 if (!_mesa_has_NV_conservative_raster(ctx
))
1876 goto invalid_enum_error
;
1877 return ctx
->ConservativeRasterization
;
1879 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1880 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1881 goto invalid_enum_error
;
1882 return ctx
->TileRasterOrderFixed
;
1884 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1885 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1886 goto invalid_enum_error
;
1887 return ctx
->TileRasterOrderIncreasingX
;
1889 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1890 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1891 goto invalid_enum_error
;
1892 return ctx
->TileRasterOrderIncreasingY
;
1895 goto invalid_enum_error
;
1901 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1902 _mesa_enum_to_string(cap
));