mesa: don't flag _NEW_COLOR for st/mesa if possible
[mesa.git] / src / mesa / main / enable.c
1 /**
2 * \file enable.c
3 * Enable/disable/query GL capabilities.
4 */
5
6 /*
7 * Mesa 3-D graphics library
8 *
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
10 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
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.
28 */
29
30
31 #include "glheader.h"
32 #include "blend.h"
33 #include "clip.h"
34 #include "context.h"
35 #include "debug_output.h"
36 #include "enable.h"
37 #include "errors.h"
38 #include "light.h"
39 #include "mtypes.h"
40 #include "enums.h"
41 #include "texstate.h"
42
43
44
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 goto invalid_enum_error; \
48 }
49
50
51 static void
52 update_derived_primitive_restart_state(struct gl_context *ctx)
53 {
54 /* Update derived primitive restart state.
55 */
56 ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart
57 || ctx->Array.PrimitiveRestartFixedIndex;
58 }
59
60 /**
61 * Helper to enable/disable client-side state.
62 */
63 static void
64 client_state(struct gl_context *ctx, GLenum cap, GLboolean state)
65 {
66 struct gl_vertex_array_object *vao = ctx->Array.VAO;
67 GLbitfield64 flag;
68 GLboolean *var;
69
70 switch (cap) {
71 case GL_VERTEX_ARRAY:
72 var = &vao->VertexAttrib[VERT_ATTRIB_POS].Enabled;
73 flag = VERT_BIT_POS;
74 break;
75 case GL_NORMAL_ARRAY:
76 var = &vao->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
77 flag = VERT_BIT_NORMAL;
78 break;
79 case GL_COLOR_ARRAY:
80 var = &vao->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled;
81 flag = VERT_BIT_COLOR0;
82 break;
83 case GL_INDEX_ARRAY:
84 var = &vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled;
85 flag = VERT_BIT_COLOR_INDEX;
86 break;
87 case GL_TEXTURE_COORD_ARRAY:
88 var = &vao->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled;
89 flag = VERT_BIT_TEX(ctx->Array.ActiveTexture);
90 break;
91 case GL_EDGE_FLAG_ARRAY:
92 var = &vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled;
93 flag = VERT_BIT_EDGEFLAG;
94 break;
95 case GL_FOG_COORDINATE_ARRAY_EXT:
96 var = &vao->VertexAttrib[VERT_ATTRIB_FOG].Enabled;
97 flag = VERT_BIT_FOG;
98 break;
99 case GL_SECONDARY_COLOR_ARRAY_EXT:
100 var = &vao->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled;
101 flag = VERT_BIT_COLOR1;
102 break;
103
104 case GL_POINT_SIZE_ARRAY_OES:
105 var = &vao->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled;
106 flag = VERT_BIT_POINT_SIZE;
107 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
108 ctx->VertexProgram.PointSizeEnabled = state;
109 break;
110
111 /* GL_NV_primitive_restart */
112 case GL_PRIMITIVE_RESTART_NV:
113 if (!ctx->Extensions.NV_primitive_restart) {
114 goto invalid_enum_error;
115 }
116 var = &ctx->Array.PrimitiveRestart;
117 flag = 0;
118 break;
119
120 default:
121 goto invalid_enum_error;
122 }
123
124 if (*var == state)
125 return;
126
127 FLUSH_VERTICES(ctx, _NEW_ARRAY);
128
129 *var = state;
130
131 update_derived_primitive_restart_state(ctx);
132
133 if (state)
134 vao->_Enabled |= flag;
135 else
136 vao->_Enabled &= ~flag;
137
138 vao->NewArrays |= flag;
139
140 if (ctx->Driver.Enable) {
141 ctx->Driver.Enable( ctx, cap, state );
142 }
143
144 return;
145
146 invalid_enum_error:
147 _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(%s)",
148 state ? "Enable" : "Disable", _mesa_enum_to_string(cap));
149 }
150
151
152 /**
153 * Enable GL capability.
154 * \param cap state to enable/disable.
155 *
156 * Get's the current context, assures that we're outside glBegin()/glEnd() and
157 * calls client_state().
158 */
159 void GLAPIENTRY
160 _mesa_EnableClientState( GLenum cap )
161 {
162 GET_CURRENT_CONTEXT(ctx);
163 client_state( ctx, cap, GL_TRUE );
164 }
165
166
167 /**
168 * Disable GL capability.
169 * \param cap state to enable/disable.
170 *
171 * Get's the current context, assures that we're outside glBegin()/glEnd() and
172 * calls client_state().
173 */
174 void GLAPIENTRY
175 _mesa_DisableClientState( GLenum cap )
176 {
177 GET_CURRENT_CONTEXT(ctx);
178 client_state( ctx, cap, GL_FALSE );
179 }
180
181
182 #undef CHECK_EXTENSION
183 #define CHECK_EXTENSION(EXTNAME, CAP) \
184 if (!ctx->Extensions.EXTNAME) { \
185 goto invalid_enum_error; \
186 }
187
188 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
189 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
190 goto invalid_enum_error; \
191 }
192
193 /**
194 * Return pointer to current texture unit for setting/getting coordinate
195 * state.
196 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
197 * texture unit is higher than the number of supported coordinate units.
198 */
199 static struct gl_texture_unit *
200 get_texcoord_unit(struct gl_context *ctx)
201 {
202 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
203 _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)");
204 return NULL;
205 }
206 else {
207 return &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
208 }
209 }
210
211
212 /**
213 * Helper function to enable or disable a texture target.
214 * \param bit one of the TEXTURE_x_BIT values
215 * \return GL_TRUE if state is changing or GL_FALSE if no change
216 */
217 static GLboolean
218 enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit)
219 {
220 struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
221 const GLbitfield newenabled = state
222 ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit);
223
224 if (texUnit->Enabled == newenabled)
225 return GL_FALSE;
226
227 FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE);
228 texUnit->Enabled = newenabled;
229 return GL_TRUE;
230 }
231
232
233 /**
234 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
235 * whether the API supports it (GLES doesn't).
236 */
237 void
238 _mesa_set_multisample(struct gl_context *ctx, GLboolean state)
239 {
240 if (ctx->Multisample.Enabled == state)
241 return;
242 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
243 ctx->Multisample.Enabled = state;
244
245 if (ctx->Driver.Enable) {
246 ctx->Driver.Enable(ctx, GL_MULTISAMPLE, state);
247 }
248 }
249
250 /**
251 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
252 * check for whether the API supports it (GLES doesn't).
253 */
254 void
255 _mesa_set_framebuffer_srgb(struct gl_context *ctx, GLboolean state)
256 {
257 if (ctx->Color.sRGBEnabled == state)
258 return;
259
260 /* TODO: Switch i965 to the new flag and remove the conditional */
261 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewFramebufferSRGB ? 0 : _NEW_BUFFERS);
262 ctx->NewDriverState |= ctx->DriverFlags.NewFramebufferSRGB;
263 ctx->Color.sRGBEnabled = state;
264
265 if (ctx->Driver.Enable) {
266 ctx->Driver.Enable(ctx, GL_FRAMEBUFFER_SRGB, state);
267 }
268 }
269
270 /**
271 * Helper function to enable or disable state.
272 *
273 * \param ctx GL context.
274 * \param cap the state to enable/disable
275 * \param state whether to enable or disable the specified capability.
276 *
277 * Updates the current context and flushes the vertices as needed. For
278 * capabilities associated with extensions it verifies that those extensions
279 * are effectivly present before updating. Notifies the driver via
280 * dd_function_table::Enable.
281 */
282 void
283 _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
284 {
285 if (MESA_VERBOSE & VERBOSE_API)
286 _mesa_debug(ctx, "%s %s (newstate is %x)\n",
287 state ? "glEnable" : "glDisable",
288 _mesa_enum_to_string(cap),
289 ctx->NewState);
290
291 switch (cap) {
292 case GL_ALPHA_TEST:
293 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
294 goto invalid_enum_error;
295 if (ctx->Color.AlphaEnabled == state)
296 return;
297 /* AlphaEnabled is used by the fixed-func fragment program */
298 FLUSH_VERTICES(ctx, _NEW_COLOR);
299 ctx->NewDriverState |= ctx->DriverFlags.NewAlphaTest;
300 ctx->Color.AlphaEnabled = state;
301 break;
302 case GL_AUTO_NORMAL:
303 if (ctx->API != API_OPENGL_COMPAT)
304 goto invalid_enum_error;
305 if (ctx->Eval.AutoNormal == state)
306 return;
307 FLUSH_VERTICES(ctx, _NEW_EVAL);
308 ctx->Eval.AutoNormal = state;
309 break;
310 case GL_BLEND:
311 {
312 GLbitfield newEnabled =
313 state * ((1 << ctx->Const.MaxDrawBuffers) - 1);
314 if (newEnabled != ctx->Color.BlendEnabled) {
315 _mesa_flush_vertices_for_blend_state(ctx);
316 ctx->Color.BlendEnabled = newEnabled;
317 }
318 }
319 break;
320 case GL_CLIP_DISTANCE0: /* aka GL_CLIP_PLANE0 */
321 case GL_CLIP_DISTANCE1:
322 case GL_CLIP_DISTANCE2:
323 case GL_CLIP_DISTANCE3:
324 case GL_CLIP_DISTANCE4:
325 case GL_CLIP_DISTANCE5:
326 case GL_CLIP_DISTANCE6:
327 case GL_CLIP_DISTANCE7:
328 {
329 const GLuint p = cap - GL_CLIP_DISTANCE0;
330
331 if (p >= ctx->Const.MaxClipPlanes)
332 goto invalid_enum_error;
333
334 if ((ctx->Transform.ClipPlanesEnabled & (1 << p))
335 == ((GLuint) state << p))
336 return;
337
338 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
339
340 if (state) {
341 ctx->Transform.ClipPlanesEnabled |= (1 << p);
342 _mesa_update_clip_plane(ctx, p);
343 }
344 else {
345 ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
346 }
347 }
348 break;
349 case GL_COLOR_MATERIAL:
350 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
351 goto invalid_enum_error;
352 if (ctx->Light.ColorMaterialEnabled == state)
353 return;
354 FLUSH_VERTICES(ctx, _NEW_LIGHT);
355 FLUSH_CURRENT(ctx, 0);
356 ctx->Light.ColorMaterialEnabled = state;
357 if (state) {
358 _mesa_update_color_material( ctx,
359 ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
360 }
361 break;
362 case GL_CULL_FACE:
363 if (ctx->Polygon.CullFlag == state)
364 return;
365 FLUSH_VERTICES(ctx, _NEW_POLYGON);
366 ctx->Polygon.CullFlag = state;
367 break;
368 case GL_DEPTH_TEST:
369 if (ctx->Depth.Test == state)
370 return;
371 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewDepth ? 0 : _NEW_DEPTH);
372 ctx->NewDriverState |= ctx->DriverFlags.NewDepth;
373 ctx->Depth.Test = state;
374 break;
375 case GL_DEBUG_OUTPUT:
376 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB:
377 _mesa_set_debug_state_int(ctx, cap, state);
378 break;
379 case GL_DITHER:
380 if (ctx->Color.DitherFlag == state)
381 return;
382 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlend ? 0 : _NEW_COLOR);
383 ctx->NewDriverState |= ctx->DriverFlags.NewBlend;
384 ctx->Color.DitherFlag = state;
385 break;
386 case GL_FOG:
387 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
388 goto invalid_enum_error;
389 if (ctx->Fog.Enabled == state)
390 return;
391 FLUSH_VERTICES(ctx, _NEW_FOG);
392 ctx->Fog.Enabled = state;
393 ctx->Fog._PackedEnabledMode = state ? ctx->Fog._PackedMode : FOG_NONE;
394 break;
395 case GL_LIGHT0:
396 case GL_LIGHT1:
397 case GL_LIGHT2:
398 case GL_LIGHT3:
399 case GL_LIGHT4:
400 case GL_LIGHT5:
401 case GL_LIGHT6:
402 case GL_LIGHT7:
403 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
404 goto invalid_enum_error;
405 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state)
406 return;
407 FLUSH_VERTICES(ctx, _NEW_LIGHT);
408 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
409 if (state) {
410 ctx->Light._EnabledLights |= 1u << (cap - GL_LIGHT0);
411 }
412 else {
413 ctx->Light._EnabledLights &= ~(1u << (cap - GL_LIGHT0));
414 }
415 break;
416 case GL_LIGHTING:
417 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
418 goto invalid_enum_error;
419 if (ctx->Light.Enabled == state)
420 return;
421 FLUSH_VERTICES(ctx, _NEW_LIGHT);
422 ctx->Light.Enabled = state;
423 break;
424 case GL_LINE_SMOOTH:
425 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
426 goto invalid_enum_error;
427 if (ctx->Line.SmoothFlag == state)
428 return;
429 FLUSH_VERTICES(ctx, _NEW_LINE);
430 ctx->Line.SmoothFlag = state;
431 break;
432 case GL_LINE_STIPPLE:
433 if (ctx->API != API_OPENGL_COMPAT)
434 goto invalid_enum_error;
435 if (ctx->Line.StippleFlag == state)
436 return;
437 FLUSH_VERTICES(ctx, _NEW_LINE);
438 ctx->Line.StippleFlag = state;
439 break;
440 case GL_INDEX_LOGIC_OP:
441 if (ctx->API != API_OPENGL_COMPAT)
442 goto invalid_enum_error;
443 if (ctx->Color.IndexLogicOpEnabled == state)
444 return;
445 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLogicOp ? 0 : _NEW_COLOR);
446 ctx->NewDriverState |= ctx->DriverFlags.NewLogicOp;
447 ctx->Color.IndexLogicOpEnabled = state;
448 break;
449 case GL_CONSERVATIVE_RASTERIZATION_INTEL:
450 if (!_mesa_has_INTEL_conservative_rasterization(ctx))
451 goto invalid_enum_error;
452 if (ctx->IntelConservativeRasterization == state)
453 return;
454 FLUSH_VERTICES(ctx, 0);
455 ctx->NewDriverState |=
456 ctx->DriverFlags.NewIntelConservativeRasterization;
457 ctx->IntelConservativeRasterization = state;
458 break;
459 case GL_COLOR_LOGIC_OP:
460 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
461 goto invalid_enum_error;
462 if (ctx->Color.ColorLogicOpEnabled == state)
463 return;
464 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLogicOp ? 0 : _NEW_COLOR);
465 ctx->NewDriverState |= ctx->DriverFlags.NewLogicOp;
466 ctx->Color.ColorLogicOpEnabled = state;
467 break;
468 case GL_MAP1_COLOR_4:
469 if (ctx->API != API_OPENGL_COMPAT)
470 goto invalid_enum_error;
471 if (ctx->Eval.Map1Color4 == state)
472 return;
473 FLUSH_VERTICES(ctx, _NEW_EVAL);
474 ctx->Eval.Map1Color4 = state;
475 break;
476 case GL_MAP1_INDEX:
477 if (ctx->API != API_OPENGL_COMPAT)
478 goto invalid_enum_error;
479 if (ctx->Eval.Map1Index == state)
480 return;
481 FLUSH_VERTICES(ctx, _NEW_EVAL);
482 ctx->Eval.Map1Index = state;
483 break;
484 case GL_MAP1_NORMAL:
485 if (ctx->API != API_OPENGL_COMPAT)
486 goto invalid_enum_error;
487 if (ctx->Eval.Map1Normal == state)
488 return;
489 FLUSH_VERTICES(ctx, _NEW_EVAL);
490 ctx->Eval.Map1Normal = state;
491 break;
492 case GL_MAP1_TEXTURE_COORD_1:
493 if (ctx->API != API_OPENGL_COMPAT)
494 goto invalid_enum_error;
495 if (ctx->Eval.Map1TextureCoord1 == state)
496 return;
497 FLUSH_VERTICES(ctx, _NEW_EVAL);
498 ctx->Eval.Map1TextureCoord1 = state;
499 break;
500 case GL_MAP1_TEXTURE_COORD_2:
501 if (ctx->API != API_OPENGL_COMPAT)
502 goto invalid_enum_error;
503 if (ctx->Eval.Map1TextureCoord2 == state)
504 return;
505 FLUSH_VERTICES(ctx, _NEW_EVAL);
506 ctx->Eval.Map1TextureCoord2 = state;
507 break;
508 case GL_MAP1_TEXTURE_COORD_3:
509 if (ctx->API != API_OPENGL_COMPAT)
510 goto invalid_enum_error;
511 if (ctx->Eval.Map1TextureCoord3 == state)
512 return;
513 FLUSH_VERTICES(ctx, _NEW_EVAL);
514 ctx->Eval.Map1TextureCoord3 = state;
515 break;
516 case GL_MAP1_TEXTURE_COORD_4:
517 if (ctx->API != API_OPENGL_COMPAT)
518 goto invalid_enum_error;
519 if (ctx->Eval.Map1TextureCoord4 == state)
520 return;
521 FLUSH_VERTICES(ctx, _NEW_EVAL);
522 ctx->Eval.Map1TextureCoord4 = state;
523 break;
524 case GL_MAP1_VERTEX_3:
525 if (ctx->API != API_OPENGL_COMPAT)
526 goto invalid_enum_error;
527 if (ctx->Eval.Map1Vertex3 == state)
528 return;
529 FLUSH_VERTICES(ctx, _NEW_EVAL);
530 ctx->Eval.Map1Vertex3 = state;
531 break;
532 case GL_MAP1_VERTEX_4:
533 if (ctx->API != API_OPENGL_COMPAT)
534 goto invalid_enum_error;
535 if (ctx->Eval.Map1Vertex4 == state)
536 return;
537 FLUSH_VERTICES(ctx, _NEW_EVAL);
538 ctx->Eval.Map1Vertex4 = state;
539 break;
540 case GL_MAP2_COLOR_4:
541 if (ctx->API != API_OPENGL_COMPAT)
542 goto invalid_enum_error;
543 if (ctx->Eval.Map2Color4 == state)
544 return;
545 FLUSH_VERTICES(ctx, _NEW_EVAL);
546 ctx->Eval.Map2Color4 = state;
547 break;
548 case GL_MAP2_INDEX:
549 if (ctx->API != API_OPENGL_COMPAT)
550 goto invalid_enum_error;
551 if (ctx->Eval.Map2Index == state)
552 return;
553 FLUSH_VERTICES(ctx, _NEW_EVAL);
554 ctx->Eval.Map2Index = state;
555 break;
556 case GL_MAP2_NORMAL:
557 if (ctx->API != API_OPENGL_COMPAT)
558 goto invalid_enum_error;
559 if (ctx->Eval.Map2Normal == state)
560 return;
561 FLUSH_VERTICES(ctx, _NEW_EVAL);
562 ctx->Eval.Map2Normal = state;
563 break;
564 case GL_MAP2_TEXTURE_COORD_1:
565 if (ctx->API != API_OPENGL_COMPAT)
566 goto invalid_enum_error;
567 if (ctx->Eval.Map2TextureCoord1 == state)
568 return;
569 FLUSH_VERTICES(ctx, _NEW_EVAL);
570 ctx->Eval.Map2TextureCoord1 = state;
571 break;
572 case GL_MAP2_TEXTURE_COORD_2:
573 if (ctx->API != API_OPENGL_COMPAT)
574 goto invalid_enum_error;
575 if (ctx->Eval.Map2TextureCoord2 == state)
576 return;
577 FLUSH_VERTICES(ctx, _NEW_EVAL);
578 ctx->Eval.Map2TextureCoord2 = state;
579 break;
580 case GL_MAP2_TEXTURE_COORD_3:
581 if (ctx->API != API_OPENGL_COMPAT)
582 goto invalid_enum_error;
583 if (ctx->Eval.Map2TextureCoord3 == state)
584 return;
585 FLUSH_VERTICES(ctx, _NEW_EVAL);
586 ctx->Eval.Map2TextureCoord3 = state;
587 break;
588 case GL_MAP2_TEXTURE_COORD_4:
589 if (ctx->API != API_OPENGL_COMPAT)
590 goto invalid_enum_error;
591 if (ctx->Eval.Map2TextureCoord4 == state)
592 return;
593 FLUSH_VERTICES(ctx, _NEW_EVAL);
594 ctx->Eval.Map2TextureCoord4 = state;
595 break;
596 case GL_MAP2_VERTEX_3:
597 if (ctx->API != API_OPENGL_COMPAT)
598 goto invalid_enum_error;
599 if (ctx->Eval.Map2Vertex3 == state)
600 return;
601 FLUSH_VERTICES(ctx, _NEW_EVAL);
602 ctx->Eval.Map2Vertex3 = state;
603 break;
604 case GL_MAP2_VERTEX_4:
605 if (ctx->API != API_OPENGL_COMPAT)
606 goto invalid_enum_error;
607 if (ctx->Eval.Map2Vertex4 == state)
608 return;
609 FLUSH_VERTICES(ctx, _NEW_EVAL);
610 ctx->Eval.Map2Vertex4 = state;
611 break;
612 case GL_NORMALIZE:
613 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
614 goto invalid_enum_error;
615 if (ctx->Transform.Normalize == state)
616 return;
617 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
618 ctx->Transform.Normalize = state;
619 break;
620 case GL_POINT_SMOOTH:
621 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
622 goto invalid_enum_error;
623 if (ctx->Point.SmoothFlag == state)
624 return;
625 FLUSH_VERTICES(ctx, _NEW_POINT);
626 ctx->Point.SmoothFlag = state;
627 break;
628 case GL_POLYGON_SMOOTH:
629 if (!_mesa_is_desktop_gl(ctx))
630 goto invalid_enum_error;
631 if (ctx->Polygon.SmoothFlag == state)
632 return;
633 FLUSH_VERTICES(ctx, _NEW_POLYGON);
634 ctx->Polygon.SmoothFlag = state;
635 break;
636 case GL_POLYGON_STIPPLE:
637 if (ctx->API != API_OPENGL_COMPAT)
638 goto invalid_enum_error;
639 if (ctx->Polygon.StippleFlag == state)
640 return;
641 FLUSH_VERTICES(ctx, _NEW_POLYGON);
642 ctx->Polygon.StippleFlag = state;
643 break;
644 case GL_POLYGON_OFFSET_POINT:
645 if (!_mesa_is_desktop_gl(ctx))
646 goto invalid_enum_error;
647 if (ctx->Polygon.OffsetPoint == state)
648 return;
649 FLUSH_VERTICES(ctx, _NEW_POLYGON);
650 ctx->Polygon.OffsetPoint = state;
651 break;
652 case GL_POLYGON_OFFSET_LINE:
653 if (!_mesa_is_desktop_gl(ctx))
654 goto invalid_enum_error;
655 if (ctx->Polygon.OffsetLine == state)
656 return;
657 FLUSH_VERTICES(ctx, _NEW_POLYGON);
658 ctx->Polygon.OffsetLine = state;
659 break;
660 case GL_POLYGON_OFFSET_FILL:
661 if (ctx->Polygon.OffsetFill == state)
662 return;
663 FLUSH_VERTICES(ctx, _NEW_POLYGON);
664 ctx->Polygon.OffsetFill = state;
665 break;
666 case GL_RESCALE_NORMAL_EXT:
667 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
668 goto invalid_enum_error;
669 if (ctx->Transform.RescaleNormals == state)
670 return;
671 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
672 ctx->Transform.RescaleNormals = state;
673 break;
674 case GL_SCISSOR_TEST:
675 {
676 /* Must expand glEnable to all scissors */
677 GLbitfield newEnabled =
678 state * ((1 << ctx->Const.MaxViewports) - 1);
679 if (newEnabled != ctx->Scissor.EnableFlags) {
680 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewScissorTest ? 0 :
681 _NEW_SCISSOR);
682 ctx->NewDriverState |= ctx->DriverFlags.NewScissorTest;
683 ctx->Scissor.EnableFlags = newEnabled;
684 }
685 }
686 break;
687 case GL_STENCIL_TEST:
688 if (ctx->Stencil.Enabled == state)
689 return;
690 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewStencil ? 0 : _NEW_STENCIL);
691 ctx->NewDriverState |= ctx->DriverFlags.NewStencil;
692 ctx->Stencil.Enabled = state;
693 break;
694 case GL_TEXTURE_1D:
695 if (ctx->API != API_OPENGL_COMPAT)
696 goto invalid_enum_error;
697 if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) {
698 return;
699 }
700 break;
701 case GL_TEXTURE_2D:
702 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
703 goto invalid_enum_error;
704 if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) {
705 return;
706 }
707 break;
708 case GL_TEXTURE_3D:
709 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
710 goto invalid_enum_error;
711 if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) {
712 return;
713 }
714 break;
715 case GL_TEXTURE_GEN_S:
716 case GL_TEXTURE_GEN_T:
717 case GL_TEXTURE_GEN_R:
718 case GL_TEXTURE_GEN_Q:
719 {
720 struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
721
722 if (ctx->API != API_OPENGL_COMPAT)
723 goto invalid_enum_error;
724
725 if (texUnit) {
726 GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S);
727 GLbitfield newenabled = texUnit->TexGenEnabled & ~coordBit;
728 if (state)
729 newenabled |= coordBit;
730 if (texUnit->TexGenEnabled == newenabled)
731 return;
732 FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE);
733 texUnit->TexGenEnabled = newenabled;
734 }
735 }
736 break;
737
738 case GL_TEXTURE_GEN_STR_OES:
739 /* disable S, T, and R at the same time */
740 {
741 struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
742
743 if (ctx->API != API_OPENGLES)
744 goto invalid_enum_error;
745
746 if (texUnit) {
747 GLuint newenabled =
748 texUnit->TexGenEnabled & ~STR_BITS;
749 if (state)
750 newenabled |= STR_BITS;
751 if (texUnit->TexGenEnabled == newenabled)
752 return;
753 FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE);
754 texUnit->TexGenEnabled = newenabled;
755 }
756 }
757 break;
758
759 /* client-side state */
760 case GL_VERTEX_ARRAY:
761 case GL_NORMAL_ARRAY:
762 case GL_COLOR_ARRAY:
763 case GL_TEXTURE_COORD_ARRAY:
764 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
765 goto invalid_enum_error;
766 client_state( ctx, cap, state );
767 return;
768 case GL_INDEX_ARRAY:
769 case GL_EDGE_FLAG_ARRAY:
770 case GL_FOG_COORDINATE_ARRAY_EXT:
771 case GL_SECONDARY_COLOR_ARRAY_EXT:
772 if (ctx->API != API_OPENGL_COMPAT)
773 goto invalid_enum_error;
774 client_state( ctx, cap, state );
775 return;
776 case GL_POINT_SIZE_ARRAY_OES:
777 if (ctx->API != API_OPENGLES)
778 goto invalid_enum_error;
779 client_state( ctx, cap, state );
780 return;
781
782 /* GL_ARB_texture_cube_map */
783 case GL_TEXTURE_CUBE_MAP:
784 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
785 goto invalid_enum_error;
786 CHECK_EXTENSION(ARB_texture_cube_map, cap);
787 if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) {
788 return;
789 }
790 break;
791
792 /* GL_EXT_secondary_color */
793 case GL_COLOR_SUM_EXT:
794 if (ctx->API != API_OPENGL_COMPAT)
795 goto invalid_enum_error;
796 if (ctx->Fog.ColorSumEnabled == state)
797 return;
798 FLUSH_VERTICES(ctx, _NEW_FOG);
799 ctx->Fog.ColorSumEnabled = state;
800 break;
801
802 /* GL_ARB_multisample */
803 case GL_MULTISAMPLE_ARB:
804 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
805 goto invalid_enum_error;
806 _mesa_set_multisample(ctx, state);
807 return;
808 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
809 if (ctx->Multisample.SampleAlphaToCoverage == state)
810 return;
811 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
812 ctx->Multisample.SampleAlphaToCoverage = state;
813 break;
814 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
815 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
816 goto invalid_enum_error;
817 if (ctx->Multisample.SampleAlphaToOne == state)
818 return;
819 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
820 ctx->Multisample.SampleAlphaToOne = state;
821 break;
822 case GL_SAMPLE_COVERAGE_ARB:
823 if (ctx->Multisample.SampleCoverage == state)
824 return;
825 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
826 ctx->Multisample.SampleCoverage = state;
827 break;
828 case GL_SAMPLE_COVERAGE_INVERT_ARB:
829 if (!_mesa_is_desktop_gl(ctx))
830 goto invalid_enum_error;
831 if (ctx->Multisample.SampleCoverageInvert == state)
832 return;
833 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
834 ctx->Multisample.SampleCoverageInvert = state;
835 break;
836
837 /* GL_ARB_sample_shading */
838 case GL_SAMPLE_SHADING:
839 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
840 goto invalid_enum_error;
841 CHECK_EXTENSION(ARB_sample_shading, cap);
842 if (ctx->Multisample.SampleShading == state)
843 return;
844 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
845 ctx->Multisample.SampleShading = state;
846 break;
847
848 /* GL_IBM_rasterpos_clip */
849 case GL_RASTER_POSITION_UNCLIPPED_IBM:
850 if (ctx->API != API_OPENGL_COMPAT)
851 goto invalid_enum_error;
852 if (ctx->Transform.RasterPositionUnclipped == state)
853 return;
854 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
855 ctx->Transform.RasterPositionUnclipped = state;
856 break;
857
858 /* GL_NV_point_sprite */
859 case GL_POINT_SPRITE_NV:
860 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
861 goto invalid_enum_error;
862 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap);
863 if (ctx->Point.PointSprite == state)
864 return;
865 FLUSH_VERTICES(ctx, _NEW_POINT);
866 ctx->Point.PointSprite = state;
867 break;
868
869 case GL_VERTEX_PROGRAM_ARB:
870 if (ctx->API != API_OPENGL_COMPAT)
871 goto invalid_enum_error;
872 CHECK_EXTENSION(ARB_vertex_program, cap);
873 if (ctx->VertexProgram.Enabled == state)
874 return;
875 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
876 ctx->VertexProgram.Enabled = state;
877 break;
878 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
879 /* This was added with ARB_vertex_program, but it is also used with
880 * GLSL vertex shaders on desktop.
881 */
882 if (!_mesa_is_desktop_gl(ctx))
883 goto invalid_enum_error;
884 CHECK_EXTENSION(ARB_vertex_program, cap);
885 if (ctx->VertexProgram.PointSizeEnabled == state)
886 return;
887 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
888 ctx->VertexProgram.PointSizeEnabled = state;
889 break;
890 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
891 if (ctx->API != API_OPENGL_COMPAT)
892 goto invalid_enum_error;
893 CHECK_EXTENSION(ARB_vertex_program, cap);
894 if (ctx->VertexProgram.TwoSideEnabled == state)
895 return;
896 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
897 ctx->VertexProgram.TwoSideEnabled = state;
898 break;
899
900 /* GL_NV_texture_rectangle */
901 case GL_TEXTURE_RECTANGLE_NV:
902 if (ctx->API != API_OPENGL_COMPAT)
903 goto invalid_enum_error;
904 CHECK_EXTENSION(NV_texture_rectangle, cap);
905 if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) {
906 return;
907 }
908 break;
909
910 /* GL_EXT_stencil_two_side */
911 case GL_STENCIL_TEST_TWO_SIDE_EXT:
912 if (ctx->API != API_OPENGL_COMPAT)
913 goto invalid_enum_error;
914 CHECK_EXTENSION(EXT_stencil_two_side, cap);
915 if (ctx->Stencil.TestTwoSide == state)
916 return;
917 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewStencil ? 0 : _NEW_STENCIL);
918 ctx->NewDriverState |= ctx->DriverFlags.NewStencil;
919 ctx->Stencil.TestTwoSide = state;
920 if (state) {
921 ctx->Stencil._BackFace = 2;
922 } else {
923 ctx->Stencil._BackFace = 1;
924 }
925 break;
926
927 case GL_FRAGMENT_PROGRAM_ARB:
928 if (ctx->API != API_OPENGL_COMPAT)
929 goto invalid_enum_error;
930 CHECK_EXTENSION(ARB_fragment_program, cap);
931 if (ctx->FragmentProgram.Enabled == state)
932 return;
933 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
934 ctx->FragmentProgram.Enabled = state;
935 break;
936
937 /* GL_EXT_depth_bounds_test */
938 case GL_DEPTH_BOUNDS_TEST_EXT:
939 if (!_mesa_is_desktop_gl(ctx))
940 goto invalid_enum_error;
941 CHECK_EXTENSION(EXT_depth_bounds_test, cap);
942 if (ctx->Depth.BoundsTest == state)
943 return;
944 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewDepth ? 0 : _NEW_DEPTH);
945 ctx->NewDriverState |= ctx->DriverFlags.NewDepth;
946 ctx->Depth.BoundsTest = state;
947 break;
948
949 case GL_DEPTH_CLAMP:
950 if (!_mesa_is_desktop_gl(ctx))
951 goto invalid_enum_error;
952 CHECK_EXTENSION(ARB_depth_clamp, cap);
953 if (ctx->Transform.DepthClamp == state)
954 return;
955 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
956 ctx->Transform.DepthClamp = state;
957 break;
958
959 case GL_FRAGMENT_SHADER_ATI:
960 if (ctx->API != API_OPENGL_COMPAT)
961 goto invalid_enum_error;
962 CHECK_EXTENSION(ATI_fragment_shader, cap);
963 if (ctx->ATIFragmentShader.Enabled == state)
964 return;
965 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
966 ctx->ATIFragmentShader.Enabled = state;
967 break;
968
969 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
970 if (!_mesa_is_desktop_gl(ctx))
971 goto invalid_enum_error;
972 CHECK_EXTENSION(ARB_seamless_cube_map, cap);
973 if (ctx->Texture.CubeMapSeamless != state) {
974 FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
975 ctx->Texture.CubeMapSeamless = state;
976 }
977 break;
978
979 case GL_RASTERIZER_DISCARD:
980 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
981 goto invalid_enum_error;
982 CHECK_EXTENSION(EXT_transform_feedback, cap);
983 if (ctx->RasterDiscard != state) {
984 FLUSH_VERTICES(ctx, 0);
985 ctx->NewDriverState |= ctx->DriverFlags.NewRasterizerDiscard;
986 ctx->RasterDiscard = state;
987 }
988 break;
989
990 /* GL 3.1 primitive restart. Note: this enum is different from
991 * GL_PRIMITIVE_RESTART_NV (which is client state).
992 */
993 case GL_PRIMITIVE_RESTART:
994 if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 31) {
995 goto invalid_enum_error;
996 }
997 if (ctx->Array.PrimitiveRestart != state) {
998 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
999 ctx->Array.PrimitiveRestart = state;
1000 update_derived_primitive_restart_state(ctx);
1001 }
1002 break;
1003
1004 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
1005 if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility)
1006 goto invalid_enum_error;
1007 if (ctx->Array.PrimitiveRestartFixedIndex != state) {
1008 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
1009 ctx->Array.PrimitiveRestartFixedIndex = state;
1010 update_derived_primitive_restart_state(ctx);
1011 }
1012 break;
1013
1014 /* GL3.0 - GL_framebuffer_sRGB */
1015 case GL_FRAMEBUFFER_SRGB_EXT:
1016 if (!_mesa_is_desktop_gl(ctx))
1017 goto invalid_enum_error;
1018 CHECK_EXTENSION(EXT_framebuffer_sRGB, cap);
1019 _mesa_set_framebuffer_srgb(ctx, state);
1020 return;
1021
1022 /* GL_OES_EGL_image_external */
1023 case GL_TEXTURE_EXTERNAL_OES:
1024 if (!_mesa_is_gles(ctx))
1025 goto invalid_enum_error;
1026 CHECK_EXTENSION(OES_EGL_image_external, cap);
1027 if (!enable_texture(ctx, state, TEXTURE_EXTERNAL_BIT)) {
1028 return;
1029 }
1030 break;
1031
1032 /* ARB_texture_multisample */
1033 case GL_SAMPLE_MASK:
1034 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx))
1035 goto invalid_enum_error;
1036 CHECK_EXTENSION(ARB_texture_multisample, cap);
1037 if (ctx->Multisample.SampleMask == state)
1038 return;
1039 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
1040 ctx->Multisample.SampleMask = state;
1041 break;
1042
1043 case GL_BLEND_ADVANCED_COHERENT_KHR:
1044 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent, cap);
1045 if (ctx->Color.BlendCoherent == state)
1046 return;
1047 FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlend ? 0 : _NEW_COLOR);
1048 ctx->NewDriverState |= ctx->DriverFlags.NewBlend;
1049 ctx->Color.BlendCoherent = state;
1050 break;
1051
1052 default:
1053 goto invalid_enum_error;
1054 }
1055
1056 if (ctx->Driver.Enable) {
1057 ctx->Driver.Enable( ctx, cap, state );
1058 }
1059
1060 return;
1061
1062 invalid_enum_error:
1063 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(%s)",
1064 state ? "Enable" : "Disable", _mesa_enum_to_string(cap));
1065 }
1066
1067
1068 /**
1069 * Enable GL capability. Called by glEnable()
1070 * \param cap state to enable.
1071 */
1072 void GLAPIENTRY
1073 _mesa_Enable( GLenum cap )
1074 {
1075 GET_CURRENT_CONTEXT(ctx);
1076
1077 _mesa_set_enable( ctx, cap, GL_TRUE );
1078 }
1079
1080
1081 /**
1082 * Disable GL capability. Called by glDisable()
1083 * \param cap state to disable.
1084 */
1085 void GLAPIENTRY
1086 _mesa_Disable( GLenum cap )
1087 {
1088 GET_CURRENT_CONTEXT(ctx);
1089
1090 _mesa_set_enable( ctx, cap, GL_FALSE );
1091 }
1092
1093
1094
1095 /**
1096 * Enable/disable an indexed state var.
1097 */
1098 void
1099 _mesa_set_enablei(struct gl_context *ctx, GLenum cap,
1100 GLuint index, GLboolean state)
1101 {
1102 assert(state == 0 || state == 1);
1103 switch (cap) {
1104 case GL_BLEND:
1105 if (!ctx->Extensions.EXT_draw_buffers2) {
1106 goto invalid_enum_error;
1107 }
1108 if (index >= ctx->Const.MaxDrawBuffers) {
1109 _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)",
1110 state ? "glEnableIndexed" : "glDisableIndexed", index);
1111 return;
1112 }
1113 if (((ctx->Color.BlendEnabled >> index) & 1) != state) {
1114 _mesa_flush_vertices_for_blend_state(ctx);
1115 if (state)
1116 ctx->Color.BlendEnabled |= (1 << index);
1117 else
1118 ctx->Color.BlendEnabled &= ~(1 << index);
1119 }
1120 break;
1121 case GL_SCISSOR_TEST:
1122 if (index >= ctx->Const.MaxViewports) {
1123 _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)",
1124 state ? "glEnablei" : "glDisablei", index);
1125 return;
1126 }
1127 if (((ctx->Scissor.EnableFlags >> index) & 1) != state) {
1128 FLUSH_VERTICES(ctx,
1129 ctx->DriverFlags.NewScissorTest ? 0 : _NEW_SCISSOR);
1130 ctx->NewDriverState |= ctx->DriverFlags.NewScissorTest;
1131 if (state)
1132 ctx->Scissor.EnableFlags |= (1 << index);
1133 else
1134 ctx->Scissor.EnableFlags &= ~(1 << index);
1135 }
1136 break;
1137 default:
1138 goto invalid_enum_error;
1139 }
1140 return;
1141
1142 invalid_enum_error:
1143 _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)",
1144 state ? "glEnablei" : "glDisablei",
1145 _mesa_enum_to_string(cap));
1146 }
1147
1148
1149 void GLAPIENTRY
1150 _mesa_Disablei( GLenum cap, GLuint index )
1151 {
1152 GET_CURRENT_CONTEXT(ctx);
1153 _mesa_set_enablei(ctx, cap, index, GL_FALSE);
1154 }
1155
1156
1157 void GLAPIENTRY
1158 _mesa_Enablei( GLenum cap, GLuint index )
1159 {
1160 GET_CURRENT_CONTEXT(ctx);
1161 _mesa_set_enablei(ctx, cap, index, GL_TRUE);
1162 }
1163
1164
1165 GLboolean GLAPIENTRY
1166 _mesa_IsEnabledi( GLenum cap, GLuint index )
1167 {
1168 GET_CURRENT_CONTEXT(ctx);
1169 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
1170 switch (cap) {
1171 case GL_BLEND:
1172 if (index >= ctx->Const.MaxDrawBuffers) {
1173 _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)",
1174 index);
1175 return GL_FALSE;
1176 }
1177 return (ctx->Color.BlendEnabled >> index) & 1;
1178 case GL_SCISSOR_TEST:
1179 if (index >= ctx->Const.MaxViewports) {
1180 _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)",
1181 index);
1182 return GL_FALSE;
1183 }
1184 return (ctx->Scissor.EnableFlags >> index) & 1;
1185 default:
1186 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)",
1187 _mesa_enum_to_string(cap));
1188 return GL_FALSE;
1189 }
1190 }
1191
1192
1193
1194
1195 #undef CHECK_EXTENSION
1196 #define CHECK_EXTENSION(EXTNAME) \
1197 if (!ctx->Extensions.EXTNAME) { \
1198 goto invalid_enum_error; \
1199 }
1200
1201 #undef CHECK_EXTENSION2
1202 #define CHECK_EXTENSION2(EXT1, EXT2) \
1203 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1204 goto invalid_enum_error; \
1205 }
1206
1207
1208 /**
1209 * Helper function to determine whether a texture target is enabled.
1210 */
1211 static GLboolean
1212 is_texture_enabled(struct gl_context *ctx, GLbitfield bit)
1213 {
1214 const struct gl_texture_unit *const texUnit =
1215 &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1216 return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE;
1217 }
1218
1219
1220 /**
1221 * Return simple enable/disable state.
1222 *
1223 * \param cap state variable to query.
1224 *
1225 * Returns the state of the specified capability from the current GL context.
1226 * For the capabilities associated with extensions verifies that those
1227 * extensions are effectively present before reporting.
1228 */
1229 GLboolean GLAPIENTRY
1230 _mesa_IsEnabled( GLenum cap )
1231 {
1232 GET_CURRENT_CONTEXT(ctx);
1233 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
1234
1235 switch (cap) {
1236 case GL_ALPHA_TEST:
1237 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1238 goto invalid_enum_error;
1239 return ctx->Color.AlphaEnabled;
1240 case GL_AUTO_NORMAL:
1241 if (ctx->API != API_OPENGL_COMPAT)
1242 goto invalid_enum_error;
1243 return ctx->Eval.AutoNormal;
1244 case GL_BLEND:
1245 return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */
1246 case GL_CLIP_DISTANCE0: /* aka GL_CLIP_PLANE0 */
1247 case GL_CLIP_DISTANCE1:
1248 case GL_CLIP_DISTANCE2:
1249 case GL_CLIP_DISTANCE3:
1250 case GL_CLIP_DISTANCE4:
1251 case GL_CLIP_DISTANCE5:
1252 case GL_CLIP_DISTANCE6:
1253 case GL_CLIP_DISTANCE7: {
1254 const GLuint p = cap - GL_CLIP_DISTANCE0;
1255
1256 if (p >= ctx->Const.MaxClipPlanes)
1257 goto invalid_enum_error;
1258
1259 return (ctx->Transform.ClipPlanesEnabled >> p) & 1;
1260 }
1261 case GL_COLOR_MATERIAL:
1262 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1263 goto invalid_enum_error;
1264 return ctx->Light.ColorMaterialEnabled;
1265 case GL_CULL_FACE:
1266 return ctx->Polygon.CullFlag;
1267 case GL_DEBUG_OUTPUT:
1268 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB:
1269 return (GLboolean) _mesa_get_debug_state_int(ctx, cap);
1270 case GL_DEPTH_TEST:
1271 return ctx->Depth.Test;
1272 case GL_DITHER:
1273 return ctx->Color.DitherFlag;
1274 case GL_FOG:
1275 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1276 goto invalid_enum_error;
1277 return ctx->Fog.Enabled;
1278 case GL_LIGHTING:
1279 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1280 goto invalid_enum_error;
1281 return ctx->Light.Enabled;
1282 case GL_LIGHT0:
1283 case GL_LIGHT1:
1284 case GL_LIGHT2:
1285 case GL_LIGHT3:
1286 case GL_LIGHT4:
1287 case GL_LIGHT5:
1288 case GL_LIGHT6:
1289 case GL_LIGHT7:
1290 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1291 goto invalid_enum_error;
1292 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
1293 case GL_LINE_SMOOTH:
1294 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
1295 goto invalid_enum_error;
1296 return ctx->Line.SmoothFlag;
1297 case GL_LINE_STIPPLE:
1298 if (ctx->API != API_OPENGL_COMPAT)
1299 goto invalid_enum_error;
1300 return ctx->Line.StippleFlag;
1301 case GL_INDEX_LOGIC_OP:
1302 if (ctx->API != API_OPENGL_COMPAT)
1303 goto invalid_enum_error;
1304 return ctx->Color.IndexLogicOpEnabled;
1305 case GL_COLOR_LOGIC_OP:
1306 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
1307 goto invalid_enum_error;
1308 return ctx->Color.ColorLogicOpEnabled;
1309 case GL_MAP1_COLOR_4:
1310 if (ctx->API != API_OPENGL_COMPAT)
1311 goto invalid_enum_error;
1312 return ctx->Eval.Map1Color4;
1313 case GL_MAP1_INDEX:
1314 if (ctx->API != API_OPENGL_COMPAT)
1315 goto invalid_enum_error;
1316 return ctx->Eval.Map1Index;
1317 case GL_MAP1_NORMAL:
1318 if (ctx->API != API_OPENGL_COMPAT)
1319 goto invalid_enum_error;
1320 return ctx->Eval.Map1Normal;
1321 case GL_MAP1_TEXTURE_COORD_1:
1322 if (ctx->API != API_OPENGL_COMPAT)
1323 goto invalid_enum_error;
1324 return ctx->Eval.Map1TextureCoord1;
1325 case GL_MAP1_TEXTURE_COORD_2:
1326 if (ctx->API != API_OPENGL_COMPAT)
1327 goto invalid_enum_error;
1328 return ctx->Eval.Map1TextureCoord2;
1329 case GL_MAP1_TEXTURE_COORD_3:
1330 if (ctx->API != API_OPENGL_COMPAT)
1331 goto invalid_enum_error;
1332 return ctx->Eval.Map1TextureCoord3;
1333 case GL_MAP1_TEXTURE_COORD_4:
1334 if (ctx->API != API_OPENGL_COMPAT)
1335 goto invalid_enum_error;
1336 return ctx->Eval.Map1TextureCoord4;
1337 case GL_MAP1_VERTEX_3:
1338 if (ctx->API != API_OPENGL_COMPAT)
1339 goto invalid_enum_error;
1340 return ctx->Eval.Map1Vertex3;
1341 case GL_MAP1_VERTEX_4:
1342 if (ctx->API != API_OPENGL_COMPAT)
1343 goto invalid_enum_error;
1344 return ctx->Eval.Map1Vertex4;
1345 case GL_MAP2_COLOR_4:
1346 if (ctx->API != API_OPENGL_COMPAT)
1347 goto invalid_enum_error;
1348 return ctx->Eval.Map2Color4;
1349 case GL_MAP2_INDEX:
1350 if (ctx->API != API_OPENGL_COMPAT)
1351 goto invalid_enum_error;
1352 return ctx->Eval.Map2Index;
1353 case GL_MAP2_NORMAL:
1354 if (ctx->API != API_OPENGL_COMPAT)
1355 goto invalid_enum_error;
1356 return ctx->Eval.Map2Normal;
1357 case GL_MAP2_TEXTURE_COORD_1:
1358 if (ctx->API != API_OPENGL_COMPAT)
1359 goto invalid_enum_error;
1360 return ctx->Eval.Map2TextureCoord1;
1361 case GL_MAP2_TEXTURE_COORD_2:
1362 if (ctx->API != API_OPENGL_COMPAT)
1363 goto invalid_enum_error;
1364 return ctx->Eval.Map2TextureCoord2;
1365 case GL_MAP2_TEXTURE_COORD_3:
1366 if (ctx->API != API_OPENGL_COMPAT)
1367 goto invalid_enum_error;
1368 return ctx->Eval.Map2TextureCoord3;
1369 case GL_MAP2_TEXTURE_COORD_4:
1370 if (ctx->API != API_OPENGL_COMPAT)
1371 goto invalid_enum_error;
1372 return ctx->Eval.Map2TextureCoord4;
1373 case GL_MAP2_VERTEX_3:
1374 if (ctx->API != API_OPENGL_COMPAT)
1375 goto invalid_enum_error;
1376 return ctx->Eval.Map2Vertex3;
1377 case GL_MAP2_VERTEX_4:
1378 if (ctx->API != API_OPENGL_COMPAT)
1379 goto invalid_enum_error;
1380 return ctx->Eval.Map2Vertex4;
1381 case GL_NORMALIZE:
1382 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1383 goto invalid_enum_error;
1384 return ctx->Transform.Normalize;
1385 case GL_POINT_SMOOTH:
1386 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1387 goto invalid_enum_error;
1388 return ctx->Point.SmoothFlag;
1389 case GL_POLYGON_SMOOTH:
1390 if (!_mesa_is_desktop_gl(ctx))
1391 goto invalid_enum_error;
1392 return ctx->Polygon.SmoothFlag;
1393 case GL_POLYGON_STIPPLE:
1394 if (ctx->API != API_OPENGL_COMPAT)
1395 goto invalid_enum_error;
1396 return ctx->Polygon.StippleFlag;
1397 case GL_POLYGON_OFFSET_POINT:
1398 if (!_mesa_is_desktop_gl(ctx))
1399 goto invalid_enum_error;
1400 return ctx->Polygon.OffsetPoint;
1401 case GL_POLYGON_OFFSET_LINE:
1402 if (!_mesa_is_desktop_gl(ctx))
1403 goto invalid_enum_error;
1404 return ctx->Polygon.OffsetLine;
1405 case GL_POLYGON_OFFSET_FILL:
1406 return ctx->Polygon.OffsetFill;
1407 case GL_RESCALE_NORMAL_EXT:
1408 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1409 goto invalid_enum_error;
1410 return ctx->Transform.RescaleNormals;
1411 case GL_SCISSOR_TEST:
1412 return ctx->Scissor.EnableFlags & 1; /* return state for index 0 */
1413 case GL_STENCIL_TEST:
1414 return ctx->Stencil.Enabled;
1415 case GL_TEXTURE_1D:
1416 if (ctx->API != API_OPENGL_COMPAT)
1417 goto invalid_enum_error;
1418 return is_texture_enabled(ctx, TEXTURE_1D_BIT);
1419 case GL_TEXTURE_2D:
1420 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1421 goto invalid_enum_error;
1422 return is_texture_enabled(ctx, TEXTURE_2D_BIT);
1423 case GL_TEXTURE_3D:
1424 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1425 goto invalid_enum_error;
1426 return is_texture_enabled(ctx, TEXTURE_3D_BIT);
1427 case GL_TEXTURE_GEN_S:
1428 case GL_TEXTURE_GEN_T:
1429 case GL_TEXTURE_GEN_R:
1430 case GL_TEXTURE_GEN_Q:
1431 {
1432 const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
1433
1434 if (ctx->API != API_OPENGL_COMPAT)
1435 goto invalid_enum_error;
1436
1437 if (texUnit) {
1438 GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S);
1439 return (texUnit->TexGenEnabled & coordBit) ? GL_TRUE : GL_FALSE;
1440 }
1441 }
1442 return GL_FALSE;
1443 case GL_TEXTURE_GEN_STR_OES:
1444 {
1445 const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
1446
1447 if (ctx->API != API_OPENGLES)
1448 goto invalid_enum_error;
1449
1450 if (texUnit) {
1451 return (texUnit->TexGenEnabled & STR_BITS) == STR_BITS
1452 ? GL_TRUE : GL_FALSE;
1453 }
1454 }
1455
1456 /* client-side state */
1457 case GL_VERTEX_ARRAY:
1458 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1459 goto invalid_enum_error;
1460 return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS].Enabled;
1461 case GL_NORMAL_ARRAY:
1462 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1463 goto invalid_enum_error;
1464 return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
1465 case GL_COLOR_ARRAY:
1466 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1467 goto invalid_enum_error;
1468 return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled;
1469 case GL_INDEX_ARRAY:
1470 if (ctx->API != API_OPENGL_COMPAT)
1471 goto invalid_enum_error;
1472 return ctx->Array.VAO->
1473 VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled;
1474 case GL_TEXTURE_COORD_ARRAY:
1475 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1476 goto invalid_enum_error;
1477 return ctx->Array.VAO->
1478 VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled;
1479 case GL_EDGE_FLAG_ARRAY:
1480 if (ctx->API != API_OPENGL_COMPAT)
1481 goto invalid_enum_error;
1482 return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled;
1483 case GL_FOG_COORDINATE_ARRAY_EXT:
1484 if (ctx->API != API_OPENGL_COMPAT)
1485 goto invalid_enum_error;
1486 return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_FOG].Enabled;
1487 case GL_SECONDARY_COLOR_ARRAY_EXT:
1488 if (ctx->API != API_OPENGL_COMPAT)
1489 goto invalid_enum_error;
1490 return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled;
1491 case GL_POINT_SIZE_ARRAY_OES:
1492 if (ctx->API != API_OPENGLES)
1493 goto invalid_enum_error;
1494 return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled;
1495
1496 /* GL_ARB_texture_cube_map */
1497 case GL_TEXTURE_CUBE_MAP:
1498 CHECK_EXTENSION(ARB_texture_cube_map);
1499 return is_texture_enabled(ctx, TEXTURE_CUBE_BIT);
1500
1501 /* GL_EXT_secondary_color */
1502 case GL_COLOR_SUM_EXT:
1503 if (ctx->API != API_OPENGL_COMPAT)
1504 goto invalid_enum_error;
1505 return ctx->Fog.ColorSumEnabled;
1506
1507 /* GL_ARB_multisample */
1508 case GL_MULTISAMPLE_ARB:
1509 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
1510 goto invalid_enum_error;
1511 return ctx->Multisample.Enabled;
1512 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
1513 return ctx->Multisample.SampleAlphaToCoverage;
1514 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
1515 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
1516 goto invalid_enum_error;
1517 return ctx->Multisample.SampleAlphaToOne;
1518 case GL_SAMPLE_COVERAGE_ARB:
1519 return ctx->Multisample.SampleCoverage;
1520 case GL_SAMPLE_COVERAGE_INVERT_ARB:
1521 if (!_mesa_is_desktop_gl(ctx))
1522 goto invalid_enum_error;
1523 return ctx->Multisample.SampleCoverageInvert;
1524
1525 /* GL_IBM_rasterpos_clip */
1526 case GL_RASTER_POSITION_UNCLIPPED_IBM:
1527 if (ctx->API != API_OPENGL_COMPAT)
1528 goto invalid_enum_error;
1529 return ctx->Transform.RasterPositionUnclipped;
1530
1531 /* GL_NV_point_sprite */
1532 case GL_POINT_SPRITE_NV:
1533 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1534 goto invalid_enum_error;
1535 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite)
1536 return ctx->Point.PointSprite;
1537
1538 case GL_VERTEX_PROGRAM_ARB:
1539 if (ctx->API != API_OPENGL_COMPAT)
1540 goto invalid_enum_error;
1541 CHECK_EXTENSION(ARB_vertex_program);
1542 return ctx->VertexProgram.Enabled;
1543 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
1544 /* This was added with ARB_vertex_program, but it is also used with
1545 * GLSL vertex shaders on desktop.
1546 */
1547 if (!_mesa_is_desktop_gl(ctx))
1548 goto invalid_enum_error;
1549 CHECK_EXTENSION(ARB_vertex_program);
1550 return ctx->VertexProgram.PointSizeEnabled;
1551 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
1552 if (ctx->API != API_OPENGL_COMPAT)
1553 goto invalid_enum_error;
1554 CHECK_EXTENSION(ARB_vertex_program);
1555 return ctx->VertexProgram.TwoSideEnabled;
1556
1557 /* GL_NV_texture_rectangle */
1558 case GL_TEXTURE_RECTANGLE_NV:
1559 if (ctx->API != API_OPENGL_COMPAT)
1560 goto invalid_enum_error;
1561 CHECK_EXTENSION(NV_texture_rectangle);
1562 return is_texture_enabled(ctx, TEXTURE_RECT_BIT);
1563
1564 /* GL_EXT_stencil_two_side */
1565 case GL_STENCIL_TEST_TWO_SIDE_EXT:
1566 if (ctx->API != API_OPENGL_COMPAT)
1567 goto invalid_enum_error;
1568 CHECK_EXTENSION(EXT_stencil_two_side);
1569 return ctx->Stencil.TestTwoSide;
1570
1571 case GL_FRAGMENT_PROGRAM_ARB:
1572 if (ctx->API != API_OPENGL_COMPAT)
1573 goto invalid_enum_error;
1574 return ctx->FragmentProgram.Enabled;
1575
1576 /* GL_EXT_depth_bounds_test */
1577 case GL_DEPTH_BOUNDS_TEST_EXT:
1578 if (!_mesa_is_desktop_gl(ctx))
1579 goto invalid_enum_error;
1580 CHECK_EXTENSION(EXT_depth_bounds_test);
1581 return ctx->Depth.BoundsTest;
1582
1583 /* GL_ARB_depth_clamp */
1584 case GL_DEPTH_CLAMP:
1585 if (!_mesa_is_desktop_gl(ctx))
1586 goto invalid_enum_error;
1587 CHECK_EXTENSION(ARB_depth_clamp);
1588 return ctx->Transform.DepthClamp;
1589
1590 case GL_FRAGMENT_SHADER_ATI:
1591 if (ctx->API != API_OPENGL_COMPAT)
1592 goto invalid_enum_error;
1593 CHECK_EXTENSION(ATI_fragment_shader);
1594 return ctx->ATIFragmentShader.Enabled;
1595
1596 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1597 if (!_mesa_is_desktop_gl(ctx))
1598 goto invalid_enum_error;
1599 CHECK_EXTENSION(ARB_seamless_cube_map);
1600 return ctx->Texture.CubeMapSeamless;
1601
1602 case GL_RASTERIZER_DISCARD:
1603 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1604 goto invalid_enum_error;
1605 CHECK_EXTENSION(EXT_transform_feedback);
1606 return ctx->RasterDiscard;
1607
1608 /* GL_NV_primitive_restart */
1609 case GL_PRIMITIVE_RESTART_NV:
1610 if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.NV_primitive_restart) {
1611 goto invalid_enum_error;
1612 }
1613 return ctx->Array.PrimitiveRestart;
1614
1615 /* GL 3.1 primitive restart */
1616 case GL_PRIMITIVE_RESTART:
1617 if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 31) {
1618 goto invalid_enum_error;
1619 }
1620 return ctx->Array.PrimitiveRestart;
1621
1622 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
1623 if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility) {
1624 goto invalid_enum_error;
1625 }
1626 return ctx->Array.PrimitiveRestartFixedIndex;
1627
1628 /* GL3.0 - GL_framebuffer_sRGB */
1629 case GL_FRAMEBUFFER_SRGB_EXT:
1630 if (!_mesa_is_desktop_gl(ctx))
1631 goto invalid_enum_error;
1632 CHECK_EXTENSION(EXT_framebuffer_sRGB);
1633 return ctx->Color.sRGBEnabled;
1634
1635 /* GL_OES_EGL_image_external */
1636 case GL_TEXTURE_EXTERNAL_OES:
1637 if (!_mesa_is_gles(ctx))
1638 goto invalid_enum_error;
1639 CHECK_EXTENSION(OES_EGL_image_external);
1640 return is_texture_enabled(ctx, TEXTURE_EXTERNAL_BIT);
1641
1642 /* ARB_texture_multisample */
1643 case GL_SAMPLE_MASK:
1644 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx))
1645 goto invalid_enum_error;
1646 CHECK_EXTENSION(ARB_texture_multisample);
1647 return ctx->Multisample.SampleMask;
1648
1649 /* ARB_sample_shading */
1650 case GL_SAMPLE_SHADING:
1651 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1652 goto invalid_enum_error;
1653 CHECK_EXTENSION(ARB_sample_shading);
1654 return ctx->Multisample.SampleShading;
1655
1656 case GL_BLEND_ADVANCED_COHERENT_KHR:
1657 CHECK_EXTENSION(KHR_blend_equation_advanced_coherent);
1658 return ctx->Color.BlendCoherent;
1659
1660 case GL_CONSERVATIVE_RASTERIZATION_INTEL:
1661 CHECK_EXTENSION(INTEL_conservative_rasterization);
1662 return ctx->IntelConservativeRasterization;
1663
1664 default:
1665 goto invalid_enum_error;
1666 }
1667
1668 return GL_FALSE;
1669
1670 invalid_enum_error:
1671 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(%s)",
1672 _mesa_enum_to_string(cap));
1673 return GL_FALSE;
1674 }