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"
47 #define CHECK_EXTENSION(EXTNAME, CAP) \
48 if (!ctx->Extensions.EXTNAME) { \
49 goto invalid_enum_error; \
54 update_derived_primitive_restart_state(struct gl_context
*ctx
)
56 /* Update derived primitive restart state.
58 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
59 || ctx
->Array
.PrimitiveRestartFixedIndex
;
64 * Helper to enable/disable VAO client-side state.
67 vao_state(struct gl_context
*ctx
, gl_vert_attrib attr
, GLboolean state
)
70 _mesa_enable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attr
);
72 _mesa_disable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attr
);
77 * Helper to enable/disable client-side state.
80 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
84 vao_state(ctx
, VERT_ATTRIB_POS
, state
);
87 vao_state(ctx
, VERT_ATTRIB_NORMAL
, state
);
90 vao_state(ctx
, VERT_ATTRIB_COLOR0
, state
);
93 vao_state(ctx
, VERT_ATTRIB_COLOR_INDEX
, state
);
95 case GL_TEXTURE_COORD_ARRAY
:
96 vao_state(ctx
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
98 case GL_EDGE_FLAG_ARRAY
:
99 vao_state(ctx
, VERT_ATTRIB_EDGEFLAG
, state
);
101 case GL_FOG_COORDINATE_ARRAY_EXT
:
102 vao_state(ctx
, VERT_ATTRIB_FOG
, state
);
104 case GL_SECONDARY_COLOR_ARRAY_EXT
:
105 vao_state(ctx
, VERT_ATTRIB_COLOR1
, state
);
108 case GL_POINT_SIZE_ARRAY_OES
:
109 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
110 ctx
->VertexProgram
.PointSizeEnabled
= state
;
111 vao_state(ctx
, VERT_ATTRIB_POINT_SIZE
, state
);
114 /* GL_NV_primitive_restart */
115 case GL_PRIMITIVE_RESTART_NV
:
116 if (!ctx
->Extensions
.NV_primitive_restart
)
117 goto invalid_enum_error
;
118 if (ctx
->Array
.PrimitiveRestart
== state
)
121 FLUSH_VERTICES(ctx
, 0);
122 ctx
->Array
.PrimitiveRestart
= state
;
123 update_derived_primitive_restart_state(ctx
);
127 goto invalid_enum_error
;
130 if (ctx
->Driver
.Enable
) {
131 ctx
->Driver
.Enable( ctx
, cap
, state
);
137 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
138 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
143 * Enable GL capability.
144 * \param cap state to enable/disable.
146 * Get's the current context, assures that we're outside glBegin()/glEnd() and
147 * calls client_state().
150 _mesa_EnableClientState( GLenum cap
)
152 GET_CURRENT_CONTEXT(ctx
);
153 client_state( ctx
, cap
, GL_TRUE
);
158 * Disable GL capability.
159 * \param cap state to enable/disable.
161 * Get's the current context, assures that we're outside glBegin()/glEnd() and
162 * calls client_state().
165 _mesa_DisableClientState( GLenum cap
)
167 GET_CURRENT_CONTEXT(ctx
);
168 client_state( ctx
, cap
, GL_FALSE
);
172 #undef CHECK_EXTENSION
173 #define CHECK_EXTENSION(EXTNAME, CAP) \
174 if (!ctx->Extensions.EXTNAME) { \
175 goto invalid_enum_error; \
178 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
179 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
180 goto invalid_enum_error; \
184 * Return pointer to current texture unit for setting/getting coordinate
186 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
187 * texture unit is higher than the number of supported coordinate units.
189 static struct gl_texture_unit
*
190 get_texcoord_unit(struct gl_context
*ctx
)
192 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
193 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
197 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
203 * Helper function to enable or disable a texture target.
204 * \param bit one of the TEXTURE_x_BIT values
205 * \return GL_TRUE if state is changing or GL_FALSE if no change
208 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
210 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
211 const GLbitfield newenabled
= state
212 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
214 if (texUnit
->Enabled
== newenabled
)
217 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
218 texUnit
->Enabled
= newenabled
;
224 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
225 * whether the API supports it (GLES doesn't).
228 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
230 if (ctx
->Multisample
.Enabled
== state
)
233 /* GL compatibility needs Multisample.Enable to determine program state
236 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
237 !ctx
->DriverFlags
.NewMultisampleEnable
) {
238 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
240 FLUSH_VERTICES(ctx
, 0);
243 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
244 ctx
->Multisample
.Enabled
= state
;
246 if (ctx
->Driver
.Enable
) {
247 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
252 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
253 * check for whether the API supports it (GLES doesn't).
256 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
258 if (ctx
->Color
.sRGBEnabled
== state
)
261 /* TODO: Switch i965 to the new flag and remove the conditional */
262 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
263 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
264 ctx
->Color
.sRGBEnabled
= state
;
266 if (ctx
->Driver
.Enable
) {
267 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
272 * Helper function to enable or disable state.
274 * \param ctx GL context.
275 * \param cap the state to enable/disable
276 * \param state whether to enable or disable the specified capability.
278 * Updates the current context and flushes the vertices as needed. For
279 * capabilities associated with extensions it verifies that those extensions
280 * are effectivly present before updating. Notifies the driver via
281 * dd_function_table::Enable.
284 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
286 if (MESA_VERBOSE
& VERBOSE_API
)
287 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
288 state
? "glEnable" : "glDisable",
289 _mesa_enum_to_string(cap
),
294 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
295 goto invalid_enum_error
;
296 if (ctx
->Color
.AlphaEnabled
== state
)
298 /* AlphaEnabled is used by the fixed-func fragment program */
299 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
300 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
301 ctx
->Color
.AlphaEnabled
= state
;
304 if (ctx
->API
!= API_OPENGL_COMPAT
)
305 goto invalid_enum_error
;
306 if (ctx
->Eval
.AutoNormal
== state
)
308 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
309 ctx
->Eval
.AutoNormal
= state
;
313 GLbitfield newEnabled
=
314 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
315 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
316 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
317 ctx
->Color
._AdvancedBlendMode
);
318 ctx
->Color
.BlendEnabled
= newEnabled
;
322 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
323 case GL_CLIP_DISTANCE1
:
324 case GL_CLIP_DISTANCE2
:
325 case GL_CLIP_DISTANCE3
:
326 case GL_CLIP_DISTANCE4
:
327 case GL_CLIP_DISTANCE5
:
328 case GL_CLIP_DISTANCE6
:
329 case GL_CLIP_DISTANCE7
:
331 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
333 if (p
>= ctx
->Const
.MaxClipPlanes
)
334 goto invalid_enum_error
;
336 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
337 == ((GLuint
) state
<< p
))
340 /* The compatibility profile needs _NEW_TRANSFORM to transform
341 * clip planes according to the projection matrix.
343 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
344 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
345 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
347 FLUSH_VERTICES(ctx
, 0);
349 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
352 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
354 /* The projection matrix transforms the clip plane. */
355 /* TODO: glEnable might not be the best place to do it. */
356 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
357 _mesa_update_clip_plane(ctx
, p
);
358 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
362 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
366 case GL_COLOR_MATERIAL
:
367 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
368 goto invalid_enum_error
;
369 if (ctx
->Light
.ColorMaterialEnabled
== state
)
371 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
372 FLUSH_CURRENT(ctx
, 0);
373 ctx
->Light
.ColorMaterialEnabled
= state
;
375 _mesa_update_color_material( ctx
,
376 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
380 if (ctx
->Polygon
.CullFlag
== state
)
383 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
384 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
385 ctx
->Polygon
.CullFlag
= state
;
388 if (ctx
->Depth
.Test
== state
)
390 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
391 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
392 ctx
->Depth
.Test
= state
;
394 case GL_DEBUG_OUTPUT
:
395 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
396 _mesa_set_debug_state_int(ctx
, cap
, state
);
399 if (ctx
->Color
.DitherFlag
== state
)
401 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
402 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
403 ctx
->Color
.DitherFlag
= state
;
406 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
407 goto invalid_enum_error
;
408 if (ctx
->Fog
.Enabled
== state
)
410 FLUSH_VERTICES(ctx
, _NEW_FOG
);
411 ctx
->Fog
.Enabled
= state
;
412 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
422 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
423 goto invalid_enum_error
;
424 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
426 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
427 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
429 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
432 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
436 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
437 goto invalid_enum_error
;
438 if (ctx
->Light
.Enabled
== state
)
440 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
441 ctx
->Light
.Enabled
= state
;
444 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
445 goto invalid_enum_error
;
446 if (ctx
->Line
.SmoothFlag
== state
)
448 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
449 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
450 ctx
->Line
.SmoothFlag
= state
;
452 case GL_LINE_STIPPLE
:
453 if (ctx
->API
!= API_OPENGL_COMPAT
)
454 goto invalid_enum_error
;
455 if (ctx
->Line
.StippleFlag
== state
)
457 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
458 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
459 ctx
->Line
.StippleFlag
= state
;
461 case GL_INDEX_LOGIC_OP
:
462 if (ctx
->API
!= API_OPENGL_COMPAT
)
463 goto invalid_enum_error
;
464 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
466 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
467 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
468 ctx
->Color
.IndexLogicOpEnabled
= state
;
470 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
471 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
472 goto invalid_enum_error
;
473 if (ctx
->IntelConservativeRasterization
== state
)
475 FLUSH_VERTICES(ctx
, 0);
476 ctx
->NewDriverState
|=
477 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
478 ctx
->IntelConservativeRasterization
= state
;
480 case GL_COLOR_LOGIC_OP
:
481 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
482 goto invalid_enum_error
;
483 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
485 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
486 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
487 ctx
->Color
.ColorLogicOpEnabled
= state
;
489 case GL_MAP1_COLOR_4
:
490 if (ctx
->API
!= API_OPENGL_COMPAT
)
491 goto invalid_enum_error
;
492 if (ctx
->Eval
.Map1Color4
== state
)
494 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
495 ctx
->Eval
.Map1Color4
= state
;
498 if (ctx
->API
!= API_OPENGL_COMPAT
)
499 goto invalid_enum_error
;
500 if (ctx
->Eval
.Map1Index
== state
)
502 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
503 ctx
->Eval
.Map1Index
= state
;
506 if (ctx
->API
!= API_OPENGL_COMPAT
)
507 goto invalid_enum_error
;
508 if (ctx
->Eval
.Map1Normal
== state
)
510 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
511 ctx
->Eval
.Map1Normal
= state
;
513 case GL_MAP1_TEXTURE_COORD_1
:
514 if (ctx
->API
!= API_OPENGL_COMPAT
)
515 goto invalid_enum_error
;
516 if (ctx
->Eval
.Map1TextureCoord1
== state
)
518 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
519 ctx
->Eval
.Map1TextureCoord1
= state
;
521 case GL_MAP1_TEXTURE_COORD_2
:
522 if (ctx
->API
!= API_OPENGL_COMPAT
)
523 goto invalid_enum_error
;
524 if (ctx
->Eval
.Map1TextureCoord2
== state
)
526 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
527 ctx
->Eval
.Map1TextureCoord2
= state
;
529 case GL_MAP1_TEXTURE_COORD_3
:
530 if (ctx
->API
!= API_OPENGL_COMPAT
)
531 goto invalid_enum_error
;
532 if (ctx
->Eval
.Map1TextureCoord3
== state
)
534 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
535 ctx
->Eval
.Map1TextureCoord3
= state
;
537 case GL_MAP1_TEXTURE_COORD_4
:
538 if (ctx
->API
!= API_OPENGL_COMPAT
)
539 goto invalid_enum_error
;
540 if (ctx
->Eval
.Map1TextureCoord4
== state
)
542 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
543 ctx
->Eval
.Map1TextureCoord4
= state
;
545 case GL_MAP1_VERTEX_3
:
546 if (ctx
->API
!= API_OPENGL_COMPAT
)
547 goto invalid_enum_error
;
548 if (ctx
->Eval
.Map1Vertex3
== state
)
550 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
551 ctx
->Eval
.Map1Vertex3
= state
;
553 case GL_MAP1_VERTEX_4
:
554 if (ctx
->API
!= API_OPENGL_COMPAT
)
555 goto invalid_enum_error
;
556 if (ctx
->Eval
.Map1Vertex4
== state
)
558 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
559 ctx
->Eval
.Map1Vertex4
= state
;
561 case GL_MAP2_COLOR_4
:
562 if (ctx
->API
!= API_OPENGL_COMPAT
)
563 goto invalid_enum_error
;
564 if (ctx
->Eval
.Map2Color4
== state
)
566 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
567 ctx
->Eval
.Map2Color4
= state
;
570 if (ctx
->API
!= API_OPENGL_COMPAT
)
571 goto invalid_enum_error
;
572 if (ctx
->Eval
.Map2Index
== state
)
574 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
575 ctx
->Eval
.Map2Index
= state
;
578 if (ctx
->API
!= API_OPENGL_COMPAT
)
579 goto invalid_enum_error
;
580 if (ctx
->Eval
.Map2Normal
== state
)
582 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
583 ctx
->Eval
.Map2Normal
= state
;
585 case GL_MAP2_TEXTURE_COORD_1
:
586 if (ctx
->API
!= API_OPENGL_COMPAT
)
587 goto invalid_enum_error
;
588 if (ctx
->Eval
.Map2TextureCoord1
== state
)
590 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
591 ctx
->Eval
.Map2TextureCoord1
= state
;
593 case GL_MAP2_TEXTURE_COORD_2
:
594 if (ctx
->API
!= API_OPENGL_COMPAT
)
595 goto invalid_enum_error
;
596 if (ctx
->Eval
.Map2TextureCoord2
== state
)
598 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
599 ctx
->Eval
.Map2TextureCoord2
= state
;
601 case GL_MAP2_TEXTURE_COORD_3
:
602 if (ctx
->API
!= API_OPENGL_COMPAT
)
603 goto invalid_enum_error
;
604 if (ctx
->Eval
.Map2TextureCoord3
== state
)
606 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
607 ctx
->Eval
.Map2TextureCoord3
= state
;
609 case GL_MAP2_TEXTURE_COORD_4
:
610 if (ctx
->API
!= API_OPENGL_COMPAT
)
611 goto invalid_enum_error
;
612 if (ctx
->Eval
.Map2TextureCoord4
== state
)
614 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
615 ctx
->Eval
.Map2TextureCoord4
= state
;
617 case GL_MAP2_VERTEX_3
:
618 if (ctx
->API
!= API_OPENGL_COMPAT
)
619 goto invalid_enum_error
;
620 if (ctx
->Eval
.Map2Vertex3
== state
)
622 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
623 ctx
->Eval
.Map2Vertex3
= state
;
625 case GL_MAP2_VERTEX_4
:
626 if (ctx
->API
!= API_OPENGL_COMPAT
)
627 goto invalid_enum_error
;
628 if (ctx
->Eval
.Map2Vertex4
== state
)
630 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
631 ctx
->Eval
.Map2Vertex4
= state
;
634 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
635 goto invalid_enum_error
;
636 if (ctx
->Transform
.Normalize
== state
)
638 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
639 ctx
->Transform
.Normalize
= state
;
641 case GL_POINT_SMOOTH
:
642 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
643 goto invalid_enum_error
;
644 if (ctx
->Point
.SmoothFlag
== state
)
646 FLUSH_VERTICES(ctx
, _NEW_POINT
);
647 ctx
->Point
.SmoothFlag
= state
;
649 case GL_POLYGON_SMOOTH
:
650 if (!_mesa_is_desktop_gl(ctx
))
651 goto invalid_enum_error
;
652 if (ctx
->Polygon
.SmoothFlag
== state
)
655 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
656 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
657 ctx
->Polygon
.SmoothFlag
= state
;
659 case GL_POLYGON_STIPPLE
:
660 if (ctx
->API
!= API_OPENGL_COMPAT
)
661 goto invalid_enum_error
;
662 if (ctx
->Polygon
.StippleFlag
== state
)
665 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
666 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
667 ctx
->Polygon
.StippleFlag
= state
;
669 case GL_POLYGON_OFFSET_POINT
:
670 if (!_mesa_is_desktop_gl(ctx
))
671 goto invalid_enum_error
;
672 if (ctx
->Polygon
.OffsetPoint
== state
)
675 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
676 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
677 ctx
->Polygon
.OffsetPoint
= state
;
679 case GL_POLYGON_OFFSET_LINE
:
680 if (!_mesa_is_desktop_gl(ctx
))
681 goto invalid_enum_error
;
682 if (ctx
->Polygon
.OffsetLine
== state
)
685 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
686 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
687 ctx
->Polygon
.OffsetLine
= state
;
689 case GL_POLYGON_OFFSET_FILL
:
690 if (ctx
->Polygon
.OffsetFill
== state
)
693 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
694 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
695 ctx
->Polygon
.OffsetFill
= state
;
697 case GL_RESCALE_NORMAL_EXT
:
698 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
699 goto invalid_enum_error
;
700 if (ctx
->Transform
.RescaleNormals
== state
)
702 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
703 ctx
->Transform
.RescaleNormals
= state
;
705 case GL_SCISSOR_TEST
:
707 /* Must expand glEnable to all scissors */
708 GLbitfield newEnabled
=
709 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
710 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
711 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
713 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
714 ctx
->Scissor
.EnableFlags
= newEnabled
;
718 case GL_STENCIL_TEST
:
719 if (ctx
->Stencil
.Enabled
== state
)
721 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
722 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
723 ctx
->Stencil
.Enabled
= state
;
726 if (ctx
->API
!= API_OPENGL_COMPAT
)
727 goto invalid_enum_error
;
728 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
733 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
734 goto invalid_enum_error
;
735 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
740 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
741 goto invalid_enum_error
;
742 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
746 case GL_TEXTURE_GEN_S
:
747 case GL_TEXTURE_GEN_T
:
748 case GL_TEXTURE_GEN_R
:
749 case GL_TEXTURE_GEN_Q
:
751 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
753 if (ctx
->API
!= API_OPENGL_COMPAT
)
754 goto invalid_enum_error
;
757 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
758 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
760 newenabled
|= coordBit
;
761 if (texUnit
->TexGenEnabled
== newenabled
)
763 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
764 texUnit
->TexGenEnabled
= newenabled
;
769 case GL_TEXTURE_GEN_STR_OES
:
770 /* disable S, T, and R at the same time */
772 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
774 if (ctx
->API
!= API_OPENGLES
)
775 goto invalid_enum_error
;
779 texUnit
->TexGenEnabled
& ~STR_BITS
;
781 newenabled
|= STR_BITS
;
782 if (texUnit
->TexGenEnabled
== newenabled
)
784 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
785 texUnit
->TexGenEnabled
= newenabled
;
790 /* client-side state */
791 case GL_VERTEX_ARRAY
:
792 case GL_NORMAL_ARRAY
:
794 case GL_TEXTURE_COORD_ARRAY
:
795 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
796 goto invalid_enum_error
;
797 client_state( ctx
, cap
, state
);
800 case GL_EDGE_FLAG_ARRAY
:
801 case GL_FOG_COORDINATE_ARRAY_EXT
:
802 case GL_SECONDARY_COLOR_ARRAY_EXT
:
803 if (ctx
->API
!= API_OPENGL_COMPAT
)
804 goto invalid_enum_error
;
805 client_state( ctx
, cap
, state
);
807 case GL_POINT_SIZE_ARRAY_OES
:
808 if (ctx
->API
!= API_OPENGLES
)
809 goto invalid_enum_error
;
810 client_state( ctx
, cap
, state
);
813 /* GL_ARB_texture_cube_map */
814 case GL_TEXTURE_CUBE_MAP
:
815 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
816 goto invalid_enum_error
;
817 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
818 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
823 /* GL_EXT_secondary_color */
824 case GL_COLOR_SUM_EXT
:
825 if (ctx
->API
!= API_OPENGL_COMPAT
)
826 goto invalid_enum_error
;
827 if (ctx
->Fog
.ColorSumEnabled
== state
)
829 FLUSH_VERTICES(ctx
, _NEW_FOG
);
830 ctx
->Fog
.ColorSumEnabled
= state
;
833 /* GL_ARB_multisample */
834 case GL_MULTISAMPLE_ARB
:
835 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
836 goto invalid_enum_error
;
837 _mesa_set_multisample(ctx
, state
);
839 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
840 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
842 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
844 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
845 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
847 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
848 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
849 goto invalid_enum_error
;
850 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
852 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
854 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
855 ctx
->Multisample
.SampleAlphaToOne
= state
;
857 case GL_SAMPLE_COVERAGE_ARB
:
858 if (ctx
->Multisample
.SampleCoverage
== state
)
860 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
862 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
863 ctx
->Multisample
.SampleCoverage
= state
;
865 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
866 if (!_mesa_is_desktop_gl(ctx
))
867 goto invalid_enum_error
;
868 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
870 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
872 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
873 ctx
->Multisample
.SampleCoverageInvert
= state
;
876 /* GL_ARB_sample_shading */
877 case GL_SAMPLE_SHADING
:
878 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
879 goto invalid_enum_error
;
880 CHECK_EXTENSION(ARB_sample_shading
, cap
);
881 if (ctx
->Multisample
.SampleShading
== state
)
883 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
885 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
886 ctx
->Multisample
.SampleShading
= state
;
889 /* GL_IBM_rasterpos_clip */
890 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
891 if (ctx
->API
!= API_OPENGL_COMPAT
)
892 goto invalid_enum_error
;
893 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
895 FLUSH_VERTICES(ctx
, 0);
896 ctx
->Transform
.RasterPositionUnclipped
= state
;
899 /* GL_NV_point_sprite */
900 case GL_POINT_SPRITE_NV
:
901 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
902 goto invalid_enum_error
;
903 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
904 if (ctx
->Point
.PointSprite
== state
)
906 FLUSH_VERTICES(ctx
, _NEW_POINT
);
907 ctx
->Point
.PointSprite
= state
;
910 case GL_VERTEX_PROGRAM_ARB
:
911 if (ctx
->API
!= API_OPENGL_COMPAT
)
912 goto invalid_enum_error
;
913 CHECK_EXTENSION(ARB_vertex_program
, cap
);
914 if (ctx
->VertexProgram
.Enabled
== state
)
916 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
917 ctx
->VertexProgram
.Enabled
= state
;
919 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
920 /* This was added with ARB_vertex_program, but it is also used with
921 * GLSL vertex shaders on desktop.
923 if (!_mesa_is_desktop_gl(ctx
))
924 goto invalid_enum_error
;
925 CHECK_EXTENSION(ARB_vertex_program
, cap
);
926 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
928 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
929 ctx
->VertexProgram
.PointSizeEnabled
= state
;
931 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
932 if (ctx
->API
!= API_OPENGL_COMPAT
)
933 goto invalid_enum_error
;
934 CHECK_EXTENSION(ARB_vertex_program
, cap
);
935 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
937 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
938 ctx
->VertexProgram
.TwoSideEnabled
= state
;
941 /* GL_NV_texture_rectangle */
942 case GL_TEXTURE_RECTANGLE_NV
:
943 if (ctx
->API
!= API_OPENGL_COMPAT
)
944 goto invalid_enum_error
;
945 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
946 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
951 /* GL_EXT_stencil_two_side */
952 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
953 if (ctx
->API
!= API_OPENGL_COMPAT
)
954 goto invalid_enum_error
;
955 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
956 if (ctx
->Stencil
.TestTwoSide
== state
)
958 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
959 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
960 ctx
->Stencil
.TestTwoSide
= state
;
962 ctx
->Stencil
._BackFace
= 2;
964 ctx
->Stencil
._BackFace
= 1;
968 case GL_FRAGMENT_PROGRAM_ARB
:
969 if (ctx
->API
!= API_OPENGL_COMPAT
)
970 goto invalid_enum_error
;
971 CHECK_EXTENSION(ARB_fragment_program
, cap
);
972 if (ctx
->FragmentProgram
.Enabled
== state
)
974 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
975 ctx
->FragmentProgram
.Enabled
= state
;
978 /* GL_EXT_depth_bounds_test */
979 case GL_DEPTH_BOUNDS_TEST_EXT
:
980 if (!_mesa_is_desktop_gl(ctx
))
981 goto invalid_enum_error
;
982 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
983 if (ctx
->Depth
.BoundsTest
== state
)
985 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
986 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
987 ctx
->Depth
.BoundsTest
= state
;
991 if (!_mesa_is_desktop_gl(ctx
))
992 goto invalid_enum_error
;
993 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
994 if (ctx
->Transform
.DepthClamp
== state
)
996 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
998 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
999 ctx
->Transform
.DepthClamp
= state
;
1002 case GL_FRAGMENT_SHADER_ATI
:
1003 if (ctx
->API
!= API_OPENGL_COMPAT
)
1004 goto invalid_enum_error
;
1005 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
1006 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1008 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1009 ctx
->ATIFragmentShader
.Enabled
= state
;
1012 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1013 if (!_mesa_is_desktop_gl(ctx
))
1014 goto invalid_enum_error
;
1015 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
1016 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1017 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1018 ctx
->Texture
.CubeMapSeamless
= state
;
1022 case GL_RASTERIZER_DISCARD
:
1023 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1024 goto invalid_enum_error
;
1025 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
1026 if (ctx
->RasterDiscard
!= state
) {
1027 FLUSH_VERTICES(ctx
, 0);
1028 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1029 ctx
->RasterDiscard
= state
;
1033 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1034 CHECK_EXTENSION(MESA_tile_raster_order
, cap
);
1035 if (ctx
->TileRasterOrderFixed
!= state
) {
1036 FLUSH_VERTICES(ctx
, 0);
1037 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1038 ctx
->TileRasterOrderFixed
= state
;
1042 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1043 CHECK_EXTENSION(MESA_tile_raster_order
, cap
);
1044 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1045 FLUSH_VERTICES(ctx
, 0);
1046 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1047 ctx
->TileRasterOrderIncreasingX
= state
;
1051 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1052 CHECK_EXTENSION(MESA_tile_raster_order
, cap
);
1053 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1054 FLUSH_VERTICES(ctx
, 0);
1055 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1056 ctx
->TileRasterOrderIncreasingY
= state
;
1060 /* GL 3.1 primitive restart. Note: this enum is different from
1061 * GL_PRIMITIVE_RESTART_NV (which is client state).
1063 case GL_PRIMITIVE_RESTART
:
1064 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1065 goto invalid_enum_error
;
1067 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1068 FLUSH_VERTICES(ctx
, 0);
1069 ctx
->Array
.PrimitiveRestart
= state
;
1070 update_derived_primitive_restart_state(ctx
);
1074 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1075 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
)
1076 goto invalid_enum_error
;
1077 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1078 FLUSH_VERTICES(ctx
, 0);
1079 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1080 update_derived_primitive_restart_state(ctx
);
1084 /* GL3.0 - GL_framebuffer_sRGB */
1085 case GL_FRAMEBUFFER_SRGB_EXT
:
1086 if (!_mesa_is_desktop_gl(ctx
))
1087 goto invalid_enum_error
;
1088 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
1089 _mesa_set_framebuffer_srgb(ctx
, state
);
1092 /* GL_OES_EGL_image_external */
1093 case GL_TEXTURE_EXTERNAL_OES
:
1094 if (!_mesa_is_gles(ctx
))
1095 goto invalid_enum_error
;
1096 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
1097 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1102 /* ARB_texture_multisample */
1103 case GL_SAMPLE_MASK
:
1104 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1105 goto invalid_enum_error
;
1106 CHECK_EXTENSION(ARB_texture_multisample
, cap
);
1107 if (ctx
->Multisample
.SampleMask
== state
)
1109 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1111 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1112 ctx
->Multisample
.SampleMask
= state
;
1115 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1116 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent
, cap
);
1117 if (ctx
->Color
.BlendCoherent
== state
)
1119 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1120 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1121 ctx
->Color
.BlendCoherent
= state
;
1125 goto invalid_enum_error
;
1128 if (ctx
->Driver
.Enable
) {
1129 ctx
->Driver
.Enable( ctx
, cap
, state
);
1135 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1136 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1141 * Enable GL capability. Called by glEnable()
1142 * \param cap state to enable.
1145 _mesa_Enable( GLenum cap
)
1147 GET_CURRENT_CONTEXT(ctx
);
1149 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1154 * Disable GL capability. Called by glDisable()
1155 * \param cap state to disable.
1158 _mesa_Disable( GLenum cap
)
1160 GET_CURRENT_CONTEXT(ctx
);
1162 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1168 * Enable/disable an indexed state var.
1171 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1172 GLuint index
, GLboolean state
)
1174 assert(state
== 0 || state
== 1);
1177 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1178 goto invalid_enum_error
;
1180 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1181 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1182 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1185 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1186 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1189 enabled
|= (1 << index
);
1191 enabled
&= ~(1 << index
);
1193 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1194 ctx
->Color
._AdvancedBlendMode
);
1195 ctx
->Color
.BlendEnabled
= enabled
;
1198 case GL_SCISSOR_TEST
:
1199 if (index
>= ctx
->Const
.MaxViewports
) {
1200 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1201 state
? "glEnablei" : "glDisablei", index
);
1204 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1206 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1207 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1209 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1211 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1215 goto invalid_enum_error
;
1220 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1221 state
? "glEnablei" : "glDisablei",
1222 _mesa_enum_to_string(cap
));
1227 _mesa_Disablei( GLenum cap
, GLuint index
)
1229 GET_CURRENT_CONTEXT(ctx
);
1230 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1235 _mesa_Enablei( GLenum cap
, GLuint index
)
1237 GET_CURRENT_CONTEXT(ctx
);
1238 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1242 GLboolean GLAPIENTRY
1243 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1245 GET_CURRENT_CONTEXT(ctx
);
1246 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1249 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1250 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1254 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1255 case GL_SCISSOR_TEST
:
1256 if (index
>= ctx
->Const
.MaxViewports
) {
1257 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1261 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1263 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1264 _mesa_enum_to_string(cap
));
1272 #undef CHECK_EXTENSION
1273 #define CHECK_EXTENSION(EXTNAME) \
1274 if (!ctx->Extensions.EXTNAME) { \
1275 goto invalid_enum_error; \
1278 #undef CHECK_EXTENSION2
1279 #define CHECK_EXTENSION2(EXT1, EXT2) \
1280 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1281 goto invalid_enum_error; \
1286 * Helper function to determine whether a texture target is enabled.
1289 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1291 const struct gl_texture_unit
*const texUnit
=
1292 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1293 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1298 * Return simple enable/disable state.
1300 * \param cap state variable to query.
1302 * Returns the state of the specified capability from the current GL context.
1303 * For the capabilities associated with extensions verifies that those
1304 * extensions are effectively present before reporting.
1306 GLboolean GLAPIENTRY
1307 _mesa_IsEnabled( GLenum cap
)
1309 GET_CURRENT_CONTEXT(ctx
);
1310 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1314 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1315 goto invalid_enum_error
;
1316 return ctx
->Color
.AlphaEnabled
;
1317 case GL_AUTO_NORMAL
:
1318 if (ctx
->API
!= API_OPENGL_COMPAT
)
1319 goto invalid_enum_error
;
1320 return ctx
->Eval
.AutoNormal
;
1322 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1323 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1324 case GL_CLIP_DISTANCE1
:
1325 case GL_CLIP_DISTANCE2
:
1326 case GL_CLIP_DISTANCE3
:
1327 case GL_CLIP_DISTANCE4
:
1328 case GL_CLIP_DISTANCE5
:
1329 case GL_CLIP_DISTANCE6
:
1330 case GL_CLIP_DISTANCE7
: {
1331 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1333 if (p
>= ctx
->Const
.MaxClipPlanes
)
1334 goto invalid_enum_error
;
1336 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1338 case GL_COLOR_MATERIAL
:
1339 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1340 goto invalid_enum_error
;
1341 return ctx
->Light
.ColorMaterialEnabled
;
1343 return ctx
->Polygon
.CullFlag
;
1344 case GL_DEBUG_OUTPUT
:
1345 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1346 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1348 return ctx
->Depth
.Test
;
1350 return ctx
->Color
.DitherFlag
;
1352 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1353 goto invalid_enum_error
;
1354 return ctx
->Fog
.Enabled
;
1356 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1357 goto invalid_enum_error
;
1358 return ctx
->Light
.Enabled
;
1367 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1368 goto invalid_enum_error
;
1369 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1370 case GL_LINE_SMOOTH
:
1371 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1372 goto invalid_enum_error
;
1373 return ctx
->Line
.SmoothFlag
;
1374 case GL_LINE_STIPPLE
:
1375 if (ctx
->API
!= API_OPENGL_COMPAT
)
1376 goto invalid_enum_error
;
1377 return ctx
->Line
.StippleFlag
;
1378 case GL_INDEX_LOGIC_OP
:
1379 if (ctx
->API
!= API_OPENGL_COMPAT
)
1380 goto invalid_enum_error
;
1381 return ctx
->Color
.IndexLogicOpEnabled
;
1382 case GL_COLOR_LOGIC_OP
:
1383 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1384 goto invalid_enum_error
;
1385 return ctx
->Color
.ColorLogicOpEnabled
;
1386 case GL_MAP1_COLOR_4
:
1387 if (ctx
->API
!= API_OPENGL_COMPAT
)
1388 goto invalid_enum_error
;
1389 return ctx
->Eval
.Map1Color4
;
1391 if (ctx
->API
!= API_OPENGL_COMPAT
)
1392 goto invalid_enum_error
;
1393 return ctx
->Eval
.Map1Index
;
1394 case GL_MAP1_NORMAL
:
1395 if (ctx
->API
!= API_OPENGL_COMPAT
)
1396 goto invalid_enum_error
;
1397 return ctx
->Eval
.Map1Normal
;
1398 case GL_MAP1_TEXTURE_COORD_1
:
1399 if (ctx
->API
!= API_OPENGL_COMPAT
)
1400 goto invalid_enum_error
;
1401 return ctx
->Eval
.Map1TextureCoord1
;
1402 case GL_MAP1_TEXTURE_COORD_2
:
1403 if (ctx
->API
!= API_OPENGL_COMPAT
)
1404 goto invalid_enum_error
;
1405 return ctx
->Eval
.Map1TextureCoord2
;
1406 case GL_MAP1_TEXTURE_COORD_3
:
1407 if (ctx
->API
!= API_OPENGL_COMPAT
)
1408 goto invalid_enum_error
;
1409 return ctx
->Eval
.Map1TextureCoord3
;
1410 case GL_MAP1_TEXTURE_COORD_4
:
1411 if (ctx
->API
!= API_OPENGL_COMPAT
)
1412 goto invalid_enum_error
;
1413 return ctx
->Eval
.Map1TextureCoord4
;
1414 case GL_MAP1_VERTEX_3
:
1415 if (ctx
->API
!= API_OPENGL_COMPAT
)
1416 goto invalid_enum_error
;
1417 return ctx
->Eval
.Map1Vertex3
;
1418 case GL_MAP1_VERTEX_4
:
1419 if (ctx
->API
!= API_OPENGL_COMPAT
)
1420 goto invalid_enum_error
;
1421 return ctx
->Eval
.Map1Vertex4
;
1422 case GL_MAP2_COLOR_4
:
1423 if (ctx
->API
!= API_OPENGL_COMPAT
)
1424 goto invalid_enum_error
;
1425 return ctx
->Eval
.Map2Color4
;
1427 if (ctx
->API
!= API_OPENGL_COMPAT
)
1428 goto invalid_enum_error
;
1429 return ctx
->Eval
.Map2Index
;
1430 case GL_MAP2_NORMAL
:
1431 if (ctx
->API
!= API_OPENGL_COMPAT
)
1432 goto invalid_enum_error
;
1433 return ctx
->Eval
.Map2Normal
;
1434 case GL_MAP2_TEXTURE_COORD_1
:
1435 if (ctx
->API
!= API_OPENGL_COMPAT
)
1436 goto invalid_enum_error
;
1437 return ctx
->Eval
.Map2TextureCoord1
;
1438 case GL_MAP2_TEXTURE_COORD_2
:
1439 if (ctx
->API
!= API_OPENGL_COMPAT
)
1440 goto invalid_enum_error
;
1441 return ctx
->Eval
.Map2TextureCoord2
;
1442 case GL_MAP2_TEXTURE_COORD_3
:
1443 if (ctx
->API
!= API_OPENGL_COMPAT
)
1444 goto invalid_enum_error
;
1445 return ctx
->Eval
.Map2TextureCoord3
;
1446 case GL_MAP2_TEXTURE_COORD_4
:
1447 if (ctx
->API
!= API_OPENGL_COMPAT
)
1448 goto invalid_enum_error
;
1449 return ctx
->Eval
.Map2TextureCoord4
;
1450 case GL_MAP2_VERTEX_3
:
1451 if (ctx
->API
!= API_OPENGL_COMPAT
)
1452 goto invalid_enum_error
;
1453 return ctx
->Eval
.Map2Vertex3
;
1454 case GL_MAP2_VERTEX_4
:
1455 if (ctx
->API
!= API_OPENGL_COMPAT
)
1456 goto invalid_enum_error
;
1457 return ctx
->Eval
.Map2Vertex4
;
1459 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1460 goto invalid_enum_error
;
1461 return ctx
->Transform
.Normalize
;
1462 case GL_POINT_SMOOTH
:
1463 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1464 goto invalid_enum_error
;
1465 return ctx
->Point
.SmoothFlag
;
1466 case GL_POLYGON_SMOOTH
:
1467 if (!_mesa_is_desktop_gl(ctx
))
1468 goto invalid_enum_error
;
1469 return ctx
->Polygon
.SmoothFlag
;
1470 case GL_POLYGON_STIPPLE
:
1471 if (ctx
->API
!= API_OPENGL_COMPAT
)
1472 goto invalid_enum_error
;
1473 return ctx
->Polygon
.StippleFlag
;
1474 case GL_POLYGON_OFFSET_POINT
:
1475 if (!_mesa_is_desktop_gl(ctx
))
1476 goto invalid_enum_error
;
1477 return ctx
->Polygon
.OffsetPoint
;
1478 case GL_POLYGON_OFFSET_LINE
:
1479 if (!_mesa_is_desktop_gl(ctx
))
1480 goto invalid_enum_error
;
1481 return ctx
->Polygon
.OffsetLine
;
1482 case GL_POLYGON_OFFSET_FILL
:
1483 return ctx
->Polygon
.OffsetFill
;
1484 case GL_RESCALE_NORMAL_EXT
:
1485 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1486 goto invalid_enum_error
;
1487 return ctx
->Transform
.RescaleNormals
;
1488 case GL_SCISSOR_TEST
:
1489 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1490 case GL_STENCIL_TEST
:
1491 return ctx
->Stencil
.Enabled
;
1493 if (ctx
->API
!= API_OPENGL_COMPAT
)
1494 goto invalid_enum_error
;
1495 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1497 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1498 goto invalid_enum_error
;
1499 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1501 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1502 goto invalid_enum_error
;
1503 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1504 case GL_TEXTURE_GEN_S
:
1505 case GL_TEXTURE_GEN_T
:
1506 case GL_TEXTURE_GEN_R
:
1507 case GL_TEXTURE_GEN_Q
:
1509 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1511 if (ctx
->API
!= API_OPENGL_COMPAT
)
1512 goto invalid_enum_error
;
1515 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1516 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1520 case GL_TEXTURE_GEN_STR_OES
:
1522 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1524 if (ctx
->API
!= API_OPENGLES
)
1525 goto invalid_enum_error
;
1528 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1529 ? GL_TRUE
: GL_FALSE
;
1533 /* client-side state */
1534 case GL_VERTEX_ARRAY
:
1535 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1536 goto invalid_enum_error
;
1537 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
1538 case GL_NORMAL_ARRAY
:
1539 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1540 goto invalid_enum_error
;
1541 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
1542 case GL_COLOR_ARRAY
:
1543 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1544 goto invalid_enum_error
;
1545 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
1546 case GL_INDEX_ARRAY
:
1547 if (ctx
->API
!= API_OPENGL_COMPAT
)
1548 goto invalid_enum_error
;
1549 return ctx
->Array
.VAO
->
1550 VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
1551 case GL_TEXTURE_COORD_ARRAY
:
1552 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1553 goto invalid_enum_error
;
1554 return ctx
->Array
.VAO
->
1555 VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
1556 case GL_EDGE_FLAG_ARRAY
:
1557 if (ctx
->API
!= API_OPENGL_COMPAT
)
1558 goto invalid_enum_error
;
1559 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
1560 case GL_FOG_COORDINATE_ARRAY_EXT
:
1561 if (ctx
->API
!= API_OPENGL_COMPAT
)
1562 goto invalid_enum_error
;
1563 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
1564 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1565 if (ctx
->API
!= API_OPENGL_COMPAT
)
1566 goto invalid_enum_error
;
1567 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
1568 case GL_POINT_SIZE_ARRAY_OES
:
1569 if (ctx
->API
!= API_OPENGLES
)
1570 goto invalid_enum_error
;
1571 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
1573 /* GL_ARB_texture_cube_map */
1574 case GL_TEXTURE_CUBE_MAP
:
1575 CHECK_EXTENSION(ARB_texture_cube_map
);
1576 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1578 /* GL_EXT_secondary_color */
1579 case GL_COLOR_SUM_EXT
:
1580 if (ctx
->API
!= API_OPENGL_COMPAT
)
1581 goto invalid_enum_error
;
1582 return ctx
->Fog
.ColorSumEnabled
;
1584 /* GL_ARB_multisample */
1585 case GL_MULTISAMPLE_ARB
:
1586 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1587 goto invalid_enum_error
;
1588 return ctx
->Multisample
.Enabled
;
1589 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1590 return ctx
->Multisample
.SampleAlphaToCoverage
;
1591 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1592 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1593 goto invalid_enum_error
;
1594 return ctx
->Multisample
.SampleAlphaToOne
;
1595 case GL_SAMPLE_COVERAGE_ARB
:
1596 return ctx
->Multisample
.SampleCoverage
;
1597 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1598 if (!_mesa_is_desktop_gl(ctx
))
1599 goto invalid_enum_error
;
1600 return ctx
->Multisample
.SampleCoverageInvert
;
1602 /* GL_IBM_rasterpos_clip */
1603 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1604 if (ctx
->API
!= API_OPENGL_COMPAT
)
1605 goto invalid_enum_error
;
1606 return ctx
->Transform
.RasterPositionUnclipped
;
1608 /* GL_NV_point_sprite */
1609 case GL_POINT_SPRITE_NV
:
1610 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1611 goto invalid_enum_error
;
1612 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1613 return ctx
->Point
.PointSprite
;
1615 case GL_VERTEX_PROGRAM_ARB
:
1616 if (ctx
->API
!= API_OPENGL_COMPAT
)
1617 goto invalid_enum_error
;
1618 CHECK_EXTENSION(ARB_vertex_program
);
1619 return ctx
->VertexProgram
.Enabled
;
1620 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1621 /* This was added with ARB_vertex_program, but it is also used with
1622 * GLSL vertex shaders on desktop.
1624 if (!_mesa_is_desktop_gl(ctx
))
1625 goto invalid_enum_error
;
1626 CHECK_EXTENSION(ARB_vertex_program
);
1627 return ctx
->VertexProgram
.PointSizeEnabled
;
1628 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1629 if (ctx
->API
!= API_OPENGL_COMPAT
)
1630 goto invalid_enum_error
;
1631 CHECK_EXTENSION(ARB_vertex_program
);
1632 return ctx
->VertexProgram
.TwoSideEnabled
;
1634 /* GL_NV_texture_rectangle */
1635 case GL_TEXTURE_RECTANGLE_NV
:
1636 if (ctx
->API
!= API_OPENGL_COMPAT
)
1637 goto invalid_enum_error
;
1638 CHECK_EXTENSION(NV_texture_rectangle
);
1639 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1641 /* GL_EXT_stencil_two_side */
1642 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1643 if (ctx
->API
!= API_OPENGL_COMPAT
)
1644 goto invalid_enum_error
;
1645 CHECK_EXTENSION(EXT_stencil_two_side
);
1646 return ctx
->Stencil
.TestTwoSide
;
1648 case GL_FRAGMENT_PROGRAM_ARB
:
1649 if (ctx
->API
!= API_OPENGL_COMPAT
)
1650 goto invalid_enum_error
;
1651 return ctx
->FragmentProgram
.Enabled
;
1653 /* GL_EXT_depth_bounds_test */
1654 case GL_DEPTH_BOUNDS_TEST_EXT
:
1655 if (!_mesa_is_desktop_gl(ctx
))
1656 goto invalid_enum_error
;
1657 CHECK_EXTENSION(EXT_depth_bounds_test
);
1658 return ctx
->Depth
.BoundsTest
;
1660 /* GL_ARB_depth_clamp */
1661 case GL_DEPTH_CLAMP
:
1662 if (!_mesa_is_desktop_gl(ctx
))
1663 goto invalid_enum_error
;
1664 CHECK_EXTENSION(ARB_depth_clamp
);
1665 return ctx
->Transform
.DepthClamp
;
1667 case GL_FRAGMENT_SHADER_ATI
:
1668 if (ctx
->API
!= API_OPENGL_COMPAT
)
1669 goto invalid_enum_error
;
1670 CHECK_EXTENSION(ATI_fragment_shader
);
1671 return ctx
->ATIFragmentShader
.Enabled
;
1673 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1674 if (!_mesa_is_desktop_gl(ctx
))
1675 goto invalid_enum_error
;
1676 CHECK_EXTENSION(ARB_seamless_cube_map
);
1677 return ctx
->Texture
.CubeMapSeamless
;
1679 case GL_RASTERIZER_DISCARD
:
1680 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1681 goto invalid_enum_error
;
1682 CHECK_EXTENSION(EXT_transform_feedback
);
1683 return ctx
->RasterDiscard
;
1685 /* GL_NV_primitive_restart */
1686 case GL_PRIMITIVE_RESTART_NV
:
1687 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1688 goto invalid_enum_error
;
1690 return ctx
->Array
.PrimitiveRestart
;
1692 /* GL 3.1 primitive restart */
1693 case GL_PRIMITIVE_RESTART
:
1694 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1695 goto invalid_enum_error
;
1697 return ctx
->Array
.PrimitiveRestart
;
1699 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1700 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1701 goto invalid_enum_error
;
1703 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1705 /* GL3.0 - GL_framebuffer_sRGB */
1706 case GL_FRAMEBUFFER_SRGB_EXT
:
1707 if (!_mesa_is_desktop_gl(ctx
))
1708 goto invalid_enum_error
;
1709 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1710 return ctx
->Color
.sRGBEnabled
;
1712 /* GL_OES_EGL_image_external */
1713 case GL_TEXTURE_EXTERNAL_OES
:
1714 if (!_mesa_is_gles(ctx
))
1715 goto invalid_enum_error
;
1716 CHECK_EXTENSION(OES_EGL_image_external
);
1717 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1719 /* ARB_texture_multisample */
1720 case GL_SAMPLE_MASK
:
1721 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1722 goto invalid_enum_error
;
1723 CHECK_EXTENSION(ARB_texture_multisample
);
1724 return ctx
->Multisample
.SampleMask
;
1726 /* ARB_sample_shading */
1727 case GL_SAMPLE_SHADING
:
1728 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1729 goto invalid_enum_error
;
1730 CHECK_EXTENSION(ARB_sample_shading
);
1731 return ctx
->Multisample
.SampleShading
;
1733 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1734 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent
);
1735 return ctx
->Color
.BlendCoherent
;
1737 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1738 CHECK_EXTENSION(INTEL_conservative_rasterization
);
1739 return ctx
->IntelConservativeRasterization
;
1741 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1742 CHECK_EXTENSION(MESA_tile_raster_order
);
1743 return ctx
->TileRasterOrderFixed
;
1745 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1746 CHECK_EXTENSION(MESA_tile_raster_order
);
1747 return ctx
->TileRasterOrderIncreasingX
;
1749 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1750 CHECK_EXTENSION(MESA_tile_raster_order
);
1751 return ctx
->TileRasterOrderIncreasingY
;
1754 goto invalid_enum_error
;
1760 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1761 _mesa_enum_to_string(cap
));