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