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
));
137 * Enable GL capability.
138 * \param cap state to enable/disable.
140 * Get's the current context, assures that we're outside glBegin()/glEnd() and
141 * calls client_state().
144 _mesa_EnableClientState( GLenum cap
)
146 GET_CURRENT_CONTEXT(ctx
);
147 client_state( ctx
, cap
, GL_TRUE
);
152 * Disable GL capability.
153 * \param cap state to enable/disable.
155 * Get's the current context, assures that we're outside glBegin()/glEnd() and
156 * calls client_state().
159 _mesa_DisableClientState( GLenum cap
)
161 GET_CURRENT_CONTEXT(ctx
);
162 client_state( ctx
, cap
, GL_FALSE
);
166 #define CHECK_EXTENSION(EXTNAME) \
167 if (!ctx->Extensions.EXTNAME) { \
168 goto invalid_enum_error; \
171 #define CHECK_EXTENSION2(EXT1, EXT2) \
172 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
173 goto invalid_enum_error; \
177 * Return pointer to current texture unit for setting/getting coordinate
179 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
180 * texture unit is higher than the number of supported coordinate units.
182 static struct gl_fixedfunc_texture_unit
*
183 get_texcoord_unit(struct gl_context
*ctx
)
185 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
186 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
190 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
196 * Helper function to enable or disable a texture target.
197 * \param bit one of the TEXTURE_x_BIT values
198 * \return GL_TRUE if state is changing or GL_FALSE if no change
201 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
203 struct gl_fixedfunc_texture_unit
*texUnit
=
204 _mesa_get_current_fixedfunc_tex_unit(ctx
);
208 const GLbitfield newenabled
= state
209 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
211 if (texUnit
->Enabled
== newenabled
)
214 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
215 texUnit
->Enabled
= newenabled
;
221 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
222 * whether the API supports it (GLES doesn't).
225 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
227 if (ctx
->Multisample
.Enabled
== state
)
230 /* GL compatibility needs Multisample.Enable to determine program state
233 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
234 !ctx
->DriverFlags
.NewMultisampleEnable
) {
235 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
237 FLUSH_VERTICES(ctx
, 0);
240 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
241 ctx
->Multisample
.Enabled
= state
;
243 if (ctx
->Driver
.Enable
) {
244 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
249 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
250 * check for whether the API supports it (GLES doesn't).
253 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
255 if (ctx
->Color
.sRGBEnabled
== state
)
258 /* TODO: Switch i965 to the new flag and remove the conditional */
259 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
260 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
261 ctx
->Color
.sRGBEnabled
= state
;
263 if (ctx
->Driver
.Enable
) {
264 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
269 * Helper function to enable or disable state.
271 * \param ctx GL context.
272 * \param cap the state to enable/disable
273 * \param state whether to enable or disable the specified capability.
275 * Updates the current context and flushes the vertices as needed. For
276 * capabilities associated with extensions it verifies that those extensions
277 * are effectivly present before updating. Notifies the driver via
278 * dd_function_table::Enable.
281 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
283 if (MESA_VERBOSE
& VERBOSE_API
)
284 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
285 state
? "glEnable" : "glDisable",
286 _mesa_enum_to_string(cap
),
291 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
292 goto invalid_enum_error
;
293 if (ctx
->Color
.AlphaEnabled
== state
)
295 /* AlphaEnabled is used by the fixed-func fragment program */
296 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
297 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
298 ctx
->Color
.AlphaEnabled
= state
;
301 if (ctx
->API
!= API_OPENGL_COMPAT
)
302 goto invalid_enum_error
;
303 if (ctx
->Eval
.AutoNormal
== state
)
305 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
306 ctx
->Eval
.AutoNormal
= state
;
310 GLbitfield newEnabled
=
311 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
312 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
313 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
314 ctx
->Color
._AdvancedBlendMode
);
315 ctx
->Color
.BlendEnabled
= newEnabled
;
319 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
320 case GL_CLIP_DISTANCE1
:
321 case GL_CLIP_DISTANCE2
:
322 case GL_CLIP_DISTANCE3
:
323 case GL_CLIP_DISTANCE4
:
324 case GL_CLIP_DISTANCE5
:
325 case GL_CLIP_DISTANCE6
:
326 case GL_CLIP_DISTANCE7
:
328 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
330 if (p
>= ctx
->Const
.MaxClipPlanes
)
331 goto invalid_enum_error
;
333 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
334 == ((GLuint
) state
<< p
))
337 /* The compatibility profile needs _NEW_TRANSFORM to transform
338 * clip planes according to the projection matrix.
340 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
341 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
342 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
344 FLUSH_VERTICES(ctx
, 0);
346 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
349 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
351 /* The projection matrix transforms the clip plane. */
352 /* TODO: glEnable might not be the best place to do it. */
353 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
354 _mesa_update_clip_plane(ctx
, p
);
355 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
359 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
363 case GL_COLOR_MATERIAL
:
364 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
365 goto invalid_enum_error
;
366 if (ctx
->Light
.ColorMaterialEnabled
== state
)
368 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
369 FLUSH_CURRENT(ctx
, 0);
370 ctx
->Light
.ColorMaterialEnabled
= state
;
372 _mesa_update_color_material( ctx
,
373 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
377 if (ctx
->Polygon
.CullFlag
== state
)
380 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
381 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
382 ctx
->Polygon
.CullFlag
= state
;
385 if (ctx
->Depth
.Test
== state
)
387 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
388 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
389 ctx
->Depth
.Test
= state
;
391 case GL_DEBUG_OUTPUT
:
392 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
393 _mesa_set_debug_state_int(ctx
, cap
, state
);
396 if (ctx
->Color
.DitherFlag
== state
)
398 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
399 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
400 ctx
->Color
.DitherFlag
= state
;
403 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
404 goto invalid_enum_error
;
405 if (ctx
->Fog
.Enabled
== state
)
407 FLUSH_VERTICES(ctx
, _NEW_FOG
);
408 ctx
->Fog
.Enabled
= state
;
409 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
419 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
420 goto invalid_enum_error
;
421 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
423 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
424 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
426 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
429 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
433 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
434 goto invalid_enum_error
;
435 if (ctx
->Light
.Enabled
== state
)
437 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
438 ctx
->Light
.Enabled
= state
;
441 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
442 goto invalid_enum_error
;
443 if (ctx
->Line
.SmoothFlag
== state
)
445 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
446 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
447 ctx
->Line
.SmoothFlag
= state
;
449 case GL_LINE_STIPPLE
:
450 if (ctx
->API
!= API_OPENGL_COMPAT
)
451 goto invalid_enum_error
;
452 if (ctx
->Line
.StippleFlag
== state
)
454 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
455 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
456 ctx
->Line
.StippleFlag
= state
;
458 case GL_INDEX_LOGIC_OP
:
459 if (ctx
->API
!= API_OPENGL_COMPAT
)
460 goto invalid_enum_error
;
461 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
463 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
464 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
465 ctx
->Color
.IndexLogicOpEnabled
= state
;
467 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
468 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
469 goto invalid_enum_error
;
470 if (ctx
->IntelConservativeRasterization
== state
)
472 FLUSH_VERTICES(ctx
, 0);
473 ctx
->NewDriverState
|=
474 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
475 ctx
->IntelConservativeRasterization
= state
;
477 case GL_CONSERVATIVE_RASTERIZATION_NV
:
478 if (!_mesa_has_NV_conservative_raster(ctx
))
479 goto invalid_enum_error
;
480 if (ctx
->ConservativeRasterization
== state
)
482 FLUSH_VERTICES(ctx
, 0);
483 ctx
->NewDriverState
|=
484 ctx
->DriverFlags
.NewNvConservativeRasterization
;
485 ctx
->ConservativeRasterization
= state
;
487 case GL_COLOR_LOGIC_OP
:
488 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
489 goto invalid_enum_error
;
490 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
492 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
493 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
494 ctx
->Color
.ColorLogicOpEnabled
= state
;
496 case GL_MAP1_COLOR_4
:
497 if (ctx
->API
!= API_OPENGL_COMPAT
)
498 goto invalid_enum_error
;
499 if (ctx
->Eval
.Map1Color4
== state
)
501 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
502 ctx
->Eval
.Map1Color4
= state
;
505 if (ctx
->API
!= API_OPENGL_COMPAT
)
506 goto invalid_enum_error
;
507 if (ctx
->Eval
.Map1Index
== state
)
509 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
510 ctx
->Eval
.Map1Index
= state
;
513 if (ctx
->API
!= API_OPENGL_COMPAT
)
514 goto invalid_enum_error
;
515 if (ctx
->Eval
.Map1Normal
== state
)
517 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
518 ctx
->Eval
.Map1Normal
= state
;
520 case GL_MAP1_TEXTURE_COORD_1
:
521 if (ctx
->API
!= API_OPENGL_COMPAT
)
522 goto invalid_enum_error
;
523 if (ctx
->Eval
.Map1TextureCoord1
== state
)
525 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
526 ctx
->Eval
.Map1TextureCoord1
= state
;
528 case GL_MAP1_TEXTURE_COORD_2
:
529 if (ctx
->API
!= API_OPENGL_COMPAT
)
530 goto invalid_enum_error
;
531 if (ctx
->Eval
.Map1TextureCoord2
== state
)
533 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
534 ctx
->Eval
.Map1TextureCoord2
= state
;
536 case GL_MAP1_TEXTURE_COORD_3
:
537 if (ctx
->API
!= API_OPENGL_COMPAT
)
538 goto invalid_enum_error
;
539 if (ctx
->Eval
.Map1TextureCoord3
== state
)
541 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
542 ctx
->Eval
.Map1TextureCoord3
= state
;
544 case GL_MAP1_TEXTURE_COORD_4
:
545 if (ctx
->API
!= API_OPENGL_COMPAT
)
546 goto invalid_enum_error
;
547 if (ctx
->Eval
.Map1TextureCoord4
== state
)
549 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
550 ctx
->Eval
.Map1TextureCoord4
= state
;
552 case GL_MAP1_VERTEX_3
:
553 if (ctx
->API
!= API_OPENGL_COMPAT
)
554 goto invalid_enum_error
;
555 if (ctx
->Eval
.Map1Vertex3
== state
)
557 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
558 ctx
->Eval
.Map1Vertex3
= state
;
560 case GL_MAP1_VERTEX_4
:
561 if (ctx
->API
!= API_OPENGL_COMPAT
)
562 goto invalid_enum_error
;
563 if (ctx
->Eval
.Map1Vertex4
== state
)
565 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
566 ctx
->Eval
.Map1Vertex4
= state
;
568 case GL_MAP2_COLOR_4
:
569 if (ctx
->API
!= API_OPENGL_COMPAT
)
570 goto invalid_enum_error
;
571 if (ctx
->Eval
.Map2Color4
== state
)
573 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
574 ctx
->Eval
.Map2Color4
= state
;
577 if (ctx
->API
!= API_OPENGL_COMPAT
)
578 goto invalid_enum_error
;
579 if (ctx
->Eval
.Map2Index
== state
)
581 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
582 ctx
->Eval
.Map2Index
= state
;
585 if (ctx
->API
!= API_OPENGL_COMPAT
)
586 goto invalid_enum_error
;
587 if (ctx
->Eval
.Map2Normal
== state
)
589 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
590 ctx
->Eval
.Map2Normal
= state
;
592 case GL_MAP2_TEXTURE_COORD_1
:
593 if (ctx
->API
!= API_OPENGL_COMPAT
)
594 goto invalid_enum_error
;
595 if (ctx
->Eval
.Map2TextureCoord1
== state
)
597 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
598 ctx
->Eval
.Map2TextureCoord1
= state
;
600 case GL_MAP2_TEXTURE_COORD_2
:
601 if (ctx
->API
!= API_OPENGL_COMPAT
)
602 goto invalid_enum_error
;
603 if (ctx
->Eval
.Map2TextureCoord2
== state
)
605 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
606 ctx
->Eval
.Map2TextureCoord2
= state
;
608 case GL_MAP2_TEXTURE_COORD_3
:
609 if (ctx
->API
!= API_OPENGL_COMPAT
)
610 goto invalid_enum_error
;
611 if (ctx
->Eval
.Map2TextureCoord3
== state
)
613 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
614 ctx
->Eval
.Map2TextureCoord3
= state
;
616 case GL_MAP2_TEXTURE_COORD_4
:
617 if (ctx
->API
!= API_OPENGL_COMPAT
)
618 goto invalid_enum_error
;
619 if (ctx
->Eval
.Map2TextureCoord4
== state
)
621 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
622 ctx
->Eval
.Map2TextureCoord4
= state
;
624 case GL_MAP2_VERTEX_3
:
625 if (ctx
->API
!= API_OPENGL_COMPAT
)
626 goto invalid_enum_error
;
627 if (ctx
->Eval
.Map2Vertex3
== state
)
629 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
630 ctx
->Eval
.Map2Vertex3
= state
;
632 case GL_MAP2_VERTEX_4
:
633 if (ctx
->API
!= API_OPENGL_COMPAT
)
634 goto invalid_enum_error
;
635 if (ctx
->Eval
.Map2Vertex4
== state
)
637 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
638 ctx
->Eval
.Map2Vertex4
= state
;
641 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
642 goto invalid_enum_error
;
643 if (ctx
->Transform
.Normalize
== state
)
645 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
646 ctx
->Transform
.Normalize
= state
;
648 case GL_POINT_SMOOTH
:
649 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
650 goto invalid_enum_error
;
651 if (ctx
->Point
.SmoothFlag
== state
)
653 FLUSH_VERTICES(ctx
, _NEW_POINT
);
654 ctx
->Point
.SmoothFlag
= state
;
656 case GL_POLYGON_SMOOTH
:
657 if (!_mesa_is_desktop_gl(ctx
))
658 goto invalid_enum_error
;
659 if (ctx
->Polygon
.SmoothFlag
== state
)
662 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
663 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
664 ctx
->Polygon
.SmoothFlag
= state
;
666 case GL_POLYGON_STIPPLE
:
667 if (ctx
->API
!= API_OPENGL_COMPAT
)
668 goto invalid_enum_error
;
669 if (ctx
->Polygon
.StippleFlag
== state
)
672 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
673 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
674 ctx
->Polygon
.StippleFlag
= state
;
676 case GL_POLYGON_OFFSET_POINT
:
677 if (!_mesa_is_desktop_gl(ctx
))
678 goto invalid_enum_error
;
679 if (ctx
->Polygon
.OffsetPoint
== state
)
682 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
683 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
684 ctx
->Polygon
.OffsetPoint
= state
;
686 case GL_POLYGON_OFFSET_LINE
:
687 if (!_mesa_is_desktop_gl(ctx
))
688 goto invalid_enum_error
;
689 if (ctx
->Polygon
.OffsetLine
== state
)
692 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
693 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
694 ctx
->Polygon
.OffsetLine
= state
;
696 case GL_POLYGON_OFFSET_FILL
:
697 if (ctx
->Polygon
.OffsetFill
== state
)
700 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
701 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
702 ctx
->Polygon
.OffsetFill
= state
;
704 case GL_RESCALE_NORMAL_EXT
:
705 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
706 goto invalid_enum_error
;
707 if (ctx
->Transform
.RescaleNormals
== state
)
709 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
710 ctx
->Transform
.RescaleNormals
= state
;
712 case GL_SCISSOR_TEST
:
714 /* Must expand glEnable to all scissors */
715 GLbitfield newEnabled
=
716 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
717 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
718 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
720 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
721 ctx
->Scissor
.EnableFlags
= newEnabled
;
725 case GL_STENCIL_TEST
:
726 if (ctx
->Stencil
.Enabled
== state
)
728 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
729 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
730 ctx
->Stencil
.Enabled
= state
;
733 if (ctx
->API
!= API_OPENGL_COMPAT
)
734 goto invalid_enum_error
;
735 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
740 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
741 goto invalid_enum_error
;
742 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
747 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
748 goto invalid_enum_error
;
749 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
753 case GL_TEXTURE_GEN_S
:
754 case GL_TEXTURE_GEN_T
:
755 case GL_TEXTURE_GEN_R
:
756 case GL_TEXTURE_GEN_Q
:
758 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
760 if (ctx
->API
!= API_OPENGL_COMPAT
)
761 goto invalid_enum_error
;
764 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
765 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
767 newenabled
|= coordBit
;
768 if (texUnit
->TexGenEnabled
== newenabled
)
770 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
771 texUnit
->TexGenEnabled
= newenabled
;
776 case GL_TEXTURE_GEN_STR_OES
:
777 /* disable S, T, and R at the same time */
779 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
781 if (ctx
->API
!= API_OPENGLES
)
782 goto invalid_enum_error
;
786 texUnit
->TexGenEnabled
& ~STR_BITS
;
788 newenabled
|= STR_BITS
;
789 if (texUnit
->TexGenEnabled
== newenabled
)
791 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
792 texUnit
->TexGenEnabled
= newenabled
;
797 /* client-side state */
798 case GL_VERTEX_ARRAY
:
799 case GL_NORMAL_ARRAY
:
801 case GL_TEXTURE_COORD_ARRAY
:
802 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
803 goto invalid_enum_error
;
804 client_state( ctx
, cap
, state
);
807 case GL_EDGE_FLAG_ARRAY
:
808 case GL_FOG_COORDINATE_ARRAY_EXT
:
809 case GL_SECONDARY_COLOR_ARRAY_EXT
:
810 if (ctx
->API
!= API_OPENGL_COMPAT
)
811 goto invalid_enum_error
;
812 client_state( ctx
, cap
, state
);
814 case GL_POINT_SIZE_ARRAY_OES
:
815 if (ctx
->API
!= API_OPENGLES
)
816 goto invalid_enum_error
;
817 client_state( ctx
, cap
, state
);
820 /* GL_ARB_texture_cube_map */
821 case GL_TEXTURE_CUBE_MAP
:
822 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
823 !_mesa_has_OES_texture_cube_map(ctx
))
824 goto invalid_enum_error
;
825 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
830 /* GL_EXT_secondary_color */
831 case GL_COLOR_SUM_EXT
:
832 if (ctx
->API
!= API_OPENGL_COMPAT
)
833 goto invalid_enum_error
;
834 if (ctx
->Fog
.ColorSumEnabled
== state
)
836 FLUSH_VERTICES(ctx
, _NEW_FOG
);
837 ctx
->Fog
.ColorSumEnabled
= state
;
840 /* GL_ARB_multisample */
841 case GL_MULTISAMPLE_ARB
:
842 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
843 goto invalid_enum_error
;
844 _mesa_set_multisample(ctx
, state
);
846 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
847 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
849 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
851 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
852 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
854 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
855 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
856 goto invalid_enum_error
;
857 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
859 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
861 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
862 ctx
->Multisample
.SampleAlphaToOne
= state
;
864 case GL_SAMPLE_COVERAGE_ARB
:
865 if (ctx
->Multisample
.SampleCoverage
== state
)
867 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
869 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
870 ctx
->Multisample
.SampleCoverage
= state
;
872 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
873 if (!_mesa_is_desktop_gl(ctx
))
874 goto invalid_enum_error
;
875 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
877 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
879 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
880 ctx
->Multisample
.SampleCoverageInvert
= state
;
883 /* GL_ARB_sample_shading */
884 case GL_SAMPLE_SHADING
:
885 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
886 goto invalid_enum_error
;
887 CHECK_EXTENSION(ARB_sample_shading
);
888 if (ctx
->Multisample
.SampleShading
== state
)
890 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
892 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
893 ctx
->Multisample
.SampleShading
= state
;
896 /* GL_IBM_rasterpos_clip */
897 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
898 if (ctx
->API
!= API_OPENGL_COMPAT
)
899 goto invalid_enum_error
;
900 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
902 FLUSH_VERTICES(ctx
, 0);
903 ctx
->Transform
.RasterPositionUnclipped
= state
;
906 /* GL_NV_point_sprite */
907 case GL_POINT_SPRITE_NV
:
908 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
909 goto invalid_enum_error
;
910 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
);
911 if (ctx
->Point
.PointSprite
== state
)
913 FLUSH_VERTICES(ctx
, _NEW_POINT
);
914 ctx
->Point
.PointSprite
= state
;
917 case GL_VERTEX_PROGRAM_ARB
:
918 if (ctx
->API
!= API_OPENGL_COMPAT
)
919 goto invalid_enum_error
;
920 CHECK_EXTENSION(ARB_vertex_program
);
921 if (ctx
->VertexProgram
.Enabled
== state
)
923 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
924 ctx
->VertexProgram
.Enabled
= state
;
925 _mesa_update_vertex_processing_mode(ctx
);
927 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
928 /* This was added with ARB_vertex_program, but it is also used with
929 * GLSL vertex shaders on desktop.
931 if (!_mesa_is_desktop_gl(ctx
))
932 goto invalid_enum_error
;
933 CHECK_EXTENSION(ARB_vertex_program
);
934 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
936 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
937 ctx
->VertexProgram
.PointSizeEnabled
= state
;
939 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
940 if (ctx
->API
!= API_OPENGL_COMPAT
)
941 goto invalid_enum_error
;
942 CHECK_EXTENSION(ARB_vertex_program
);
943 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
945 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
946 ctx
->VertexProgram
.TwoSideEnabled
= state
;
949 /* GL_NV_texture_rectangle */
950 case GL_TEXTURE_RECTANGLE_NV
:
951 if (ctx
->API
!= API_OPENGL_COMPAT
)
952 goto invalid_enum_error
;
953 CHECK_EXTENSION(NV_texture_rectangle
);
954 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
959 /* GL_EXT_stencil_two_side */
960 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
961 if (ctx
->API
!= API_OPENGL_COMPAT
)
962 goto invalid_enum_error
;
963 CHECK_EXTENSION(EXT_stencil_two_side
);
964 if (ctx
->Stencil
.TestTwoSide
== state
)
966 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
967 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
968 ctx
->Stencil
.TestTwoSide
= state
;
970 ctx
->Stencil
._BackFace
= 2;
972 ctx
->Stencil
._BackFace
= 1;
976 case GL_FRAGMENT_PROGRAM_ARB
:
977 if (!_mesa_has_ARB_fragment_program(ctx
))
978 goto invalid_enum_error
;
979 if (ctx
->FragmentProgram
.Enabled
== state
)
981 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
982 ctx
->FragmentProgram
.Enabled
= state
;
985 /* GL_EXT_depth_bounds_test */
986 case GL_DEPTH_BOUNDS_TEST_EXT
:
987 if (!_mesa_is_desktop_gl(ctx
))
988 goto invalid_enum_error
;
989 CHECK_EXTENSION(EXT_depth_bounds_test
);
990 if (ctx
->Depth
.BoundsTest
== state
)
992 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
993 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
994 ctx
->Depth
.BoundsTest
= state
;
998 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
999 !_mesa_has_EXT_depth_clamp(ctx
))
1000 goto invalid_enum_error
;
1001 if (ctx
->Transform
.DepthClampNear
== state
&&
1002 ctx
->Transform
.DepthClampFar
== state
)
1004 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1006 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1007 ctx
->Transform
.DepthClampNear
= state
;
1008 ctx
->Transform
.DepthClampFar
= state
;
1011 case GL_DEPTH_CLAMP_NEAR_AMD
:
1012 if (!_mesa_is_desktop_gl(ctx
))
1013 goto invalid_enum_error
;
1014 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1015 if (ctx
->Transform
.DepthClampNear
== state
)
1017 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1019 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1020 ctx
->Transform
.DepthClampNear
= state
;
1023 case GL_DEPTH_CLAMP_FAR_AMD
:
1024 if (!_mesa_is_desktop_gl(ctx
))
1025 goto invalid_enum_error
;
1026 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1027 if (ctx
->Transform
.DepthClampFar
== state
)
1029 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1031 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1032 ctx
->Transform
.DepthClampFar
= state
;
1035 case GL_FRAGMENT_SHADER_ATI
:
1036 if (ctx
->API
!= API_OPENGL_COMPAT
)
1037 goto invalid_enum_error
;
1038 CHECK_EXTENSION(ATI_fragment_shader
);
1039 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1041 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1042 ctx
->ATIFragmentShader
.Enabled
= state
;
1045 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1046 if (!_mesa_is_desktop_gl(ctx
))
1047 goto invalid_enum_error
;
1048 CHECK_EXTENSION(ARB_seamless_cube_map
);
1049 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1050 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1051 ctx
->Texture
.CubeMapSeamless
= state
;
1055 case GL_RASTERIZER_DISCARD
:
1056 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1057 goto invalid_enum_error
;
1058 CHECK_EXTENSION(EXT_transform_feedback
);
1059 if (ctx
->RasterDiscard
!= state
) {
1060 FLUSH_VERTICES(ctx
, 0);
1061 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1062 ctx
->RasterDiscard
= state
;
1066 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1067 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1068 goto invalid_enum_error
;
1069 if (ctx
->TileRasterOrderFixed
!= state
) {
1070 FLUSH_VERTICES(ctx
, 0);
1071 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1072 ctx
->TileRasterOrderFixed
= state
;
1076 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1077 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1078 goto invalid_enum_error
;
1079 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1080 FLUSH_VERTICES(ctx
, 0);
1081 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1082 ctx
->TileRasterOrderIncreasingX
= state
;
1086 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1087 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1088 goto invalid_enum_error
;
1089 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1090 FLUSH_VERTICES(ctx
, 0);
1091 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1092 ctx
->TileRasterOrderIncreasingY
= state
;
1096 /* GL 3.1 primitive restart. Note: this enum is different from
1097 * GL_PRIMITIVE_RESTART_NV (which is client state).
1099 case GL_PRIMITIVE_RESTART
:
1100 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1101 goto invalid_enum_error
;
1103 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1104 FLUSH_VERTICES(ctx
, 0);
1105 ctx
->Array
.PrimitiveRestart
= state
;
1106 update_derived_primitive_restart_state(ctx
);
1110 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1111 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1112 goto invalid_enum_error
;
1113 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1114 FLUSH_VERTICES(ctx
, 0);
1115 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1116 update_derived_primitive_restart_state(ctx
);
1120 /* GL3.0 - GL_framebuffer_sRGB */
1121 case GL_FRAMEBUFFER_SRGB_EXT
:
1122 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1123 !_mesa_has_EXT_sRGB_write_control(ctx
))
1124 goto invalid_enum_error
;
1125 _mesa_set_framebuffer_srgb(ctx
, state
);
1128 /* GL_OES_EGL_image_external */
1129 case GL_TEXTURE_EXTERNAL_OES
:
1130 if (!_mesa_is_gles(ctx
))
1131 goto invalid_enum_error
;
1132 CHECK_EXTENSION(OES_EGL_image_external
);
1133 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1138 /* ARB_texture_multisample */
1139 case GL_SAMPLE_MASK
:
1140 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1141 goto invalid_enum_error
;
1142 CHECK_EXTENSION(ARB_texture_multisample
);
1143 if (ctx
->Multisample
.SampleMask
== state
)
1145 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1147 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1148 ctx
->Multisample
.SampleMask
= state
;
1151 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1152 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1153 goto invalid_enum_error
;
1154 if (ctx
->Color
.BlendCoherent
== state
)
1156 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1157 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1158 ctx
->Color
.BlendCoherent
= state
;
1162 goto invalid_enum_error
;
1165 if (ctx
->Driver
.Enable
) {
1166 ctx
->Driver
.Enable( ctx
, cap
, state
);
1172 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1173 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1178 * Enable GL capability. Called by glEnable()
1179 * \param cap state to enable.
1182 _mesa_Enable( GLenum cap
)
1184 GET_CURRENT_CONTEXT(ctx
);
1186 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1191 * Disable GL capability. Called by glDisable()
1192 * \param cap state to disable.
1195 _mesa_Disable( GLenum cap
)
1197 GET_CURRENT_CONTEXT(ctx
);
1199 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1205 * Enable/disable an indexed state var.
1208 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1209 GLuint index
, GLboolean state
)
1211 assert(state
== 0 || state
== 1);
1214 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1215 goto invalid_enum_error
;
1217 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1218 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1219 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1222 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1223 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1226 enabled
|= (1 << index
);
1228 enabled
&= ~(1 << index
);
1230 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1231 ctx
->Color
._AdvancedBlendMode
);
1232 ctx
->Color
.BlendEnabled
= enabled
;
1235 case GL_SCISSOR_TEST
:
1236 if (index
>= ctx
->Const
.MaxViewports
) {
1237 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1238 state
? "glEnablei" : "glDisablei", index
);
1241 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1243 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1244 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1246 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1248 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1252 goto invalid_enum_error
;
1257 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1258 state
? "glEnablei" : "glDisablei",
1259 _mesa_enum_to_string(cap
));
1264 _mesa_Disablei( GLenum cap
, GLuint index
)
1266 GET_CURRENT_CONTEXT(ctx
);
1267 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1272 _mesa_Enablei( GLenum cap
, GLuint index
)
1274 GET_CURRENT_CONTEXT(ctx
);
1275 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1279 GLboolean GLAPIENTRY
1280 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1282 GET_CURRENT_CONTEXT(ctx
);
1283 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1286 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1287 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1291 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1292 case GL_SCISSOR_TEST
:
1293 if (index
>= ctx
->Const
.MaxViewports
) {
1294 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1298 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1300 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1301 _mesa_enum_to_string(cap
));
1309 * Helper function to determine whether a texture target is enabled.
1312 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1314 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1315 _mesa_get_current_fixedfunc_tex_unit(ctx
);
1320 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1325 * Return simple enable/disable state.
1327 * \param cap state variable to query.
1329 * Returns the state of the specified capability from the current GL context.
1330 * For the capabilities associated with extensions verifies that those
1331 * extensions are effectively present before reporting.
1333 GLboolean GLAPIENTRY
1334 _mesa_IsEnabled( GLenum cap
)
1336 GET_CURRENT_CONTEXT(ctx
);
1337 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1341 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1342 goto invalid_enum_error
;
1343 return ctx
->Color
.AlphaEnabled
;
1344 case GL_AUTO_NORMAL
:
1345 if (ctx
->API
!= API_OPENGL_COMPAT
)
1346 goto invalid_enum_error
;
1347 return ctx
->Eval
.AutoNormal
;
1349 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1350 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1351 case GL_CLIP_DISTANCE1
:
1352 case GL_CLIP_DISTANCE2
:
1353 case GL_CLIP_DISTANCE3
:
1354 case GL_CLIP_DISTANCE4
:
1355 case GL_CLIP_DISTANCE5
:
1356 case GL_CLIP_DISTANCE6
:
1357 case GL_CLIP_DISTANCE7
: {
1358 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1360 if (p
>= ctx
->Const
.MaxClipPlanes
)
1361 goto invalid_enum_error
;
1363 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1365 case GL_COLOR_MATERIAL
:
1366 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1367 goto invalid_enum_error
;
1368 return ctx
->Light
.ColorMaterialEnabled
;
1370 return ctx
->Polygon
.CullFlag
;
1371 case GL_DEBUG_OUTPUT
:
1372 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1373 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1375 return ctx
->Depth
.Test
;
1377 return ctx
->Color
.DitherFlag
;
1379 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1380 goto invalid_enum_error
;
1381 return ctx
->Fog
.Enabled
;
1383 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1384 goto invalid_enum_error
;
1385 return ctx
->Light
.Enabled
;
1394 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1395 goto invalid_enum_error
;
1396 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1397 case GL_LINE_SMOOTH
:
1398 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1399 goto invalid_enum_error
;
1400 return ctx
->Line
.SmoothFlag
;
1401 case GL_LINE_STIPPLE
:
1402 if (ctx
->API
!= API_OPENGL_COMPAT
)
1403 goto invalid_enum_error
;
1404 return ctx
->Line
.StippleFlag
;
1405 case GL_INDEX_LOGIC_OP
:
1406 if (ctx
->API
!= API_OPENGL_COMPAT
)
1407 goto invalid_enum_error
;
1408 return ctx
->Color
.IndexLogicOpEnabled
;
1409 case GL_COLOR_LOGIC_OP
:
1410 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1411 goto invalid_enum_error
;
1412 return ctx
->Color
.ColorLogicOpEnabled
;
1413 case GL_MAP1_COLOR_4
:
1414 if (ctx
->API
!= API_OPENGL_COMPAT
)
1415 goto invalid_enum_error
;
1416 return ctx
->Eval
.Map1Color4
;
1418 if (ctx
->API
!= API_OPENGL_COMPAT
)
1419 goto invalid_enum_error
;
1420 return ctx
->Eval
.Map1Index
;
1421 case GL_MAP1_NORMAL
:
1422 if (ctx
->API
!= API_OPENGL_COMPAT
)
1423 goto invalid_enum_error
;
1424 return ctx
->Eval
.Map1Normal
;
1425 case GL_MAP1_TEXTURE_COORD_1
:
1426 if (ctx
->API
!= API_OPENGL_COMPAT
)
1427 goto invalid_enum_error
;
1428 return ctx
->Eval
.Map1TextureCoord1
;
1429 case GL_MAP1_TEXTURE_COORD_2
:
1430 if (ctx
->API
!= API_OPENGL_COMPAT
)
1431 goto invalid_enum_error
;
1432 return ctx
->Eval
.Map1TextureCoord2
;
1433 case GL_MAP1_TEXTURE_COORD_3
:
1434 if (ctx
->API
!= API_OPENGL_COMPAT
)
1435 goto invalid_enum_error
;
1436 return ctx
->Eval
.Map1TextureCoord3
;
1437 case GL_MAP1_TEXTURE_COORD_4
:
1438 if (ctx
->API
!= API_OPENGL_COMPAT
)
1439 goto invalid_enum_error
;
1440 return ctx
->Eval
.Map1TextureCoord4
;
1441 case GL_MAP1_VERTEX_3
:
1442 if (ctx
->API
!= API_OPENGL_COMPAT
)
1443 goto invalid_enum_error
;
1444 return ctx
->Eval
.Map1Vertex3
;
1445 case GL_MAP1_VERTEX_4
:
1446 if (ctx
->API
!= API_OPENGL_COMPAT
)
1447 goto invalid_enum_error
;
1448 return ctx
->Eval
.Map1Vertex4
;
1449 case GL_MAP2_COLOR_4
:
1450 if (ctx
->API
!= API_OPENGL_COMPAT
)
1451 goto invalid_enum_error
;
1452 return ctx
->Eval
.Map2Color4
;
1454 if (ctx
->API
!= API_OPENGL_COMPAT
)
1455 goto invalid_enum_error
;
1456 return ctx
->Eval
.Map2Index
;
1457 case GL_MAP2_NORMAL
:
1458 if (ctx
->API
!= API_OPENGL_COMPAT
)
1459 goto invalid_enum_error
;
1460 return ctx
->Eval
.Map2Normal
;
1461 case GL_MAP2_TEXTURE_COORD_1
:
1462 if (ctx
->API
!= API_OPENGL_COMPAT
)
1463 goto invalid_enum_error
;
1464 return ctx
->Eval
.Map2TextureCoord1
;
1465 case GL_MAP2_TEXTURE_COORD_2
:
1466 if (ctx
->API
!= API_OPENGL_COMPAT
)
1467 goto invalid_enum_error
;
1468 return ctx
->Eval
.Map2TextureCoord2
;
1469 case GL_MAP2_TEXTURE_COORD_3
:
1470 if (ctx
->API
!= API_OPENGL_COMPAT
)
1471 goto invalid_enum_error
;
1472 return ctx
->Eval
.Map2TextureCoord3
;
1473 case GL_MAP2_TEXTURE_COORD_4
:
1474 if (ctx
->API
!= API_OPENGL_COMPAT
)
1475 goto invalid_enum_error
;
1476 return ctx
->Eval
.Map2TextureCoord4
;
1477 case GL_MAP2_VERTEX_3
:
1478 if (ctx
->API
!= API_OPENGL_COMPAT
)
1479 goto invalid_enum_error
;
1480 return ctx
->Eval
.Map2Vertex3
;
1481 case GL_MAP2_VERTEX_4
:
1482 if (ctx
->API
!= API_OPENGL_COMPAT
)
1483 goto invalid_enum_error
;
1484 return ctx
->Eval
.Map2Vertex4
;
1486 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1487 goto invalid_enum_error
;
1488 return ctx
->Transform
.Normalize
;
1489 case GL_POINT_SMOOTH
:
1490 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1491 goto invalid_enum_error
;
1492 return ctx
->Point
.SmoothFlag
;
1493 case GL_POLYGON_SMOOTH
:
1494 if (!_mesa_is_desktop_gl(ctx
))
1495 goto invalid_enum_error
;
1496 return ctx
->Polygon
.SmoothFlag
;
1497 case GL_POLYGON_STIPPLE
:
1498 if (ctx
->API
!= API_OPENGL_COMPAT
)
1499 goto invalid_enum_error
;
1500 return ctx
->Polygon
.StippleFlag
;
1501 case GL_POLYGON_OFFSET_POINT
:
1502 if (!_mesa_is_desktop_gl(ctx
))
1503 goto invalid_enum_error
;
1504 return ctx
->Polygon
.OffsetPoint
;
1505 case GL_POLYGON_OFFSET_LINE
:
1506 if (!_mesa_is_desktop_gl(ctx
))
1507 goto invalid_enum_error
;
1508 return ctx
->Polygon
.OffsetLine
;
1509 case GL_POLYGON_OFFSET_FILL
:
1510 return ctx
->Polygon
.OffsetFill
;
1511 case GL_RESCALE_NORMAL_EXT
:
1512 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1513 goto invalid_enum_error
;
1514 return ctx
->Transform
.RescaleNormals
;
1515 case GL_SCISSOR_TEST
:
1516 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1517 case GL_STENCIL_TEST
:
1518 return ctx
->Stencil
.Enabled
;
1520 if (ctx
->API
!= API_OPENGL_COMPAT
)
1521 goto invalid_enum_error
;
1522 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1524 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1525 goto invalid_enum_error
;
1526 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1528 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1529 goto invalid_enum_error
;
1530 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1531 case GL_TEXTURE_GEN_S
:
1532 case GL_TEXTURE_GEN_T
:
1533 case GL_TEXTURE_GEN_R
:
1534 case GL_TEXTURE_GEN_Q
:
1536 const struct gl_fixedfunc_texture_unit
*texUnit
=
1537 get_texcoord_unit(ctx
);
1539 if (ctx
->API
!= API_OPENGL_COMPAT
)
1540 goto invalid_enum_error
;
1543 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1544 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1548 case GL_TEXTURE_GEN_STR_OES
:
1550 const struct gl_fixedfunc_texture_unit
*texUnit
=
1551 get_texcoord_unit(ctx
);
1553 if (ctx
->API
!= API_OPENGLES
)
1554 goto invalid_enum_error
;
1557 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1558 ? GL_TRUE
: GL_FALSE
;
1562 /* client-side state */
1563 case GL_VERTEX_ARRAY
:
1564 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1565 goto invalid_enum_error
;
1566 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
1567 case GL_NORMAL_ARRAY
:
1568 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1569 goto invalid_enum_error
;
1570 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
1571 case GL_COLOR_ARRAY
:
1572 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1573 goto invalid_enum_error
;
1574 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
1575 case GL_INDEX_ARRAY
:
1576 if (ctx
->API
!= API_OPENGL_COMPAT
)
1577 goto invalid_enum_error
;
1578 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
1579 case GL_TEXTURE_COORD_ARRAY
:
1580 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1581 goto invalid_enum_error
;
1582 return !!(ctx
->Array
.VAO
->Enabled
&
1583 VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
1584 case GL_EDGE_FLAG_ARRAY
:
1585 if (ctx
->API
!= API_OPENGL_COMPAT
)
1586 goto invalid_enum_error
;
1587 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
1588 case GL_FOG_COORDINATE_ARRAY_EXT
:
1589 if (ctx
->API
!= API_OPENGL_COMPAT
)
1590 goto invalid_enum_error
;
1591 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
1592 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1593 if (ctx
->API
!= API_OPENGL_COMPAT
)
1594 goto invalid_enum_error
;
1595 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
1596 case GL_POINT_SIZE_ARRAY_OES
:
1597 if (ctx
->API
!= API_OPENGLES
)
1598 goto invalid_enum_error
;
1599 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
1601 /* GL_ARB_texture_cube_map */
1602 case GL_TEXTURE_CUBE_MAP
:
1603 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
1604 !_mesa_has_OES_texture_cube_map(ctx
))
1605 goto invalid_enum_error
;
1606 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1608 /* GL_EXT_secondary_color */
1609 case GL_COLOR_SUM_EXT
:
1610 if (ctx
->API
!= API_OPENGL_COMPAT
)
1611 goto invalid_enum_error
;
1612 return ctx
->Fog
.ColorSumEnabled
;
1614 /* GL_ARB_multisample */
1615 case GL_MULTISAMPLE_ARB
:
1616 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1617 goto invalid_enum_error
;
1618 return ctx
->Multisample
.Enabled
;
1619 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1620 return ctx
->Multisample
.SampleAlphaToCoverage
;
1621 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1622 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1623 goto invalid_enum_error
;
1624 return ctx
->Multisample
.SampleAlphaToOne
;
1625 case GL_SAMPLE_COVERAGE_ARB
:
1626 return ctx
->Multisample
.SampleCoverage
;
1627 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1628 if (!_mesa_is_desktop_gl(ctx
))
1629 goto invalid_enum_error
;
1630 return ctx
->Multisample
.SampleCoverageInvert
;
1632 /* GL_IBM_rasterpos_clip */
1633 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1634 if (ctx
->API
!= API_OPENGL_COMPAT
)
1635 goto invalid_enum_error
;
1636 return ctx
->Transform
.RasterPositionUnclipped
;
1638 /* GL_NV_point_sprite */
1639 case GL_POINT_SPRITE_NV
:
1640 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1641 goto invalid_enum_error
;
1642 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1643 return ctx
->Point
.PointSprite
;
1645 case GL_VERTEX_PROGRAM_ARB
:
1646 if (ctx
->API
!= API_OPENGL_COMPAT
)
1647 goto invalid_enum_error
;
1648 CHECK_EXTENSION(ARB_vertex_program
);
1649 return ctx
->VertexProgram
.Enabled
;
1650 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1651 /* This was added with ARB_vertex_program, but it is also used with
1652 * GLSL vertex shaders on desktop.
1654 if (!_mesa_is_desktop_gl(ctx
))
1655 goto invalid_enum_error
;
1656 CHECK_EXTENSION(ARB_vertex_program
);
1657 return ctx
->VertexProgram
.PointSizeEnabled
;
1658 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1659 if (ctx
->API
!= API_OPENGL_COMPAT
)
1660 goto invalid_enum_error
;
1661 CHECK_EXTENSION(ARB_vertex_program
);
1662 return ctx
->VertexProgram
.TwoSideEnabled
;
1664 /* GL_NV_texture_rectangle */
1665 case GL_TEXTURE_RECTANGLE_NV
:
1666 if (ctx
->API
!= API_OPENGL_COMPAT
)
1667 goto invalid_enum_error
;
1668 CHECK_EXTENSION(NV_texture_rectangle
);
1669 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1671 /* GL_EXT_stencil_two_side */
1672 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1673 if (ctx
->API
!= API_OPENGL_COMPAT
)
1674 goto invalid_enum_error
;
1675 CHECK_EXTENSION(EXT_stencil_two_side
);
1676 return ctx
->Stencil
.TestTwoSide
;
1678 case GL_FRAGMENT_PROGRAM_ARB
:
1679 if (!_mesa_has_ARB_fragment_program(ctx
))
1680 goto invalid_enum_error
;
1681 return ctx
->FragmentProgram
.Enabled
;
1683 /* GL_EXT_depth_bounds_test */
1684 case GL_DEPTH_BOUNDS_TEST_EXT
:
1685 if (!_mesa_is_desktop_gl(ctx
))
1686 goto invalid_enum_error
;
1687 CHECK_EXTENSION(EXT_depth_bounds_test
);
1688 return ctx
->Depth
.BoundsTest
;
1690 /* GL_ARB_depth_clamp */
1691 case GL_DEPTH_CLAMP
:
1692 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1693 !_mesa_has_EXT_depth_clamp(ctx
))
1694 goto invalid_enum_error
;
1695 return ctx
->Transform
.DepthClampNear
||
1696 ctx
->Transform
.DepthClampFar
;
1698 case GL_DEPTH_CLAMP_NEAR_AMD
:
1699 if (!_mesa_is_desktop_gl(ctx
))
1700 goto invalid_enum_error
;
1701 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1702 return ctx
->Transform
.DepthClampNear
;
1704 case GL_DEPTH_CLAMP_FAR_AMD
:
1705 if (!_mesa_is_desktop_gl(ctx
))
1706 goto invalid_enum_error
;
1707 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1708 return ctx
->Transform
.DepthClampFar
;
1710 case GL_FRAGMENT_SHADER_ATI
:
1711 if (ctx
->API
!= API_OPENGL_COMPAT
)
1712 goto invalid_enum_error
;
1713 CHECK_EXTENSION(ATI_fragment_shader
);
1714 return ctx
->ATIFragmentShader
.Enabled
;
1716 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1717 if (!_mesa_is_desktop_gl(ctx
))
1718 goto invalid_enum_error
;
1719 CHECK_EXTENSION(ARB_seamless_cube_map
);
1720 return ctx
->Texture
.CubeMapSeamless
;
1722 case GL_RASTERIZER_DISCARD
:
1723 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1724 goto invalid_enum_error
;
1725 CHECK_EXTENSION(EXT_transform_feedback
);
1726 return ctx
->RasterDiscard
;
1728 /* GL_NV_primitive_restart */
1729 case GL_PRIMITIVE_RESTART_NV
:
1730 if (!_mesa_has_NV_primitive_restart(ctx
))
1731 goto invalid_enum_error
;
1732 return ctx
->Array
.PrimitiveRestart
;
1734 /* GL 3.1 primitive restart */
1735 case GL_PRIMITIVE_RESTART
:
1736 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1737 goto invalid_enum_error
;
1739 return ctx
->Array
.PrimitiveRestart
;
1741 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1742 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1743 goto invalid_enum_error
;
1744 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1746 /* GL3.0 - GL_framebuffer_sRGB */
1747 case GL_FRAMEBUFFER_SRGB_EXT
:
1748 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1749 !_mesa_has_EXT_sRGB_write_control(ctx
))
1750 goto invalid_enum_error
;
1751 return ctx
->Color
.sRGBEnabled
;
1753 /* GL_OES_EGL_image_external */
1754 case GL_TEXTURE_EXTERNAL_OES
:
1755 if (!_mesa_is_gles(ctx
))
1756 goto invalid_enum_error
;
1757 CHECK_EXTENSION(OES_EGL_image_external
);
1758 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1760 /* ARB_texture_multisample */
1761 case GL_SAMPLE_MASK
:
1762 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1763 goto invalid_enum_error
;
1764 CHECK_EXTENSION(ARB_texture_multisample
);
1765 return ctx
->Multisample
.SampleMask
;
1767 /* ARB_sample_shading */
1768 case GL_SAMPLE_SHADING
:
1769 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1770 goto invalid_enum_error
;
1771 CHECK_EXTENSION(ARB_sample_shading
);
1772 return ctx
->Multisample
.SampleShading
;
1774 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1775 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1776 goto invalid_enum_error
;
1777 return ctx
->Color
.BlendCoherent
;
1779 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1780 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
1781 goto invalid_enum_error
;
1782 return ctx
->IntelConservativeRasterization
;
1784 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1785 if (!_mesa_has_NV_conservative_raster(ctx
))
1786 goto invalid_enum_error
;
1787 return ctx
->ConservativeRasterization
;
1789 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1790 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1791 goto invalid_enum_error
;
1792 return ctx
->TileRasterOrderFixed
;
1794 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1795 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1796 goto invalid_enum_error
;
1797 return ctx
->TileRasterOrderIncreasingX
;
1799 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1800 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1801 goto invalid_enum_error
;
1802 return ctx
->TileRasterOrderIncreasingY
;
1805 goto invalid_enum_error
;
1811 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1812 _mesa_enum_to_string(cap
));