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.
35 #include "debug_output.h"
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 goto invalid_enum_error; \
52 update_derived_primitive_restart_state(struct gl_context
*ctx
)
54 /* Update derived primitive restart state.
56 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
57 || ctx
->Array
.PrimitiveRestartFixedIndex
;
61 * Helper to enable/disable client-side state.
64 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
66 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
72 var
= &vao
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
76 var
= &vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
77 flag
= VERT_BIT_NORMAL
;
80 var
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
81 flag
= VERT_BIT_COLOR0
;
84 var
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
85 flag
= VERT_BIT_COLOR_INDEX
;
87 case GL_TEXTURE_COORD_ARRAY
:
88 var
= &vao
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
89 flag
= VERT_BIT_TEX(ctx
->Array
.ActiveTexture
);
91 case GL_EDGE_FLAG_ARRAY
:
92 var
= &vao
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
93 flag
= VERT_BIT_EDGEFLAG
;
95 case GL_FOG_COORDINATE_ARRAY_EXT
:
96 var
= &vao
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
99 case GL_SECONDARY_COLOR_ARRAY_EXT
:
100 var
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
101 flag
= VERT_BIT_COLOR1
;
104 case GL_POINT_SIZE_ARRAY_OES
:
105 var
= &vao
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
106 flag
= VERT_BIT_POINT_SIZE
;
107 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
108 ctx
->VertexProgram
.PointSizeEnabled
= state
;
111 /* GL_NV_primitive_restart */
112 case GL_PRIMITIVE_RESTART_NV
:
113 if (!ctx
->Extensions
.NV_primitive_restart
)
114 goto invalid_enum_error
;
115 if (ctx
->Array
.PrimitiveRestart
== state
)
118 FLUSH_VERTICES(ctx
, 0);
119 ctx
->Array
.PrimitiveRestart
= state
;
120 update_derived_primitive_restart_state(ctx
);
124 goto invalid_enum_error
;
130 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
135 vao
->_Enabled
|= flag
;
137 vao
->_Enabled
&= ~flag
;
139 vao
->NewArrays
|= flag
;
141 if (ctx
->Driver
.Enable
) {
142 ctx
->Driver
.Enable( ctx
, cap
, state
);
148 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
149 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
154 * Enable GL capability.
155 * \param cap state to enable/disable.
157 * Get's the current context, assures that we're outside glBegin()/glEnd() and
158 * calls client_state().
161 _mesa_EnableClientState( GLenum cap
)
163 GET_CURRENT_CONTEXT(ctx
);
164 client_state( ctx
, cap
, GL_TRUE
);
169 * Disable GL capability.
170 * \param cap state to enable/disable.
172 * Get's the current context, assures that we're outside glBegin()/glEnd() and
173 * calls client_state().
176 _mesa_DisableClientState( GLenum cap
)
178 GET_CURRENT_CONTEXT(ctx
);
179 client_state( ctx
, cap
, GL_FALSE
);
183 #undef CHECK_EXTENSION
184 #define CHECK_EXTENSION(EXTNAME, CAP) \
185 if (!ctx->Extensions.EXTNAME) { \
186 goto invalid_enum_error; \
189 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
190 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
191 goto invalid_enum_error; \
195 * Return pointer to current texture unit for setting/getting coordinate
197 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
198 * texture unit is higher than the number of supported coordinate units.
200 static struct gl_texture_unit
*
201 get_texcoord_unit(struct gl_context
*ctx
)
203 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
204 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
208 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
214 * Helper function to enable or disable a texture target.
215 * \param bit one of the TEXTURE_x_BIT values
216 * \return GL_TRUE if state is changing or GL_FALSE if no change
219 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
221 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
222 const GLbitfield newenabled
= state
223 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
225 if (texUnit
->Enabled
== newenabled
)
228 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
229 texUnit
->Enabled
= newenabled
;
235 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
236 * whether the API supports it (GLES doesn't).
239 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
241 if (ctx
->Multisample
.Enabled
== state
)
244 /* GL compatibility needs Multisample.Enable to determine program state
247 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
248 !ctx
->DriverFlags
.NewMultisampleEnable
) {
249 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
251 FLUSH_VERTICES(ctx
, 0);
254 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
255 ctx
->Multisample
.Enabled
= state
;
257 if (ctx
->Driver
.Enable
) {
258 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
263 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
264 * check for whether the API supports it (GLES doesn't).
267 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
269 if (ctx
->Color
.sRGBEnabled
== state
)
272 /* TODO: Switch i965 to the new flag and remove the conditional */
273 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
274 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
275 ctx
->Color
.sRGBEnabled
= state
;
277 if (ctx
->Driver
.Enable
) {
278 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
283 * Helper function to enable or disable state.
285 * \param ctx GL context.
286 * \param cap the state to enable/disable
287 * \param state whether to enable or disable the specified capability.
289 * Updates the current context and flushes the vertices as needed. For
290 * capabilities associated with extensions it verifies that those extensions
291 * are effectivly present before updating. Notifies the driver via
292 * dd_function_table::Enable.
295 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
297 if (MESA_VERBOSE
& VERBOSE_API
)
298 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
299 state
? "glEnable" : "glDisable",
300 _mesa_enum_to_string(cap
),
305 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
306 goto invalid_enum_error
;
307 if (ctx
->Color
.AlphaEnabled
== state
)
309 /* AlphaEnabled is used by the fixed-func fragment program */
310 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
311 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
312 ctx
->Color
.AlphaEnabled
= state
;
315 if (ctx
->API
!= API_OPENGL_COMPAT
)
316 goto invalid_enum_error
;
317 if (ctx
->Eval
.AutoNormal
== state
)
319 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
320 ctx
->Eval
.AutoNormal
= state
;
324 GLbitfield newEnabled
=
325 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
326 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
327 _mesa_flush_vertices_for_blend_state(ctx
);
328 ctx
->Color
.BlendEnabled
= newEnabled
;
332 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
333 case GL_CLIP_DISTANCE1
:
334 case GL_CLIP_DISTANCE2
:
335 case GL_CLIP_DISTANCE3
:
336 case GL_CLIP_DISTANCE4
:
337 case GL_CLIP_DISTANCE5
:
338 case GL_CLIP_DISTANCE6
:
339 case GL_CLIP_DISTANCE7
:
341 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
343 if (p
>= ctx
->Const
.MaxClipPlanes
)
344 goto invalid_enum_error
;
346 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
347 == ((GLuint
) state
<< p
))
350 /* The compatibility profile needs _NEW_TRANSFORM to transform
351 * clip planes according to the projection matrix.
353 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
354 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
355 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
357 FLUSH_VERTICES(ctx
, 0);
359 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
362 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
364 /* The projection matrix transforms the clip plane. */
365 /* TODO: glEnable might not be the best place to do it. */
366 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
367 _mesa_update_clip_plane(ctx
, p
);
368 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
372 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
376 case GL_COLOR_MATERIAL
:
377 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
378 goto invalid_enum_error
;
379 if (ctx
->Light
.ColorMaterialEnabled
== state
)
381 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
382 FLUSH_CURRENT(ctx
, 0);
383 ctx
->Light
.ColorMaterialEnabled
= state
;
385 _mesa_update_color_material( ctx
,
386 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
390 if (ctx
->Polygon
.CullFlag
== state
)
393 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
394 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
395 ctx
->Polygon
.CullFlag
= state
;
398 if (ctx
->Depth
.Test
== state
)
400 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
401 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
402 ctx
->Depth
.Test
= state
;
404 case GL_DEBUG_OUTPUT
:
405 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
406 _mesa_set_debug_state_int(ctx
, cap
, state
);
409 if (ctx
->Color
.DitherFlag
== state
)
411 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
412 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
413 ctx
->Color
.DitherFlag
= state
;
416 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
417 goto invalid_enum_error
;
418 if (ctx
->Fog
.Enabled
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_FOG
);
421 ctx
->Fog
.Enabled
= state
;
422 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
432 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
433 goto invalid_enum_error
;
434 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
436 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
437 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
439 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
442 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
446 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
447 goto invalid_enum_error
;
448 if (ctx
->Light
.Enabled
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
451 ctx
->Light
.Enabled
= state
;
454 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
455 goto invalid_enum_error
;
456 if (ctx
->Line
.SmoothFlag
== state
)
458 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
459 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
460 ctx
->Line
.SmoothFlag
= state
;
462 case GL_LINE_STIPPLE
:
463 if (ctx
->API
!= API_OPENGL_COMPAT
)
464 goto invalid_enum_error
;
465 if (ctx
->Line
.StippleFlag
== state
)
467 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
468 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
469 ctx
->Line
.StippleFlag
= state
;
471 case GL_INDEX_LOGIC_OP
:
472 if (ctx
->API
!= API_OPENGL_COMPAT
)
473 goto invalid_enum_error
;
474 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
476 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
477 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
478 ctx
->Color
.IndexLogicOpEnabled
= state
;
480 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
481 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
482 goto invalid_enum_error
;
483 if (ctx
->IntelConservativeRasterization
== state
)
485 FLUSH_VERTICES(ctx
, 0);
486 ctx
->NewDriverState
|=
487 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
488 ctx
->IntelConservativeRasterization
= state
;
490 case GL_COLOR_LOGIC_OP
:
491 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
492 goto invalid_enum_error
;
493 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
495 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
496 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
497 ctx
->Color
.ColorLogicOpEnabled
= state
;
499 case GL_MAP1_COLOR_4
:
500 if (ctx
->API
!= API_OPENGL_COMPAT
)
501 goto invalid_enum_error
;
502 if (ctx
->Eval
.Map1Color4
== state
)
504 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
505 ctx
->Eval
.Map1Color4
= state
;
508 if (ctx
->API
!= API_OPENGL_COMPAT
)
509 goto invalid_enum_error
;
510 if (ctx
->Eval
.Map1Index
== state
)
512 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
513 ctx
->Eval
.Map1Index
= state
;
516 if (ctx
->API
!= API_OPENGL_COMPAT
)
517 goto invalid_enum_error
;
518 if (ctx
->Eval
.Map1Normal
== state
)
520 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
521 ctx
->Eval
.Map1Normal
= state
;
523 case GL_MAP1_TEXTURE_COORD_1
:
524 if (ctx
->API
!= API_OPENGL_COMPAT
)
525 goto invalid_enum_error
;
526 if (ctx
->Eval
.Map1TextureCoord1
== state
)
528 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
529 ctx
->Eval
.Map1TextureCoord1
= state
;
531 case GL_MAP1_TEXTURE_COORD_2
:
532 if (ctx
->API
!= API_OPENGL_COMPAT
)
533 goto invalid_enum_error
;
534 if (ctx
->Eval
.Map1TextureCoord2
== state
)
536 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
537 ctx
->Eval
.Map1TextureCoord2
= state
;
539 case GL_MAP1_TEXTURE_COORD_3
:
540 if (ctx
->API
!= API_OPENGL_COMPAT
)
541 goto invalid_enum_error
;
542 if (ctx
->Eval
.Map1TextureCoord3
== state
)
544 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
545 ctx
->Eval
.Map1TextureCoord3
= state
;
547 case GL_MAP1_TEXTURE_COORD_4
:
548 if (ctx
->API
!= API_OPENGL_COMPAT
)
549 goto invalid_enum_error
;
550 if (ctx
->Eval
.Map1TextureCoord4
== state
)
552 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
553 ctx
->Eval
.Map1TextureCoord4
= state
;
555 case GL_MAP1_VERTEX_3
:
556 if (ctx
->API
!= API_OPENGL_COMPAT
)
557 goto invalid_enum_error
;
558 if (ctx
->Eval
.Map1Vertex3
== state
)
560 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
561 ctx
->Eval
.Map1Vertex3
= state
;
563 case GL_MAP1_VERTEX_4
:
564 if (ctx
->API
!= API_OPENGL_COMPAT
)
565 goto invalid_enum_error
;
566 if (ctx
->Eval
.Map1Vertex4
== state
)
568 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
569 ctx
->Eval
.Map1Vertex4
= state
;
571 case GL_MAP2_COLOR_4
:
572 if (ctx
->API
!= API_OPENGL_COMPAT
)
573 goto invalid_enum_error
;
574 if (ctx
->Eval
.Map2Color4
== state
)
576 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
577 ctx
->Eval
.Map2Color4
= state
;
580 if (ctx
->API
!= API_OPENGL_COMPAT
)
581 goto invalid_enum_error
;
582 if (ctx
->Eval
.Map2Index
== state
)
584 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
585 ctx
->Eval
.Map2Index
= state
;
588 if (ctx
->API
!= API_OPENGL_COMPAT
)
589 goto invalid_enum_error
;
590 if (ctx
->Eval
.Map2Normal
== state
)
592 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
593 ctx
->Eval
.Map2Normal
= state
;
595 case GL_MAP2_TEXTURE_COORD_1
:
596 if (ctx
->API
!= API_OPENGL_COMPAT
)
597 goto invalid_enum_error
;
598 if (ctx
->Eval
.Map2TextureCoord1
== state
)
600 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
601 ctx
->Eval
.Map2TextureCoord1
= state
;
603 case GL_MAP2_TEXTURE_COORD_2
:
604 if (ctx
->API
!= API_OPENGL_COMPAT
)
605 goto invalid_enum_error
;
606 if (ctx
->Eval
.Map2TextureCoord2
== state
)
608 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
609 ctx
->Eval
.Map2TextureCoord2
= state
;
611 case GL_MAP2_TEXTURE_COORD_3
:
612 if (ctx
->API
!= API_OPENGL_COMPAT
)
613 goto invalid_enum_error
;
614 if (ctx
->Eval
.Map2TextureCoord3
== state
)
616 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
617 ctx
->Eval
.Map2TextureCoord3
= state
;
619 case GL_MAP2_TEXTURE_COORD_4
:
620 if (ctx
->API
!= API_OPENGL_COMPAT
)
621 goto invalid_enum_error
;
622 if (ctx
->Eval
.Map2TextureCoord4
== state
)
624 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
625 ctx
->Eval
.Map2TextureCoord4
= state
;
627 case GL_MAP2_VERTEX_3
:
628 if (ctx
->API
!= API_OPENGL_COMPAT
)
629 goto invalid_enum_error
;
630 if (ctx
->Eval
.Map2Vertex3
== state
)
632 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
633 ctx
->Eval
.Map2Vertex3
= state
;
635 case GL_MAP2_VERTEX_4
:
636 if (ctx
->API
!= API_OPENGL_COMPAT
)
637 goto invalid_enum_error
;
638 if (ctx
->Eval
.Map2Vertex4
== state
)
640 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
641 ctx
->Eval
.Map2Vertex4
= state
;
644 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
645 goto invalid_enum_error
;
646 if (ctx
->Transform
.Normalize
== state
)
648 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
649 ctx
->Transform
.Normalize
= state
;
651 case GL_POINT_SMOOTH
:
652 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
653 goto invalid_enum_error
;
654 if (ctx
->Point
.SmoothFlag
== state
)
656 FLUSH_VERTICES(ctx
, _NEW_POINT
);
657 ctx
->Point
.SmoothFlag
= state
;
659 case GL_POLYGON_SMOOTH
:
660 if (!_mesa_is_desktop_gl(ctx
))
661 goto invalid_enum_error
;
662 if (ctx
->Polygon
.SmoothFlag
== state
)
665 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
666 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
667 ctx
->Polygon
.SmoothFlag
= state
;
669 case GL_POLYGON_STIPPLE
:
670 if (ctx
->API
!= API_OPENGL_COMPAT
)
671 goto invalid_enum_error
;
672 if (ctx
->Polygon
.StippleFlag
== state
)
675 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
676 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
677 ctx
->Polygon
.StippleFlag
= state
;
679 case GL_POLYGON_OFFSET_POINT
:
680 if (!_mesa_is_desktop_gl(ctx
))
681 goto invalid_enum_error
;
682 if (ctx
->Polygon
.OffsetPoint
== state
)
685 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
686 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
687 ctx
->Polygon
.OffsetPoint
= state
;
689 case GL_POLYGON_OFFSET_LINE
:
690 if (!_mesa_is_desktop_gl(ctx
))
691 goto invalid_enum_error
;
692 if (ctx
->Polygon
.OffsetLine
== state
)
695 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
696 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
697 ctx
->Polygon
.OffsetLine
= state
;
699 case GL_POLYGON_OFFSET_FILL
:
700 if (ctx
->Polygon
.OffsetFill
== state
)
703 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
704 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
705 ctx
->Polygon
.OffsetFill
= state
;
707 case GL_RESCALE_NORMAL_EXT
:
708 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
709 goto invalid_enum_error
;
710 if (ctx
->Transform
.RescaleNormals
== state
)
712 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
713 ctx
->Transform
.RescaleNormals
= state
;
715 case GL_SCISSOR_TEST
:
717 /* Must expand glEnable to all scissors */
718 GLbitfield newEnabled
=
719 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
720 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
721 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
723 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
724 ctx
->Scissor
.EnableFlags
= newEnabled
;
728 case GL_STENCIL_TEST
:
729 if (ctx
->Stencil
.Enabled
== state
)
731 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
732 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
733 ctx
->Stencil
.Enabled
= state
;
736 if (ctx
->API
!= API_OPENGL_COMPAT
)
737 goto invalid_enum_error
;
738 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
743 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
744 goto invalid_enum_error
;
745 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
750 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
751 goto invalid_enum_error
;
752 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
756 case GL_TEXTURE_GEN_S
:
757 case GL_TEXTURE_GEN_T
:
758 case GL_TEXTURE_GEN_R
:
759 case GL_TEXTURE_GEN_Q
:
761 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
763 if (ctx
->API
!= API_OPENGL_COMPAT
)
764 goto invalid_enum_error
;
767 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
768 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
770 newenabled
|= coordBit
;
771 if (texUnit
->TexGenEnabled
== newenabled
)
773 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
774 texUnit
->TexGenEnabled
= newenabled
;
779 case GL_TEXTURE_GEN_STR_OES
:
780 /* disable S, T, and R at the same time */
782 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
784 if (ctx
->API
!= API_OPENGLES
)
785 goto invalid_enum_error
;
789 texUnit
->TexGenEnabled
& ~STR_BITS
;
791 newenabled
|= STR_BITS
;
792 if (texUnit
->TexGenEnabled
== newenabled
)
794 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
795 texUnit
->TexGenEnabled
= newenabled
;
800 /* client-side state */
801 case GL_VERTEX_ARRAY
:
802 case GL_NORMAL_ARRAY
:
804 case GL_TEXTURE_COORD_ARRAY
:
805 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
806 goto invalid_enum_error
;
807 client_state( ctx
, cap
, state
);
810 case GL_EDGE_FLAG_ARRAY
:
811 case GL_FOG_COORDINATE_ARRAY_EXT
:
812 case GL_SECONDARY_COLOR_ARRAY_EXT
:
813 if (ctx
->API
!= API_OPENGL_COMPAT
)
814 goto invalid_enum_error
;
815 client_state( ctx
, cap
, state
);
817 case GL_POINT_SIZE_ARRAY_OES
:
818 if (ctx
->API
!= API_OPENGLES
)
819 goto invalid_enum_error
;
820 client_state( ctx
, cap
, state
);
823 /* GL_ARB_texture_cube_map */
824 case GL_TEXTURE_CUBE_MAP
:
825 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
826 goto invalid_enum_error
;
827 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
828 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
833 /* GL_EXT_secondary_color */
834 case GL_COLOR_SUM_EXT
:
835 if (ctx
->API
!= API_OPENGL_COMPAT
)
836 goto invalid_enum_error
;
837 if (ctx
->Fog
.ColorSumEnabled
== state
)
839 FLUSH_VERTICES(ctx
, _NEW_FOG
);
840 ctx
->Fog
.ColorSumEnabled
= state
;
843 /* GL_ARB_multisample */
844 case GL_MULTISAMPLE_ARB
:
845 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
846 goto invalid_enum_error
;
847 _mesa_set_multisample(ctx
, state
);
849 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
850 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
852 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
854 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
855 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
857 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
858 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
859 goto invalid_enum_error
;
860 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
862 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
864 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
865 ctx
->Multisample
.SampleAlphaToOne
= state
;
867 case GL_SAMPLE_COVERAGE_ARB
:
868 if (ctx
->Multisample
.SampleCoverage
== state
)
870 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
872 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
873 ctx
->Multisample
.SampleCoverage
= state
;
875 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
876 if (!_mesa_is_desktop_gl(ctx
))
877 goto invalid_enum_error
;
878 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
880 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
882 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
883 ctx
->Multisample
.SampleCoverageInvert
= state
;
886 /* GL_ARB_sample_shading */
887 case GL_SAMPLE_SHADING
:
888 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
889 goto invalid_enum_error
;
890 CHECK_EXTENSION(ARB_sample_shading
, cap
);
891 if (ctx
->Multisample
.SampleShading
== state
)
893 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
895 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
896 ctx
->Multisample
.SampleShading
= state
;
899 /* GL_IBM_rasterpos_clip */
900 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
901 if (ctx
->API
!= API_OPENGL_COMPAT
)
902 goto invalid_enum_error
;
903 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
905 FLUSH_VERTICES(ctx
, 0);
906 ctx
->Transform
.RasterPositionUnclipped
= state
;
909 /* GL_NV_point_sprite */
910 case GL_POINT_SPRITE_NV
:
911 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
912 goto invalid_enum_error
;
913 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
914 if (ctx
->Point
.PointSprite
== state
)
916 FLUSH_VERTICES(ctx
, _NEW_POINT
);
917 ctx
->Point
.PointSprite
= state
;
920 case GL_VERTEX_PROGRAM_ARB
:
921 if (ctx
->API
!= API_OPENGL_COMPAT
)
922 goto invalid_enum_error
;
923 CHECK_EXTENSION(ARB_vertex_program
, cap
);
924 if (ctx
->VertexProgram
.Enabled
== state
)
926 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
927 ctx
->VertexProgram
.Enabled
= state
;
929 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
930 /* This was added with ARB_vertex_program, but it is also used with
931 * GLSL vertex shaders on desktop.
933 if (!_mesa_is_desktop_gl(ctx
))
934 goto invalid_enum_error
;
935 CHECK_EXTENSION(ARB_vertex_program
, cap
);
936 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
938 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
939 ctx
->VertexProgram
.PointSizeEnabled
= state
;
941 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
942 if (ctx
->API
!= API_OPENGL_COMPAT
)
943 goto invalid_enum_error
;
944 CHECK_EXTENSION(ARB_vertex_program
, cap
);
945 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
947 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
948 ctx
->VertexProgram
.TwoSideEnabled
= state
;
951 /* GL_NV_texture_rectangle */
952 case GL_TEXTURE_RECTANGLE_NV
:
953 if (ctx
->API
!= API_OPENGL_COMPAT
)
954 goto invalid_enum_error
;
955 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
956 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
961 /* GL_EXT_stencil_two_side */
962 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
963 if (ctx
->API
!= API_OPENGL_COMPAT
)
964 goto invalid_enum_error
;
965 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
966 if (ctx
->Stencil
.TestTwoSide
== state
)
968 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
969 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
970 ctx
->Stencil
.TestTwoSide
= state
;
972 ctx
->Stencil
._BackFace
= 2;
974 ctx
->Stencil
._BackFace
= 1;
978 case GL_FRAGMENT_PROGRAM_ARB
:
979 if (ctx
->API
!= API_OPENGL_COMPAT
)
980 goto invalid_enum_error
;
981 CHECK_EXTENSION(ARB_fragment_program
, cap
);
982 if (ctx
->FragmentProgram
.Enabled
== state
)
984 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
985 ctx
->FragmentProgram
.Enabled
= state
;
988 /* GL_EXT_depth_bounds_test */
989 case GL_DEPTH_BOUNDS_TEST_EXT
:
990 if (!_mesa_is_desktop_gl(ctx
))
991 goto invalid_enum_error
;
992 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
993 if (ctx
->Depth
.BoundsTest
== state
)
995 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
996 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
997 ctx
->Depth
.BoundsTest
= state
;
1000 case GL_DEPTH_CLAMP
:
1001 if (!_mesa_is_desktop_gl(ctx
))
1002 goto invalid_enum_error
;
1003 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
1004 if (ctx
->Transform
.DepthClamp
== state
)
1006 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1008 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1009 ctx
->Transform
.DepthClamp
= state
;
1012 case GL_FRAGMENT_SHADER_ATI
:
1013 if (ctx
->API
!= API_OPENGL_COMPAT
)
1014 goto invalid_enum_error
;
1015 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
1016 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1018 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1019 ctx
->ATIFragmentShader
.Enabled
= state
;
1022 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1023 if (!_mesa_is_desktop_gl(ctx
))
1024 goto invalid_enum_error
;
1025 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
1026 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1027 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1028 ctx
->Texture
.CubeMapSeamless
= state
;
1032 case GL_RASTERIZER_DISCARD
:
1033 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1034 goto invalid_enum_error
;
1035 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
1036 if (ctx
->RasterDiscard
!= state
) {
1037 FLUSH_VERTICES(ctx
, 0);
1038 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1039 ctx
->RasterDiscard
= state
;
1043 /* GL 3.1 primitive restart. Note: this enum is different from
1044 * GL_PRIMITIVE_RESTART_NV (which is client state).
1046 case GL_PRIMITIVE_RESTART
:
1047 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1048 goto invalid_enum_error
;
1050 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1051 FLUSH_VERTICES(ctx
, 0);
1052 ctx
->Array
.PrimitiveRestart
= state
;
1053 update_derived_primitive_restart_state(ctx
);
1057 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1058 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
)
1059 goto invalid_enum_error
;
1060 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1061 FLUSH_VERTICES(ctx
, 0);
1062 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1063 update_derived_primitive_restart_state(ctx
);
1067 /* GL3.0 - GL_framebuffer_sRGB */
1068 case GL_FRAMEBUFFER_SRGB_EXT
:
1069 if (!_mesa_is_desktop_gl(ctx
))
1070 goto invalid_enum_error
;
1071 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
1072 _mesa_set_framebuffer_srgb(ctx
, state
);
1075 /* GL_OES_EGL_image_external */
1076 case GL_TEXTURE_EXTERNAL_OES
:
1077 if (!_mesa_is_gles(ctx
))
1078 goto invalid_enum_error
;
1079 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
1080 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1085 /* ARB_texture_multisample */
1086 case GL_SAMPLE_MASK
:
1087 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1088 goto invalid_enum_error
;
1089 CHECK_EXTENSION(ARB_texture_multisample
, cap
);
1090 if (ctx
->Multisample
.SampleMask
== state
)
1092 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1094 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1095 ctx
->Multisample
.SampleMask
= state
;
1098 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1099 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent
, cap
);
1100 if (ctx
->Color
.BlendCoherent
== state
)
1102 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1103 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1104 ctx
->Color
.BlendCoherent
= state
;
1108 goto invalid_enum_error
;
1111 if (ctx
->Driver
.Enable
) {
1112 ctx
->Driver
.Enable( ctx
, cap
, state
);
1118 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1119 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1124 * Enable GL capability. Called by glEnable()
1125 * \param cap state to enable.
1128 _mesa_Enable( GLenum cap
)
1130 GET_CURRENT_CONTEXT(ctx
);
1132 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1137 * Disable GL capability. Called by glDisable()
1138 * \param cap state to disable.
1141 _mesa_Disable( GLenum cap
)
1143 GET_CURRENT_CONTEXT(ctx
);
1145 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1151 * Enable/disable an indexed state var.
1154 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1155 GLuint index
, GLboolean state
)
1157 assert(state
== 0 || state
== 1);
1160 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1161 goto invalid_enum_error
;
1163 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1164 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1165 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1168 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1169 _mesa_flush_vertices_for_blend_state(ctx
);
1171 ctx
->Color
.BlendEnabled
|= (1 << index
);
1173 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1176 case GL_SCISSOR_TEST
:
1177 if (index
>= ctx
->Const
.MaxViewports
) {
1178 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1179 state
? "glEnablei" : "glDisablei", index
);
1182 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1184 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1185 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1187 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1189 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1193 goto invalid_enum_error
;
1198 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1199 state
? "glEnablei" : "glDisablei",
1200 _mesa_enum_to_string(cap
));
1205 _mesa_Disablei( GLenum cap
, GLuint index
)
1207 GET_CURRENT_CONTEXT(ctx
);
1208 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1213 _mesa_Enablei( GLenum cap
, GLuint index
)
1215 GET_CURRENT_CONTEXT(ctx
);
1216 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1220 GLboolean GLAPIENTRY
1221 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1223 GET_CURRENT_CONTEXT(ctx
);
1224 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1227 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1228 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1232 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1233 case GL_SCISSOR_TEST
:
1234 if (index
>= ctx
->Const
.MaxViewports
) {
1235 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1239 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1241 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1242 _mesa_enum_to_string(cap
));
1250 #undef CHECK_EXTENSION
1251 #define CHECK_EXTENSION(EXTNAME) \
1252 if (!ctx->Extensions.EXTNAME) { \
1253 goto invalid_enum_error; \
1256 #undef CHECK_EXTENSION2
1257 #define CHECK_EXTENSION2(EXT1, EXT2) \
1258 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1259 goto invalid_enum_error; \
1264 * Helper function to determine whether a texture target is enabled.
1267 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1269 const struct gl_texture_unit
*const texUnit
=
1270 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1271 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1276 * Return simple enable/disable state.
1278 * \param cap state variable to query.
1280 * Returns the state of the specified capability from the current GL context.
1281 * For the capabilities associated with extensions verifies that those
1282 * extensions are effectively present before reporting.
1284 GLboolean GLAPIENTRY
1285 _mesa_IsEnabled( GLenum cap
)
1287 GET_CURRENT_CONTEXT(ctx
);
1288 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1292 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1293 goto invalid_enum_error
;
1294 return ctx
->Color
.AlphaEnabled
;
1295 case GL_AUTO_NORMAL
:
1296 if (ctx
->API
!= API_OPENGL_COMPAT
)
1297 goto invalid_enum_error
;
1298 return ctx
->Eval
.AutoNormal
;
1300 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1301 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1302 case GL_CLIP_DISTANCE1
:
1303 case GL_CLIP_DISTANCE2
:
1304 case GL_CLIP_DISTANCE3
:
1305 case GL_CLIP_DISTANCE4
:
1306 case GL_CLIP_DISTANCE5
:
1307 case GL_CLIP_DISTANCE6
:
1308 case GL_CLIP_DISTANCE7
: {
1309 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1311 if (p
>= ctx
->Const
.MaxClipPlanes
)
1312 goto invalid_enum_error
;
1314 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1316 case GL_COLOR_MATERIAL
:
1317 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1318 goto invalid_enum_error
;
1319 return ctx
->Light
.ColorMaterialEnabled
;
1321 return ctx
->Polygon
.CullFlag
;
1322 case GL_DEBUG_OUTPUT
:
1323 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1324 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1326 return ctx
->Depth
.Test
;
1328 return ctx
->Color
.DitherFlag
;
1330 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1331 goto invalid_enum_error
;
1332 return ctx
->Fog
.Enabled
;
1334 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1335 goto invalid_enum_error
;
1336 return ctx
->Light
.Enabled
;
1345 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1346 goto invalid_enum_error
;
1347 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1348 case GL_LINE_SMOOTH
:
1349 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1350 goto invalid_enum_error
;
1351 return ctx
->Line
.SmoothFlag
;
1352 case GL_LINE_STIPPLE
:
1353 if (ctx
->API
!= API_OPENGL_COMPAT
)
1354 goto invalid_enum_error
;
1355 return ctx
->Line
.StippleFlag
;
1356 case GL_INDEX_LOGIC_OP
:
1357 if (ctx
->API
!= API_OPENGL_COMPAT
)
1358 goto invalid_enum_error
;
1359 return ctx
->Color
.IndexLogicOpEnabled
;
1360 case GL_COLOR_LOGIC_OP
:
1361 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1362 goto invalid_enum_error
;
1363 return ctx
->Color
.ColorLogicOpEnabled
;
1364 case GL_MAP1_COLOR_4
:
1365 if (ctx
->API
!= API_OPENGL_COMPAT
)
1366 goto invalid_enum_error
;
1367 return ctx
->Eval
.Map1Color4
;
1369 if (ctx
->API
!= API_OPENGL_COMPAT
)
1370 goto invalid_enum_error
;
1371 return ctx
->Eval
.Map1Index
;
1372 case GL_MAP1_NORMAL
:
1373 if (ctx
->API
!= API_OPENGL_COMPAT
)
1374 goto invalid_enum_error
;
1375 return ctx
->Eval
.Map1Normal
;
1376 case GL_MAP1_TEXTURE_COORD_1
:
1377 if (ctx
->API
!= API_OPENGL_COMPAT
)
1378 goto invalid_enum_error
;
1379 return ctx
->Eval
.Map1TextureCoord1
;
1380 case GL_MAP1_TEXTURE_COORD_2
:
1381 if (ctx
->API
!= API_OPENGL_COMPAT
)
1382 goto invalid_enum_error
;
1383 return ctx
->Eval
.Map1TextureCoord2
;
1384 case GL_MAP1_TEXTURE_COORD_3
:
1385 if (ctx
->API
!= API_OPENGL_COMPAT
)
1386 goto invalid_enum_error
;
1387 return ctx
->Eval
.Map1TextureCoord3
;
1388 case GL_MAP1_TEXTURE_COORD_4
:
1389 if (ctx
->API
!= API_OPENGL_COMPAT
)
1390 goto invalid_enum_error
;
1391 return ctx
->Eval
.Map1TextureCoord4
;
1392 case GL_MAP1_VERTEX_3
:
1393 if (ctx
->API
!= API_OPENGL_COMPAT
)
1394 goto invalid_enum_error
;
1395 return ctx
->Eval
.Map1Vertex3
;
1396 case GL_MAP1_VERTEX_4
:
1397 if (ctx
->API
!= API_OPENGL_COMPAT
)
1398 goto invalid_enum_error
;
1399 return ctx
->Eval
.Map1Vertex4
;
1400 case GL_MAP2_COLOR_4
:
1401 if (ctx
->API
!= API_OPENGL_COMPAT
)
1402 goto invalid_enum_error
;
1403 return ctx
->Eval
.Map2Color4
;
1405 if (ctx
->API
!= API_OPENGL_COMPAT
)
1406 goto invalid_enum_error
;
1407 return ctx
->Eval
.Map2Index
;
1408 case GL_MAP2_NORMAL
:
1409 if (ctx
->API
!= API_OPENGL_COMPAT
)
1410 goto invalid_enum_error
;
1411 return ctx
->Eval
.Map2Normal
;
1412 case GL_MAP2_TEXTURE_COORD_1
:
1413 if (ctx
->API
!= API_OPENGL_COMPAT
)
1414 goto invalid_enum_error
;
1415 return ctx
->Eval
.Map2TextureCoord1
;
1416 case GL_MAP2_TEXTURE_COORD_2
:
1417 if (ctx
->API
!= API_OPENGL_COMPAT
)
1418 goto invalid_enum_error
;
1419 return ctx
->Eval
.Map2TextureCoord2
;
1420 case GL_MAP2_TEXTURE_COORD_3
:
1421 if (ctx
->API
!= API_OPENGL_COMPAT
)
1422 goto invalid_enum_error
;
1423 return ctx
->Eval
.Map2TextureCoord3
;
1424 case GL_MAP2_TEXTURE_COORD_4
:
1425 if (ctx
->API
!= API_OPENGL_COMPAT
)
1426 goto invalid_enum_error
;
1427 return ctx
->Eval
.Map2TextureCoord4
;
1428 case GL_MAP2_VERTEX_3
:
1429 if (ctx
->API
!= API_OPENGL_COMPAT
)
1430 goto invalid_enum_error
;
1431 return ctx
->Eval
.Map2Vertex3
;
1432 case GL_MAP2_VERTEX_4
:
1433 if (ctx
->API
!= API_OPENGL_COMPAT
)
1434 goto invalid_enum_error
;
1435 return ctx
->Eval
.Map2Vertex4
;
1437 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1438 goto invalid_enum_error
;
1439 return ctx
->Transform
.Normalize
;
1440 case GL_POINT_SMOOTH
:
1441 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1442 goto invalid_enum_error
;
1443 return ctx
->Point
.SmoothFlag
;
1444 case GL_POLYGON_SMOOTH
:
1445 if (!_mesa_is_desktop_gl(ctx
))
1446 goto invalid_enum_error
;
1447 return ctx
->Polygon
.SmoothFlag
;
1448 case GL_POLYGON_STIPPLE
:
1449 if (ctx
->API
!= API_OPENGL_COMPAT
)
1450 goto invalid_enum_error
;
1451 return ctx
->Polygon
.StippleFlag
;
1452 case GL_POLYGON_OFFSET_POINT
:
1453 if (!_mesa_is_desktop_gl(ctx
))
1454 goto invalid_enum_error
;
1455 return ctx
->Polygon
.OffsetPoint
;
1456 case GL_POLYGON_OFFSET_LINE
:
1457 if (!_mesa_is_desktop_gl(ctx
))
1458 goto invalid_enum_error
;
1459 return ctx
->Polygon
.OffsetLine
;
1460 case GL_POLYGON_OFFSET_FILL
:
1461 return ctx
->Polygon
.OffsetFill
;
1462 case GL_RESCALE_NORMAL_EXT
:
1463 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1464 goto invalid_enum_error
;
1465 return ctx
->Transform
.RescaleNormals
;
1466 case GL_SCISSOR_TEST
:
1467 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1468 case GL_STENCIL_TEST
:
1469 return ctx
->Stencil
.Enabled
;
1471 if (ctx
->API
!= API_OPENGL_COMPAT
)
1472 goto invalid_enum_error
;
1473 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1475 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1476 goto invalid_enum_error
;
1477 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1479 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1480 goto invalid_enum_error
;
1481 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1482 case GL_TEXTURE_GEN_S
:
1483 case GL_TEXTURE_GEN_T
:
1484 case GL_TEXTURE_GEN_R
:
1485 case GL_TEXTURE_GEN_Q
:
1487 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1489 if (ctx
->API
!= API_OPENGL_COMPAT
)
1490 goto invalid_enum_error
;
1493 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1494 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1498 case GL_TEXTURE_GEN_STR_OES
:
1500 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1502 if (ctx
->API
!= API_OPENGLES
)
1503 goto invalid_enum_error
;
1506 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1507 ? GL_TRUE
: GL_FALSE
;
1511 /* client-side state */
1512 case GL_VERTEX_ARRAY
:
1513 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1514 goto invalid_enum_error
;
1515 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
1516 case GL_NORMAL_ARRAY
:
1517 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1518 goto invalid_enum_error
;
1519 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
1520 case GL_COLOR_ARRAY
:
1521 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1522 goto invalid_enum_error
;
1523 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
1524 case GL_INDEX_ARRAY
:
1525 if (ctx
->API
!= API_OPENGL_COMPAT
)
1526 goto invalid_enum_error
;
1527 return ctx
->Array
.VAO
->
1528 VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
1529 case GL_TEXTURE_COORD_ARRAY
:
1530 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1531 goto invalid_enum_error
;
1532 return ctx
->Array
.VAO
->
1533 VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
1534 case GL_EDGE_FLAG_ARRAY
:
1535 if (ctx
->API
!= API_OPENGL_COMPAT
)
1536 goto invalid_enum_error
;
1537 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
1538 case GL_FOG_COORDINATE_ARRAY_EXT
:
1539 if (ctx
->API
!= API_OPENGL_COMPAT
)
1540 goto invalid_enum_error
;
1541 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
1542 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1543 if (ctx
->API
!= API_OPENGL_COMPAT
)
1544 goto invalid_enum_error
;
1545 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
1546 case GL_POINT_SIZE_ARRAY_OES
:
1547 if (ctx
->API
!= API_OPENGLES
)
1548 goto invalid_enum_error
;
1549 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
1551 /* GL_ARB_texture_cube_map */
1552 case GL_TEXTURE_CUBE_MAP
:
1553 CHECK_EXTENSION(ARB_texture_cube_map
);
1554 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1556 /* GL_EXT_secondary_color */
1557 case GL_COLOR_SUM_EXT
:
1558 if (ctx
->API
!= API_OPENGL_COMPAT
)
1559 goto invalid_enum_error
;
1560 return ctx
->Fog
.ColorSumEnabled
;
1562 /* GL_ARB_multisample */
1563 case GL_MULTISAMPLE_ARB
:
1564 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1565 goto invalid_enum_error
;
1566 return ctx
->Multisample
.Enabled
;
1567 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1568 return ctx
->Multisample
.SampleAlphaToCoverage
;
1569 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1570 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1571 goto invalid_enum_error
;
1572 return ctx
->Multisample
.SampleAlphaToOne
;
1573 case GL_SAMPLE_COVERAGE_ARB
:
1574 return ctx
->Multisample
.SampleCoverage
;
1575 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1576 if (!_mesa_is_desktop_gl(ctx
))
1577 goto invalid_enum_error
;
1578 return ctx
->Multisample
.SampleCoverageInvert
;
1580 /* GL_IBM_rasterpos_clip */
1581 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1582 if (ctx
->API
!= API_OPENGL_COMPAT
)
1583 goto invalid_enum_error
;
1584 return ctx
->Transform
.RasterPositionUnclipped
;
1586 /* GL_NV_point_sprite */
1587 case GL_POINT_SPRITE_NV
:
1588 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1589 goto invalid_enum_error
;
1590 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1591 return ctx
->Point
.PointSprite
;
1593 case GL_VERTEX_PROGRAM_ARB
:
1594 if (ctx
->API
!= API_OPENGL_COMPAT
)
1595 goto invalid_enum_error
;
1596 CHECK_EXTENSION(ARB_vertex_program
);
1597 return ctx
->VertexProgram
.Enabled
;
1598 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1599 /* This was added with ARB_vertex_program, but it is also used with
1600 * GLSL vertex shaders on desktop.
1602 if (!_mesa_is_desktop_gl(ctx
))
1603 goto invalid_enum_error
;
1604 CHECK_EXTENSION(ARB_vertex_program
);
1605 return ctx
->VertexProgram
.PointSizeEnabled
;
1606 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1607 if (ctx
->API
!= API_OPENGL_COMPAT
)
1608 goto invalid_enum_error
;
1609 CHECK_EXTENSION(ARB_vertex_program
);
1610 return ctx
->VertexProgram
.TwoSideEnabled
;
1612 /* GL_NV_texture_rectangle */
1613 case GL_TEXTURE_RECTANGLE_NV
:
1614 if (ctx
->API
!= API_OPENGL_COMPAT
)
1615 goto invalid_enum_error
;
1616 CHECK_EXTENSION(NV_texture_rectangle
);
1617 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1619 /* GL_EXT_stencil_two_side */
1620 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1621 if (ctx
->API
!= API_OPENGL_COMPAT
)
1622 goto invalid_enum_error
;
1623 CHECK_EXTENSION(EXT_stencil_two_side
);
1624 return ctx
->Stencil
.TestTwoSide
;
1626 case GL_FRAGMENT_PROGRAM_ARB
:
1627 if (ctx
->API
!= API_OPENGL_COMPAT
)
1628 goto invalid_enum_error
;
1629 return ctx
->FragmentProgram
.Enabled
;
1631 /* GL_EXT_depth_bounds_test */
1632 case GL_DEPTH_BOUNDS_TEST_EXT
:
1633 if (!_mesa_is_desktop_gl(ctx
))
1634 goto invalid_enum_error
;
1635 CHECK_EXTENSION(EXT_depth_bounds_test
);
1636 return ctx
->Depth
.BoundsTest
;
1638 /* GL_ARB_depth_clamp */
1639 case GL_DEPTH_CLAMP
:
1640 if (!_mesa_is_desktop_gl(ctx
))
1641 goto invalid_enum_error
;
1642 CHECK_EXTENSION(ARB_depth_clamp
);
1643 return ctx
->Transform
.DepthClamp
;
1645 case GL_FRAGMENT_SHADER_ATI
:
1646 if (ctx
->API
!= API_OPENGL_COMPAT
)
1647 goto invalid_enum_error
;
1648 CHECK_EXTENSION(ATI_fragment_shader
);
1649 return ctx
->ATIFragmentShader
.Enabled
;
1651 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1652 if (!_mesa_is_desktop_gl(ctx
))
1653 goto invalid_enum_error
;
1654 CHECK_EXTENSION(ARB_seamless_cube_map
);
1655 return ctx
->Texture
.CubeMapSeamless
;
1657 case GL_RASTERIZER_DISCARD
:
1658 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1659 goto invalid_enum_error
;
1660 CHECK_EXTENSION(EXT_transform_feedback
);
1661 return ctx
->RasterDiscard
;
1663 /* GL_NV_primitive_restart */
1664 case GL_PRIMITIVE_RESTART_NV
:
1665 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1666 goto invalid_enum_error
;
1668 return ctx
->Array
.PrimitiveRestart
;
1670 /* GL 3.1 primitive restart */
1671 case GL_PRIMITIVE_RESTART
:
1672 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1673 goto invalid_enum_error
;
1675 return ctx
->Array
.PrimitiveRestart
;
1677 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1678 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1679 goto invalid_enum_error
;
1681 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1683 /* GL3.0 - GL_framebuffer_sRGB */
1684 case GL_FRAMEBUFFER_SRGB_EXT
:
1685 if (!_mesa_is_desktop_gl(ctx
))
1686 goto invalid_enum_error
;
1687 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1688 return ctx
->Color
.sRGBEnabled
;
1690 /* GL_OES_EGL_image_external */
1691 case GL_TEXTURE_EXTERNAL_OES
:
1692 if (!_mesa_is_gles(ctx
))
1693 goto invalid_enum_error
;
1694 CHECK_EXTENSION(OES_EGL_image_external
);
1695 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1697 /* ARB_texture_multisample */
1698 case GL_SAMPLE_MASK
:
1699 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1700 goto invalid_enum_error
;
1701 CHECK_EXTENSION(ARB_texture_multisample
);
1702 return ctx
->Multisample
.SampleMask
;
1704 /* ARB_sample_shading */
1705 case GL_SAMPLE_SHADING
:
1706 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1707 goto invalid_enum_error
;
1708 CHECK_EXTENSION(ARB_sample_shading
);
1709 return ctx
->Multisample
.SampleShading
;
1711 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1712 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent
);
1713 return ctx
->Color
.BlendCoherent
;
1715 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1716 CHECK_EXTENSION(INTEL_conservative_rasterization
);
1717 return ctx
->IntelConservativeRasterization
;
1720 goto invalid_enum_error
;
1726 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1727 _mesa_enum_to_string(cap
));