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 #define CHECK_EXTENSION(EXTNAME, CAP) \
49 if (!ctx->Extensions.EXTNAME) { \
50 goto invalid_enum_error; \
55 update_derived_primitive_restart_state(struct gl_context
*ctx
)
57 /* Update derived primitive restart state.
59 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
60 || ctx
->Array
.PrimitiveRestartFixedIndex
;
65 * Helper to enable/disable VAO client-side state.
68 vao_state(struct gl_context
*ctx
, gl_vert_attrib attr
, GLboolean state
)
71 _mesa_enable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attr
, true);
73 _mesa_disable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attr
, true);
78 * Helper to enable/disable client-side state.
81 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
85 vao_state(ctx
, VERT_ATTRIB_POS
, state
);
88 vao_state(ctx
, VERT_ATTRIB_NORMAL
, state
);
91 vao_state(ctx
, VERT_ATTRIB_COLOR0
, state
);
94 vao_state(ctx
, VERT_ATTRIB_COLOR_INDEX
, state
);
96 case GL_TEXTURE_COORD_ARRAY
:
97 vao_state(ctx
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
99 case GL_EDGE_FLAG_ARRAY
:
100 vao_state(ctx
, VERT_ATTRIB_EDGEFLAG
, state
);
102 case GL_FOG_COORDINATE_ARRAY_EXT
:
103 vao_state(ctx
, VERT_ATTRIB_FOG
, state
);
105 case GL_SECONDARY_COLOR_ARRAY_EXT
:
106 vao_state(ctx
, VERT_ATTRIB_COLOR1
, state
);
109 case GL_POINT_SIZE_ARRAY_OES
:
110 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
111 ctx
->VertexProgram
.PointSizeEnabled
= state
;
112 vao_state(ctx
, VERT_ATTRIB_POINT_SIZE
, state
);
115 /* GL_NV_primitive_restart */
116 case GL_PRIMITIVE_RESTART_NV
:
117 if (!ctx
->Extensions
.NV_primitive_restart
)
118 goto invalid_enum_error
;
119 if (ctx
->Array
.PrimitiveRestart
== state
)
122 FLUSH_VERTICES(ctx
, 0);
123 ctx
->Array
.PrimitiveRestart
= state
;
124 update_derived_primitive_restart_state(ctx
);
128 goto invalid_enum_error
;
131 if (ctx
->Driver
.Enable
) {
132 ctx
->Driver
.Enable( ctx
, cap
, state
);
138 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
139 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
144 * Enable GL capability.
145 * \param cap state to enable/disable.
147 * Get's the current context, assures that we're outside glBegin()/glEnd() and
148 * calls client_state().
151 _mesa_EnableClientState( GLenum cap
)
153 GET_CURRENT_CONTEXT(ctx
);
154 client_state( ctx
, cap
, GL_TRUE
);
159 * Disable GL capability.
160 * \param cap state to enable/disable.
162 * Get's the current context, assures that we're outside glBegin()/glEnd() and
163 * calls client_state().
166 _mesa_DisableClientState( GLenum cap
)
168 GET_CURRENT_CONTEXT(ctx
);
169 client_state( ctx
, cap
, GL_FALSE
);
173 #undef CHECK_EXTENSION
174 #define CHECK_EXTENSION(EXTNAME, CAP) \
175 if (!ctx->Extensions.EXTNAME) { \
176 goto invalid_enum_error; \
179 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
180 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
181 goto invalid_enum_error; \
185 * Return pointer to current texture unit for setting/getting coordinate
187 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
188 * texture unit is higher than the number of supported coordinate units.
190 static struct gl_fixedfunc_texture_unit
*
191 get_texcoord_unit(struct gl_context
*ctx
)
193 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
194 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
198 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
204 * Helper function to enable or disable a texture target.
205 * \param bit one of the TEXTURE_x_BIT values
206 * \return GL_TRUE if state is changing or GL_FALSE if no change
209 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
211 struct gl_fixedfunc_texture_unit
*texUnit
=
212 _mesa_get_current_fixedfunc_tex_unit(ctx
);
216 const GLbitfield newenabled
= state
217 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
219 if (texUnit
->Enabled
== newenabled
)
222 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
223 texUnit
->Enabled
= newenabled
;
229 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
230 * whether the API supports it (GLES doesn't).
233 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
235 if (ctx
->Multisample
.Enabled
== state
)
238 /* GL compatibility needs Multisample.Enable to determine program state
241 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
242 !ctx
->DriverFlags
.NewMultisampleEnable
) {
243 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
245 FLUSH_VERTICES(ctx
, 0);
248 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
249 ctx
->Multisample
.Enabled
= state
;
251 if (ctx
->Driver
.Enable
) {
252 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
257 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
258 * check for whether the API supports it (GLES doesn't).
261 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
263 if (ctx
->Color
.sRGBEnabled
== state
)
266 /* TODO: Switch i965 to the new flag and remove the conditional */
267 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
268 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
269 ctx
->Color
.sRGBEnabled
= state
;
271 if (ctx
->Driver
.Enable
) {
272 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
277 * Helper function to enable or disable state.
279 * \param ctx GL context.
280 * \param cap the state to enable/disable
281 * \param state whether to enable or disable the specified capability.
283 * Updates the current context and flushes the vertices as needed. For
284 * capabilities associated with extensions it verifies that those extensions
285 * are effectivly present before updating. Notifies the driver via
286 * dd_function_table::Enable.
289 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
291 if (MESA_VERBOSE
& VERBOSE_API
)
292 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
293 state
? "glEnable" : "glDisable",
294 _mesa_enum_to_string(cap
),
299 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
300 goto invalid_enum_error
;
301 if (ctx
->Color
.AlphaEnabled
== state
)
303 /* AlphaEnabled is used by the fixed-func fragment program */
304 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
305 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
306 ctx
->Color
.AlphaEnabled
= state
;
309 if (ctx
->API
!= API_OPENGL_COMPAT
)
310 goto invalid_enum_error
;
311 if (ctx
->Eval
.AutoNormal
== state
)
313 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
314 ctx
->Eval
.AutoNormal
= state
;
318 GLbitfield newEnabled
=
319 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
320 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
321 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
322 ctx
->Color
._AdvancedBlendMode
);
323 ctx
->Color
.BlendEnabled
= newEnabled
;
327 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
328 case GL_CLIP_DISTANCE1
:
329 case GL_CLIP_DISTANCE2
:
330 case GL_CLIP_DISTANCE3
:
331 case GL_CLIP_DISTANCE4
:
332 case GL_CLIP_DISTANCE5
:
333 case GL_CLIP_DISTANCE6
:
334 case GL_CLIP_DISTANCE7
:
336 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
338 if (p
>= ctx
->Const
.MaxClipPlanes
)
339 goto invalid_enum_error
;
341 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
342 == ((GLuint
) state
<< p
))
345 /* The compatibility profile needs _NEW_TRANSFORM to transform
346 * clip planes according to the projection matrix.
348 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
349 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
350 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
352 FLUSH_VERTICES(ctx
, 0);
354 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
357 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
359 /* The projection matrix transforms the clip plane. */
360 /* TODO: glEnable might not be the best place to do it. */
361 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
362 _mesa_update_clip_plane(ctx
, p
);
363 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
367 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
371 case GL_COLOR_MATERIAL
:
372 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
373 goto invalid_enum_error
;
374 if (ctx
->Light
.ColorMaterialEnabled
== state
)
376 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
377 FLUSH_CURRENT(ctx
, 0);
378 ctx
->Light
.ColorMaterialEnabled
= state
;
380 _mesa_update_color_material( ctx
,
381 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
385 if (ctx
->Polygon
.CullFlag
== state
)
388 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
389 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
390 ctx
->Polygon
.CullFlag
= state
;
393 if (ctx
->Depth
.Test
== state
)
395 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
396 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
397 ctx
->Depth
.Test
= state
;
399 case GL_DEBUG_OUTPUT
:
400 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
401 _mesa_set_debug_state_int(ctx
, cap
, state
);
404 if (ctx
->Color
.DitherFlag
== state
)
406 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
407 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
408 ctx
->Color
.DitherFlag
= state
;
411 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
412 goto invalid_enum_error
;
413 if (ctx
->Fog
.Enabled
== state
)
415 FLUSH_VERTICES(ctx
, _NEW_FOG
);
416 ctx
->Fog
.Enabled
= state
;
417 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
427 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
428 goto invalid_enum_error
;
429 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
431 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
432 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
434 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
437 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
441 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
442 goto invalid_enum_error
;
443 if (ctx
->Light
.Enabled
== state
)
445 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
446 ctx
->Light
.Enabled
= state
;
449 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
450 goto invalid_enum_error
;
451 if (ctx
->Line
.SmoothFlag
== state
)
453 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
454 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
455 ctx
->Line
.SmoothFlag
= state
;
457 case GL_LINE_STIPPLE
:
458 if (ctx
->API
!= API_OPENGL_COMPAT
)
459 goto invalid_enum_error
;
460 if (ctx
->Line
.StippleFlag
== state
)
462 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
463 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
464 ctx
->Line
.StippleFlag
= state
;
466 case GL_INDEX_LOGIC_OP
:
467 if (ctx
->API
!= API_OPENGL_COMPAT
)
468 goto invalid_enum_error
;
469 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
471 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
472 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
473 ctx
->Color
.IndexLogicOpEnabled
= state
;
475 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
476 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
477 goto invalid_enum_error
;
478 if (ctx
->IntelConservativeRasterization
== state
)
480 FLUSH_VERTICES(ctx
, 0);
481 ctx
->NewDriverState
|=
482 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
483 ctx
->IntelConservativeRasterization
= state
;
485 case GL_CONSERVATIVE_RASTERIZATION_NV
:
486 if (!_mesa_has_NV_conservative_raster(ctx
))
487 goto invalid_enum_error
;
488 if (ctx
->ConservativeRasterization
== state
)
490 FLUSH_VERTICES(ctx
, 0);
491 ctx
->NewDriverState
|=
492 ctx
->DriverFlags
.NewNvConservativeRasterization
;
493 ctx
->ConservativeRasterization
= state
;
495 case GL_COLOR_LOGIC_OP
:
496 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
497 goto invalid_enum_error
;
498 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
500 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
501 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
502 ctx
->Color
.ColorLogicOpEnabled
= state
;
504 case GL_MAP1_COLOR_4
:
505 if (ctx
->API
!= API_OPENGL_COMPAT
)
506 goto invalid_enum_error
;
507 if (ctx
->Eval
.Map1Color4
== state
)
509 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
510 ctx
->Eval
.Map1Color4
= state
;
513 if (ctx
->API
!= API_OPENGL_COMPAT
)
514 goto invalid_enum_error
;
515 if (ctx
->Eval
.Map1Index
== state
)
517 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
518 ctx
->Eval
.Map1Index
= state
;
521 if (ctx
->API
!= API_OPENGL_COMPAT
)
522 goto invalid_enum_error
;
523 if (ctx
->Eval
.Map1Normal
== state
)
525 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
526 ctx
->Eval
.Map1Normal
= state
;
528 case GL_MAP1_TEXTURE_COORD_1
:
529 if (ctx
->API
!= API_OPENGL_COMPAT
)
530 goto invalid_enum_error
;
531 if (ctx
->Eval
.Map1TextureCoord1
== state
)
533 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
534 ctx
->Eval
.Map1TextureCoord1
= state
;
536 case GL_MAP1_TEXTURE_COORD_2
:
537 if (ctx
->API
!= API_OPENGL_COMPAT
)
538 goto invalid_enum_error
;
539 if (ctx
->Eval
.Map1TextureCoord2
== state
)
541 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
542 ctx
->Eval
.Map1TextureCoord2
= state
;
544 case GL_MAP1_TEXTURE_COORD_3
:
545 if (ctx
->API
!= API_OPENGL_COMPAT
)
546 goto invalid_enum_error
;
547 if (ctx
->Eval
.Map1TextureCoord3
== state
)
549 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
550 ctx
->Eval
.Map1TextureCoord3
= state
;
552 case GL_MAP1_TEXTURE_COORD_4
:
553 if (ctx
->API
!= API_OPENGL_COMPAT
)
554 goto invalid_enum_error
;
555 if (ctx
->Eval
.Map1TextureCoord4
== state
)
557 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
558 ctx
->Eval
.Map1TextureCoord4
= state
;
560 case GL_MAP1_VERTEX_3
:
561 if (ctx
->API
!= API_OPENGL_COMPAT
)
562 goto invalid_enum_error
;
563 if (ctx
->Eval
.Map1Vertex3
== state
)
565 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
566 ctx
->Eval
.Map1Vertex3
= state
;
568 case GL_MAP1_VERTEX_4
:
569 if (ctx
->API
!= API_OPENGL_COMPAT
)
570 goto invalid_enum_error
;
571 if (ctx
->Eval
.Map1Vertex4
== state
)
573 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
574 ctx
->Eval
.Map1Vertex4
= state
;
576 case GL_MAP2_COLOR_4
:
577 if (ctx
->API
!= API_OPENGL_COMPAT
)
578 goto invalid_enum_error
;
579 if (ctx
->Eval
.Map2Color4
== state
)
581 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
582 ctx
->Eval
.Map2Color4
= state
;
585 if (ctx
->API
!= API_OPENGL_COMPAT
)
586 goto invalid_enum_error
;
587 if (ctx
->Eval
.Map2Index
== state
)
589 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
590 ctx
->Eval
.Map2Index
= state
;
593 if (ctx
->API
!= API_OPENGL_COMPAT
)
594 goto invalid_enum_error
;
595 if (ctx
->Eval
.Map2Normal
== state
)
597 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
598 ctx
->Eval
.Map2Normal
= state
;
600 case GL_MAP2_TEXTURE_COORD_1
:
601 if (ctx
->API
!= API_OPENGL_COMPAT
)
602 goto invalid_enum_error
;
603 if (ctx
->Eval
.Map2TextureCoord1
== state
)
605 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
606 ctx
->Eval
.Map2TextureCoord1
= state
;
608 case GL_MAP2_TEXTURE_COORD_2
:
609 if (ctx
->API
!= API_OPENGL_COMPAT
)
610 goto invalid_enum_error
;
611 if (ctx
->Eval
.Map2TextureCoord2
== state
)
613 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
614 ctx
->Eval
.Map2TextureCoord2
= state
;
616 case GL_MAP2_TEXTURE_COORD_3
:
617 if (ctx
->API
!= API_OPENGL_COMPAT
)
618 goto invalid_enum_error
;
619 if (ctx
->Eval
.Map2TextureCoord3
== state
)
621 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
622 ctx
->Eval
.Map2TextureCoord3
= state
;
624 case GL_MAP2_TEXTURE_COORD_4
:
625 if (ctx
->API
!= API_OPENGL_COMPAT
)
626 goto invalid_enum_error
;
627 if (ctx
->Eval
.Map2TextureCoord4
== state
)
629 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
630 ctx
->Eval
.Map2TextureCoord4
= state
;
632 case GL_MAP2_VERTEX_3
:
633 if (ctx
->API
!= API_OPENGL_COMPAT
)
634 goto invalid_enum_error
;
635 if (ctx
->Eval
.Map2Vertex3
== state
)
637 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
638 ctx
->Eval
.Map2Vertex3
= state
;
640 case GL_MAP2_VERTEX_4
:
641 if (ctx
->API
!= API_OPENGL_COMPAT
)
642 goto invalid_enum_error
;
643 if (ctx
->Eval
.Map2Vertex4
== state
)
645 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
646 ctx
->Eval
.Map2Vertex4
= state
;
649 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
650 goto invalid_enum_error
;
651 if (ctx
->Transform
.Normalize
== state
)
653 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
654 ctx
->Transform
.Normalize
= state
;
656 case GL_POINT_SMOOTH
:
657 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
658 goto invalid_enum_error
;
659 if (ctx
->Point
.SmoothFlag
== state
)
661 FLUSH_VERTICES(ctx
, _NEW_POINT
);
662 ctx
->Point
.SmoothFlag
= state
;
664 case GL_POLYGON_SMOOTH
:
665 if (!_mesa_is_desktop_gl(ctx
))
666 goto invalid_enum_error
;
667 if (ctx
->Polygon
.SmoothFlag
== state
)
670 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
671 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
672 ctx
->Polygon
.SmoothFlag
= state
;
674 case GL_POLYGON_STIPPLE
:
675 if (ctx
->API
!= API_OPENGL_COMPAT
)
676 goto invalid_enum_error
;
677 if (ctx
->Polygon
.StippleFlag
== state
)
680 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
681 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
682 ctx
->Polygon
.StippleFlag
= state
;
684 case GL_POLYGON_OFFSET_POINT
:
685 if (!_mesa_is_desktop_gl(ctx
))
686 goto invalid_enum_error
;
687 if (ctx
->Polygon
.OffsetPoint
== state
)
690 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
691 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
692 ctx
->Polygon
.OffsetPoint
= state
;
694 case GL_POLYGON_OFFSET_LINE
:
695 if (!_mesa_is_desktop_gl(ctx
))
696 goto invalid_enum_error
;
697 if (ctx
->Polygon
.OffsetLine
== state
)
700 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
701 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
702 ctx
->Polygon
.OffsetLine
= state
;
704 case GL_POLYGON_OFFSET_FILL
:
705 if (ctx
->Polygon
.OffsetFill
== state
)
708 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
709 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
710 ctx
->Polygon
.OffsetFill
= state
;
712 case GL_RESCALE_NORMAL_EXT
:
713 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
714 goto invalid_enum_error
;
715 if (ctx
->Transform
.RescaleNormals
== state
)
717 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
718 ctx
->Transform
.RescaleNormals
= state
;
720 case GL_SCISSOR_TEST
:
722 /* Must expand glEnable to all scissors */
723 GLbitfield newEnabled
=
724 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
725 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
726 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
728 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
729 ctx
->Scissor
.EnableFlags
= newEnabled
;
733 case GL_STENCIL_TEST
:
734 if (ctx
->Stencil
.Enabled
== state
)
736 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
737 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
738 ctx
->Stencil
.Enabled
= state
;
741 if (ctx
->API
!= API_OPENGL_COMPAT
)
742 goto invalid_enum_error
;
743 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
748 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
749 goto invalid_enum_error
;
750 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
755 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
756 goto invalid_enum_error
;
757 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
761 case GL_TEXTURE_GEN_S
:
762 case GL_TEXTURE_GEN_T
:
763 case GL_TEXTURE_GEN_R
:
764 case GL_TEXTURE_GEN_Q
:
766 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
768 if (ctx
->API
!= API_OPENGL_COMPAT
)
769 goto invalid_enum_error
;
772 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
773 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
775 newenabled
|= coordBit
;
776 if (texUnit
->TexGenEnabled
== newenabled
)
778 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
779 texUnit
->TexGenEnabled
= newenabled
;
784 case GL_TEXTURE_GEN_STR_OES
:
785 /* disable S, T, and R at the same time */
787 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
789 if (ctx
->API
!= API_OPENGLES
)
790 goto invalid_enum_error
;
794 texUnit
->TexGenEnabled
& ~STR_BITS
;
796 newenabled
|= STR_BITS
;
797 if (texUnit
->TexGenEnabled
== newenabled
)
799 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
800 texUnit
->TexGenEnabled
= newenabled
;
805 /* client-side state */
806 case GL_VERTEX_ARRAY
:
807 case GL_NORMAL_ARRAY
:
809 case GL_TEXTURE_COORD_ARRAY
:
810 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
811 goto invalid_enum_error
;
812 client_state( ctx
, cap
, state
);
815 case GL_EDGE_FLAG_ARRAY
:
816 case GL_FOG_COORDINATE_ARRAY_EXT
:
817 case GL_SECONDARY_COLOR_ARRAY_EXT
:
818 if (ctx
->API
!= API_OPENGL_COMPAT
)
819 goto invalid_enum_error
;
820 client_state( ctx
, cap
, state
);
822 case GL_POINT_SIZE_ARRAY_OES
:
823 if (ctx
->API
!= API_OPENGLES
)
824 goto invalid_enum_error
;
825 client_state( ctx
, cap
, state
);
828 /* GL_ARB_texture_cube_map */
829 case GL_TEXTURE_CUBE_MAP
:
830 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
831 goto invalid_enum_error
;
832 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
833 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
838 /* GL_EXT_secondary_color */
839 case GL_COLOR_SUM_EXT
:
840 if (ctx
->API
!= API_OPENGL_COMPAT
)
841 goto invalid_enum_error
;
842 if (ctx
->Fog
.ColorSumEnabled
== state
)
844 FLUSH_VERTICES(ctx
, _NEW_FOG
);
845 ctx
->Fog
.ColorSumEnabled
= state
;
848 /* GL_ARB_multisample */
849 case GL_MULTISAMPLE_ARB
:
850 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
851 goto invalid_enum_error
;
852 _mesa_set_multisample(ctx
, state
);
854 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
855 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
857 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
859 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
860 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
862 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
863 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
864 goto invalid_enum_error
;
865 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
867 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
869 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
870 ctx
->Multisample
.SampleAlphaToOne
= state
;
872 case GL_SAMPLE_COVERAGE_ARB
:
873 if (ctx
->Multisample
.SampleCoverage
== state
)
875 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
877 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
878 ctx
->Multisample
.SampleCoverage
= state
;
880 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
881 if (!_mesa_is_desktop_gl(ctx
))
882 goto invalid_enum_error
;
883 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
885 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
887 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
888 ctx
->Multisample
.SampleCoverageInvert
= state
;
891 /* GL_ARB_sample_shading */
892 case GL_SAMPLE_SHADING
:
893 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
894 goto invalid_enum_error
;
895 CHECK_EXTENSION(ARB_sample_shading
, cap
);
896 if (ctx
->Multisample
.SampleShading
== state
)
898 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
900 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
901 ctx
->Multisample
.SampleShading
= state
;
904 /* GL_IBM_rasterpos_clip */
905 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
906 if (ctx
->API
!= API_OPENGL_COMPAT
)
907 goto invalid_enum_error
;
908 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
910 FLUSH_VERTICES(ctx
, 0);
911 ctx
->Transform
.RasterPositionUnclipped
= state
;
914 /* GL_NV_point_sprite */
915 case GL_POINT_SPRITE_NV
:
916 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
917 goto invalid_enum_error
;
918 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
919 if (ctx
->Point
.PointSprite
== state
)
921 FLUSH_VERTICES(ctx
, _NEW_POINT
);
922 ctx
->Point
.PointSprite
= state
;
925 case GL_VERTEX_PROGRAM_ARB
:
926 if (ctx
->API
!= API_OPENGL_COMPAT
)
927 goto invalid_enum_error
;
928 CHECK_EXTENSION(ARB_vertex_program
, cap
);
929 if (ctx
->VertexProgram
.Enabled
== state
)
931 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
932 ctx
->VertexProgram
.Enabled
= state
;
933 _mesa_update_vertex_processing_mode(ctx
);
935 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
936 /* This was added with ARB_vertex_program, but it is also used with
937 * GLSL vertex shaders on desktop.
939 if (!_mesa_is_desktop_gl(ctx
))
940 goto invalid_enum_error
;
941 CHECK_EXTENSION(ARB_vertex_program
, cap
);
942 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
944 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
945 ctx
->VertexProgram
.PointSizeEnabled
= state
;
947 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
948 if (ctx
->API
!= API_OPENGL_COMPAT
)
949 goto invalid_enum_error
;
950 CHECK_EXTENSION(ARB_vertex_program
, cap
);
951 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
953 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
954 ctx
->VertexProgram
.TwoSideEnabled
= state
;
957 /* GL_NV_texture_rectangle */
958 case GL_TEXTURE_RECTANGLE_NV
:
959 if (ctx
->API
!= API_OPENGL_COMPAT
)
960 goto invalid_enum_error
;
961 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
962 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
967 /* GL_EXT_stencil_two_side */
968 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
969 if (ctx
->API
!= API_OPENGL_COMPAT
)
970 goto invalid_enum_error
;
971 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
972 if (ctx
->Stencil
.TestTwoSide
== state
)
974 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
975 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
976 ctx
->Stencil
.TestTwoSide
= state
;
978 ctx
->Stencil
._BackFace
= 2;
980 ctx
->Stencil
._BackFace
= 1;
984 case GL_FRAGMENT_PROGRAM_ARB
:
985 if (ctx
->API
!= API_OPENGL_COMPAT
)
986 goto invalid_enum_error
;
987 CHECK_EXTENSION(ARB_fragment_program
, cap
);
988 if (ctx
->FragmentProgram
.Enabled
== state
)
990 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
991 ctx
->FragmentProgram
.Enabled
= state
;
994 /* GL_EXT_depth_bounds_test */
995 case GL_DEPTH_BOUNDS_TEST_EXT
:
996 if (!_mesa_is_desktop_gl(ctx
))
997 goto invalid_enum_error
;
998 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
999 if (ctx
->Depth
.BoundsTest
== state
)
1001 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
1002 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
1003 ctx
->Depth
.BoundsTest
= state
;
1006 case GL_DEPTH_CLAMP
:
1007 if (!_mesa_is_desktop_gl(ctx
))
1008 goto invalid_enum_error
;
1009 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
1010 if (ctx
->Transform
.DepthClamp
== state
)
1012 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1014 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1015 ctx
->Transform
.DepthClamp
= state
;
1018 case GL_FRAGMENT_SHADER_ATI
:
1019 if (ctx
->API
!= API_OPENGL_COMPAT
)
1020 goto invalid_enum_error
;
1021 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
1022 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1024 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1025 ctx
->ATIFragmentShader
.Enabled
= state
;
1028 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1029 if (!_mesa_is_desktop_gl(ctx
))
1030 goto invalid_enum_error
;
1031 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
1032 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1033 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1034 ctx
->Texture
.CubeMapSeamless
= state
;
1038 case GL_RASTERIZER_DISCARD
:
1039 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1040 goto invalid_enum_error
;
1041 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
1042 if (ctx
->RasterDiscard
!= state
) {
1043 FLUSH_VERTICES(ctx
, 0);
1044 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1045 ctx
->RasterDiscard
= state
;
1049 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1050 CHECK_EXTENSION(MESA_tile_raster_order
, cap
);
1051 if (ctx
->TileRasterOrderFixed
!= state
) {
1052 FLUSH_VERTICES(ctx
, 0);
1053 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1054 ctx
->TileRasterOrderFixed
= state
;
1058 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1059 CHECK_EXTENSION(MESA_tile_raster_order
, cap
);
1060 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1061 FLUSH_VERTICES(ctx
, 0);
1062 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1063 ctx
->TileRasterOrderIncreasingX
= state
;
1067 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1068 CHECK_EXTENSION(MESA_tile_raster_order
, cap
);
1069 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1070 FLUSH_VERTICES(ctx
, 0);
1071 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1072 ctx
->TileRasterOrderIncreasingY
= state
;
1076 /* GL 3.1 primitive restart. Note: this enum is different from
1077 * GL_PRIMITIVE_RESTART_NV (which is client state).
1079 case GL_PRIMITIVE_RESTART
:
1080 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1081 goto invalid_enum_error
;
1083 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1084 FLUSH_VERTICES(ctx
, 0);
1085 ctx
->Array
.PrimitiveRestart
= state
;
1086 update_derived_primitive_restart_state(ctx
);
1090 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1091 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
)
1092 goto invalid_enum_error
;
1093 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1094 FLUSH_VERTICES(ctx
, 0);
1095 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1096 update_derived_primitive_restart_state(ctx
);
1100 /* GL3.0 - GL_framebuffer_sRGB */
1101 case GL_FRAMEBUFFER_SRGB_EXT
:
1102 if (!_mesa_is_desktop_gl(ctx
))
1103 goto invalid_enum_error
;
1104 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
1105 _mesa_set_framebuffer_srgb(ctx
, state
);
1108 /* GL_OES_EGL_image_external */
1109 case GL_TEXTURE_EXTERNAL_OES
:
1110 if (!_mesa_is_gles(ctx
))
1111 goto invalid_enum_error
;
1112 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
1113 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1118 /* ARB_texture_multisample */
1119 case GL_SAMPLE_MASK
:
1120 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1121 goto invalid_enum_error
;
1122 CHECK_EXTENSION(ARB_texture_multisample
, cap
);
1123 if (ctx
->Multisample
.SampleMask
== state
)
1125 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1127 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1128 ctx
->Multisample
.SampleMask
= state
;
1131 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1132 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent
, cap
);
1133 if (ctx
->Color
.BlendCoherent
== state
)
1135 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1136 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1137 ctx
->Color
.BlendCoherent
= state
;
1141 goto invalid_enum_error
;
1144 if (ctx
->Driver
.Enable
) {
1145 ctx
->Driver
.Enable( ctx
, cap
, state
);
1151 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1152 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1157 * Enable GL capability. Called by glEnable()
1158 * \param cap state to enable.
1161 _mesa_Enable( GLenum cap
)
1163 GET_CURRENT_CONTEXT(ctx
);
1165 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1170 * Disable GL capability. Called by glDisable()
1171 * \param cap state to disable.
1174 _mesa_Disable( GLenum cap
)
1176 GET_CURRENT_CONTEXT(ctx
);
1178 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1184 * Enable/disable an indexed state var.
1187 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1188 GLuint index
, GLboolean state
)
1190 assert(state
== 0 || state
== 1);
1193 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1194 goto invalid_enum_error
;
1196 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1197 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1198 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1201 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1202 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1205 enabled
|= (1 << index
);
1207 enabled
&= ~(1 << index
);
1209 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1210 ctx
->Color
._AdvancedBlendMode
);
1211 ctx
->Color
.BlendEnabled
= enabled
;
1214 case GL_SCISSOR_TEST
:
1215 if (index
>= ctx
->Const
.MaxViewports
) {
1216 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1217 state
? "glEnablei" : "glDisablei", index
);
1220 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1222 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1223 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1225 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1227 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1231 goto invalid_enum_error
;
1236 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1237 state
? "glEnablei" : "glDisablei",
1238 _mesa_enum_to_string(cap
));
1243 _mesa_Disablei( GLenum cap
, GLuint index
)
1245 GET_CURRENT_CONTEXT(ctx
);
1246 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1251 _mesa_Enablei( GLenum cap
, GLuint index
)
1253 GET_CURRENT_CONTEXT(ctx
);
1254 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1258 GLboolean GLAPIENTRY
1259 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1261 GET_CURRENT_CONTEXT(ctx
);
1262 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1265 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1266 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1270 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1271 case GL_SCISSOR_TEST
:
1272 if (index
>= ctx
->Const
.MaxViewports
) {
1273 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1277 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1279 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1280 _mesa_enum_to_string(cap
));
1288 #undef CHECK_EXTENSION
1289 #define CHECK_EXTENSION(EXTNAME) \
1290 if (!ctx->Extensions.EXTNAME) { \
1291 goto invalid_enum_error; \
1294 #undef CHECK_EXTENSION2
1295 #define CHECK_EXTENSION2(EXT1, EXT2) \
1296 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1297 goto invalid_enum_error; \
1302 * Helper function to determine whether a texture target is enabled.
1305 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1307 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1308 _mesa_get_current_fixedfunc_tex_unit(ctx
);
1313 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1318 * Return simple enable/disable state.
1320 * \param cap state variable to query.
1322 * Returns the state of the specified capability from the current GL context.
1323 * For the capabilities associated with extensions verifies that those
1324 * extensions are effectively present before reporting.
1326 GLboolean GLAPIENTRY
1327 _mesa_IsEnabled( GLenum cap
)
1329 GET_CURRENT_CONTEXT(ctx
);
1330 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1334 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1335 goto invalid_enum_error
;
1336 return ctx
->Color
.AlphaEnabled
;
1337 case GL_AUTO_NORMAL
:
1338 if (ctx
->API
!= API_OPENGL_COMPAT
)
1339 goto invalid_enum_error
;
1340 return ctx
->Eval
.AutoNormal
;
1342 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1343 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1344 case GL_CLIP_DISTANCE1
:
1345 case GL_CLIP_DISTANCE2
:
1346 case GL_CLIP_DISTANCE3
:
1347 case GL_CLIP_DISTANCE4
:
1348 case GL_CLIP_DISTANCE5
:
1349 case GL_CLIP_DISTANCE6
:
1350 case GL_CLIP_DISTANCE7
: {
1351 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1353 if (p
>= ctx
->Const
.MaxClipPlanes
)
1354 goto invalid_enum_error
;
1356 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1358 case GL_COLOR_MATERIAL
:
1359 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1360 goto invalid_enum_error
;
1361 return ctx
->Light
.ColorMaterialEnabled
;
1363 return ctx
->Polygon
.CullFlag
;
1364 case GL_DEBUG_OUTPUT
:
1365 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1366 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1368 return ctx
->Depth
.Test
;
1370 return ctx
->Color
.DitherFlag
;
1372 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1373 goto invalid_enum_error
;
1374 return ctx
->Fog
.Enabled
;
1376 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1377 goto invalid_enum_error
;
1378 return ctx
->Light
.Enabled
;
1387 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1388 goto invalid_enum_error
;
1389 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1390 case GL_LINE_SMOOTH
:
1391 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1392 goto invalid_enum_error
;
1393 return ctx
->Line
.SmoothFlag
;
1394 case GL_LINE_STIPPLE
:
1395 if (ctx
->API
!= API_OPENGL_COMPAT
)
1396 goto invalid_enum_error
;
1397 return ctx
->Line
.StippleFlag
;
1398 case GL_INDEX_LOGIC_OP
:
1399 if (ctx
->API
!= API_OPENGL_COMPAT
)
1400 goto invalid_enum_error
;
1401 return ctx
->Color
.IndexLogicOpEnabled
;
1402 case GL_COLOR_LOGIC_OP
:
1403 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1404 goto invalid_enum_error
;
1405 return ctx
->Color
.ColorLogicOpEnabled
;
1406 case GL_MAP1_COLOR_4
:
1407 if (ctx
->API
!= API_OPENGL_COMPAT
)
1408 goto invalid_enum_error
;
1409 return ctx
->Eval
.Map1Color4
;
1411 if (ctx
->API
!= API_OPENGL_COMPAT
)
1412 goto invalid_enum_error
;
1413 return ctx
->Eval
.Map1Index
;
1414 case GL_MAP1_NORMAL
:
1415 if (ctx
->API
!= API_OPENGL_COMPAT
)
1416 goto invalid_enum_error
;
1417 return ctx
->Eval
.Map1Normal
;
1418 case GL_MAP1_TEXTURE_COORD_1
:
1419 if (ctx
->API
!= API_OPENGL_COMPAT
)
1420 goto invalid_enum_error
;
1421 return ctx
->Eval
.Map1TextureCoord1
;
1422 case GL_MAP1_TEXTURE_COORD_2
:
1423 if (ctx
->API
!= API_OPENGL_COMPAT
)
1424 goto invalid_enum_error
;
1425 return ctx
->Eval
.Map1TextureCoord2
;
1426 case GL_MAP1_TEXTURE_COORD_3
:
1427 if (ctx
->API
!= API_OPENGL_COMPAT
)
1428 goto invalid_enum_error
;
1429 return ctx
->Eval
.Map1TextureCoord3
;
1430 case GL_MAP1_TEXTURE_COORD_4
:
1431 if (ctx
->API
!= API_OPENGL_COMPAT
)
1432 goto invalid_enum_error
;
1433 return ctx
->Eval
.Map1TextureCoord4
;
1434 case GL_MAP1_VERTEX_3
:
1435 if (ctx
->API
!= API_OPENGL_COMPAT
)
1436 goto invalid_enum_error
;
1437 return ctx
->Eval
.Map1Vertex3
;
1438 case GL_MAP1_VERTEX_4
:
1439 if (ctx
->API
!= API_OPENGL_COMPAT
)
1440 goto invalid_enum_error
;
1441 return ctx
->Eval
.Map1Vertex4
;
1442 case GL_MAP2_COLOR_4
:
1443 if (ctx
->API
!= API_OPENGL_COMPAT
)
1444 goto invalid_enum_error
;
1445 return ctx
->Eval
.Map2Color4
;
1447 if (ctx
->API
!= API_OPENGL_COMPAT
)
1448 goto invalid_enum_error
;
1449 return ctx
->Eval
.Map2Index
;
1450 case GL_MAP2_NORMAL
:
1451 if (ctx
->API
!= API_OPENGL_COMPAT
)
1452 goto invalid_enum_error
;
1453 return ctx
->Eval
.Map2Normal
;
1454 case GL_MAP2_TEXTURE_COORD_1
:
1455 if (ctx
->API
!= API_OPENGL_COMPAT
)
1456 goto invalid_enum_error
;
1457 return ctx
->Eval
.Map2TextureCoord1
;
1458 case GL_MAP2_TEXTURE_COORD_2
:
1459 if (ctx
->API
!= API_OPENGL_COMPAT
)
1460 goto invalid_enum_error
;
1461 return ctx
->Eval
.Map2TextureCoord2
;
1462 case GL_MAP2_TEXTURE_COORD_3
:
1463 if (ctx
->API
!= API_OPENGL_COMPAT
)
1464 goto invalid_enum_error
;
1465 return ctx
->Eval
.Map2TextureCoord3
;
1466 case GL_MAP2_TEXTURE_COORD_4
:
1467 if (ctx
->API
!= API_OPENGL_COMPAT
)
1468 goto invalid_enum_error
;
1469 return ctx
->Eval
.Map2TextureCoord4
;
1470 case GL_MAP2_VERTEX_3
:
1471 if (ctx
->API
!= API_OPENGL_COMPAT
)
1472 goto invalid_enum_error
;
1473 return ctx
->Eval
.Map2Vertex3
;
1474 case GL_MAP2_VERTEX_4
:
1475 if (ctx
->API
!= API_OPENGL_COMPAT
)
1476 goto invalid_enum_error
;
1477 return ctx
->Eval
.Map2Vertex4
;
1479 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1480 goto invalid_enum_error
;
1481 return ctx
->Transform
.Normalize
;
1482 case GL_POINT_SMOOTH
:
1483 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1484 goto invalid_enum_error
;
1485 return ctx
->Point
.SmoothFlag
;
1486 case GL_POLYGON_SMOOTH
:
1487 if (!_mesa_is_desktop_gl(ctx
))
1488 goto invalid_enum_error
;
1489 return ctx
->Polygon
.SmoothFlag
;
1490 case GL_POLYGON_STIPPLE
:
1491 if (ctx
->API
!= API_OPENGL_COMPAT
)
1492 goto invalid_enum_error
;
1493 return ctx
->Polygon
.StippleFlag
;
1494 case GL_POLYGON_OFFSET_POINT
:
1495 if (!_mesa_is_desktop_gl(ctx
))
1496 goto invalid_enum_error
;
1497 return ctx
->Polygon
.OffsetPoint
;
1498 case GL_POLYGON_OFFSET_LINE
:
1499 if (!_mesa_is_desktop_gl(ctx
))
1500 goto invalid_enum_error
;
1501 return ctx
->Polygon
.OffsetLine
;
1502 case GL_POLYGON_OFFSET_FILL
:
1503 return ctx
->Polygon
.OffsetFill
;
1504 case GL_RESCALE_NORMAL_EXT
:
1505 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1506 goto invalid_enum_error
;
1507 return ctx
->Transform
.RescaleNormals
;
1508 case GL_SCISSOR_TEST
:
1509 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1510 case GL_STENCIL_TEST
:
1511 return ctx
->Stencil
.Enabled
;
1513 if (ctx
->API
!= API_OPENGL_COMPAT
)
1514 goto invalid_enum_error
;
1515 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1517 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1518 goto invalid_enum_error
;
1519 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1521 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1522 goto invalid_enum_error
;
1523 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1524 case GL_TEXTURE_GEN_S
:
1525 case GL_TEXTURE_GEN_T
:
1526 case GL_TEXTURE_GEN_R
:
1527 case GL_TEXTURE_GEN_Q
:
1529 const struct gl_fixedfunc_texture_unit
*texUnit
=
1530 get_texcoord_unit(ctx
);
1532 if (ctx
->API
!= API_OPENGL_COMPAT
)
1533 goto invalid_enum_error
;
1536 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1537 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1541 case GL_TEXTURE_GEN_STR_OES
:
1543 const struct gl_fixedfunc_texture_unit
*texUnit
=
1544 get_texcoord_unit(ctx
);
1546 if (ctx
->API
!= API_OPENGLES
)
1547 goto invalid_enum_error
;
1550 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1551 ? GL_TRUE
: GL_FALSE
;
1555 /* client-side state */
1556 case GL_VERTEX_ARRAY
:
1557 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1558 goto invalid_enum_error
;
1559 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
1560 case GL_NORMAL_ARRAY
:
1561 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1562 goto invalid_enum_error
;
1563 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
1564 case GL_COLOR_ARRAY
:
1565 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1566 goto invalid_enum_error
;
1567 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
1568 case GL_INDEX_ARRAY
:
1569 if (ctx
->API
!= API_OPENGL_COMPAT
)
1570 goto invalid_enum_error
;
1571 return ctx
->Array
.VAO
->
1572 VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
1573 case GL_TEXTURE_COORD_ARRAY
:
1574 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1575 goto invalid_enum_error
;
1576 return ctx
->Array
.VAO
->
1577 VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
1578 case GL_EDGE_FLAG_ARRAY
:
1579 if (ctx
->API
!= API_OPENGL_COMPAT
)
1580 goto invalid_enum_error
;
1581 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
1582 case GL_FOG_COORDINATE_ARRAY_EXT
:
1583 if (ctx
->API
!= API_OPENGL_COMPAT
)
1584 goto invalid_enum_error
;
1585 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
1586 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1587 if (ctx
->API
!= API_OPENGL_COMPAT
)
1588 goto invalid_enum_error
;
1589 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
1590 case GL_POINT_SIZE_ARRAY_OES
:
1591 if (ctx
->API
!= API_OPENGLES
)
1592 goto invalid_enum_error
;
1593 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
1595 /* GL_ARB_texture_cube_map */
1596 case GL_TEXTURE_CUBE_MAP
:
1597 CHECK_EXTENSION(ARB_texture_cube_map
);
1598 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1600 /* GL_EXT_secondary_color */
1601 case GL_COLOR_SUM_EXT
:
1602 if (ctx
->API
!= API_OPENGL_COMPAT
)
1603 goto invalid_enum_error
;
1604 return ctx
->Fog
.ColorSumEnabled
;
1606 /* GL_ARB_multisample */
1607 case GL_MULTISAMPLE_ARB
:
1608 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1609 goto invalid_enum_error
;
1610 return ctx
->Multisample
.Enabled
;
1611 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1612 return ctx
->Multisample
.SampleAlphaToCoverage
;
1613 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1614 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1615 goto invalid_enum_error
;
1616 return ctx
->Multisample
.SampleAlphaToOne
;
1617 case GL_SAMPLE_COVERAGE_ARB
:
1618 return ctx
->Multisample
.SampleCoverage
;
1619 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1620 if (!_mesa_is_desktop_gl(ctx
))
1621 goto invalid_enum_error
;
1622 return ctx
->Multisample
.SampleCoverageInvert
;
1624 /* GL_IBM_rasterpos_clip */
1625 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1626 if (ctx
->API
!= API_OPENGL_COMPAT
)
1627 goto invalid_enum_error
;
1628 return ctx
->Transform
.RasterPositionUnclipped
;
1630 /* GL_NV_point_sprite */
1631 case GL_POINT_SPRITE_NV
:
1632 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1633 goto invalid_enum_error
;
1634 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1635 return ctx
->Point
.PointSprite
;
1637 case GL_VERTEX_PROGRAM_ARB
:
1638 if (ctx
->API
!= API_OPENGL_COMPAT
)
1639 goto invalid_enum_error
;
1640 CHECK_EXTENSION(ARB_vertex_program
);
1641 return ctx
->VertexProgram
.Enabled
;
1642 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1643 /* This was added with ARB_vertex_program, but it is also used with
1644 * GLSL vertex shaders on desktop.
1646 if (!_mesa_is_desktop_gl(ctx
))
1647 goto invalid_enum_error
;
1648 CHECK_EXTENSION(ARB_vertex_program
);
1649 return ctx
->VertexProgram
.PointSizeEnabled
;
1650 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1651 if (ctx
->API
!= API_OPENGL_COMPAT
)
1652 goto invalid_enum_error
;
1653 CHECK_EXTENSION(ARB_vertex_program
);
1654 return ctx
->VertexProgram
.TwoSideEnabled
;
1656 /* GL_NV_texture_rectangle */
1657 case GL_TEXTURE_RECTANGLE_NV
:
1658 if (ctx
->API
!= API_OPENGL_COMPAT
)
1659 goto invalid_enum_error
;
1660 CHECK_EXTENSION(NV_texture_rectangle
);
1661 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1663 /* GL_EXT_stencil_two_side */
1664 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1665 if (ctx
->API
!= API_OPENGL_COMPAT
)
1666 goto invalid_enum_error
;
1667 CHECK_EXTENSION(EXT_stencil_two_side
);
1668 return ctx
->Stencil
.TestTwoSide
;
1670 case GL_FRAGMENT_PROGRAM_ARB
:
1671 if (ctx
->API
!= API_OPENGL_COMPAT
)
1672 goto invalid_enum_error
;
1673 return ctx
->FragmentProgram
.Enabled
;
1675 /* GL_EXT_depth_bounds_test */
1676 case GL_DEPTH_BOUNDS_TEST_EXT
:
1677 if (!_mesa_is_desktop_gl(ctx
))
1678 goto invalid_enum_error
;
1679 CHECK_EXTENSION(EXT_depth_bounds_test
);
1680 return ctx
->Depth
.BoundsTest
;
1682 /* GL_ARB_depth_clamp */
1683 case GL_DEPTH_CLAMP
:
1684 if (!_mesa_is_desktop_gl(ctx
))
1685 goto invalid_enum_error
;
1686 CHECK_EXTENSION(ARB_depth_clamp
);
1687 return ctx
->Transform
.DepthClamp
;
1689 case GL_FRAGMENT_SHADER_ATI
:
1690 if (ctx
->API
!= API_OPENGL_COMPAT
)
1691 goto invalid_enum_error
;
1692 CHECK_EXTENSION(ATI_fragment_shader
);
1693 return ctx
->ATIFragmentShader
.Enabled
;
1695 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1696 if (!_mesa_is_desktop_gl(ctx
))
1697 goto invalid_enum_error
;
1698 CHECK_EXTENSION(ARB_seamless_cube_map
);
1699 return ctx
->Texture
.CubeMapSeamless
;
1701 case GL_RASTERIZER_DISCARD
:
1702 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1703 goto invalid_enum_error
;
1704 CHECK_EXTENSION(EXT_transform_feedback
);
1705 return ctx
->RasterDiscard
;
1707 /* GL_NV_primitive_restart */
1708 case GL_PRIMITIVE_RESTART_NV
:
1709 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1710 goto invalid_enum_error
;
1712 return ctx
->Array
.PrimitiveRestart
;
1714 /* GL 3.1 primitive restart */
1715 case GL_PRIMITIVE_RESTART
:
1716 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1717 goto invalid_enum_error
;
1719 return ctx
->Array
.PrimitiveRestart
;
1721 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1722 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1723 goto invalid_enum_error
;
1725 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1727 /* GL3.0 - GL_framebuffer_sRGB */
1728 case GL_FRAMEBUFFER_SRGB_EXT
:
1729 if (!_mesa_is_desktop_gl(ctx
))
1730 goto invalid_enum_error
;
1731 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1732 return ctx
->Color
.sRGBEnabled
;
1734 /* GL_OES_EGL_image_external */
1735 case GL_TEXTURE_EXTERNAL_OES
:
1736 if (!_mesa_is_gles(ctx
))
1737 goto invalid_enum_error
;
1738 CHECK_EXTENSION(OES_EGL_image_external
);
1739 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1741 /* ARB_texture_multisample */
1742 case GL_SAMPLE_MASK
:
1743 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1744 goto invalid_enum_error
;
1745 CHECK_EXTENSION(ARB_texture_multisample
);
1746 return ctx
->Multisample
.SampleMask
;
1748 /* ARB_sample_shading */
1749 case GL_SAMPLE_SHADING
:
1750 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1751 goto invalid_enum_error
;
1752 CHECK_EXTENSION(ARB_sample_shading
);
1753 return ctx
->Multisample
.SampleShading
;
1755 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1756 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent
);
1757 return ctx
->Color
.BlendCoherent
;
1759 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1760 CHECK_EXTENSION(INTEL_conservative_rasterization
);
1761 return ctx
->IntelConservativeRasterization
;
1763 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1764 CHECK_EXTENSION(NV_conservative_raster
);
1765 return ctx
->ConservativeRasterization
;
1767 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1768 CHECK_EXTENSION(MESA_tile_raster_order
);
1769 return ctx
->TileRasterOrderFixed
;
1771 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1772 CHECK_EXTENSION(MESA_tile_raster_order
);
1773 return ctx
->TileRasterOrderIncreasingX
;
1775 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1776 CHECK_EXTENSION(MESA_tile_raster_order
);
1777 return ctx
->TileRasterOrderIncreasingY
;
1780 goto invalid_enum_error
;
1786 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1787 _mesa_enum_to_string(cap
));