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