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
, gl_vert_attrib attr
, GLboolean state
)
64 _mesa_enable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attr
);
66 _mesa_disable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attr
);
71 * Helper to enable/disable client-side state.
74 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
78 vao_state(ctx
, VERT_ATTRIB_POS
, state
);
81 vao_state(ctx
, VERT_ATTRIB_NORMAL
, state
);
84 vao_state(ctx
, VERT_ATTRIB_COLOR0
, state
);
87 vao_state(ctx
, VERT_ATTRIB_COLOR_INDEX
, state
);
89 case GL_TEXTURE_COORD_ARRAY
:
90 vao_state(ctx
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
92 case GL_EDGE_FLAG_ARRAY
:
93 vao_state(ctx
, VERT_ATTRIB_EDGEFLAG
, state
);
95 case GL_FOG_COORDINATE_ARRAY_EXT
:
96 vao_state(ctx
, VERT_ATTRIB_FOG
, state
);
98 case GL_SECONDARY_COLOR_ARRAY_EXT
:
99 vao_state(ctx
, VERT_ATTRIB_COLOR1
, state
);
102 case GL_POINT_SIZE_ARRAY_OES
:
103 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
104 ctx
->VertexProgram
.PointSizeEnabled
= state
;
105 vao_state(ctx
, VERT_ATTRIB_POINT_SIZE
, state
);
108 /* GL_NV_primitive_restart */
109 case GL_PRIMITIVE_RESTART_NV
:
110 if (!_mesa_has_NV_primitive_restart(ctx
))
111 goto invalid_enum_error
;
112 if (ctx
->Array
.PrimitiveRestart
== state
)
115 FLUSH_VERTICES(ctx
, 0);
116 ctx
->Array
.PrimitiveRestart
= state
;
117 update_derived_primitive_restart_state(ctx
);
121 goto invalid_enum_error
;
124 if (ctx
->Driver
.Enable
) {
125 ctx
->Driver
.Enable( ctx
, cap
, state
);
131 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
132 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
136 /* Helper for GL_EXT_direct_state_access following functions:
137 * - EnableClientStateIndexedEXT
138 * - EnableClientStateiEXT
139 * - DisableClientStateIndexedEXT
140 * - DisableClientStateiEXT
143 client_state_i(struct gl_context
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
147 if (cap
!= GL_TEXTURE_COORD_ARRAY
) {
148 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientStateiEXT(cap=%s)",
149 state
? "Enable" : "Disable",
150 _mesa_enum_to_string(cap
));
154 if (index
>= ctx
->Const
.MaxTextureCoordUnits
) {
155 _mesa_error(ctx
, GL_INVALID_VALUE
, "gl%sClientStateiEXT(index=%d)",
156 state
? "Enable" : "Disable",
161 saved_active
= ctx
->Array
.ActiveTexture
;
162 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
163 client_state(ctx
, cap
, state
);
164 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
169 * Enable GL capability.
170 * \param cap state to enable/disable.
172 * Get's the current context, assures that we're outside glBegin()/glEnd() and
173 * calls client_state().
176 _mesa_EnableClientState( GLenum cap
)
178 GET_CURRENT_CONTEXT(ctx
);
179 client_state( ctx
, cap
, GL_TRUE
);
184 _mesa_EnableClientStateiEXT( GLenum cap
, GLuint index
)
186 GET_CURRENT_CONTEXT(ctx
);
187 client_state_i(ctx
, cap
, index
, GL_TRUE
);
192 * Disable GL capability.
193 * \param cap state to enable/disable.
195 * Get's the current context, assures that we're outside glBegin()/glEnd() and
196 * calls client_state().
199 _mesa_DisableClientState( GLenum cap
)
201 GET_CURRENT_CONTEXT(ctx
);
202 client_state( ctx
, cap
, GL_FALSE
);
206 _mesa_DisableClientStateiEXT( GLenum cap
, GLuint index
)
208 GET_CURRENT_CONTEXT(ctx
);
209 client_state_i(ctx
, cap
, index
, GL_FALSE
);
212 #define CHECK_EXTENSION(EXTNAME) \
213 if (!ctx->Extensions.EXTNAME) { \
214 goto invalid_enum_error; \
217 #define CHECK_EXTENSION2(EXT1, EXT2) \
218 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
219 goto invalid_enum_error; \
223 * Return pointer to current texture unit for setting/getting coordinate
225 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
226 * texture unit is higher than the number of supported coordinate units.
228 static struct gl_fixedfunc_texture_unit
*
229 get_texcoord_unit(struct gl_context
*ctx
)
231 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
232 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
236 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
242 * Helper function to enable or disable a texture target.
243 * \param bit one of the TEXTURE_x_BIT values
244 * \return GL_TRUE if state is changing or GL_FALSE if no change
247 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
249 struct gl_fixedfunc_texture_unit
*texUnit
=
250 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
254 const GLbitfield newenabled
= state
255 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
257 if (texUnit
->Enabled
== newenabled
)
260 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
261 texUnit
->Enabled
= newenabled
;
267 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
268 * whether the API supports it (GLES doesn't).
271 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
273 if (ctx
->Multisample
.Enabled
== state
)
276 /* GL compatibility needs Multisample.Enable to determine program state
279 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
280 !ctx
->DriverFlags
.NewMultisampleEnable
) {
281 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
283 FLUSH_VERTICES(ctx
, 0);
286 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
287 ctx
->Multisample
.Enabled
= state
;
289 if (ctx
->Driver
.Enable
) {
290 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
295 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
296 * check for whether the API supports it (GLES doesn't).
299 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
301 if (ctx
->Color
.sRGBEnabled
== state
)
304 /* TODO: Switch i965 to the new flag and remove the conditional */
305 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
306 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
307 ctx
->Color
.sRGBEnabled
= state
;
309 if (ctx
->Driver
.Enable
) {
310 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
315 * Helper function to enable or disable state.
317 * \param ctx GL context.
318 * \param cap the state to enable/disable
319 * \param state whether to enable or disable the specified capability.
321 * Updates the current context and flushes the vertices as needed. For
322 * capabilities associated with extensions it verifies that those extensions
323 * are effectivly present before updating. Notifies the driver via
324 * dd_function_table::Enable.
327 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
329 if (MESA_VERBOSE
& VERBOSE_API
)
330 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
331 state
? "glEnable" : "glDisable",
332 _mesa_enum_to_string(cap
),
337 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
338 goto invalid_enum_error
;
339 if (ctx
->Color
.AlphaEnabled
== state
)
341 /* AlphaEnabled is used by the fixed-func fragment program */
342 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
343 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
344 ctx
->Color
.AlphaEnabled
= state
;
347 if (ctx
->API
!= API_OPENGL_COMPAT
)
348 goto invalid_enum_error
;
349 if (ctx
->Eval
.AutoNormal
== state
)
351 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
352 ctx
->Eval
.AutoNormal
= state
;
356 GLbitfield newEnabled
=
357 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
358 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
359 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
360 ctx
->Color
._AdvancedBlendMode
);
361 ctx
->Color
.BlendEnabled
= newEnabled
;
365 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
366 case GL_CLIP_DISTANCE1
:
367 case GL_CLIP_DISTANCE2
:
368 case GL_CLIP_DISTANCE3
:
369 case GL_CLIP_DISTANCE4
:
370 case GL_CLIP_DISTANCE5
:
371 case GL_CLIP_DISTANCE6
:
372 case GL_CLIP_DISTANCE7
:
374 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
376 if (p
>= ctx
->Const
.MaxClipPlanes
)
377 goto invalid_enum_error
;
379 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
380 == ((GLuint
) state
<< p
))
383 /* The compatibility profile needs _NEW_TRANSFORM to transform
384 * clip planes according to the projection matrix.
386 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
387 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
388 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
390 FLUSH_VERTICES(ctx
, 0);
392 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
395 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
397 /* The projection matrix transforms the clip plane. */
398 /* TODO: glEnable might not be the best place to do it. */
399 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
400 _mesa_update_clip_plane(ctx
, p
);
401 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
405 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
409 case GL_COLOR_MATERIAL
:
410 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
411 goto invalid_enum_error
;
412 if (ctx
->Light
.ColorMaterialEnabled
== state
)
414 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
415 FLUSH_CURRENT(ctx
, 0);
416 ctx
->Light
.ColorMaterialEnabled
= state
;
418 _mesa_update_color_material( ctx
,
419 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
423 if (ctx
->Polygon
.CullFlag
== state
)
426 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
427 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
428 ctx
->Polygon
.CullFlag
= state
;
431 if (ctx
->Depth
.Test
== state
)
433 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
434 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
435 ctx
->Depth
.Test
= state
;
437 case GL_DEBUG_OUTPUT
:
438 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
439 _mesa_set_debug_state_int(ctx
, cap
, state
);
442 if (ctx
->Color
.DitherFlag
== state
)
444 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
445 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
446 ctx
->Color
.DitherFlag
= state
;
449 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
450 goto invalid_enum_error
;
451 if (ctx
->Fog
.Enabled
== state
)
453 FLUSH_VERTICES(ctx
, _NEW_FOG
);
454 ctx
->Fog
.Enabled
= state
;
455 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
465 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
466 goto invalid_enum_error
;
467 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
469 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
470 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
472 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
475 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
479 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
480 goto invalid_enum_error
;
481 if (ctx
->Light
.Enabled
== state
)
483 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
484 ctx
->Light
.Enabled
= state
;
487 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
488 goto invalid_enum_error
;
489 if (ctx
->Line
.SmoothFlag
== state
)
491 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
492 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
493 ctx
->Line
.SmoothFlag
= state
;
495 case GL_LINE_STIPPLE
:
496 if (ctx
->API
!= API_OPENGL_COMPAT
)
497 goto invalid_enum_error
;
498 if (ctx
->Line
.StippleFlag
== state
)
500 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
501 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
502 ctx
->Line
.StippleFlag
= state
;
504 case GL_INDEX_LOGIC_OP
:
505 if (ctx
->API
!= API_OPENGL_COMPAT
)
506 goto invalid_enum_error
;
507 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
509 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
510 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
511 ctx
->Color
.IndexLogicOpEnabled
= state
;
513 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
514 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
515 goto invalid_enum_error
;
516 if (ctx
->IntelConservativeRasterization
== state
)
518 FLUSH_VERTICES(ctx
, 0);
519 ctx
->NewDriverState
|=
520 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
521 ctx
->IntelConservativeRasterization
= state
;
523 case GL_CONSERVATIVE_RASTERIZATION_NV
:
524 if (!_mesa_has_NV_conservative_raster(ctx
))
525 goto invalid_enum_error
;
526 if (ctx
->ConservativeRasterization
== state
)
528 FLUSH_VERTICES(ctx
, 0);
529 ctx
->NewDriverState
|=
530 ctx
->DriverFlags
.NewNvConservativeRasterization
;
531 ctx
->ConservativeRasterization
= state
;
533 case GL_COLOR_LOGIC_OP
:
534 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
535 goto invalid_enum_error
;
536 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
538 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
539 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
540 ctx
->Color
.ColorLogicOpEnabled
= state
;
542 case GL_MAP1_COLOR_4
:
543 if (ctx
->API
!= API_OPENGL_COMPAT
)
544 goto invalid_enum_error
;
545 if (ctx
->Eval
.Map1Color4
== state
)
547 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
548 ctx
->Eval
.Map1Color4
= state
;
551 if (ctx
->API
!= API_OPENGL_COMPAT
)
552 goto invalid_enum_error
;
553 if (ctx
->Eval
.Map1Index
== state
)
555 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
556 ctx
->Eval
.Map1Index
= state
;
559 if (ctx
->API
!= API_OPENGL_COMPAT
)
560 goto invalid_enum_error
;
561 if (ctx
->Eval
.Map1Normal
== state
)
563 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
564 ctx
->Eval
.Map1Normal
= state
;
566 case GL_MAP1_TEXTURE_COORD_1
:
567 if (ctx
->API
!= API_OPENGL_COMPAT
)
568 goto invalid_enum_error
;
569 if (ctx
->Eval
.Map1TextureCoord1
== state
)
571 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
572 ctx
->Eval
.Map1TextureCoord1
= state
;
574 case GL_MAP1_TEXTURE_COORD_2
:
575 if (ctx
->API
!= API_OPENGL_COMPAT
)
576 goto invalid_enum_error
;
577 if (ctx
->Eval
.Map1TextureCoord2
== state
)
579 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
580 ctx
->Eval
.Map1TextureCoord2
= state
;
582 case GL_MAP1_TEXTURE_COORD_3
:
583 if (ctx
->API
!= API_OPENGL_COMPAT
)
584 goto invalid_enum_error
;
585 if (ctx
->Eval
.Map1TextureCoord3
== state
)
587 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
588 ctx
->Eval
.Map1TextureCoord3
= state
;
590 case GL_MAP1_TEXTURE_COORD_4
:
591 if (ctx
->API
!= API_OPENGL_COMPAT
)
592 goto invalid_enum_error
;
593 if (ctx
->Eval
.Map1TextureCoord4
== state
)
595 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
596 ctx
->Eval
.Map1TextureCoord4
= state
;
598 case GL_MAP1_VERTEX_3
:
599 if (ctx
->API
!= API_OPENGL_COMPAT
)
600 goto invalid_enum_error
;
601 if (ctx
->Eval
.Map1Vertex3
== state
)
603 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
604 ctx
->Eval
.Map1Vertex3
= state
;
606 case GL_MAP1_VERTEX_4
:
607 if (ctx
->API
!= API_OPENGL_COMPAT
)
608 goto invalid_enum_error
;
609 if (ctx
->Eval
.Map1Vertex4
== state
)
611 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
612 ctx
->Eval
.Map1Vertex4
= state
;
614 case GL_MAP2_COLOR_4
:
615 if (ctx
->API
!= API_OPENGL_COMPAT
)
616 goto invalid_enum_error
;
617 if (ctx
->Eval
.Map2Color4
== state
)
619 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
620 ctx
->Eval
.Map2Color4
= state
;
623 if (ctx
->API
!= API_OPENGL_COMPAT
)
624 goto invalid_enum_error
;
625 if (ctx
->Eval
.Map2Index
== state
)
627 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
628 ctx
->Eval
.Map2Index
= state
;
631 if (ctx
->API
!= API_OPENGL_COMPAT
)
632 goto invalid_enum_error
;
633 if (ctx
->Eval
.Map2Normal
== state
)
635 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
636 ctx
->Eval
.Map2Normal
= state
;
638 case GL_MAP2_TEXTURE_COORD_1
:
639 if (ctx
->API
!= API_OPENGL_COMPAT
)
640 goto invalid_enum_error
;
641 if (ctx
->Eval
.Map2TextureCoord1
== state
)
643 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
644 ctx
->Eval
.Map2TextureCoord1
= state
;
646 case GL_MAP2_TEXTURE_COORD_2
:
647 if (ctx
->API
!= API_OPENGL_COMPAT
)
648 goto invalid_enum_error
;
649 if (ctx
->Eval
.Map2TextureCoord2
== state
)
651 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
652 ctx
->Eval
.Map2TextureCoord2
= state
;
654 case GL_MAP2_TEXTURE_COORD_3
:
655 if (ctx
->API
!= API_OPENGL_COMPAT
)
656 goto invalid_enum_error
;
657 if (ctx
->Eval
.Map2TextureCoord3
== state
)
659 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
660 ctx
->Eval
.Map2TextureCoord3
= state
;
662 case GL_MAP2_TEXTURE_COORD_4
:
663 if (ctx
->API
!= API_OPENGL_COMPAT
)
664 goto invalid_enum_error
;
665 if (ctx
->Eval
.Map2TextureCoord4
== state
)
667 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
668 ctx
->Eval
.Map2TextureCoord4
= state
;
670 case GL_MAP2_VERTEX_3
:
671 if (ctx
->API
!= API_OPENGL_COMPAT
)
672 goto invalid_enum_error
;
673 if (ctx
->Eval
.Map2Vertex3
== state
)
675 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
676 ctx
->Eval
.Map2Vertex3
= state
;
678 case GL_MAP2_VERTEX_4
:
679 if (ctx
->API
!= API_OPENGL_COMPAT
)
680 goto invalid_enum_error
;
681 if (ctx
->Eval
.Map2Vertex4
== state
)
683 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
684 ctx
->Eval
.Map2Vertex4
= state
;
687 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
688 goto invalid_enum_error
;
689 if (ctx
->Transform
.Normalize
== state
)
691 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
692 ctx
->Transform
.Normalize
= state
;
694 case GL_POINT_SMOOTH
:
695 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
696 goto invalid_enum_error
;
697 if (ctx
->Point
.SmoothFlag
== state
)
699 FLUSH_VERTICES(ctx
, _NEW_POINT
);
700 ctx
->Point
.SmoothFlag
= state
;
702 case GL_POLYGON_SMOOTH
:
703 if (!_mesa_is_desktop_gl(ctx
))
704 goto invalid_enum_error
;
705 if (ctx
->Polygon
.SmoothFlag
== state
)
708 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
709 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
710 ctx
->Polygon
.SmoothFlag
= state
;
712 case GL_POLYGON_STIPPLE
:
713 if (ctx
->API
!= API_OPENGL_COMPAT
)
714 goto invalid_enum_error
;
715 if (ctx
->Polygon
.StippleFlag
== state
)
718 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
719 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
720 ctx
->Polygon
.StippleFlag
= state
;
722 case GL_POLYGON_OFFSET_POINT
:
723 if (!_mesa_is_desktop_gl(ctx
))
724 goto invalid_enum_error
;
725 if (ctx
->Polygon
.OffsetPoint
== state
)
728 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
729 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
730 ctx
->Polygon
.OffsetPoint
= state
;
732 case GL_POLYGON_OFFSET_LINE
:
733 if (!_mesa_is_desktop_gl(ctx
))
734 goto invalid_enum_error
;
735 if (ctx
->Polygon
.OffsetLine
== state
)
738 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
739 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
740 ctx
->Polygon
.OffsetLine
= state
;
742 case GL_POLYGON_OFFSET_FILL
:
743 if (ctx
->Polygon
.OffsetFill
== state
)
746 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
747 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
748 ctx
->Polygon
.OffsetFill
= state
;
750 case GL_RESCALE_NORMAL_EXT
:
751 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
752 goto invalid_enum_error
;
753 if (ctx
->Transform
.RescaleNormals
== state
)
755 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
756 ctx
->Transform
.RescaleNormals
= state
;
758 case GL_SCISSOR_TEST
:
760 /* Must expand glEnable to all scissors */
761 GLbitfield newEnabled
=
762 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
763 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
764 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
766 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
767 ctx
->Scissor
.EnableFlags
= newEnabled
;
771 case GL_STENCIL_TEST
:
772 if (ctx
->Stencil
.Enabled
== state
)
774 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
775 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
776 ctx
->Stencil
.Enabled
= state
;
779 if (ctx
->API
!= API_OPENGL_COMPAT
)
780 goto invalid_enum_error
;
781 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
786 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
787 goto invalid_enum_error
;
788 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
793 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
794 goto invalid_enum_error
;
795 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
799 case GL_TEXTURE_GEN_S
:
800 case GL_TEXTURE_GEN_T
:
801 case GL_TEXTURE_GEN_R
:
802 case GL_TEXTURE_GEN_Q
:
804 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
806 if (ctx
->API
!= API_OPENGL_COMPAT
)
807 goto invalid_enum_error
;
810 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
811 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
813 newenabled
|= coordBit
;
814 if (texUnit
->TexGenEnabled
== newenabled
)
816 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
817 texUnit
->TexGenEnabled
= newenabled
;
822 case GL_TEXTURE_GEN_STR_OES
:
823 /* disable S, T, and R at the same time */
825 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
827 if (ctx
->API
!= API_OPENGLES
)
828 goto invalid_enum_error
;
832 texUnit
->TexGenEnabled
& ~STR_BITS
;
834 newenabled
|= STR_BITS
;
835 if (texUnit
->TexGenEnabled
== newenabled
)
837 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
838 texUnit
->TexGenEnabled
= newenabled
;
843 /* client-side state */
844 case GL_VERTEX_ARRAY
:
845 case GL_NORMAL_ARRAY
:
847 case GL_TEXTURE_COORD_ARRAY
:
848 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
849 goto invalid_enum_error
;
850 client_state( ctx
, cap
, state
);
853 case GL_EDGE_FLAG_ARRAY
:
854 case GL_FOG_COORDINATE_ARRAY_EXT
:
855 case GL_SECONDARY_COLOR_ARRAY_EXT
:
856 if (ctx
->API
!= API_OPENGL_COMPAT
)
857 goto invalid_enum_error
;
858 client_state( ctx
, cap
, state
);
860 case GL_POINT_SIZE_ARRAY_OES
:
861 if (ctx
->API
!= API_OPENGLES
)
862 goto invalid_enum_error
;
863 client_state( ctx
, cap
, state
);
866 /* GL_ARB_texture_cube_map */
867 case GL_TEXTURE_CUBE_MAP
:
868 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
869 !_mesa_has_OES_texture_cube_map(ctx
))
870 goto invalid_enum_error
;
871 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
876 /* GL_EXT_secondary_color */
877 case GL_COLOR_SUM_EXT
:
878 if (ctx
->API
!= API_OPENGL_COMPAT
)
879 goto invalid_enum_error
;
880 if (ctx
->Fog
.ColorSumEnabled
== state
)
882 FLUSH_VERTICES(ctx
, _NEW_FOG
);
883 ctx
->Fog
.ColorSumEnabled
= state
;
886 /* GL_ARB_multisample */
887 case GL_MULTISAMPLE_ARB
:
888 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
889 goto invalid_enum_error
;
890 _mesa_set_multisample(ctx
, state
);
892 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
893 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
895 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
897 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
898 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
900 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
901 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
902 goto invalid_enum_error
;
903 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
905 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
907 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
908 ctx
->Multisample
.SampleAlphaToOne
= state
;
910 case GL_SAMPLE_COVERAGE_ARB
:
911 if (ctx
->Multisample
.SampleCoverage
== state
)
913 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
915 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
916 ctx
->Multisample
.SampleCoverage
= state
;
918 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
919 if (!_mesa_is_desktop_gl(ctx
))
920 goto invalid_enum_error
;
921 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
923 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
925 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
926 ctx
->Multisample
.SampleCoverageInvert
= state
;
929 /* GL_ARB_sample_shading */
930 case GL_SAMPLE_SHADING
:
931 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
932 goto invalid_enum_error
;
933 if (ctx
->Multisample
.SampleShading
== state
)
935 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
937 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
938 ctx
->Multisample
.SampleShading
= state
;
941 /* GL_IBM_rasterpos_clip */
942 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
943 if (ctx
->API
!= API_OPENGL_COMPAT
)
944 goto invalid_enum_error
;
945 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
947 FLUSH_VERTICES(ctx
, 0);
948 ctx
->Transform
.RasterPositionUnclipped
= state
;
951 /* GL_NV_point_sprite */
952 case GL_POINT_SPRITE_NV
:
953 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
954 goto invalid_enum_error
;
955 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
);
956 if (ctx
->Point
.PointSprite
== state
)
958 FLUSH_VERTICES(ctx
, _NEW_POINT
);
959 ctx
->Point
.PointSprite
= state
;
962 case GL_VERTEX_PROGRAM_ARB
:
963 if (ctx
->API
!= API_OPENGL_COMPAT
)
964 goto invalid_enum_error
;
965 CHECK_EXTENSION(ARB_vertex_program
);
966 if (ctx
->VertexProgram
.Enabled
== state
)
968 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
969 ctx
->VertexProgram
.Enabled
= state
;
970 _mesa_update_vertex_processing_mode(ctx
);
972 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
973 /* This was added with ARB_vertex_program, but it is also used with
974 * GLSL vertex shaders on desktop.
976 if (!_mesa_is_desktop_gl(ctx
))
977 goto invalid_enum_error
;
978 CHECK_EXTENSION(ARB_vertex_program
);
979 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
981 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
982 ctx
->VertexProgram
.PointSizeEnabled
= state
;
984 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
985 if (ctx
->API
!= API_OPENGL_COMPAT
)
986 goto invalid_enum_error
;
987 CHECK_EXTENSION(ARB_vertex_program
);
988 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
990 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
991 ctx
->VertexProgram
.TwoSideEnabled
= state
;
994 /* GL_NV_texture_rectangle */
995 case GL_TEXTURE_RECTANGLE_NV
:
996 if (ctx
->API
!= API_OPENGL_COMPAT
)
997 goto invalid_enum_error
;
998 CHECK_EXTENSION(NV_texture_rectangle
);
999 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
1004 /* GL_EXT_stencil_two_side */
1005 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1006 if (ctx
->API
!= API_OPENGL_COMPAT
)
1007 goto invalid_enum_error
;
1008 CHECK_EXTENSION(EXT_stencil_two_side
);
1009 if (ctx
->Stencil
.TestTwoSide
== state
)
1011 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
1012 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
1013 ctx
->Stencil
.TestTwoSide
= state
;
1015 ctx
->Stencil
._BackFace
= 2;
1017 ctx
->Stencil
._BackFace
= 1;
1021 case GL_FRAGMENT_PROGRAM_ARB
:
1022 if (!_mesa_has_ARB_fragment_program(ctx
))
1023 goto invalid_enum_error
;
1024 if (ctx
->FragmentProgram
.Enabled
== state
)
1026 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1027 ctx
->FragmentProgram
.Enabled
= state
;
1030 /* GL_EXT_depth_bounds_test */
1031 case GL_DEPTH_BOUNDS_TEST_EXT
:
1032 if (!_mesa_is_desktop_gl(ctx
))
1033 goto invalid_enum_error
;
1034 CHECK_EXTENSION(EXT_depth_bounds_test
);
1035 if (ctx
->Depth
.BoundsTest
== state
)
1037 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
1038 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
1039 ctx
->Depth
.BoundsTest
= state
;
1042 case GL_DEPTH_CLAMP
:
1043 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1044 !_mesa_has_EXT_depth_clamp(ctx
))
1045 goto invalid_enum_error
;
1046 if (ctx
->Transform
.DepthClampNear
== state
&&
1047 ctx
->Transform
.DepthClampFar
== state
)
1049 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1051 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1052 ctx
->Transform
.DepthClampNear
= state
;
1053 ctx
->Transform
.DepthClampFar
= state
;
1056 case GL_DEPTH_CLAMP_NEAR_AMD
:
1057 if (!_mesa_is_desktop_gl(ctx
))
1058 goto invalid_enum_error
;
1059 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1060 if (ctx
->Transform
.DepthClampNear
== state
)
1062 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1064 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1065 ctx
->Transform
.DepthClampNear
= state
;
1068 case GL_DEPTH_CLAMP_FAR_AMD
:
1069 if (!_mesa_is_desktop_gl(ctx
))
1070 goto invalid_enum_error
;
1071 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1072 if (ctx
->Transform
.DepthClampFar
== state
)
1074 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1076 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1077 ctx
->Transform
.DepthClampFar
= state
;
1080 case GL_FRAGMENT_SHADER_ATI
:
1081 if (ctx
->API
!= API_OPENGL_COMPAT
)
1082 goto invalid_enum_error
;
1083 CHECK_EXTENSION(ATI_fragment_shader
);
1084 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1086 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1087 ctx
->ATIFragmentShader
.Enabled
= state
;
1090 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1091 if (!_mesa_is_desktop_gl(ctx
))
1092 goto invalid_enum_error
;
1093 CHECK_EXTENSION(ARB_seamless_cube_map
);
1094 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1095 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1096 ctx
->Texture
.CubeMapSeamless
= state
;
1100 case GL_RASTERIZER_DISCARD
:
1101 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1102 goto invalid_enum_error
;
1103 CHECK_EXTENSION(EXT_transform_feedback
);
1104 if (ctx
->RasterDiscard
!= state
) {
1105 FLUSH_VERTICES(ctx
, 0);
1106 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1107 ctx
->RasterDiscard
= state
;
1111 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1112 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1113 goto invalid_enum_error
;
1114 if (ctx
->TileRasterOrderFixed
!= state
) {
1115 FLUSH_VERTICES(ctx
, 0);
1116 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1117 ctx
->TileRasterOrderFixed
= state
;
1121 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1122 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1123 goto invalid_enum_error
;
1124 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1125 FLUSH_VERTICES(ctx
, 0);
1126 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1127 ctx
->TileRasterOrderIncreasingX
= state
;
1131 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1132 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1133 goto invalid_enum_error
;
1134 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1135 FLUSH_VERTICES(ctx
, 0);
1136 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1137 ctx
->TileRasterOrderIncreasingY
= state
;
1141 /* GL 3.1 primitive restart. Note: this enum is different from
1142 * GL_PRIMITIVE_RESTART_NV (which is client state).
1144 case GL_PRIMITIVE_RESTART
:
1145 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1146 goto invalid_enum_error
;
1148 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1149 FLUSH_VERTICES(ctx
, 0);
1150 ctx
->Array
.PrimitiveRestart
= state
;
1151 update_derived_primitive_restart_state(ctx
);
1155 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1156 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1157 goto invalid_enum_error
;
1158 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1159 FLUSH_VERTICES(ctx
, 0);
1160 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1161 update_derived_primitive_restart_state(ctx
);
1165 /* GL3.0 - GL_framebuffer_sRGB */
1166 case GL_FRAMEBUFFER_SRGB_EXT
:
1167 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1168 !_mesa_has_EXT_sRGB_write_control(ctx
))
1169 goto invalid_enum_error
;
1170 _mesa_set_framebuffer_srgb(ctx
, state
);
1173 /* GL_OES_EGL_image_external */
1174 case GL_TEXTURE_EXTERNAL_OES
:
1175 if (!_mesa_is_gles(ctx
))
1176 goto invalid_enum_error
;
1177 CHECK_EXTENSION(OES_EGL_image_external
);
1178 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1183 /* ARB_texture_multisample */
1184 case GL_SAMPLE_MASK
:
1185 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1186 goto invalid_enum_error
;
1187 if (ctx
->Multisample
.SampleMask
== state
)
1189 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1191 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1192 ctx
->Multisample
.SampleMask
= state
;
1195 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1196 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1197 goto invalid_enum_error
;
1198 if (ctx
->Color
.BlendCoherent
== state
)
1200 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1201 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1202 ctx
->Color
.BlendCoherent
= state
;
1206 goto invalid_enum_error
;
1209 if (ctx
->Driver
.Enable
) {
1210 ctx
->Driver
.Enable( ctx
, cap
, state
);
1216 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1217 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1222 * Enable GL capability. Called by glEnable()
1223 * \param cap state to enable.
1226 _mesa_Enable( GLenum cap
)
1228 GET_CURRENT_CONTEXT(ctx
);
1230 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1235 * Disable GL capability. Called by glDisable()
1236 * \param cap state to disable.
1239 _mesa_Disable( GLenum cap
)
1241 GET_CURRENT_CONTEXT(ctx
);
1243 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1249 * Enable/disable an indexed state var.
1252 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1253 GLuint index
, GLboolean state
)
1255 assert(state
== 0 || state
== 1);
1258 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1259 goto invalid_enum_error
;
1261 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1262 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1263 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1266 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1267 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1270 enabled
|= (1 << index
);
1272 enabled
&= ~(1 << index
);
1274 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1275 ctx
->Color
._AdvancedBlendMode
);
1276 ctx
->Color
.BlendEnabled
= enabled
;
1279 case GL_SCISSOR_TEST
:
1280 if (index
>= ctx
->Const
.MaxViewports
) {
1281 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1282 state
? "glEnablei" : "glDisablei", index
);
1285 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1287 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1288 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1290 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1292 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1295 /* EXT_direct_state_access */
1299 case GL_TEXTURE_CUBE_MAP
:
1300 case GL_TEXTURE_GEN_S
:
1301 case GL_TEXTURE_GEN_T
:
1302 case GL_TEXTURE_GEN_R
:
1303 case GL_TEXTURE_GEN_Q
:
1304 case GL_TEXTURE_RECTANGLE_ARB
: {
1305 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1306 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1307 ctx
->Const
.MaxTextureCoordUnits
)) {
1308 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1309 state
? "glEnablei" : "glDisablei", index
);
1312 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1313 _mesa_set_enable( ctx
, cap
, state
);
1314 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1318 goto invalid_enum_error
;
1323 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1324 state
? "glEnablei" : "glDisablei",
1325 _mesa_enum_to_string(cap
));
1330 _mesa_Disablei( GLenum cap
, GLuint index
)
1332 GET_CURRENT_CONTEXT(ctx
);
1333 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1338 _mesa_Enablei( GLenum cap
, GLuint index
)
1340 GET_CURRENT_CONTEXT(ctx
);
1341 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1345 GLboolean GLAPIENTRY
1346 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1348 GET_CURRENT_CONTEXT(ctx
);
1349 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1352 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1353 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1357 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1358 case GL_SCISSOR_TEST
:
1359 if (index
>= ctx
->Const
.MaxViewports
) {
1360 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1364 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1365 /* EXT_direct_state_access */
1369 case GL_TEXTURE_CUBE_MAP
:
1370 case GL_TEXTURE_GEN_S
:
1371 case GL_TEXTURE_GEN_T
:
1372 case GL_TEXTURE_GEN_R
:
1373 case GL_TEXTURE_GEN_Q
:
1374 case GL_TEXTURE_RECTANGLE_ARB
: {
1376 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1377 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1378 ctx
->Const
.MaxTextureCoordUnits
)) {
1379 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1383 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1384 state
= _mesa_IsEnabled(cap
);
1385 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1389 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1390 _mesa_enum_to_string(cap
));
1398 * Helper function to determine whether a texture target is enabled.
1401 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1403 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1404 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
1409 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1414 * Return simple enable/disable state.
1416 * \param cap state variable to query.
1418 * Returns the state of the specified capability from the current GL context.
1419 * For the capabilities associated with extensions verifies that those
1420 * extensions are effectively present before reporting.
1422 GLboolean GLAPIENTRY
1423 _mesa_IsEnabled( GLenum cap
)
1425 GET_CURRENT_CONTEXT(ctx
);
1426 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1430 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1431 goto invalid_enum_error
;
1432 return ctx
->Color
.AlphaEnabled
;
1433 case GL_AUTO_NORMAL
:
1434 if (ctx
->API
!= API_OPENGL_COMPAT
)
1435 goto invalid_enum_error
;
1436 return ctx
->Eval
.AutoNormal
;
1438 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1439 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1440 case GL_CLIP_DISTANCE1
:
1441 case GL_CLIP_DISTANCE2
:
1442 case GL_CLIP_DISTANCE3
:
1443 case GL_CLIP_DISTANCE4
:
1444 case GL_CLIP_DISTANCE5
:
1445 case GL_CLIP_DISTANCE6
:
1446 case GL_CLIP_DISTANCE7
: {
1447 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1449 if (p
>= ctx
->Const
.MaxClipPlanes
)
1450 goto invalid_enum_error
;
1452 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1454 case GL_COLOR_MATERIAL
:
1455 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1456 goto invalid_enum_error
;
1457 return ctx
->Light
.ColorMaterialEnabled
;
1459 return ctx
->Polygon
.CullFlag
;
1460 case GL_DEBUG_OUTPUT
:
1461 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1462 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1464 return ctx
->Depth
.Test
;
1466 return ctx
->Color
.DitherFlag
;
1468 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1469 goto invalid_enum_error
;
1470 return ctx
->Fog
.Enabled
;
1472 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1473 goto invalid_enum_error
;
1474 return ctx
->Light
.Enabled
;
1483 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1484 goto invalid_enum_error
;
1485 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1486 case GL_LINE_SMOOTH
:
1487 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1488 goto invalid_enum_error
;
1489 return ctx
->Line
.SmoothFlag
;
1490 case GL_LINE_STIPPLE
:
1491 if (ctx
->API
!= API_OPENGL_COMPAT
)
1492 goto invalid_enum_error
;
1493 return ctx
->Line
.StippleFlag
;
1494 case GL_INDEX_LOGIC_OP
:
1495 if (ctx
->API
!= API_OPENGL_COMPAT
)
1496 goto invalid_enum_error
;
1497 return ctx
->Color
.IndexLogicOpEnabled
;
1498 case GL_COLOR_LOGIC_OP
:
1499 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1500 goto invalid_enum_error
;
1501 return ctx
->Color
.ColorLogicOpEnabled
;
1502 case GL_MAP1_COLOR_4
:
1503 if (ctx
->API
!= API_OPENGL_COMPAT
)
1504 goto invalid_enum_error
;
1505 return ctx
->Eval
.Map1Color4
;
1507 if (ctx
->API
!= API_OPENGL_COMPAT
)
1508 goto invalid_enum_error
;
1509 return ctx
->Eval
.Map1Index
;
1510 case GL_MAP1_NORMAL
:
1511 if (ctx
->API
!= API_OPENGL_COMPAT
)
1512 goto invalid_enum_error
;
1513 return ctx
->Eval
.Map1Normal
;
1514 case GL_MAP1_TEXTURE_COORD_1
:
1515 if (ctx
->API
!= API_OPENGL_COMPAT
)
1516 goto invalid_enum_error
;
1517 return ctx
->Eval
.Map1TextureCoord1
;
1518 case GL_MAP1_TEXTURE_COORD_2
:
1519 if (ctx
->API
!= API_OPENGL_COMPAT
)
1520 goto invalid_enum_error
;
1521 return ctx
->Eval
.Map1TextureCoord2
;
1522 case GL_MAP1_TEXTURE_COORD_3
:
1523 if (ctx
->API
!= API_OPENGL_COMPAT
)
1524 goto invalid_enum_error
;
1525 return ctx
->Eval
.Map1TextureCoord3
;
1526 case GL_MAP1_TEXTURE_COORD_4
:
1527 if (ctx
->API
!= API_OPENGL_COMPAT
)
1528 goto invalid_enum_error
;
1529 return ctx
->Eval
.Map1TextureCoord4
;
1530 case GL_MAP1_VERTEX_3
:
1531 if (ctx
->API
!= API_OPENGL_COMPAT
)
1532 goto invalid_enum_error
;
1533 return ctx
->Eval
.Map1Vertex3
;
1534 case GL_MAP1_VERTEX_4
:
1535 if (ctx
->API
!= API_OPENGL_COMPAT
)
1536 goto invalid_enum_error
;
1537 return ctx
->Eval
.Map1Vertex4
;
1538 case GL_MAP2_COLOR_4
:
1539 if (ctx
->API
!= API_OPENGL_COMPAT
)
1540 goto invalid_enum_error
;
1541 return ctx
->Eval
.Map2Color4
;
1543 if (ctx
->API
!= API_OPENGL_COMPAT
)
1544 goto invalid_enum_error
;
1545 return ctx
->Eval
.Map2Index
;
1546 case GL_MAP2_NORMAL
:
1547 if (ctx
->API
!= API_OPENGL_COMPAT
)
1548 goto invalid_enum_error
;
1549 return ctx
->Eval
.Map2Normal
;
1550 case GL_MAP2_TEXTURE_COORD_1
:
1551 if (ctx
->API
!= API_OPENGL_COMPAT
)
1552 goto invalid_enum_error
;
1553 return ctx
->Eval
.Map2TextureCoord1
;
1554 case GL_MAP2_TEXTURE_COORD_2
:
1555 if (ctx
->API
!= API_OPENGL_COMPAT
)
1556 goto invalid_enum_error
;
1557 return ctx
->Eval
.Map2TextureCoord2
;
1558 case GL_MAP2_TEXTURE_COORD_3
:
1559 if (ctx
->API
!= API_OPENGL_COMPAT
)
1560 goto invalid_enum_error
;
1561 return ctx
->Eval
.Map2TextureCoord3
;
1562 case GL_MAP2_TEXTURE_COORD_4
:
1563 if (ctx
->API
!= API_OPENGL_COMPAT
)
1564 goto invalid_enum_error
;
1565 return ctx
->Eval
.Map2TextureCoord4
;
1566 case GL_MAP2_VERTEX_3
:
1567 if (ctx
->API
!= API_OPENGL_COMPAT
)
1568 goto invalid_enum_error
;
1569 return ctx
->Eval
.Map2Vertex3
;
1570 case GL_MAP2_VERTEX_4
:
1571 if (ctx
->API
!= API_OPENGL_COMPAT
)
1572 goto invalid_enum_error
;
1573 return ctx
->Eval
.Map2Vertex4
;
1575 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1576 goto invalid_enum_error
;
1577 return ctx
->Transform
.Normalize
;
1578 case GL_POINT_SMOOTH
:
1579 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1580 goto invalid_enum_error
;
1581 return ctx
->Point
.SmoothFlag
;
1582 case GL_POLYGON_SMOOTH
:
1583 if (!_mesa_is_desktop_gl(ctx
))
1584 goto invalid_enum_error
;
1585 return ctx
->Polygon
.SmoothFlag
;
1586 case GL_POLYGON_STIPPLE
:
1587 if (ctx
->API
!= API_OPENGL_COMPAT
)
1588 goto invalid_enum_error
;
1589 return ctx
->Polygon
.StippleFlag
;
1590 case GL_POLYGON_OFFSET_POINT
:
1591 if (!_mesa_is_desktop_gl(ctx
))
1592 goto invalid_enum_error
;
1593 return ctx
->Polygon
.OffsetPoint
;
1594 case GL_POLYGON_OFFSET_LINE
:
1595 if (!_mesa_is_desktop_gl(ctx
))
1596 goto invalid_enum_error
;
1597 return ctx
->Polygon
.OffsetLine
;
1598 case GL_POLYGON_OFFSET_FILL
:
1599 return ctx
->Polygon
.OffsetFill
;
1600 case GL_RESCALE_NORMAL_EXT
:
1601 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1602 goto invalid_enum_error
;
1603 return ctx
->Transform
.RescaleNormals
;
1604 case GL_SCISSOR_TEST
:
1605 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1606 case GL_STENCIL_TEST
:
1607 return ctx
->Stencil
.Enabled
;
1609 if (ctx
->API
!= API_OPENGL_COMPAT
)
1610 goto invalid_enum_error
;
1611 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1613 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1614 goto invalid_enum_error
;
1615 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1617 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1618 goto invalid_enum_error
;
1619 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1620 case GL_TEXTURE_GEN_S
:
1621 case GL_TEXTURE_GEN_T
:
1622 case GL_TEXTURE_GEN_R
:
1623 case GL_TEXTURE_GEN_Q
:
1625 const struct gl_fixedfunc_texture_unit
*texUnit
=
1626 get_texcoord_unit(ctx
);
1628 if (ctx
->API
!= API_OPENGL_COMPAT
)
1629 goto invalid_enum_error
;
1632 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1633 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1637 case GL_TEXTURE_GEN_STR_OES
:
1639 const struct gl_fixedfunc_texture_unit
*texUnit
=
1640 get_texcoord_unit(ctx
);
1642 if (ctx
->API
!= API_OPENGLES
)
1643 goto invalid_enum_error
;
1646 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1647 ? GL_TRUE
: GL_FALSE
;
1651 /* client-side state */
1652 case GL_VERTEX_ARRAY
:
1653 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1654 goto invalid_enum_error
;
1655 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
1656 case GL_NORMAL_ARRAY
:
1657 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1658 goto invalid_enum_error
;
1659 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
1660 case GL_COLOR_ARRAY
:
1661 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1662 goto invalid_enum_error
;
1663 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
1664 case GL_INDEX_ARRAY
:
1665 if (ctx
->API
!= API_OPENGL_COMPAT
)
1666 goto invalid_enum_error
;
1667 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
1668 case GL_TEXTURE_COORD_ARRAY
:
1669 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1670 goto invalid_enum_error
;
1671 return !!(ctx
->Array
.VAO
->Enabled
&
1672 VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
1673 case GL_EDGE_FLAG_ARRAY
:
1674 if (ctx
->API
!= API_OPENGL_COMPAT
)
1675 goto invalid_enum_error
;
1676 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
1677 case GL_FOG_COORDINATE_ARRAY_EXT
:
1678 if (ctx
->API
!= API_OPENGL_COMPAT
)
1679 goto invalid_enum_error
;
1680 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
1681 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1682 if (ctx
->API
!= API_OPENGL_COMPAT
)
1683 goto invalid_enum_error
;
1684 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
1685 case GL_POINT_SIZE_ARRAY_OES
:
1686 if (ctx
->API
!= API_OPENGLES
)
1687 goto invalid_enum_error
;
1688 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
1690 /* GL_ARB_texture_cube_map */
1691 case GL_TEXTURE_CUBE_MAP
:
1692 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
1693 !_mesa_has_OES_texture_cube_map(ctx
))
1694 goto invalid_enum_error
;
1695 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1697 /* GL_EXT_secondary_color */
1698 case GL_COLOR_SUM_EXT
:
1699 if (ctx
->API
!= API_OPENGL_COMPAT
)
1700 goto invalid_enum_error
;
1701 return ctx
->Fog
.ColorSumEnabled
;
1703 /* GL_ARB_multisample */
1704 case GL_MULTISAMPLE_ARB
:
1705 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1706 goto invalid_enum_error
;
1707 return ctx
->Multisample
.Enabled
;
1708 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1709 return ctx
->Multisample
.SampleAlphaToCoverage
;
1710 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1711 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1712 goto invalid_enum_error
;
1713 return ctx
->Multisample
.SampleAlphaToOne
;
1714 case GL_SAMPLE_COVERAGE_ARB
:
1715 return ctx
->Multisample
.SampleCoverage
;
1716 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1717 if (!_mesa_is_desktop_gl(ctx
))
1718 goto invalid_enum_error
;
1719 return ctx
->Multisample
.SampleCoverageInvert
;
1721 /* GL_IBM_rasterpos_clip */
1722 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1723 if (ctx
->API
!= API_OPENGL_COMPAT
)
1724 goto invalid_enum_error
;
1725 return ctx
->Transform
.RasterPositionUnclipped
;
1727 /* GL_NV_point_sprite */
1728 case GL_POINT_SPRITE_NV
:
1729 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1730 goto invalid_enum_error
;
1731 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1732 return ctx
->Point
.PointSprite
;
1734 case GL_VERTEX_PROGRAM_ARB
:
1735 if (ctx
->API
!= API_OPENGL_COMPAT
)
1736 goto invalid_enum_error
;
1737 CHECK_EXTENSION(ARB_vertex_program
);
1738 return ctx
->VertexProgram
.Enabled
;
1739 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1740 /* This was added with ARB_vertex_program, but it is also used with
1741 * GLSL vertex shaders on desktop.
1743 if (!_mesa_is_desktop_gl(ctx
))
1744 goto invalid_enum_error
;
1745 CHECK_EXTENSION(ARB_vertex_program
);
1746 return ctx
->VertexProgram
.PointSizeEnabled
;
1747 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1748 if (ctx
->API
!= API_OPENGL_COMPAT
)
1749 goto invalid_enum_error
;
1750 CHECK_EXTENSION(ARB_vertex_program
);
1751 return ctx
->VertexProgram
.TwoSideEnabled
;
1753 /* GL_NV_texture_rectangle */
1754 case GL_TEXTURE_RECTANGLE_NV
:
1755 if (ctx
->API
!= API_OPENGL_COMPAT
)
1756 goto invalid_enum_error
;
1757 CHECK_EXTENSION(NV_texture_rectangle
);
1758 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1760 /* GL_EXT_stencil_two_side */
1761 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1762 if (ctx
->API
!= API_OPENGL_COMPAT
)
1763 goto invalid_enum_error
;
1764 CHECK_EXTENSION(EXT_stencil_two_side
);
1765 return ctx
->Stencil
.TestTwoSide
;
1767 case GL_FRAGMENT_PROGRAM_ARB
:
1768 if (!_mesa_has_ARB_fragment_program(ctx
))
1769 goto invalid_enum_error
;
1770 return ctx
->FragmentProgram
.Enabled
;
1772 /* GL_EXT_depth_bounds_test */
1773 case GL_DEPTH_BOUNDS_TEST_EXT
:
1774 if (!_mesa_is_desktop_gl(ctx
))
1775 goto invalid_enum_error
;
1776 CHECK_EXTENSION(EXT_depth_bounds_test
);
1777 return ctx
->Depth
.BoundsTest
;
1779 /* GL_ARB_depth_clamp */
1780 case GL_DEPTH_CLAMP
:
1781 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1782 !_mesa_has_EXT_depth_clamp(ctx
))
1783 goto invalid_enum_error
;
1784 return ctx
->Transform
.DepthClampNear
||
1785 ctx
->Transform
.DepthClampFar
;
1787 case GL_DEPTH_CLAMP_NEAR_AMD
:
1788 if (!_mesa_is_desktop_gl(ctx
))
1789 goto invalid_enum_error
;
1790 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1791 return ctx
->Transform
.DepthClampNear
;
1793 case GL_DEPTH_CLAMP_FAR_AMD
:
1794 if (!_mesa_is_desktop_gl(ctx
))
1795 goto invalid_enum_error
;
1796 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1797 return ctx
->Transform
.DepthClampFar
;
1799 case GL_FRAGMENT_SHADER_ATI
:
1800 if (ctx
->API
!= API_OPENGL_COMPAT
)
1801 goto invalid_enum_error
;
1802 CHECK_EXTENSION(ATI_fragment_shader
);
1803 return ctx
->ATIFragmentShader
.Enabled
;
1805 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1806 if (!_mesa_is_desktop_gl(ctx
))
1807 goto invalid_enum_error
;
1808 CHECK_EXTENSION(ARB_seamless_cube_map
);
1809 return ctx
->Texture
.CubeMapSeamless
;
1811 case GL_RASTERIZER_DISCARD
:
1812 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1813 goto invalid_enum_error
;
1814 CHECK_EXTENSION(EXT_transform_feedback
);
1815 return ctx
->RasterDiscard
;
1817 /* GL_NV_primitive_restart */
1818 case GL_PRIMITIVE_RESTART_NV
:
1819 if (!_mesa_has_NV_primitive_restart(ctx
))
1820 goto invalid_enum_error
;
1821 return ctx
->Array
.PrimitiveRestart
;
1823 /* GL 3.1 primitive restart */
1824 case GL_PRIMITIVE_RESTART
:
1825 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1826 goto invalid_enum_error
;
1828 return ctx
->Array
.PrimitiveRestart
;
1830 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1831 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1832 goto invalid_enum_error
;
1833 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1835 /* GL3.0 - GL_framebuffer_sRGB */
1836 case GL_FRAMEBUFFER_SRGB_EXT
:
1837 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1838 !_mesa_has_EXT_sRGB_write_control(ctx
))
1839 goto invalid_enum_error
;
1840 return ctx
->Color
.sRGBEnabled
;
1842 /* GL_OES_EGL_image_external */
1843 case GL_TEXTURE_EXTERNAL_OES
:
1844 if (!_mesa_is_gles(ctx
))
1845 goto invalid_enum_error
;
1846 CHECK_EXTENSION(OES_EGL_image_external
);
1847 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1849 /* ARB_texture_multisample */
1850 case GL_SAMPLE_MASK
:
1851 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1852 goto invalid_enum_error
;
1853 return ctx
->Multisample
.SampleMask
;
1855 /* ARB_sample_shading */
1856 case GL_SAMPLE_SHADING
:
1857 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
1858 goto invalid_enum_error
;
1859 return ctx
->Multisample
.SampleShading
;
1861 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1862 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1863 goto invalid_enum_error
;
1864 return ctx
->Color
.BlendCoherent
;
1866 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1867 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
1868 goto invalid_enum_error
;
1869 return ctx
->IntelConservativeRasterization
;
1871 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1872 if (!_mesa_has_NV_conservative_raster(ctx
))
1873 goto invalid_enum_error
;
1874 return ctx
->ConservativeRasterization
;
1876 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1877 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1878 goto invalid_enum_error
;
1879 return ctx
->TileRasterOrderFixed
;
1881 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1882 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1883 goto invalid_enum_error
;
1884 return ctx
->TileRasterOrderIncreasingX
;
1886 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1887 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1888 goto invalid_enum_error
;
1889 return ctx
->TileRasterOrderIncreasingY
;
1892 goto invalid_enum_error
;
1898 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1899 _mesa_enum_to_string(cap
));