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