3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
36 #include "debug_output.h"
48 #define CHECK_EXTENSION(EXTNAME, CAP) \
49 if (!ctx->Extensions.EXTNAME) { \
50 goto invalid_enum_error; \
55 update_derived_primitive_restart_state(struct gl_context
*ctx
)
57 /* Update derived primitive restart state.
59 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
60 || ctx
->Array
.PrimitiveRestartFixedIndex
;
65 * Helper to enable/disable VAO client-side state.
68 vao_state(struct gl_context
*ctx
, gl_vert_attrib attr
, GLboolean state
)
71 _mesa_enable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attr
, true);
73 _mesa_disable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attr
, true);
78 * Helper to enable/disable client-side state.
81 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
85 vao_state(ctx
, VERT_ATTRIB_POS
, state
);
88 vao_state(ctx
, VERT_ATTRIB_NORMAL
, state
);
91 vao_state(ctx
, VERT_ATTRIB_COLOR0
, state
);
94 vao_state(ctx
, VERT_ATTRIB_COLOR_INDEX
, state
);
96 case GL_TEXTURE_COORD_ARRAY
:
97 vao_state(ctx
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
99 case GL_EDGE_FLAG_ARRAY
:
100 vao_state(ctx
, VERT_ATTRIB_EDGEFLAG
, state
);
102 case GL_FOG_COORDINATE_ARRAY_EXT
:
103 vao_state(ctx
, VERT_ATTRIB_FOG
, state
);
105 case GL_SECONDARY_COLOR_ARRAY_EXT
:
106 vao_state(ctx
, VERT_ATTRIB_COLOR1
, state
);
109 case GL_POINT_SIZE_ARRAY_OES
:
110 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
111 ctx
->VertexProgram
.PointSizeEnabled
= state
;
112 vao_state(ctx
, VERT_ATTRIB_POINT_SIZE
, state
);
115 /* GL_NV_primitive_restart */
116 case GL_PRIMITIVE_RESTART_NV
:
117 if (!ctx
->Extensions
.NV_primitive_restart
)
118 goto invalid_enum_error
;
119 if (ctx
->Array
.PrimitiveRestart
== state
)
122 FLUSH_VERTICES(ctx
, 0);
123 ctx
->Array
.PrimitiveRestart
= state
;
124 update_derived_primitive_restart_state(ctx
);
128 goto invalid_enum_error
;
131 if (ctx
->Driver
.Enable
) {
132 ctx
->Driver
.Enable( ctx
, cap
, state
);
138 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
139 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
144 * Enable GL capability.
145 * \param cap state to enable/disable.
147 * Get's the current context, assures that we're outside glBegin()/glEnd() and
148 * calls client_state().
151 _mesa_EnableClientState( GLenum cap
)
153 GET_CURRENT_CONTEXT(ctx
);
154 client_state( ctx
, cap
, GL_TRUE
);
159 * Disable GL capability.
160 * \param cap state to enable/disable.
162 * Get's the current context, assures that we're outside glBegin()/glEnd() and
163 * calls client_state().
166 _mesa_DisableClientState( GLenum cap
)
168 GET_CURRENT_CONTEXT(ctx
);
169 client_state( ctx
, cap
, GL_FALSE
);
173 #undef CHECK_EXTENSION
174 #define CHECK_EXTENSION(EXTNAME, CAP) \
175 if (!ctx->Extensions.EXTNAME) { \
176 goto invalid_enum_error; \
179 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
180 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
181 goto invalid_enum_error; \
185 * Return pointer to current texture unit for setting/getting coordinate
187 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
188 * texture unit is higher than the number of supported coordinate units.
190 static struct gl_fixedfunc_texture_unit
*
191 get_texcoord_unit(struct gl_context
*ctx
)
193 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
194 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
198 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
204 * Helper function to enable or disable a texture target.
205 * \param bit one of the TEXTURE_x_BIT values
206 * \return GL_TRUE if state is changing or GL_FALSE if no change
209 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
211 struct gl_fixedfunc_texture_unit
*texUnit
=
212 _mesa_get_current_fixedfunc_tex_unit(ctx
);
216 const GLbitfield newenabled
= state
217 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
219 if (texUnit
->Enabled
== newenabled
)
222 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
223 texUnit
->Enabled
= newenabled
;
229 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
230 * whether the API supports it (GLES doesn't).
233 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
235 if (ctx
->Multisample
.Enabled
== state
)
238 /* GL compatibility needs Multisample.Enable to determine program state
241 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
242 !ctx
->DriverFlags
.NewMultisampleEnable
) {
243 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
245 FLUSH_VERTICES(ctx
, 0);
248 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
249 ctx
->Multisample
.Enabled
= state
;
251 if (ctx
->Driver
.Enable
) {
252 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
257 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
258 * check for whether the API supports it (GLES doesn't).
261 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
263 if (ctx
->Color
.sRGBEnabled
== state
)
266 /* TODO: Switch i965 to the new flag and remove the conditional */
267 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
268 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
269 ctx
->Color
.sRGBEnabled
= state
;
271 if (ctx
->Driver
.Enable
) {
272 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
277 * Helper function to enable or disable state.
279 * \param ctx GL context.
280 * \param cap the state to enable/disable
281 * \param state whether to enable or disable the specified capability.
283 * Updates the current context and flushes the vertices as needed. For
284 * capabilities associated with extensions it verifies that those extensions
285 * are effectivly present before updating. Notifies the driver via
286 * dd_function_table::Enable.
289 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
291 if (MESA_VERBOSE
& VERBOSE_API
)
292 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
293 state
? "glEnable" : "glDisable",
294 _mesa_enum_to_string(cap
),
299 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
300 goto invalid_enum_error
;
301 if (ctx
->Color
.AlphaEnabled
== state
)
303 /* AlphaEnabled is used by the fixed-func fragment program */
304 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
305 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
306 ctx
->Color
.AlphaEnabled
= state
;
309 if (ctx
->API
!= API_OPENGL_COMPAT
)
310 goto invalid_enum_error
;
311 if (ctx
->Eval
.AutoNormal
== state
)
313 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
314 ctx
->Eval
.AutoNormal
= state
;
318 GLbitfield newEnabled
=
319 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
320 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
321 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
322 ctx
->Color
._AdvancedBlendMode
);
323 ctx
->Color
.BlendEnabled
= newEnabled
;
327 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
328 case GL_CLIP_DISTANCE1
:
329 case GL_CLIP_DISTANCE2
:
330 case GL_CLIP_DISTANCE3
:
331 case GL_CLIP_DISTANCE4
:
332 case GL_CLIP_DISTANCE5
:
333 case GL_CLIP_DISTANCE6
:
334 case GL_CLIP_DISTANCE7
:
336 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
338 if (p
>= ctx
->Const
.MaxClipPlanes
)
339 goto invalid_enum_error
;
341 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
342 == ((GLuint
) state
<< p
))
345 /* The compatibility profile needs _NEW_TRANSFORM to transform
346 * clip planes according to the projection matrix.
348 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
349 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
350 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
352 FLUSH_VERTICES(ctx
, 0);
354 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
357 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
359 /* The projection matrix transforms the clip plane. */
360 /* TODO: glEnable might not be the best place to do it. */
361 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
362 _mesa_update_clip_plane(ctx
, p
);
363 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
367 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
371 case GL_COLOR_MATERIAL
:
372 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
373 goto invalid_enum_error
;
374 if (ctx
->Light
.ColorMaterialEnabled
== state
)
376 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
377 FLUSH_CURRENT(ctx
, 0);
378 ctx
->Light
.ColorMaterialEnabled
= state
;
380 _mesa_update_color_material( ctx
,
381 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
385 if (ctx
->Polygon
.CullFlag
== state
)
388 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
389 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
390 ctx
->Polygon
.CullFlag
= state
;
393 if (ctx
->Depth
.Test
== state
)
395 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
396 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
397 ctx
->Depth
.Test
= state
;
399 case GL_DEBUG_OUTPUT
:
400 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
401 _mesa_set_debug_state_int(ctx
, cap
, state
);
404 if (ctx
->Color
.DitherFlag
== state
)
406 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
407 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
408 ctx
->Color
.DitherFlag
= state
;
411 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
412 goto invalid_enum_error
;
413 if (ctx
->Fog
.Enabled
== state
)
415 FLUSH_VERTICES(ctx
, _NEW_FOG
);
416 ctx
->Fog
.Enabled
= state
;
417 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
427 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
428 goto invalid_enum_error
;
429 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
431 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
432 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
434 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
437 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
441 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
442 goto invalid_enum_error
;
443 if (ctx
->Light
.Enabled
== state
)
445 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
446 ctx
->Light
.Enabled
= state
;
449 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
450 goto invalid_enum_error
;
451 if (ctx
->Line
.SmoothFlag
== state
)
453 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
454 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
455 ctx
->Line
.SmoothFlag
= state
;
457 case GL_LINE_STIPPLE
:
458 if (ctx
->API
!= API_OPENGL_COMPAT
)
459 goto invalid_enum_error
;
460 if (ctx
->Line
.StippleFlag
== state
)
462 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
463 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
464 ctx
->Line
.StippleFlag
= state
;
466 case GL_INDEX_LOGIC_OP
:
467 if (ctx
->API
!= API_OPENGL_COMPAT
)
468 goto invalid_enum_error
;
469 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
471 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
472 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
473 ctx
->Color
.IndexLogicOpEnabled
= state
;
475 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
476 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
477 goto invalid_enum_error
;
478 if (ctx
->IntelConservativeRasterization
== state
)
480 FLUSH_VERTICES(ctx
, 0);
481 ctx
->NewDriverState
|=
482 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
483 ctx
->IntelConservativeRasterization
= state
;
485 case GL_COLOR_LOGIC_OP
:
486 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
487 goto invalid_enum_error
;
488 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
490 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
491 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
492 ctx
->Color
.ColorLogicOpEnabled
= state
;
494 case GL_MAP1_COLOR_4
:
495 if (ctx
->API
!= API_OPENGL_COMPAT
)
496 goto invalid_enum_error
;
497 if (ctx
->Eval
.Map1Color4
== state
)
499 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
500 ctx
->Eval
.Map1Color4
= state
;
503 if (ctx
->API
!= API_OPENGL_COMPAT
)
504 goto invalid_enum_error
;
505 if (ctx
->Eval
.Map1Index
== state
)
507 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
508 ctx
->Eval
.Map1Index
= state
;
511 if (ctx
->API
!= API_OPENGL_COMPAT
)
512 goto invalid_enum_error
;
513 if (ctx
->Eval
.Map1Normal
== state
)
515 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
516 ctx
->Eval
.Map1Normal
= state
;
518 case GL_MAP1_TEXTURE_COORD_1
:
519 if (ctx
->API
!= API_OPENGL_COMPAT
)
520 goto invalid_enum_error
;
521 if (ctx
->Eval
.Map1TextureCoord1
== state
)
523 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
524 ctx
->Eval
.Map1TextureCoord1
= state
;
526 case GL_MAP1_TEXTURE_COORD_2
:
527 if (ctx
->API
!= API_OPENGL_COMPAT
)
528 goto invalid_enum_error
;
529 if (ctx
->Eval
.Map1TextureCoord2
== state
)
531 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
532 ctx
->Eval
.Map1TextureCoord2
= state
;
534 case GL_MAP1_TEXTURE_COORD_3
:
535 if (ctx
->API
!= API_OPENGL_COMPAT
)
536 goto invalid_enum_error
;
537 if (ctx
->Eval
.Map1TextureCoord3
== state
)
539 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
540 ctx
->Eval
.Map1TextureCoord3
= state
;
542 case GL_MAP1_TEXTURE_COORD_4
:
543 if (ctx
->API
!= API_OPENGL_COMPAT
)
544 goto invalid_enum_error
;
545 if (ctx
->Eval
.Map1TextureCoord4
== state
)
547 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
548 ctx
->Eval
.Map1TextureCoord4
= state
;
550 case GL_MAP1_VERTEX_3
:
551 if (ctx
->API
!= API_OPENGL_COMPAT
)
552 goto invalid_enum_error
;
553 if (ctx
->Eval
.Map1Vertex3
== state
)
555 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
556 ctx
->Eval
.Map1Vertex3
= state
;
558 case GL_MAP1_VERTEX_4
:
559 if (ctx
->API
!= API_OPENGL_COMPAT
)
560 goto invalid_enum_error
;
561 if (ctx
->Eval
.Map1Vertex4
== state
)
563 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
564 ctx
->Eval
.Map1Vertex4
= state
;
566 case GL_MAP2_COLOR_4
:
567 if (ctx
->API
!= API_OPENGL_COMPAT
)
568 goto invalid_enum_error
;
569 if (ctx
->Eval
.Map2Color4
== state
)
571 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
572 ctx
->Eval
.Map2Color4
= state
;
575 if (ctx
->API
!= API_OPENGL_COMPAT
)
576 goto invalid_enum_error
;
577 if (ctx
->Eval
.Map2Index
== state
)
579 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
580 ctx
->Eval
.Map2Index
= state
;
583 if (ctx
->API
!= API_OPENGL_COMPAT
)
584 goto invalid_enum_error
;
585 if (ctx
->Eval
.Map2Normal
== state
)
587 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
588 ctx
->Eval
.Map2Normal
= state
;
590 case GL_MAP2_TEXTURE_COORD_1
:
591 if (ctx
->API
!= API_OPENGL_COMPAT
)
592 goto invalid_enum_error
;
593 if (ctx
->Eval
.Map2TextureCoord1
== state
)
595 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
596 ctx
->Eval
.Map2TextureCoord1
= state
;
598 case GL_MAP2_TEXTURE_COORD_2
:
599 if (ctx
->API
!= API_OPENGL_COMPAT
)
600 goto invalid_enum_error
;
601 if (ctx
->Eval
.Map2TextureCoord2
== state
)
603 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
604 ctx
->Eval
.Map2TextureCoord2
= state
;
606 case GL_MAP2_TEXTURE_COORD_3
:
607 if (ctx
->API
!= API_OPENGL_COMPAT
)
608 goto invalid_enum_error
;
609 if (ctx
->Eval
.Map2TextureCoord3
== state
)
611 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
612 ctx
->Eval
.Map2TextureCoord3
= state
;
614 case GL_MAP2_TEXTURE_COORD_4
:
615 if (ctx
->API
!= API_OPENGL_COMPAT
)
616 goto invalid_enum_error
;
617 if (ctx
->Eval
.Map2TextureCoord4
== state
)
619 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
620 ctx
->Eval
.Map2TextureCoord4
= state
;
622 case GL_MAP2_VERTEX_3
:
623 if (ctx
->API
!= API_OPENGL_COMPAT
)
624 goto invalid_enum_error
;
625 if (ctx
->Eval
.Map2Vertex3
== state
)
627 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
628 ctx
->Eval
.Map2Vertex3
= state
;
630 case GL_MAP2_VERTEX_4
:
631 if (ctx
->API
!= API_OPENGL_COMPAT
)
632 goto invalid_enum_error
;
633 if (ctx
->Eval
.Map2Vertex4
== state
)
635 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
636 ctx
->Eval
.Map2Vertex4
= state
;
639 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
640 goto invalid_enum_error
;
641 if (ctx
->Transform
.Normalize
== state
)
643 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
644 ctx
->Transform
.Normalize
= state
;
646 case GL_POINT_SMOOTH
:
647 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
648 goto invalid_enum_error
;
649 if (ctx
->Point
.SmoothFlag
== state
)
651 FLUSH_VERTICES(ctx
, _NEW_POINT
);
652 ctx
->Point
.SmoothFlag
= state
;
654 case GL_POLYGON_SMOOTH
:
655 if (!_mesa_is_desktop_gl(ctx
))
656 goto invalid_enum_error
;
657 if (ctx
->Polygon
.SmoothFlag
== state
)
660 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
661 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
662 ctx
->Polygon
.SmoothFlag
= state
;
664 case GL_POLYGON_STIPPLE
:
665 if (ctx
->API
!= API_OPENGL_COMPAT
)
666 goto invalid_enum_error
;
667 if (ctx
->Polygon
.StippleFlag
== state
)
670 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
671 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
672 ctx
->Polygon
.StippleFlag
= state
;
674 case GL_POLYGON_OFFSET_POINT
:
675 if (!_mesa_is_desktop_gl(ctx
))
676 goto invalid_enum_error
;
677 if (ctx
->Polygon
.OffsetPoint
== state
)
680 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
681 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
682 ctx
->Polygon
.OffsetPoint
= state
;
684 case GL_POLYGON_OFFSET_LINE
:
685 if (!_mesa_is_desktop_gl(ctx
))
686 goto invalid_enum_error
;
687 if (ctx
->Polygon
.OffsetLine
== state
)
690 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
691 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
692 ctx
->Polygon
.OffsetLine
= state
;
694 case GL_POLYGON_OFFSET_FILL
:
695 if (ctx
->Polygon
.OffsetFill
== state
)
698 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
699 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
700 ctx
->Polygon
.OffsetFill
= state
;
702 case GL_RESCALE_NORMAL_EXT
:
703 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
704 goto invalid_enum_error
;
705 if (ctx
->Transform
.RescaleNormals
== state
)
707 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
708 ctx
->Transform
.RescaleNormals
= state
;
710 case GL_SCISSOR_TEST
:
712 /* Must expand glEnable to all scissors */
713 GLbitfield newEnabled
=
714 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
715 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
716 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
718 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
719 ctx
->Scissor
.EnableFlags
= newEnabled
;
723 case GL_STENCIL_TEST
:
724 if (ctx
->Stencil
.Enabled
== state
)
726 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
727 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
728 ctx
->Stencil
.Enabled
= state
;
731 if (ctx
->API
!= API_OPENGL_COMPAT
)
732 goto invalid_enum_error
;
733 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
738 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
739 goto invalid_enum_error
;
740 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
745 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
746 goto invalid_enum_error
;
747 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
751 case GL_TEXTURE_GEN_S
:
752 case GL_TEXTURE_GEN_T
:
753 case GL_TEXTURE_GEN_R
:
754 case GL_TEXTURE_GEN_Q
:
756 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
758 if (ctx
->API
!= API_OPENGL_COMPAT
)
759 goto invalid_enum_error
;
762 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
763 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
765 newenabled
|= coordBit
;
766 if (texUnit
->TexGenEnabled
== newenabled
)
768 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
769 texUnit
->TexGenEnabled
= newenabled
;
774 case GL_TEXTURE_GEN_STR_OES
:
775 /* disable S, T, and R at the same time */
777 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
779 if (ctx
->API
!= API_OPENGLES
)
780 goto invalid_enum_error
;
784 texUnit
->TexGenEnabled
& ~STR_BITS
;
786 newenabled
|= STR_BITS
;
787 if (texUnit
->TexGenEnabled
== newenabled
)
789 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
790 texUnit
->TexGenEnabled
= newenabled
;
795 /* client-side state */
796 case GL_VERTEX_ARRAY
:
797 case GL_NORMAL_ARRAY
:
799 case GL_TEXTURE_COORD_ARRAY
:
800 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
801 goto invalid_enum_error
;
802 client_state( ctx
, cap
, state
);
805 case GL_EDGE_FLAG_ARRAY
:
806 case GL_FOG_COORDINATE_ARRAY_EXT
:
807 case GL_SECONDARY_COLOR_ARRAY_EXT
:
808 if (ctx
->API
!= API_OPENGL_COMPAT
)
809 goto invalid_enum_error
;
810 client_state( ctx
, cap
, state
);
812 case GL_POINT_SIZE_ARRAY_OES
:
813 if (ctx
->API
!= API_OPENGLES
)
814 goto invalid_enum_error
;
815 client_state( ctx
, cap
, state
);
818 /* GL_ARB_texture_cube_map */
819 case GL_TEXTURE_CUBE_MAP
:
820 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
821 goto invalid_enum_error
;
822 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
823 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
828 /* GL_EXT_secondary_color */
829 case GL_COLOR_SUM_EXT
:
830 if (ctx
->API
!= API_OPENGL_COMPAT
)
831 goto invalid_enum_error
;
832 if (ctx
->Fog
.ColorSumEnabled
== state
)
834 FLUSH_VERTICES(ctx
, _NEW_FOG
);
835 ctx
->Fog
.ColorSumEnabled
= state
;
838 /* GL_ARB_multisample */
839 case GL_MULTISAMPLE_ARB
:
840 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
841 goto invalid_enum_error
;
842 _mesa_set_multisample(ctx
, state
);
844 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
845 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
847 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
849 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
850 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
852 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
853 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
854 goto invalid_enum_error
;
855 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
857 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
859 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
860 ctx
->Multisample
.SampleAlphaToOne
= state
;
862 case GL_SAMPLE_COVERAGE_ARB
:
863 if (ctx
->Multisample
.SampleCoverage
== state
)
865 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
867 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
868 ctx
->Multisample
.SampleCoverage
= state
;
870 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
871 if (!_mesa_is_desktop_gl(ctx
))
872 goto invalid_enum_error
;
873 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
875 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
877 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
878 ctx
->Multisample
.SampleCoverageInvert
= state
;
881 /* GL_ARB_sample_shading */
882 case GL_SAMPLE_SHADING
:
883 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
884 goto invalid_enum_error
;
885 CHECK_EXTENSION(ARB_sample_shading
, cap
);
886 if (ctx
->Multisample
.SampleShading
== state
)
888 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
890 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
891 ctx
->Multisample
.SampleShading
= state
;
894 /* GL_IBM_rasterpos_clip */
895 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
896 if (ctx
->API
!= API_OPENGL_COMPAT
)
897 goto invalid_enum_error
;
898 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
900 FLUSH_VERTICES(ctx
, 0);
901 ctx
->Transform
.RasterPositionUnclipped
= state
;
904 /* GL_NV_point_sprite */
905 case GL_POINT_SPRITE_NV
:
906 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
907 goto invalid_enum_error
;
908 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
909 if (ctx
->Point
.PointSprite
== state
)
911 FLUSH_VERTICES(ctx
, _NEW_POINT
);
912 ctx
->Point
.PointSprite
= state
;
915 case GL_VERTEX_PROGRAM_ARB
:
916 if (ctx
->API
!= API_OPENGL_COMPAT
)
917 goto invalid_enum_error
;
918 CHECK_EXTENSION(ARB_vertex_program
, cap
);
919 if (ctx
->VertexProgram
.Enabled
== state
)
921 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
922 ctx
->VertexProgram
.Enabled
= state
;
923 _mesa_update_vertex_processing_mode(ctx
);
925 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
926 /* This was added with ARB_vertex_program, but it is also used with
927 * GLSL vertex shaders on desktop.
929 if (!_mesa_is_desktop_gl(ctx
))
930 goto invalid_enum_error
;
931 CHECK_EXTENSION(ARB_vertex_program
, cap
);
932 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
934 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
935 ctx
->VertexProgram
.PointSizeEnabled
= state
;
937 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
938 if (ctx
->API
!= API_OPENGL_COMPAT
)
939 goto invalid_enum_error
;
940 CHECK_EXTENSION(ARB_vertex_program
, cap
);
941 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
943 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
944 ctx
->VertexProgram
.TwoSideEnabled
= state
;
947 /* GL_NV_texture_rectangle */
948 case GL_TEXTURE_RECTANGLE_NV
:
949 if (ctx
->API
!= API_OPENGL_COMPAT
)
950 goto invalid_enum_error
;
951 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
952 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
957 /* GL_EXT_stencil_two_side */
958 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
959 if (ctx
->API
!= API_OPENGL_COMPAT
)
960 goto invalid_enum_error
;
961 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
962 if (ctx
->Stencil
.TestTwoSide
== state
)
964 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
965 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
966 ctx
->Stencil
.TestTwoSide
= state
;
968 ctx
->Stencil
._BackFace
= 2;
970 ctx
->Stencil
._BackFace
= 1;
974 case GL_FRAGMENT_PROGRAM_ARB
:
975 if (ctx
->API
!= API_OPENGL_COMPAT
)
976 goto invalid_enum_error
;
977 CHECK_EXTENSION(ARB_fragment_program
, cap
);
978 if (ctx
->FragmentProgram
.Enabled
== state
)
980 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
981 ctx
->FragmentProgram
.Enabled
= state
;
984 /* GL_EXT_depth_bounds_test */
985 case GL_DEPTH_BOUNDS_TEST_EXT
:
986 if (!_mesa_is_desktop_gl(ctx
))
987 goto invalid_enum_error
;
988 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
989 if (ctx
->Depth
.BoundsTest
== state
)
991 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
992 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
993 ctx
->Depth
.BoundsTest
= state
;
997 if (!_mesa_is_desktop_gl(ctx
))
998 goto invalid_enum_error
;
999 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
1000 if (ctx
->Transform
.DepthClamp
== state
)
1002 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1004 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1005 ctx
->Transform
.DepthClamp
= state
;
1008 case GL_FRAGMENT_SHADER_ATI
:
1009 if (ctx
->API
!= API_OPENGL_COMPAT
)
1010 goto invalid_enum_error
;
1011 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
1012 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1014 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1015 ctx
->ATIFragmentShader
.Enabled
= state
;
1018 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1019 if (!_mesa_is_desktop_gl(ctx
))
1020 goto invalid_enum_error
;
1021 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
1022 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1023 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1024 ctx
->Texture
.CubeMapSeamless
= state
;
1028 case GL_RASTERIZER_DISCARD
:
1029 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1030 goto invalid_enum_error
;
1031 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
1032 if (ctx
->RasterDiscard
!= state
) {
1033 FLUSH_VERTICES(ctx
, 0);
1034 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1035 ctx
->RasterDiscard
= state
;
1039 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1040 CHECK_EXTENSION(MESA_tile_raster_order
, cap
);
1041 if (ctx
->TileRasterOrderFixed
!= state
) {
1042 FLUSH_VERTICES(ctx
, 0);
1043 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1044 ctx
->TileRasterOrderFixed
= state
;
1048 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1049 CHECK_EXTENSION(MESA_tile_raster_order
, cap
);
1050 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1051 FLUSH_VERTICES(ctx
, 0);
1052 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1053 ctx
->TileRasterOrderIncreasingX
= state
;
1057 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1058 CHECK_EXTENSION(MESA_tile_raster_order
, cap
);
1059 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1060 FLUSH_VERTICES(ctx
, 0);
1061 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1062 ctx
->TileRasterOrderIncreasingY
= state
;
1066 /* GL 3.1 primitive restart. Note: this enum is different from
1067 * GL_PRIMITIVE_RESTART_NV (which is client state).
1069 case GL_PRIMITIVE_RESTART
:
1070 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1071 goto invalid_enum_error
;
1073 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1074 FLUSH_VERTICES(ctx
, 0);
1075 ctx
->Array
.PrimitiveRestart
= state
;
1076 update_derived_primitive_restart_state(ctx
);
1080 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1081 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
)
1082 goto invalid_enum_error
;
1083 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1084 FLUSH_VERTICES(ctx
, 0);
1085 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1086 update_derived_primitive_restart_state(ctx
);
1090 /* GL3.0 - GL_framebuffer_sRGB */
1091 case GL_FRAMEBUFFER_SRGB_EXT
:
1092 if (!_mesa_is_desktop_gl(ctx
))
1093 goto invalid_enum_error
;
1094 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
1095 _mesa_set_framebuffer_srgb(ctx
, state
);
1098 /* GL_OES_EGL_image_external */
1099 case GL_TEXTURE_EXTERNAL_OES
:
1100 if (!_mesa_is_gles(ctx
))
1101 goto invalid_enum_error
;
1102 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
1103 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1108 /* ARB_texture_multisample */
1109 case GL_SAMPLE_MASK
:
1110 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1111 goto invalid_enum_error
;
1112 CHECK_EXTENSION(ARB_texture_multisample
, cap
);
1113 if (ctx
->Multisample
.SampleMask
== state
)
1115 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1117 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1118 ctx
->Multisample
.SampleMask
= state
;
1121 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1122 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent
, cap
);
1123 if (ctx
->Color
.BlendCoherent
== state
)
1125 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1126 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1127 ctx
->Color
.BlendCoherent
= state
;
1131 goto invalid_enum_error
;
1134 if (ctx
->Driver
.Enable
) {
1135 ctx
->Driver
.Enable( ctx
, cap
, state
);
1141 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1142 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1147 * Enable GL capability. Called by glEnable()
1148 * \param cap state to enable.
1151 _mesa_Enable( GLenum cap
)
1153 GET_CURRENT_CONTEXT(ctx
);
1155 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1160 * Disable GL capability. Called by glDisable()
1161 * \param cap state to disable.
1164 _mesa_Disable( GLenum cap
)
1166 GET_CURRENT_CONTEXT(ctx
);
1168 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1174 * Enable/disable an indexed state var.
1177 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1178 GLuint index
, GLboolean state
)
1180 assert(state
== 0 || state
== 1);
1183 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1184 goto invalid_enum_error
;
1186 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1187 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1188 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1191 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1192 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1195 enabled
|= (1 << index
);
1197 enabled
&= ~(1 << index
);
1199 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1200 ctx
->Color
._AdvancedBlendMode
);
1201 ctx
->Color
.BlendEnabled
= enabled
;
1204 case GL_SCISSOR_TEST
:
1205 if (index
>= ctx
->Const
.MaxViewports
) {
1206 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1207 state
? "glEnablei" : "glDisablei", index
);
1210 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1212 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1213 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1215 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1217 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1221 goto invalid_enum_error
;
1226 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1227 state
? "glEnablei" : "glDisablei",
1228 _mesa_enum_to_string(cap
));
1233 _mesa_Disablei( GLenum cap
, GLuint index
)
1235 GET_CURRENT_CONTEXT(ctx
);
1236 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1241 _mesa_Enablei( GLenum cap
, GLuint index
)
1243 GET_CURRENT_CONTEXT(ctx
);
1244 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1248 GLboolean GLAPIENTRY
1249 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1251 GET_CURRENT_CONTEXT(ctx
);
1252 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1255 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1256 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1260 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1261 case GL_SCISSOR_TEST
:
1262 if (index
>= ctx
->Const
.MaxViewports
) {
1263 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1267 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1269 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1270 _mesa_enum_to_string(cap
));
1278 #undef CHECK_EXTENSION
1279 #define CHECK_EXTENSION(EXTNAME) \
1280 if (!ctx->Extensions.EXTNAME) { \
1281 goto invalid_enum_error; \
1284 #undef CHECK_EXTENSION2
1285 #define CHECK_EXTENSION2(EXT1, EXT2) \
1286 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1287 goto invalid_enum_error; \
1292 * Helper function to determine whether a texture target is enabled.
1295 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1297 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1298 _mesa_get_current_fixedfunc_tex_unit(ctx
);
1303 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1308 * Return simple enable/disable state.
1310 * \param cap state variable to query.
1312 * Returns the state of the specified capability from the current GL context.
1313 * For the capabilities associated with extensions verifies that those
1314 * extensions are effectively present before reporting.
1316 GLboolean GLAPIENTRY
1317 _mesa_IsEnabled( GLenum cap
)
1319 GET_CURRENT_CONTEXT(ctx
);
1320 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1324 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1325 goto invalid_enum_error
;
1326 return ctx
->Color
.AlphaEnabled
;
1327 case GL_AUTO_NORMAL
:
1328 if (ctx
->API
!= API_OPENGL_COMPAT
)
1329 goto invalid_enum_error
;
1330 return ctx
->Eval
.AutoNormal
;
1332 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1333 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1334 case GL_CLIP_DISTANCE1
:
1335 case GL_CLIP_DISTANCE2
:
1336 case GL_CLIP_DISTANCE3
:
1337 case GL_CLIP_DISTANCE4
:
1338 case GL_CLIP_DISTANCE5
:
1339 case GL_CLIP_DISTANCE6
:
1340 case GL_CLIP_DISTANCE7
: {
1341 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1343 if (p
>= ctx
->Const
.MaxClipPlanes
)
1344 goto invalid_enum_error
;
1346 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1348 case GL_COLOR_MATERIAL
:
1349 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1350 goto invalid_enum_error
;
1351 return ctx
->Light
.ColorMaterialEnabled
;
1353 return ctx
->Polygon
.CullFlag
;
1354 case GL_DEBUG_OUTPUT
:
1355 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1356 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1358 return ctx
->Depth
.Test
;
1360 return ctx
->Color
.DitherFlag
;
1362 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1363 goto invalid_enum_error
;
1364 return ctx
->Fog
.Enabled
;
1366 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1367 goto invalid_enum_error
;
1368 return ctx
->Light
.Enabled
;
1377 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1378 goto invalid_enum_error
;
1379 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1380 case GL_LINE_SMOOTH
:
1381 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1382 goto invalid_enum_error
;
1383 return ctx
->Line
.SmoothFlag
;
1384 case GL_LINE_STIPPLE
:
1385 if (ctx
->API
!= API_OPENGL_COMPAT
)
1386 goto invalid_enum_error
;
1387 return ctx
->Line
.StippleFlag
;
1388 case GL_INDEX_LOGIC_OP
:
1389 if (ctx
->API
!= API_OPENGL_COMPAT
)
1390 goto invalid_enum_error
;
1391 return ctx
->Color
.IndexLogicOpEnabled
;
1392 case GL_COLOR_LOGIC_OP
:
1393 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1394 goto invalid_enum_error
;
1395 return ctx
->Color
.ColorLogicOpEnabled
;
1396 case GL_MAP1_COLOR_4
:
1397 if (ctx
->API
!= API_OPENGL_COMPAT
)
1398 goto invalid_enum_error
;
1399 return ctx
->Eval
.Map1Color4
;
1401 if (ctx
->API
!= API_OPENGL_COMPAT
)
1402 goto invalid_enum_error
;
1403 return ctx
->Eval
.Map1Index
;
1404 case GL_MAP1_NORMAL
:
1405 if (ctx
->API
!= API_OPENGL_COMPAT
)
1406 goto invalid_enum_error
;
1407 return ctx
->Eval
.Map1Normal
;
1408 case GL_MAP1_TEXTURE_COORD_1
:
1409 if (ctx
->API
!= API_OPENGL_COMPAT
)
1410 goto invalid_enum_error
;
1411 return ctx
->Eval
.Map1TextureCoord1
;
1412 case GL_MAP1_TEXTURE_COORD_2
:
1413 if (ctx
->API
!= API_OPENGL_COMPAT
)
1414 goto invalid_enum_error
;
1415 return ctx
->Eval
.Map1TextureCoord2
;
1416 case GL_MAP1_TEXTURE_COORD_3
:
1417 if (ctx
->API
!= API_OPENGL_COMPAT
)
1418 goto invalid_enum_error
;
1419 return ctx
->Eval
.Map1TextureCoord3
;
1420 case GL_MAP1_TEXTURE_COORD_4
:
1421 if (ctx
->API
!= API_OPENGL_COMPAT
)
1422 goto invalid_enum_error
;
1423 return ctx
->Eval
.Map1TextureCoord4
;
1424 case GL_MAP1_VERTEX_3
:
1425 if (ctx
->API
!= API_OPENGL_COMPAT
)
1426 goto invalid_enum_error
;
1427 return ctx
->Eval
.Map1Vertex3
;
1428 case GL_MAP1_VERTEX_4
:
1429 if (ctx
->API
!= API_OPENGL_COMPAT
)
1430 goto invalid_enum_error
;
1431 return ctx
->Eval
.Map1Vertex4
;
1432 case GL_MAP2_COLOR_4
:
1433 if (ctx
->API
!= API_OPENGL_COMPAT
)
1434 goto invalid_enum_error
;
1435 return ctx
->Eval
.Map2Color4
;
1437 if (ctx
->API
!= API_OPENGL_COMPAT
)
1438 goto invalid_enum_error
;
1439 return ctx
->Eval
.Map2Index
;
1440 case GL_MAP2_NORMAL
:
1441 if (ctx
->API
!= API_OPENGL_COMPAT
)
1442 goto invalid_enum_error
;
1443 return ctx
->Eval
.Map2Normal
;
1444 case GL_MAP2_TEXTURE_COORD_1
:
1445 if (ctx
->API
!= API_OPENGL_COMPAT
)
1446 goto invalid_enum_error
;
1447 return ctx
->Eval
.Map2TextureCoord1
;
1448 case GL_MAP2_TEXTURE_COORD_2
:
1449 if (ctx
->API
!= API_OPENGL_COMPAT
)
1450 goto invalid_enum_error
;
1451 return ctx
->Eval
.Map2TextureCoord2
;
1452 case GL_MAP2_TEXTURE_COORD_3
:
1453 if (ctx
->API
!= API_OPENGL_COMPAT
)
1454 goto invalid_enum_error
;
1455 return ctx
->Eval
.Map2TextureCoord3
;
1456 case GL_MAP2_TEXTURE_COORD_4
:
1457 if (ctx
->API
!= API_OPENGL_COMPAT
)
1458 goto invalid_enum_error
;
1459 return ctx
->Eval
.Map2TextureCoord4
;
1460 case GL_MAP2_VERTEX_3
:
1461 if (ctx
->API
!= API_OPENGL_COMPAT
)
1462 goto invalid_enum_error
;
1463 return ctx
->Eval
.Map2Vertex3
;
1464 case GL_MAP2_VERTEX_4
:
1465 if (ctx
->API
!= API_OPENGL_COMPAT
)
1466 goto invalid_enum_error
;
1467 return ctx
->Eval
.Map2Vertex4
;
1469 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1470 goto invalid_enum_error
;
1471 return ctx
->Transform
.Normalize
;
1472 case GL_POINT_SMOOTH
:
1473 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1474 goto invalid_enum_error
;
1475 return ctx
->Point
.SmoothFlag
;
1476 case GL_POLYGON_SMOOTH
:
1477 if (!_mesa_is_desktop_gl(ctx
))
1478 goto invalid_enum_error
;
1479 return ctx
->Polygon
.SmoothFlag
;
1480 case GL_POLYGON_STIPPLE
:
1481 if (ctx
->API
!= API_OPENGL_COMPAT
)
1482 goto invalid_enum_error
;
1483 return ctx
->Polygon
.StippleFlag
;
1484 case GL_POLYGON_OFFSET_POINT
:
1485 if (!_mesa_is_desktop_gl(ctx
))
1486 goto invalid_enum_error
;
1487 return ctx
->Polygon
.OffsetPoint
;
1488 case GL_POLYGON_OFFSET_LINE
:
1489 if (!_mesa_is_desktop_gl(ctx
))
1490 goto invalid_enum_error
;
1491 return ctx
->Polygon
.OffsetLine
;
1492 case GL_POLYGON_OFFSET_FILL
:
1493 return ctx
->Polygon
.OffsetFill
;
1494 case GL_RESCALE_NORMAL_EXT
:
1495 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1496 goto invalid_enum_error
;
1497 return ctx
->Transform
.RescaleNormals
;
1498 case GL_SCISSOR_TEST
:
1499 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1500 case GL_STENCIL_TEST
:
1501 return ctx
->Stencil
.Enabled
;
1503 if (ctx
->API
!= API_OPENGL_COMPAT
)
1504 goto invalid_enum_error
;
1505 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1507 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1508 goto invalid_enum_error
;
1509 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1511 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1512 goto invalid_enum_error
;
1513 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1514 case GL_TEXTURE_GEN_S
:
1515 case GL_TEXTURE_GEN_T
:
1516 case GL_TEXTURE_GEN_R
:
1517 case GL_TEXTURE_GEN_Q
:
1519 const struct gl_fixedfunc_texture_unit
*texUnit
=
1520 get_texcoord_unit(ctx
);
1522 if (ctx
->API
!= API_OPENGL_COMPAT
)
1523 goto invalid_enum_error
;
1526 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1527 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1531 case GL_TEXTURE_GEN_STR_OES
:
1533 const struct gl_fixedfunc_texture_unit
*texUnit
=
1534 get_texcoord_unit(ctx
);
1536 if (ctx
->API
!= API_OPENGLES
)
1537 goto invalid_enum_error
;
1540 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1541 ? GL_TRUE
: GL_FALSE
;
1545 /* client-side state */
1546 case GL_VERTEX_ARRAY
:
1547 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1548 goto invalid_enum_error
;
1549 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
1550 case GL_NORMAL_ARRAY
:
1551 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1552 goto invalid_enum_error
;
1553 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
1554 case GL_COLOR_ARRAY
:
1555 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1556 goto invalid_enum_error
;
1557 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
1558 case GL_INDEX_ARRAY
:
1559 if (ctx
->API
!= API_OPENGL_COMPAT
)
1560 goto invalid_enum_error
;
1561 return ctx
->Array
.VAO
->
1562 VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
1563 case GL_TEXTURE_COORD_ARRAY
:
1564 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1565 goto invalid_enum_error
;
1566 return ctx
->Array
.VAO
->
1567 VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
1568 case GL_EDGE_FLAG_ARRAY
:
1569 if (ctx
->API
!= API_OPENGL_COMPAT
)
1570 goto invalid_enum_error
;
1571 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
1572 case GL_FOG_COORDINATE_ARRAY_EXT
:
1573 if (ctx
->API
!= API_OPENGL_COMPAT
)
1574 goto invalid_enum_error
;
1575 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
1576 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1577 if (ctx
->API
!= API_OPENGL_COMPAT
)
1578 goto invalid_enum_error
;
1579 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
1580 case GL_POINT_SIZE_ARRAY_OES
:
1581 if (ctx
->API
!= API_OPENGLES
)
1582 goto invalid_enum_error
;
1583 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
1585 /* GL_ARB_texture_cube_map */
1586 case GL_TEXTURE_CUBE_MAP
:
1587 CHECK_EXTENSION(ARB_texture_cube_map
);
1588 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1590 /* GL_EXT_secondary_color */
1591 case GL_COLOR_SUM_EXT
:
1592 if (ctx
->API
!= API_OPENGL_COMPAT
)
1593 goto invalid_enum_error
;
1594 return ctx
->Fog
.ColorSumEnabled
;
1596 /* GL_ARB_multisample */
1597 case GL_MULTISAMPLE_ARB
:
1598 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1599 goto invalid_enum_error
;
1600 return ctx
->Multisample
.Enabled
;
1601 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1602 return ctx
->Multisample
.SampleAlphaToCoverage
;
1603 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1604 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1605 goto invalid_enum_error
;
1606 return ctx
->Multisample
.SampleAlphaToOne
;
1607 case GL_SAMPLE_COVERAGE_ARB
:
1608 return ctx
->Multisample
.SampleCoverage
;
1609 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1610 if (!_mesa_is_desktop_gl(ctx
))
1611 goto invalid_enum_error
;
1612 return ctx
->Multisample
.SampleCoverageInvert
;
1614 /* GL_IBM_rasterpos_clip */
1615 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1616 if (ctx
->API
!= API_OPENGL_COMPAT
)
1617 goto invalid_enum_error
;
1618 return ctx
->Transform
.RasterPositionUnclipped
;
1620 /* GL_NV_point_sprite */
1621 case GL_POINT_SPRITE_NV
:
1622 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1623 goto invalid_enum_error
;
1624 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1625 return ctx
->Point
.PointSprite
;
1627 case GL_VERTEX_PROGRAM_ARB
:
1628 if (ctx
->API
!= API_OPENGL_COMPAT
)
1629 goto invalid_enum_error
;
1630 CHECK_EXTENSION(ARB_vertex_program
);
1631 return ctx
->VertexProgram
.Enabled
;
1632 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1633 /* This was added with ARB_vertex_program, but it is also used with
1634 * GLSL vertex shaders on desktop.
1636 if (!_mesa_is_desktop_gl(ctx
))
1637 goto invalid_enum_error
;
1638 CHECK_EXTENSION(ARB_vertex_program
);
1639 return ctx
->VertexProgram
.PointSizeEnabled
;
1640 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1641 if (ctx
->API
!= API_OPENGL_COMPAT
)
1642 goto invalid_enum_error
;
1643 CHECK_EXTENSION(ARB_vertex_program
);
1644 return ctx
->VertexProgram
.TwoSideEnabled
;
1646 /* GL_NV_texture_rectangle */
1647 case GL_TEXTURE_RECTANGLE_NV
:
1648 if (ctx
->API
!= API_OPENGL_COMPAT
)
1649 goto invalid_enum_error
;
1650 CHECK_EXTENSION(NV_texture_rectangle
);
1651 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1653 /* GL_EXT_stencil_two_side */
1654 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1655 if (ctx
->API
!= API_OPENGL_COMPAT
)
1656 goto invalid_enum_error
;
1657 CHECK_EXTENSION(EXT_stencil_two_side
);
1658 return ctx
->Stencil
.TestTwoSide
;
1660 case GL_FRAGMENT_PROGRAM_ARB
:
1661 if (ctx
->API
!= API_OPENGL_COMPAT
)
1662 goto invalid_enum_error
;
1663 return ctx
->FragmentProgram
.Enabled
;
1665 /* GL_EXT_depth_bounds_test */
1666 case GL_DEPTH_BOUNDS_TEST_EXT
:
1667 if (!_mesa_is_desktop_gl(ctx
))
1668 goto invalid_enum_error
;
1669 CHECK_EXTENSION(EXT_depth_bounds_test
);
1670 return ctx
->Depth
.BoundsTest
;
1672 /* GL_ARB_depth_clamp */
1673 case GL_DEPTH_CLAMP
:
1674 if (!_mesa_is_desktop_gl(ctx
))
1675 goto invalid_enum_error
;
1676 CHECK_EXTENSION(ARB_depth_clamp
);
1677 return ctx
->Transform
.DepthClamp
;
1679 case GL_FRAGMENT_SHADER_ATI
:
1680 if (ctx
->API
!= API_OPENGL_COMPAT
)
1681 goto invalid_enum_error
;
1682 CHECK_EXTENSION(ATI_fragment_shader
);
1683 return ctx
->ATIFragmentShader
.Enabled
;
1685 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1686 if (!_mesa_is_desktop_gl(ctx
))
1687 goto invalid_enum_error
;
1688 CHECK_EXTENSION(ARB_seamless_cube_map
);
1689 return ctx
->Texture
.CubeMapSeamless
;
1691 case GL_RASTERIZER_DISCARD
:
1692 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1693 goto invalid_enum_error
;
1694 CHECK_EXTENSION(EXT_transform_feedback
);
1695 return ctx
->RasterDiscard
;
1697 /* GL_NV_primitive_restart */
1698 case GL_PRIMITIVE_RESTART_NV
:
1699 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1700 goto invalid_enum_error
;
1702 return ctx
->Array
.PrimitiveRestart
;
1704 /* GL 3.1 primitive restart */
1705 case GL_PRIMITIVE_RESTART
:
1706 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1707 goto invalid_enum_error
;
1709 return ctx
->Array
.PrimitiveRestart
;
1711 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1712 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1713 goto invalid_enum_error
;
1715 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1717 /* GL3.0 - GL_framebuffer_sRGB */
1718 case GL_FRAMEBUFFER_SRGB_EXT
:
1719 if (!_mesa_is_desktop_gl(ctx
))
1720 goto invalid_enum_error
;
1721 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1722 return ctx
->Color
.sRGBEnabled
;
1724 /* GL_OES_EGL_image_external */
1725 case GL_TEXTURE_EXTERNAL_OES
:
1726 if (!_mesa_is_gles(ctx
))
1727 goto invalid_enum_error
;
1728 CHECK_EXTENSION(OES_EGL_image_external
);
1729 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1731 /* ARB_texture_multisample */
1732 case GL_SAMPLE_MASK
:
1733 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1734 goto invalid_enum_error
;
1735 CHECK_EXTENSION(ARB_texture_multisample
);
1736 return ctx
->Multisample
.SampleMask
;
1738 /* ARB_sample_shading */
1739 case GL_SAMPLE_SHADING
:
1740 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1741 goto invalid_enum_error
;
1742 CHECK_EXTENSION(ARB_sample_shading
);
1743 return ctx
->Multisample
.SampleShading
;
1745 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1746 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent
);
1747 return ctx
->Color
.BlendCoherent
;
1749 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1750 CHECK_EXTENSION(INTEL_conservative_rasterization
);
1751 return ctx
->IntelConservativeRasterization
;
1753 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1754 CHECK_EXTENSION(MESA_tile_raster_order
);
1755 return ctx
->TileRasterOrderFixed
;
1757 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1758 CHECK_EXTENSION(MESA_tile_raster_order
);
1759 return ctx
->TileRasterOrderIncreasingX
;
1761 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1762 CHECK_EXTENSION(MESA_tile_raster_order
);
1763 return ctx
->TileRasterOrderIncreasingY
;
1766 goto invalid_enum_error
;
1772 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1773 _mesa_enum_to_string(cap
));