3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
36 #include "debug_output.h"
48 update_derived_primitive_restart_state(struct gl_context
*ctx
)
50 /* Update derived primitive restart state.
52 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
53 || ctx
->Array
.PrimitiveRestartFixedIndex
;
58 * Helper to enable/disable VAO client-side state.
61 vao_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
62 gl_vert_attrib attr
, GLboolean state
)
65 _mesa_enable_vertex_array_attrib(ctx
, vao
, attr
);
67 _mesa_disable_vertex_array_attrib(ctx
, vao
, attr
);
72 * Helper to enable/disable client-side state.
75 client_state(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
76 GLenum cap
, GLboolean state
)
80 vao_state(ctx
, vao
, VERT_ATTRIB_POS
, state
);
83 vao_state(ctx
, vao
, VERT_ATTRIB_NORMAL
, state
);
86 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR0
, state
);
89 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR_INDEX
, state
);
91 case GL_TEXTURE_COORD_ARRAY
:
92 vao_state(ctx
, vao
, VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
), state
);
94 case GL_EDGE_FLAG_ARRAY
:
95 vao_state(ctx
, vao
, VERT_ATTRIB_EDGEFLAG
, state
);
97 case GL_FOG_COORDINATE_ARRAY_EXT
:
98 vao_state(ctx
, vao
, VERT_ATTRIB_FOG
, state
);
100 case GL_SECONDARY_COLOR_ARRAY_EXT
:
101 vao_state(ctx
, vao
, VERT_ATTRIB_COLOR1
, state
);
104 case GL_POINT_SIZE_ARRAY_OES
:
105 if (ctx
->VertexProgram
.PointSizeEnabled
!= state
) {
106 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
107 ctx
->VertexProgram
.PointSizeEnabled
= state
;
109 vao_state(ctx
, vao
, VERT_ATTRIB_POINT_SIZE
, state
);
112 /* GL_NV_primitive_restart */
113 case GL_PRIMITIVE_RESTART_NV
:
114 if (!_mesa_has_NV_primitive_restart(ctx
))
115 goto invalid_enum_error
;
116 if (ctx
->Array
.PrimitiveRestart
== state
)
119 FLUSH_VERTICES(ctx
, 0);
120 ctx
->Array
.PrimitiveRestart
= state
;
121 update_derived_primitive_restart_state(ctx
);
125 goto invalid_enum_error
;
128 if (ctx
->Driver
.Enable
) {
129 ctx
->Driver
.Enable( ctx
, cap
, state
);
135 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
136 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
140 /* Helper for GL_EXT_direct_state_access following functions:
141 * - EnableClientStateIndexedEXT
142 * - EnableClientStateiEXT
143 * - DisableClientStateIndexedEXT
144 * - DisableClientStateiEXT
147 client_state_i(struct gl_context
*ctx
, struct gl_vertex_array_object
* vao
,
148 GLenum cap
, GLuint index
, GLboolean state
)
152 if (cap
!= GL_TEXTURE_COORD_ARRAY
) {
153 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientStateiEXT(cap=%s)",
154 state
? "Enable" : "Disable",
155 _mesa_enum_to_string(cap
));
159 if (index
>= ctx
->Const
.MaxTextureCoordUnits
) {
160 _mesa_error(ctx
, GL_INVALID_VALUE
, "gl%sClientStateiEXT(index=%d)",
161 state
? "Enable" : "Disable",
166 saved_active
= ctx
->Array
.ActiveTexture
;
167 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
168 client_state(ctx
, vao
, cap
, state
);
169 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
174 * Enable GL capability.
175 * \param cap state to enable/disable.
177 * Get's the current context, assures that we're outside glBegin()/glEnd() and
178 * calls client_state().
181 _mesa_EnableClientState( GLenum cap
)
183 GET_CURRENT_CONTEXT(ctx
);
184 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_TRUE
);
189 _mesa_EnableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
191 GET_CURRENT_CONTEXT(ctx
);
192 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
194 "glEnableVertexArrayEXT");
198 /* The EXT_direct_state_access spec says:
199 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
200 * the tokens TEXTURE0 through TEXTUREn where n is less than the
201 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
202 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
203 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
204 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
205 * as if the active client texture is set to texture coordinate set i
206 * based on the token TEXTUREi indicated by array."
208 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
209 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
210 _mesa_ClientActiveTexture(cap
);
211 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_TRUE
);
212 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
214 client_state(ctx
, vao
, cap
, GL_TRUE
);
220 _mesa_EnableClientStateiEXT( GLenum cap
, GLuint index
)
222 GET_CURRENT_CONTEXT(ctx
);
223 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_TRUE
);
228 * Disable GL capability.
229 * \param cap state to enable/disable.
231 * Get's the current context, assures that we're outside glBegin()/glEnd() and
232 * calls client_state().
235 _mesa_DisableClientState( GLenum cap
)
237 GET_CURRENT_CONTEXT(ctx
);
238 client_state( ctx
, ctx
->Array
.VAO
, cap
, GL_FALSE
);
242 _mesa_DisableVertexArrayEXT( GLuint vaobj
, GLenum cap
)
244 GET_CURRENT_CONTEXT(ctx
);
245 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
247 "glDisableVertexArrayEXT");
251 /* The EXT_direct_state_access spec says:
252 * "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
253 * the tokens TEXTURE0 through TEXTUREn where n is less than the
254 * implementation-dependent limit of MAX_TEXTURE_COORDS. For these
255 * GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
256 * act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
257 * or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
258 * as if the active client texture is set to texture coordinate set i
259 * based on the token TEXTUREi indicated by array."
261 if (GL_TEXTURE0
<= cap
&& cap
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureCoordUnits
) {
262 GLuint saved_active
= ctx
->Array
.ActiveTexture
;
263 _mesa_ClientActiveTexture(cap
);
264 client_state(ctx
, vao
, GL_TEXTURE_COORD_ARRAY
, GL_FALSE
);
265 _mesa_ClientActiveTexture(GL_TEXTURE0
+ saved_active
);
267 client_state(ctx
, vao
, cap
, GL_FALSE
);
272 _mesa_DisableClientStateiEXT( GLenum cap
, GLuint index
)
274 GET_CURRENT_CONTEXT(ctx
);
275 client_state_i(ctx
, ctx
->Array
.VAO
, cap
, index
, GL_FALSE
);
278 #define CHECK_EXTENSION(EXTNAME) \
279 if (!ctx->Extensions.EXTNAME) { \
280 goto invalid_enum_error; \
283 #define CHECK_EXTENSION2(EXT1, EXT2) \
284 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
285 goto invalid_enum_error; \
289 * Return pointer to current texture unit for setting/getting coordinate
291 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
292 * texture unit is higher than the number of supported coordinate units.
294 static struct gl_fixedfunc_texture_unit
*
295 get_texcoord_unit(struct gl_context
*ctx
)
297 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
298 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
302 return &ctx
->Texture
.FixedFuncUnit
[ctx
->Texture
.CurrentUnit
];
308 * Helper function to enable or disable a texture target.
309 * \param bit one of the TEXTURE_x_BIT values
310 * \return GL_TRUE if state is changing or GL_FALSE if no change
313 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
315 struct gl_fixedfunc_texture_unit
*texUnit
=
316 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
320 const GLbitfield newenabled
= state
321 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
323 if (texUnit
->Enabled
== newenabled
)
326 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
327 texUnit
->Enabled
= newenabled
;
333 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
334 * whether the API supports it (GLES doesn't).
337 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
339 if (ctx
->Multisample
.Enabled
== state
)
342 /* GL compatibility needs Multisample.Enable to determine program state
345 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
346 !ctx
->DriverFlags
.NewMultisampleEnable
) {
347 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
349 FLUSH_VERTICES(ctx
, 0);
352 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewMultisampleEnable
;
353 ctx
->Multisample
.Enabled
= state
;
355 if (ctx
->Driver
.Enable
) {
356 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
361 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
362 * check for whether the API supports it (GLES doesn't).
365 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
367 if (ctx
->Color
.sRGBEnabled
== state
)
370 /* TODO: Switch i965 to the new flag and remove the conditional */
371 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewFramebufferSRGB
? 0 : _NEW_BUFFERS
);
372 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewFramebufferSRGB
;
373 ctx
->Color
.sRGBEnabled
= state
;
375 if (ctx
->Driver
.Enable
) {
376 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
381 * Helper function to enable or disable state.
383 * \param ctx GL context.
384 * \param cap the state to enable/disable
385 * \param state whether to enable or disable the specified capability.
387 * Updates the current context and flushes the vertices as needed. For
388 * capabilities associated with extensions it verifies that those extensions
389 * are effectivly present before updating. Notifies the driver via
390 * dd_function_table::Enable.
393 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
395 if (MESA_VERBOSE
& VERBOSE_API
)
396 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
397 state
? "glEnable" : "glDisable",
398 _mesa_enum_to_string(cap
),
403 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
404 goto invalid_enum_error
;
405 if (ctx
->Color
.AlphaEnabled
== state
)
407 /* AlphaEnabled is used by the fixed-func fragment program */
408 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
409 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewAlphaTest
;
410 ctx
->Color
.AlphaEnabled
= state
;
413 if (ctx
->API
!= API_OPENGL_COMPAT
)
414 goto invalid_enum_error
;
415 if (ctx
->Eval
.AutoNormal
== state
)
417 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
418 ctx
->Eval
.AutoNormal
= state
;
422 GLbitfield newEnabled
=
423 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
424 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
425 _mesa_flush_vertices_for_blend_adv(ctx
, newEnabled
,
426 ctx
->Color
._AdvancedBlendMode
);
427 ctx
->Color
.BlendEnabled
= newEnabled
;
431 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
432 case GL_CLIP_DISTANCE1
:
433 case GL_CLIP_DISTANCE2
:
434 case GL_CLIP_DISTANCE3
:
435 case GL_CLIP_DISTANCE4
:
436 case GL_CLIP_DISTANCE5
:
437 case GL_CLIP_DISTANCE6
:
438 case GL_CLIP_DISTANCE7
:
440 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
442 if (p
>= ctx
->Const
.MaxClipPlanes
)
443 goto invalid_enum_error
;
445 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
446 == ((GLuint
) state
<< p
))
449 /* The compatibility profile needs _NEW_TRANSFORM to transform
450 * clip planes according to the projection matrix.
452 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
||
453 !ctx
->DriverFlags
.NewClipPlaneEnable
) {
454 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
456 FLUSH_VERTICES(ctx
, 0);
458 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlaneEnable
;
461 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
463 /* The projection matrix transforms the clip plane. */
464 /* TODO: glEnable might not be the best place to do it. */
465 if (ctx
->API
== API_OPENGL_COMPAT
|| ctx
->API
== API_OPENGLES
) {
466 _mesa_update_clip_plane(ctx
, p
);
467 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewClipPlane
;
471 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
475 case GL_COLOR_MATERIAL
:
476 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
477 goto invalid_enum_error
;
478 if (ctx
->Light
.ColorMaterialEnabled
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
481 FLUSH_CURRENT(ctx
, 0);
482 ctx
->Light
.ColorMaterialEnabled
= state
;
484 _mesa_update_color_material( ctx
,
485 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
489 if (ctx
->Polygon
.CullFlag
== state
)
492 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
493 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
494 ctx
->Polygon
.CullFlag
= state
;
497 if (ctx
->Depth
.Test
== state
)
499 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
500 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
501 ctx
->Depth
.Test
= state
;
503 case GL_DEBUG_OUTPUT
:
504 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
505 _mesa_set_debug_state_int(ctx
, cap
, state
);
508 if (ctx
->Color
.DitherFlag
== state
)
510 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
511 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
512 ctx
->Color
.DitherFlag
= state
;
515 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
516 goto invalid_enum_error
;
517 if (ctx
->Fog
.Enabled
== state
)
519 FLUSH_VERTICES(ctx
, _NEW_FOG
);
520 ctx
->Fog
.Enabled
= state
;
521 ctx
->Fog
._PackedEnabledMode
= state
? ctx
->Fog
._PackedMode
: FOG_NONE
;
531 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
532 goto invalid_enum_error
;
533 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
535 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
536 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
538 ctx
->Light
._EnabledLights
|= 1u << (cap
- GL_LIGHT0
);
541 ctx
->Light
._EnabledLights
&= ~(1u << (cap
- GL_LIGHT0
));
545 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
546 goto invalid_enum_error
;
547 if (ctx
->Light
.Enabled
== state
)
549 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
550 ctx
->Light
.Enabled
= state
;
553 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
554 goto invalid_enum_error
;
555 if (ctx
->Line
.SmoothFlag
== state
)
557 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
558 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
559 ctx
->Line
.SmoothFlag
= state
;
561 case GL_LINE_STIPPLE
:
562 if (ctx
->API
!= API_OPENGL_COMPAT
)
563 goto invalid_enum_error
;
564 if (ctx
->Line
.StippleFlag
== state
)
566 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLineState
? 0 : _NEW_LINE
);
567 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLineState
;
568 ctx
->Line
.StippleFlag
= state
;
570 case GL_INDEX_LOGIC_OP
:
571 if (ctx
->API
!= API_OPENGL_COMPAT
)
572 goto invalid_enum_error
;
573 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
575 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
576 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
577 ctx
->Color
.IndexLogicOpEnabled
= state
;
579 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
580 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
581 goto invalid_enum_error
;
582 if (ctx
->IntelConservativeRasterization
== state
)
584 FLUSH_VERTICES(ctx
, 0);
585 ctx
->NewDriverState
|=
586 ctx
->DriverFlags
.NewIntelConservativeRasterization
;
587 ctx
->IntelConservativeRasterization
= state
;
589 case GL_CONSERVATIVE_RASTERIZATION_NV
:
590 if (!_mesa_has_NV_conservative_raster(ctx
))
591 goto invalid_enum_error
;
592 if (ctx
->ConservativeRasterization
== state
)
594 FLUSH_VERTICES(ctx
, 0);
595 ctx
->NewDriverState
|=
596 ctx
->DriverFlags
.NewNvConservativeRasterization
;
597 ctx
->ConservativeRasterization
= state
;
599 case GL_COLOR_LOGIC_OP
:
600 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
601 goto invalid_enum_error
;
602 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
604 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewLogicOp
? 0 : _NEW_COLOR
);
605 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewLogicOp
;
606 ctx
->Color
.ColorLogicOpEnabled
= state
;
608 case GL_MAP1_COLOR_4
:
609 if (ctx
->API
!= API_OPENGL_COMPAT
)
610 goto invalid_enum_error
;
611 if (ctx
->Eval
.Map1Color4
== state
)
613 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
614 ctx
->Eval
.Map1Color4
= state
;
617 if (ctx
->API
!= API_OPENGL_COMPAT
)
618 goto invalid_enum_error
;
619 if (ctx
->Eval
.Map1Index
== state
)
621 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
622 ctx
->Eval
.Map1Index
= state
;
625 if (ctx
->API
!= API_OPENGL_COMPAT
)
626 goto invalid_enum_error
;
627 if (ctx
->Eval
.Map1Normal
== state
)
629 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
630 ctx
->Eval
.Map1Normal
= state
;
632 case GL_MAP1_TEXTURE_COORD_1
:
633 if (ctx
->API
!= API_OPENGL_COMPAT
)
634 goto invalid_enum_error
;
635 if (ctx
->Eval
.Map1TextureCoord1
== state
)
637 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
638 ctx
->Eval
.Map1TextureCoord1
= state
;
640 case GL_MAP1_TEXTURE_COORD_2
:
641 if (ctx
->API
!= API_OPENGL_COMPAT
)
642 goto invalid_enum_error
;
643 if (ctx
->Eval
.Map1TextureCoord2
== state
)
645 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
646 ctx
->Eval
.Map1TextureCoord2
= state
;
648 case GL_MAP1_TEXTURE_COORD_3
:
649 if (ctx
->API
!= API_OPENGL_COMPAT
)
650 goto invalid_enum_error
;
651 if (ctx
->Eval
.Map1TextureCoord3
== state
)
653 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
654 ctx
->Eval
.Map1TextureCoord3
= state
;
656 case GL_MAP1_TEXTURE_COORD_4
:
657 if (ctx
->API
!= API_OPENGL_COMPAT
)
658 goto invalid_enum_error
;
659 if (ctx
->Eval
.Map1TextureCoord4
== state
)
661 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
662 ctx
->Eval
.Map1TextureCoord4
= state
;
664 case GL_MAP1_VERTEX_3
:
665 if (ctx
->API
!= API_OPENGL_COMPAT
)
666 goto invalid_enum_error
;
667 if (ctx
->Eval
.Map1Vertex3
== state
)
669 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
670 ctx
->Eval
.Map1Vertex3
= state
;
672 case GL_MAP1_VERTEX_4
:
673 if (ctx
->API
!= API_OPENGL_COMPAT
)
674 goto invalid_enum_error
;
675 if (ctx
->Eval
.Map1Vertex4
== state
)
677 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
678 ctx
->Eval
.Map1Vertex4
= state
;
680 case GL_MAP2_COLOR_4
:
681 if (ctx
->API
!= API_OPENGL_COMPAT
)
682 goto invalid_enum_error
;
683 if (ctx
->Eval
.Map2Color4
== state
)
685 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
686 ctx
->Eval
.Map2Color4
= state
;
689 if (ctx
->API
!= API_OPENGL_COMPAT
)
690 goto invalid_enum_error
;
691 if (ctx
->Eval
.Map2Index
== state
)
693 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
694 ctx
->Eval
.Map2Index
= state
;
697 if (ctx
->API
!= API_OPENGL_COMPAT
)
698 goto invalid_enum_error
;
699 if (ctx
->Eval
.Map2Normal
== state
)
701 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
702 ctx
->Eval
.Map2Normal
= state
;
704 case GL_MAP2_TEXTURE_COORD_1
:
705 if (ctx
->API
!= API_OPENGL_COMPAT
)
706 goto invalid_enum_error
;
707 if (ctx
->Eval
.Map2TextureCoord1
== state
)
709 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
710 ctx
->Eval
.Map2TextureCoord1
= state
;
712 case GL_MAP2_TEXTURE_COORD_2
:
713 if (ctx
->API
!= API_OPENGL_COMPAT
)
714 goto invalid_enum_error
;
715 if (ctx
->Eval
.Map2TextureCoord2
== state
)
717 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
718 ctx
->Eval
.Map2TextureCoord2
= state
;
720 case GL_MAP2_TEXTURE_COORD_3
:
721 if (ctx
->API
!= API_OPENGL_COMPAT
)
722 goto invalid_enum_error
;
723 if (ctx
->Eval
.Map2TextureCoord3
== state
)
725 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
726 ctx
->Eval
.Map2TextureCoord3
= state
;
728 case GL_MAP2_TEXTURE_COORD_4
:
729 if (ctx
->API
!= API_OPENGL_COMPAT
)
730 goto invalid_enum_error
;
731 if (ctx
->Eval
.Map2TextureCoord4
== state
)
733 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
734 ctx
->Eval
.Map2TextureCoord4
= state
;
736 case GL_MAP2_VERTEX_3
:
737 if (ctx
->API
!= API_OPENGL_COMPAT
)
738 goto invalid_enum_error
;
739 if (ctx
->Eval
.Map2Vertex3
== state
)
741 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
742 ctx
->Eval
.Map2Vertex3
= state
;
744 case GL_MAP2_VERTEX_4
:
745 if (ctx
->API
!= API_OPENGL_COMPAT
)
746 goto invalid_enum_error
;
747 if (ctx
->Eval
.Map2Vertex4
== state
)
749 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
750 ctx
->Eval
.Map2Vertex4
= state
;
753 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
754 goto invalid_enum_error
;
755 if (ctx
->Transform
.Normalize
== state
)
757 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
758 ctx
->Transform
.Normalize
= state
;
760 case GL_POINT_SMOOTH
:
761 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
762 goto invalid_enum_error
;
763 if (ctx
->Point
.SmoothFlag
== state
)
765 FLUSH_VERTICES(ctx
, _NEW_POINT
);
766 ctx
->Point
.SmoothFlag
= state
;
768 case GL_POLYGON_SMOOTH
:
769 if (!_mesa_is_desktop_gl(ctx
))
770 goto invalid_enum_error
;
771 if (ctx
->Polygon
.SmoothFlag
== state
)
774 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
775 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
776 ctx
->Polygon
.SmoothFlag
= state
;
778 case GL_POLYGON_STIPPLE
:
779 if (ctx
->API
!= API_OPENGL_COMPAT
)
780 goto invalid_enum_error
;
781 if (ctx
->Polygon
.StippleFlag
== state
)
784 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
785 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
786 ctx
->Polygon
.StippleFlag
= state
;
788 case GL_POLYGON_OFFSET_POINT
:
789 if (!_mesa_is_desktop_gl(ctx
))
790 goto invalid_enum_error
;
791 if (ctx
->Polygon
.OffsetPoint
== state
)
794 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
795 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
796 ctx
->Polygon
.OffsetPoint
= state
;
798 case GL_POLYGON_OFFSET_LINE
:
799 if (!_mesa_is_desktop_gl(ctx
))
800 goto invalid_enum_error
;
801 if (ctx
->Polygon
.OffsetLine
== state
)
804 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
805 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
806 ctx
->Polygon
.OffsetLine
= state
;
808 case GL_POLYGON_OFFSET_FILL
:
809 if (ctx
->Polygon
.OffsetFill
== state
)
812 ctx
->DriverFlags
.NewPolygonState
? 0 : _NEW_POLYGON
);
813 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewPolygonState
;
814 ctx
->Polygon
.OffsetFill
= state
;
816 case GL_RESCALE_NORMAL_EXT
:
817 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
818 goto invalid_enum_error
;
819 if (ctx
->Transform
.RescaleNormals
== state
)
821 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
822 ctx
->Transform
.RescaleNormals
= state
;
824 case GL_SCISSOR_TEST
:
826 /* Must expand glEnable to all scissors */
827 GLbitfield newEnabled
=
828 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
829 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
830 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewScissorTest
? 0 :
832 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
833 ctx
->Scissor
.EnableFlags
= newEnabled
;
837 case GL_STENCIL_TEST
:
838 if (ctx
->Stencil
.Enabled
== state
)
840 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
841 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
842 ctx
->Stencil
.Enabled
= state
;
845 if (ctx
->API
!= API_OPENGL_COMPAT
)
846 goto invalid_enum_error
;
847 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
852 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
853 goto invalid_enum_error
;
854 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
859 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
860 goto invalid_enum_error
;
861 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
865 case GL_TEXTURE_GEN_S
:
866 case GL_TEXTURE_GEN_T
:
867 case GL_TEXTURE_GEN_R
:
868 case GL_TEXTURE_GEN_Q
:
870 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
872 if (ctx
->API
!= API_OPENGL_COMPAT
)
873 goto invalid_enum_error
;
876 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
877 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
879 newenabled
|= coordBit
;
880 if (texUnit
->TexGenEnabled
== newenabled
)
882 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
883 texUnit
->TexGenEnabled
= newenabled
;
888 case GL_TEXTURE_GEN_STR_OES
:
889 /* disable S, T, and R at the same time */
891 struct gl_fixedfunc_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
893 if (ctx
->API
!= API_OPENGLES
)
894 goto invalid_enum_error
;
898 texUnit
->TexGenEnabled
& ~STR_BITS
;
900 newenabled
|= STR_BITS
;
901 if (texUnit
->TexGenEnabled
== newenabled
)
903 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
904 texUnit
->TexGenEnabled
= newenabled
;
909 /* client-side state */
910 case GL_VERTEX_ARRAY
:
911 case GL_NORMAL_ARRAY
:
913 case GL_TEXTURE_COORD_ARRAY
:
914 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
915 goto invalid_enum_error
;
916 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
919 case GL_EDGE_FLAG_ARRAY
:
920 case GL_FOG_COORDINATE_ARRAY_EXT
:
921 case GL_SECONDARY_COLOR_ARRAY_EXT
:
922 if (ctx
->API
!= API_OPENGL_COMPAT
)
923 goto invalid_enum_error
;
924 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
926 case GL_POINT_SIZE_ARRAY_OES
:
927 if (ctx
->API
!= API_OPENGLES
)
928 goto invalid_enum_error
;
929 client_state( ctx
, ctx
->Array
.VAO
, cap
, state
);
932 /* GL_ARB_texture_cube_map */
933 case GL_TEXTURE_CUBE_MAP
:
934 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
935 !_mesa_has_OES_texture_cube_map(ctx
))
936 goto invalid_enum_error
;
937 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
942 /* GL_EXT_secondary_color */
943 case GL_COLOR_SUM_EXT
:
944 if (ctx
->API
!= API_OPENGL_COMPAT
)
945 goto invalid_enum_error
;
946 if (ctx
->Fog
.ColorSumEnabled
== state
)
948 FLUSH_VERTICES(ctx
, _NEW_FOG
);
949 ctx
->Fog
.ColorSumEnabled
= state
;
952 /* GL_ARB_multisample */
953 case GL_MULTISAMPLE_ARB
:
954 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
955 goto invalid_enum_error
;
956 _mesa_set_multisample(ctx
, state
);
958 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
959 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
961 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
963 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
964 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
966 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
967 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
968 goto invalid_enum_error
;
969 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
971 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleAlphaToXEnable
? 0 :
973 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleAlphaToXEnable
;
974 ctx
->Multisample
.SampleAlphaToOne
= state
;
976 case GL_SAMPLE_COVERAGE_ARB
:
977 if (ctx
->Multisample
.SampleCoverage
== state
)
979 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
981 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
982 ctx
->Multisample
.SampleCoverage
= state
;
984 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
985 if (!_mesa_is_desktop_gl(ctx
))
986 goto invalid_enum_error
;
987 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
989 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
991 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
992 ctx
->Multisample
.SampleCoverageInvert
= state
;
995 /* GL_ARB_sample_shading */
996 case GL_SAMPLE_SHADING
:
997 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
998 goto invalid_enum_error
;
999 if (ctx
->Multisample
.SampleShading
== state
)
1001 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleShading
? 0 :
1003 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleShading
;
1004 ctx
->Multisample
.SampleShading
= state
;
1007 /* GL_IBM_rasterpos_clip */
1008 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1009 if (ctx
->API
!= API_OPENGL_COMPAT
)
1010 goto invalid_enum_error
;
1011 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
1013 FLUSH_VERTICES(ctx
, 0);
1014 ctx
->Transform
.RasterPositionUnclipped
= state
;
1017 /* GL_NV_point_sprite */
1018 case GL_POINT_SPRITE_NV
:
1019 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1020 goto invalid_enum_error
;
1021 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
);
1022 if (ctx
->Point
.PointSprite
== state
)
1024 FLUSH_VERTICES(ctx
, _NEW_POINT
);
1025 ctx
->Point
.PointSprite
= state
;
1028 case GL_VERTEX_PROGRAM_ARB
:
1029 if (ctx
->API
!= API_OPENGL_COMPAT
)
1030 goto invalid_enum_error
;
1031 CHECK_EXTENSION(ARB_vertex_program
);
1032 if (ctx
->VertexProgram
.Enabled
== state
)
1034 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1035 ctx
->VertexProgram
.Enabled
= state
;
1036 _mesa_update_vertex_processing_mode(ctx
);
1038 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1039 /* This was added with ARB_vertex_program, but it is also used with
1040 * GLSL vertex shaders on desktop.
1042 if (!_mesa_is_desktop_gl(ctx
))
1043 goto invalid_enum_error
;
1044 CHECK_EXTENSION(ARB_vertex_program
);
1045 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
1047 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1048 ctx
->VertexProgram
.PointSizeEnabled
= state
;
1050 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1051 if (ctx
->API
!= API_OPENGL_COMPAT
)
1052 goto invalid_enum_error
;
1053 CHECK_EXTENSION(ARB_vertex_program
);
1054 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
1056 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1057 ctx
->VertexProgram
.TwoSideEnabled
= state
;
1060 /* GL_NV_texture_rectangle */
1061 case GL_TEXTURE_RECTANGLE_NV
:
1062 if (ctx
->API
!= API_OPENGL_COMPAT
)
1063 goto invalid_enum_error
;
1064 CHECK_EXTENSION(NV_texture_rectangle
);
1065 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
1070 /* GL_EXT_stencil_two_side */
1071 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1072 if (ctx
->API
!= API_OPENGL_COMPAT
)
1073 goto invalid_enum_error
;
1074 CHECK_EXTENSION(EXT_stencil_two_side
);
1075 if (ctx
->Stencil
.TestTwoSide
== state
)
1077 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewStencil
? 0 : _NEW_STENCIL
);
1078 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewStencil
;
1079 ctx
->Stencil
.TestTwoSide
= state
;
1081 ctx
->Stencil
._BackFace
= 2;
1083 ctx
->Stencil
._BackFace
= 1;
1087 case GL_FRAGMENT_PROGRAM_ARB
:
1088 if (!_mesa_has_ARB_fragment_program(ctx
))
1089 goto invalid_enum_error
;
1090 if (ctx
->FragmentProgram
.Enabled
== state
)
1092 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1093 ctx
->FragmentProgram
.Enabled
= state
;
1096 /* GL_EXT_depth_bounds_test */
1097 case GL_DEPTH_BOUNDS_TEST_EXT
:
1098 if (!_mesa_is_desktop_gl(ctx
))
1099 goto invalid_enum_error
;
1100 CHECK_EXTENSION(EXT_depth_bounds_test
);
1101 if (ctx
->Depth
.BoundsTest
== state
)
1103 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepth
? 0 : _NEW_DEPTH
);
1104 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepth
;
1105 ctx
->Depth
.BoundsTest
= state
;
1108 case GL_DEPTH_CLAMP
:
1109 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1110 !_mesa_has_EXT_depth_clamp(ctx
))
1111 goto invalid_enum_error
;
1112 if (ctx
->Transform
.DepthClampNear
== state
&&
1113 ctx
->Transform
.DepthClampFar
== state
)
1115 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1117 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1118 ctx
->Transform
.DepthClampNear
= state
;
1119 ctx
->Transform
.DepthClampFar
= state
;
1122 case GL_DEPTH_CLAMP_NEAR_AMD
:
1123 if (!_mesa_is_desktop_gl(ctx
))
1124 goto invalid_enum_error
;
1125 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1126 if (ctx
->Transform
.DepthClampNear
== state
)
1128 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1130 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1131 ctx
->Transform
.DepthClampNear
= state
;
1134 case GL_DEPTH_CLAMP_FAR_AMD
:
1135 if (!_mesa_is_desktop_gl(ctx
))
1136 goto invalid_enum_error
;
1137 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1138 if (ctx
->Transform
.DepthClampFar
== state
)
1140 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewDepthClamp
? 0 :
1142 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewDepthClamp
;
1143 ctx
->Transform
.DepthClampFar
= state
;
1146 case GL_FRAGMENT_SHADER_ATI
:
1147 if (ctx
->API
!= API_OPENGL_COMPAT
)
1148 goto invalid_enum_error
;
1149 CHECK_EXTENSION(ATI_fragment_shader
);
1150 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1152 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1153 ctx
->ATIFragmentShader
.Enabled
= state
;
1156 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1157 if (!_mesa_is_desktop_gl(ctx
))
1158 goto invalid_enum_error
;
1159 CHECK_EXTENSION(ARB_seamless_cube_map
);
1160 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1161 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1162 ctx
->Texture
.CubeMapSeamless
= state
;
1166 case GL_RASTERIZER_DISCARD
:
1167 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1168 goto invalid_enum_error
;
1169 CHECK_EXTENSION(EXT_transform_feedback
);
1170 if (ctx
->RasterDiscard
!= state
) {
1171 FLUSH_VERTICES(ctx
, 0);
1172 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
1173 ctx
->RasterDiscard
= state
;
1177 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1178 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1179 goto invalid_enum_error
;
1180 if (ctx
->TileRasterOrderFixed
!= state
) {
1181 FLUSH_VERTICES(ctx
, 0);
1182 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1183 ctx
->TileRasterOrderFixed
= state
;
1187 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1188 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1189 goto invalid_enum_error
;
1190 if (ctx
->TileRasterOrderIncreasingX
!= state
) {
1191 FLUSH_VERTICES(ctx
, 0);
1192 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1193 ctx
->TileRasterOrderIncreasingX
= state
;
1197 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1198 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1199 goto invalid_enum_error
;
1200 if (ctx
->TileRasterOrderIncreasingY
!= state
) {
1201 FLUSH_VERTICES(ctx
, 0);
1202 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewTileRasterOrder
;
1203 ctx
->TileRasterOrderIncreasingY
= state
;
1207 /* GL 3.1 primitive restart. Note: this enum is different from
1208 * GL_PRIMITIVE_RESTART_NV (which is client state).
1210 case GL_PRIMITIVE_RESTART
:
1211 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1212 goto invalid_enum_error
;
1214 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1215 FLUSH_VERTICES(ctx
, 0);
1216 ctx
->Array
.PrimitiveRestart
= state
;
1217 update_derived_primitive_restart_state(ctx
);
1221 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1222 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1223 goto invalid_enum_error
;
1224 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
1225 FLUSH_VERTICES(ctx
, 0);
1226 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
1227 update_derived_primitive_restart_state(ctx
);
1231 /* GL3.0 - GL_framebuffer_sRGB */
1232 case GL_FRAMEBUFFER_SRGB_EXT
:
1233 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1234 !_mesa_has_EXT_sRGB_write_control(ctx
))
1235 goto invalid_enum_error
;
1236 _mesa_set_framebuffer_srgb(ctx
, state
);
1239 /* GL_OES_EGL_image_external */
1240 case GL_TEXTURE_EXTERNAL_OES
:
1241 if (!_mesa_is_gles(ctx
))
1242 goto invalid_enum_error
;
1243 CHECK_EXTENSION(OES_EGL_image_external
);
1244 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1249 /* ARB_texture_multisample */
1250 case GL_SAMPLE_MASK
:
1251 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1252 goto invalid_enum_error
;
1253 if (ctx
->Multisample
.SampleMask
== state
)
1255 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewSampleMask
? 0 :
1257 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewSampleMask
;
1258 ctx
->Multisample
.SampleMask
= state
;
1261 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1262 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1263 goto invalid_enum_error
;
1264 if (ctx
->Color
.BlendCoherent
== state
)
1266 FLUSH_VERTICES(ctx
, ctx
->DriverFlags
.NewBlend
? 0 : _NEW_COLOR
);
1267 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewBlend
;
1268 ctx
->Color
.BlendCoherent
= state
;
1271 case GL_BLACKHOLE_RENDER_INTEL
:
1272 if (!_mesa_has_INTEL_blackhole_render(ctx
))
1273 goto invalid_enum_error
;
1274 if (ctx
->IntelBlackholeRender
== state
)
1276 FLUSH_VERTICES(ctx
, 0);
1277 ctx
->IntelBlackholeRender
= state
;
1281 goto invalid_enum_error
;
1284 if (ctx
->Driver
.Enable
) {
1285 ctx
->Driver
.Enable( ctx
, cap
, state
);
1291 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1292 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1297 * Enable GL capability. Called by glEnable()
1298 * \param cap state to enable.
1301 _mesa_Enable( GLenum cap
)
1303 GET_CURRENT_CONTEXT(ctx
);
1305 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1310 * Disable GL capability. Called by glDisable()
1311 * \param cap state to disable.
1314 _mesa_Disable( GLenum cap
)
1316 GET_CURRENT_CONTEXT(ctx
);
1318 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1324 * Enable/disable an indexed state var.
1327 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1328 GLuint index
, GLboolean state
)
1330 assert(state
== 0 || state
== 1);
1333 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1334 goto invalid_enum_error
;
1336 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1337 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1338 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1341 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1342 GLbitfield enabled
= ctx
->Color
.BlendEnabled
;
1345 enabled
|= (1 << index
);
1347 enabled
&= ~(1 << index
);
1349 _mesa_flush_vertices_for_blend_adv(ctx
, enabled
,
1350 ctx
->Color
._AdvancedBlendMode
);
1351 ctx
->Color
.BlendEnabled
= enabled
;
1354 case GL_SCISSOR_TEST
:
1355 if (index
>= ctx
->Const
.MaxViewports
) {
1356 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1357 state
? "glEnablei" : "glDisablei", index
);
1360 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1362 ctx
->DriverFlags
.NewScissorTest
? 0 : _NEW_SCISSOR
);
1363 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewScissorTest
;
1365 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1367 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1370 /* EXT_direct_state_access */
1374 case GL_TEXTURE_CUBE_MAP
:
1375 case GL_TEXTURE_GEN_S
:
1376 case GL_TEXTURE_GEN_T
:
1377 case GL_TEXTURE_GEN_R
:
1378 case GL_TEXTURE_GEN_Q
:
1379 case GL_TEXTURE_RECTANGLE_ARB
: {
1380 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1381 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1382 ctx
->Const
.MaxTextureCoordUnits
)) {
1383 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1384 state
? "glEnablei" : "glDisablei", index
);
1387 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1388 _mesa_set_enable( ctx
, cap
, state
);
1389 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1393 goto invalid_enum_error
;
1398 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1399 state
? "glEnablei" : "glDisablei",
1400 _mesa_enum_to_string(cap
));
1405 _mesa_Disablei( GLenum cap
, GLuint index
)
1407 GET_CURRENT_CONTEXT(ctx
);
1408 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1413 _mesa_Enablei( GLenum cap
, GLuint index
)
1415 GET_CURRENT_CONTEXT(ctx
);
1416 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1420 GLboolean GLAPIENTRY
1421 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1423 GET_CURRENT_CONTEXT(ctx
);
1424 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1427 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1428 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1432 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1433 case GL_SCISSOR_TEST
:
1434 if (index
>= ctx
->Const
.MaxViewports
) {
1435 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1439 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1440 /* EXT_direct_state_access */
1444 case GL_TEXTURE_CUBE_MAP
:
1445 case GL_TEXTURE_GEN_S
:
1446 case GL_TEXTURE_GEN_T
:
1447 case GL_TEXTURE_GEN_R
:
1448 case GL_TEXTURE_GEN_Q
:
1449 case GL_TEXTURE_RECTANGLE_ARB
: {
1451 const GLuint curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
1452 if (index
>= MAX2(ctx
->Const
.MaxCombinedTextureImageUnits
,
1453 ctx
->Const
.MaxTextureCoordUnits
)) {
1454 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1458 _mesa_ActiveTexture(GL_TEXTURE0
+ index
);
1459 state
= _mesa_IsEnabled(cap
);
1460 _mesa_ActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
1464 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1465 _mesa_enum_to_string(cap
));
1473 * Helper function to determine whether a texture target is enabled.
1476 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1478 const struct gl_fixedfunc_texture_unit
*const texUnit
=
1479 _mesa_get_fixedfunc_tex_unit(ctx
, ctx
->Texture
.CurrentUnit
);
1484 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1489 * Return simple enable/disable state.
1491 * \param cap state variable to query.
1493 * Returns the state of the specified capability from the current GL context.
1494 * For the capabilities associated with extensions verifies that those
1495 * extensions are effectively present before reporting.
1497 GLboolean GLAPIENTRY
1498 _mesa_IsEnabled( GLenum cap
)
1500 GET_CURRENT_CONTEXT(ctx
);
1501 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1505 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1506 goto invalid_enum_error
;
1507 return ctx
->Color
.AlphaEnabled
;
1508 case GL_AUTO_NORMAL
:
1509 if (ctx
->API
!= API_OPENGL_COMPAT
)
1510 goto invalid_enum_error
;
1511 return ctx
->Eval
.AutoNormal
;
1513 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1514 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1515 case GL_CLIP_DISTANCE1
:
1516 case GL_CLIP_DISTANCE2
:
1517 case GL_CLIP_DISTANCE3
:
1518 case GL_CLIP_DISTANCE4
:
1519 case GL_CLIP_DISTANCE5
:
1520 case GL_CLIP_DISTANCE6
:
1521 case GL_CLIP_DISTANCE7
: {
1522 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1524 if (p
>= ctx
->Const
.MaxClipPlanes
)
1525 goto invalid_enum_error
;
1527 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1529 case GL_COLOR_MATERIAL
:
1530 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1531 goto invalid_enum_error
;
1532 return ctx
->Light
.ColorMaterialEnabled
;
1534 return ctx
->Polygon
.CullFlag
;
1535 case GL_DEBUG_OUTPUT
:
1536 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1537 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1539 return ctx
->Depth
.Test
;
1541 return ctx
->Color
.DitherFlag
;
1543 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1544 goto invalid_enum_error
;
1545 return ctx
->Fog
.Enabled
;
1547 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1548 goto invalid_enum_error
;
1549 return ctx
->Light
.Enabled
;
1558 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1559 goto invalid_enum_error
;
1560 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1561 case GL_LINE_SMOOTH
:
1562 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1563 goto invalid_enum_error
;
1564 return ctx
->Line
.SmoothFlag
;
1565 case GL_LINE_STIPPLE
:
1566 if (ctx
->API
!= API_OPENGL_COMPAT
)
1567 goto invalid_enum_error
;
1568 return ctx
->Line
.StippleFlag
;
1569 case GL_INDEX_LOGIC_OP
:
1570 if (ctx
->API
!= API_OPENGL_COMPAT
)
1571 goto invalid_enum_error
;
1572 return ctx
->Color
.IndexLogicOpEnabled
;
1573 case GL_COLOR_LOGIC_OP
:
1574 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1575 goto invalid_enum_error
;
1576 return ctx
->Color
.ColorLogicOpEnabled
;
1577 case GL_MAP1_COLOR_4
:
1578 if (ctx
->API
!= API_OPENGL_COMPAT
)
1579 goto invalid_enum_error
;
1580 return ctx
->Eval
.Map1Color4
;
1582 if (ctx
->API
!= API_OPENGL_COMPAT
)
1583 goto invalid_enum_error
;
1584 return ctx
->Eval
.Map1Index
;
1585 case GL_MAP1_NORMAL
:
1586 if (ctx
->API
!= API_OPENGL_COMPAT
)
1587 goto invalid_enum_error
;
1588 return ctx
->Eval
.Map1Normal
;
1589 case GL_MAP1_TEXTURE_COORD_1
:
1590 if (ctx
->API
!= API_OPENGL_COMPAT
)
1591 goto invalid_enum_error
;
1592 return ctx
->Eval
.Map1TextureCoord1
;
1593 case GL_MAP1_TEXTURE_COORD_2
:
1594 if (ctx
->API
!= API_OPENGL_COMPAT
)
1595 goto invalid_enum_error
;
1596 return ctx
->Eval
.Map1TextureCoord2
;
1597 case GL_MAP1_TEXTURE_COORD_3
:
1598 if (ctx
->API
!= API_OPENGL_COMPAT
)
1599 goto invalid_enum_error
;
1600 return ctx
->Eval
.Map1TextureCoord3
;
1601 case GL_MAP1_TEXTURE_COORD_4
:
1602 if (ctx
->API
!= API_OPENGL_COMPAT
)
1603 goto invalid_enum_error
;
1604 return ctx
->Eval
.Map1TextureCoord4
;
1605 case GL_MAP1_VERTEX_3
:
1606 if (ctx
->API
!= API_OPENGL_COMPAT
)
1607 goto invalid_enum_error
;
1608 return ctx
->Eval
.Map1Vertex3
;
1609 case GL_MAP1_VERTEX_4
:
1610 if (ctx
->API
!= API_OPENGL_COMPAT
)
1611 goto invalid_enum_error
;
1612 return ctx
->Eval
.Map1Vertex4
;
1613 case GL_MAP2_COLOR_4
:
1614 if (ctx
->API
!= API_OPENGL_COMPAT
)
1615 goto invalid_enum_error
;
1616 return ctx
->Eval
.Map2Color4
;
1618 if (ctx
->API
!= API_OPENGL_COMPAT
)
1619 goto invalid_enum_error
;
1620 return ctx
->Eval
.Map2Index
;
1621 case GL_MAP2_NORMAL
:
1622 if (ctx
->API
!= API_OPENGL_COMPAT
)
1623 goto invalid_enum_error
;
1624 return ctx
->Eval
.Map2Normal
;
1625 case GL_MAP2_TEXTURE_COORD_1
:
1626 if (ctx
->API
!= API_OPENGL_COMPAT
)
1627 goto invalid_enum_error
;
1628 return ctx
->Eval
.Map2TextureCoord1
;
1629 case GL_MAP2_TEXTURE_COORD_2
:
1630 if (ctx
->API
!= API_OPENGL_COMPAT
)
1631 goto invalid_enum_error
;
1632 return ctx
->Eval
.Map2TextureCoord2
;
1633 case GL_MAP2_TEXTURE_COORD_3
:
1634 if (ctx
->API
!= API_OPENGL_COMPAT
)
1635 goto invalid_enum_error
;
1636 return ctx
->Eval
.Map2TextureCoord3
;
1637 case GL_MAP2_TEXTURE_COORD_4
:
1638 if (ctx
->API
!= API_OPENGL_COMPAT
)
1639 goto invalid_enum_error
;
1640 return ctx
->Eval
.Map2TextureCoord4
;
1641 case GL_MAP2_VERTEX_3
:
1642 if (ctx
->API
!= API_OPENGL_COMPAT
)
1643 goto invalid_enum_error
;
1644 return ctx
->Eval
.Map2Vertex3
;
1645 case GL_MAP2_VERTEX_4
:
1646 if (ctx
->API
!= API_OPENGL_COMPAT
)
1647 goto invalid_enum_error
;
1648 return ctx
->Eval
.Map2Vertex4
;
1650 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1651 goto invalid_enum_error
;
1652 return ctx
->Transform
.Normalize
;
1653 case GL_POINT_SMOOTH
:
1654 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1655 goto invalid_enum_error
;
1656 return ctx
->Point
.SmoothFlag
;
1657 case GL_POLYGON_SMOOTH
:
1658 if (!_mesa_is_desktop_gl(ctx
))
1659 goto invalid_enum_error
;
1660 return ctx
->Polygon
.SmoothFlag
;
1661 case GL_POLYGON_STIPPLE
:
1662 if (ctx
->API
!= API_OPENGL_COMPAT
)
1663 goto invalid_enum_error
;
1664 return ctx
->Polygon
.StippleFlag
;
1665 case GL_POLYGON_OFFSET_POINT
:
1666 if (!_mesa_is_desktop_gl(ctx
))
1667 goto invalid_enum_error
;
1668 return ctx
->Polygon
.OffsetPoint
;
1669 case GL_POLYGON_OFFSET_LINE
:
1670 if (!_mesa_is_desktop_gl(ctx
))
1671 goto invalid_enum_error
;
1672 return ctx
->Polygon
.OffsetLine
;
1673 case GL_POLYGON_OFFSET_FILL
:
1674 return ctx
->Polygon
.OffsetFill
;
1675 case GL_RESCALE_NORMAL_EXT
:
1676 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1677 goto invalid_enum_error
;
1678 return ctx
->Transform
.RescaleNormals
;
1679 case GL_SCISSOR_TEST
:
1680 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1681 case GL_STENCIL_TEST
:
1682 return ctx
->Stencil
.Enabled
;
1684 if (ctx
->API
!= API_OPENGL_COMPAT
)
1685 goto invalid_enum_error
;
1686 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1688 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1689 goto invalid_enum_error
;
1690 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1692 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1693 goto invalid_enum_error
;
1694 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1695 case GL_TEXTURE_GEN_S
:
1696 case GL_TEXTURE_GEN_T
:
1697 case GL_TEXTURE_GEN_R
:
1698 case GL_TEXTURE_GEN_Q
:
1700 const struct gl_fixedfunc_texture_unit
*texUnit
=
1701 get_texcoord_unit(ctx
);
1703 if (ctx
->API
!= API_OPENGL_COMPAT
)
1704 goto invalid_enum_error
;
1707 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1708 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1712 case GL_TEXTURE_GEN_STR_OES
:
1714 const struct gl_fixedfunc_texture_unit
*texUnit
=
1715 get_texcoord_unit(ctx
);
1717 if (ctx
->API
!= API_OPENGLES
)
1718 goto invalid_enum_error
;
1721 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1722 ? GL_TRUE
: GL_FALSE
;
1726 /* client-side state */
1727 case GL_VERTEX_ARRAY
:
1728 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1729 goto invalid_enum_error
;
1730 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
1731 case GL_NORMAL_ARRAY
:
1732 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1733 goto invalid_enum_error
;
1734 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
1735 case GL_COLOR_ARRAY
:
1736 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1737 goto invalid_enum_error
;
1738 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
1739 case GL_INDEX_ARRAY
:
1740 if (ctx
->API
!= API_OPENGL_COMPAT
)
1741 goto invalid_enum_error
;
1742 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
1743 case GL_TEXTURE_COORD_ARRAY
:
1744 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1745 goto invalid_enum_error
;
1746 return !!(ctx
->Array
.VAO
->Enabled
&
1747 VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
1748 case GL_EDGE_FLAG_ARRAY
:
1749 if (ctx
->API
!= API_OPENGL_COMPAT
)
1750 goto invalid_enum_error
;
1751 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
1752 case GL_FOG_COORDINATE_ARRAY_EXT
:
1753 if (ctx
->API
!= API_OPENGL_COMPAT
)
1754 goto invalid_enum_error
;
1755 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
1756 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1757 if (ctx
->API
!= API_OPENGL_COMPAT
)
1758 goto invalid_enum_error
;
1759 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
1760 case GL_POINT_SIZE_ARRAY_OES
:
1761 if (ctx
->API
!= API_OPENGLES
)
1762 goto invalid_enum_error
;
1763 return !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
1765 /* GL_ARB_texture_cube_map */
1766 case GL_TEXTURE_CUBE_MAP
:
1767 if (!_mesa_has_ARB_texture_cube_map(ctx
) &&
1768 !_mesa_has_OES_texture_cube_map(ctx
))
1769 goto invalid_enum_error
;
1770 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1772 /* GL_EXT_secondary_color */
1773 case GL_COLOR_SUM_EXT
:
1774 if (ctx
->API
!= API_OPENGL_COMPAT
)
1775 goto invalid_enum_error
;
1776 return ctx
->Fog
.ColorSumEnabled
;
1778 /* GL_ARB_multisample */
1779 case GL_MULTISAMPLE_ARB
:
1780 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1781 goto invalid_enum_error
;
1782 return ctx
->Multisample
.Enabled
;
1783 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1784 return ctx
->Multisample
.SampleAlphaToCoverage
;
1785 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1786 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1787 goto invalid_enum_error
;
1788 return ctx
->Multisample
.SampleAlphaToOne
;
1789 case GL_SAMPLE_COVERAGE_ARB
:
1790 return ctx
->Multisample
.SampleCoverage
;
1791 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1792 if (!_mesa_is_desktop_gl(ctx
))
1793 goto invalid_enum_error
;
1794 return ctx
->Multisample
.SampleCoverageInvert
;
1796 /* GL_IBM_rasterpos_clip */
1797 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1798 if (ctx
->API
!= API_OPENGL_COMPAT
)
1799 goto invalid_enum_error
;
1800 return ctx
->Transform
.RasterPositionUnclipped
;
1802 /* GL_NV_point_sprite */
1803 case GL_POINT_SPRITE_NV
:
1804 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1805 goto invalid_enum_error
;
1806 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1807 return ctx
->Point
.PointSprite
;
1809 case GL_VERTEX_PROGRAM_ARB
:
1810 if (ctx
->API
!= API_OPENGL_COMPAT
)
1811 goto invalid_enum_error
;
1812 CHECK_EXTENSION(ARB_vertex_program
);
1813 return ctx
->VertexProgram
.Enabled
;
1814 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1815 /* This was added with ARB_vertex_program, but it is also used with
1816 * GLSL vertex shaders on desktop.
1818 if (!_mesa_is_desktop_gl(ctx
))
1819 goto invalid_enum_error
;
1820 CHECK_EXTENSION(ARB_vertex_program
);
1821 return ctx
->VertexProgram
.PointSizeEnabled
;
1822 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1823 if (ctx
->API
!= API_OPENGL_COMPAT
)
1824 goto invalid_enum_error
;
1825 CHECK_EXTENSION(ARB_vertex_program
);
1826 return ctx
->VertexProgram
.TwoSideEnabled
;
1828 /* GL_NV_texture_rectangle */
1829 case GL_TEXTURE_RECTANGLE_NV
:
1830 if (ctx
->API
!= API_OPENGL_COMPAT
)
1831 goto invalid_enum_error
;
1832 CHECK_EXTENSION(NV_texture_rectangle
);
1833 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1835 /* GL_EXT_stencil_two_side */
1836 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1837 if (ctx
->API
!= API_OPENGL_COMPAT
)
1838 goto invalid_enum_error
;
1839 CHECK_EXTENSION(EXT_stencil_two_side
);
1840 return ctx
->Stencil
.TestTwoSide
;
1842 case GL_FRAGMENT_PROGRAM_ARB
:
1843 if (!_mesa_has_ARB_fragment_program(ctx
))
1844 goto invalid_enum_error
;
1845 return ctx
->FragmentProgram
.Enabled
;
1847 /* GL_EXT_depth_bounds_test */
1848 case GL_DEPTH_BOUNDS_TEST_EXT
:
1849 if (!_mesa_is_desktop_gl(ctx
))
1850 goto invalid_enum_error
;
1851 CHECK_EXTENSION(EXT_depth_bounds_test
);
1852 return ctx
->Depth
.BoundsTest
;
1854 /* GL_ARB_depth_clamp */
1855 case GL_DEPTH_CLAMP
:
1856 if (!_mesa_has_ARB_depth_clamp(ctx
) &&
1857 !_mesa_has_EXT_depth_clamp(ctx
))
1858 goto invalid_enum_error
;
1859 return ctx
->Transform
.DepthClampNear
||
1860 ctx
->Transform
.DepthClampFar
;
1862 case GL_DEPTH_CLAMP_NEAR_AMD
:
1863 if (!_mesa_is_desktop_gl(ctx
))
1864 goto invalid_enum_error
;
1865 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1866 return ctx
->Transform
.DepthClampNear
;
1868 case GL_DEPTH_CLAMP_FAR_AMD
:
1869 if (!_mesa_is_desktop_gl(ctx
))
1870 goto invalid_enum_error
;
1871 CHECK_EXTENSION(AMD_depth_clamp_separate
);
1872 return ctx
->Transform
.DepthClampFar
;
1874 case GL_FRAGMENT_SHADER_ATI
:
1875 if (ctx
->API
!= API_OPENGL_COMPAT
)
1876 goto invalid_enum_error
;
1877 CHECK_EXTENSION(ATI_fragment_shader
);
1878 return ctx
->ATIFragmentShader
.Enabled
;
1880 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1881 if (!_mesa_is_desktop_gl(ctx
))
1882 goto invalid_enum_error
;
1883 CHECK_EXTENSION(ARB_seamless_cube_map
);
1884 return ctx
->Texture
.CubeMapSeamless
;
1886 case GL_RASTERIZER_DISCARD
:
1887 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1888 goto invalid_enum_error
;
1889 CHECK_EXTENSION(EXT_transform_feedback
);
1890 return ctx
->RasterDiscard
;
1892 /* GL_NV_primitive_restart */
1893 case GL_PRIMITIVE_RESTART_NV
:
1894 if (!_mesa_has_NV_primitive_restart(ctx
))
1895 goto invalid_enum_error
;
1896 return ctx
->Array
.PrimitiveRestart
;
1898 /* GL 3.1 primitive restart */
1899 case GL_PRIMITIVE_RESTART
:
1900 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1901 goto invalid_enum_error
;
1903 return ctx
->Array
.PrimitiveRestart
;
1905 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1906 if (!_mesa_is_gles3(ctx
) && !_mesa_has_ARB_ES3_compatibility(ctx
))
1907 goto invalid_enum_error
;
1908 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1910 /* GL3.0 - GL_framebuffer_sRGB */
1911 case GL_FRAMEBUFFER_SRGB_EXT
:
1912 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) &&
1913 !_mesa_has_EXT_sRGB_write_control(ctx
))
1914 goto invalid_enum_error
;
1915 return ctx
->Color
.sRGBEnabled
;
1917 /* GL_OES_EGL_image_external */
1918 case GL_TEXTURE_EXTERNAL_OES
:
1919 if (!_mesa_is_gles(ctx
))
1920 goto invalid_enum_error
;
1921 CHECK_EXTENSION(OES_EGL_image_external
);
1922 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1924 /* ARB_texture_multisample */
1925 case GL_SAMPLE_MASK
:
1926 if (!_mesa_has_ARB_texture_multisample(ctx
) && !_mesa_is_gles31(ctx
))
1927 goto invalid_enum_error
;
1928 return ctx
->Multisample
.SampleMask
;
1930 /* ARB_sample_shading */
1931 case GL_SAMPLE_SHADING
:
1932 if (!_mesa_has_ARB_sample_shading(ctx
) && !_mesa_is_gles3(ctx
))
1933 goto invalid_enum_error
;
1934 return ctx
->Multisample
.SampleShading
;
1936 case GL_BLEND_ADVANCED_COHERENT_KHR
:
1937 if (!_mesa_has_KHR_blend_equation_advanced_coherent(ctx
))
1938 goto invalid_enum_error
;
1939 return ctx
->Color
.BlendCoherent
;
1941 case GL_CONSERVATIVE_RASTERIZATION_INTEL
:
1942 if (!_mesa_has_INTEL_conservative_rasterization(ctx
))
1943 goto invalid_enum_error
;
1944 return ctx
->IntelConservativeRasterization
;
1946 case GL_CONSERVATIVE_RASTERIZATION_NV
:
1947 if (!_mesa_has_NV_conservative_raster(ctx
))
1948 goto invalid_enum_error
;
1949 return ctx
->ConservativeRasterization
;
1951 case GL_TILE_RASTER_ORDER_FIXED_MESA
:
1952 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1953 goto invalid_enum_error
;
1954 return ctx
->TileRasterOrderFixed
;
1956 case GL_TILE_RASTER_ORDER_INCREASING_X_MESA
:
1957 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1958 goto invalid_enum_error
;
1959 return ctx
->TileRasterOrderIncreasingX
;
1961 case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA
:
1962 if (!_mesa_has_MESA_tile_raster_order(ctx
))
1963 goto invalid_enum_error
;
1964 return ctx
->TileRasterOrderIncreasingY
;
1966 case GL_BLACKHOLE_RENDER_INTEL
:
1967 CHECK_EXTENSION(INTEL_blackhole_render
);
1968 return ctx
->IntelBlackholeRender
;
1971 goto invalid_enum_error
;
1977 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1978 _mesa_enum_to_string(cap
));