enable.c revision af69d88d
17117f1b4Smrg/** 27117f1b4Smrg * \file enable.c 37117f1b4Smrg * Enable/disable/query GL capabilities. 47117f1b4Smrg */ 57117f1b4Smrg 67117f1b4Smrg/* 77117f1b4Smrg * Mesa 3-D graphics library 87117f1b4Smrg * 97117f1b4Smrg * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 107117f1b4Smrg * 117117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 127117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 137117f1b4Smrg * to deal in the Software without restriction, including without limitation 147117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 157117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 167117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 177117f1b4Smrg * 187117f1b4Smrg * The above copyright notice and this permission notice shall be included 197117f1b4Smrg * in all copies or substantial portions of the Software. 207117f1b4Smrg * 217117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 227117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 237117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 287117f1b4Smrg */ 297117f1b4Smrg 307117f1b4Smrg 317117f1b4Smrg#include "glheader.h" 323464ebd5Sriastradh#include "clip.h" 337117f1b4Smrg#include "context.h" 347117f1b4Smrg#include "enable.h" 35af69d88dSmrg#include "errors.h" 367117f1b4Smrg#include "light.h" 377117f1b4Smrg#include "simple_list.h" 387117f1b4Smrg#include "mtypes.h" 397117f1b4Smrg#include "enums.h" 40c1f859d4Smrg#include "api_arrayelt.h" 414a49301eSmrg#include "texstate.h" 42af69d88dSmrg#include "drivers/common/meta.h" 437117f1b4Smrg 447117f1b4Smrg 457117f1b4Smrg 467117f1b4Smrg#define CHECK_EXTENSION(EXTNAME, CAP) \ 477117f1b4Smrg if (!ctx->Extensions.EXTNAME) { \ 483464ebd5Sriastradh goto invalid_enum_error; \ 497117f1b4Smrg } 507117f1b4Smrg 517117f1b4Smrg 52af69d88dSmrgstatic void 53af69d88dSmrgupdate_derived_primitive_restart_state(struct gl_context *ctx) 54af69d88dSmrg{ 55af69d88dSmrg /* Update derived primitive restart state. 56af69d88dSmrg */ 57af69d88dSmrg ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart 58af69d88dSmrg || ctx->Array.PrimitiveRestartFixedIndex; 59af69d88dSmrg} 60af69d88dSmrg 617117f1b4Smrg/** 627117f1b4Smrg * Helper to enable/disable client-side state. 637117f1b4Smrg */ 647117f1b4Smrgstatic void 653464ebd5Sriastradhclient_state(struct gl_context *ctx, GLenum cap, GLboolean state) 667117f1b4Smrg{ 67af69d88dSmrg struct gl_vertex_array_object *vao = ctx->Array.VAO; 68af69d88dSmrg GLbitfield64 flag; 697117f1b4Smrg GLboolean *var; 707117f1b4Smrg 717117f1b4Smrg switch (cap) { 727117f1b4Smrg case GL_VERTEX_ARRAY: 73af69d88dSmrg var = &vao->VertexAttrib[VERT_ATTRIB_POS].Enabled; 74af69d88dSmrg flag = VERT_BIT_POS; 757117f1b4Smrg break; 767117f1b4Smrg case GL_NORMAL_ARRAY: 77af69d88dSmrg var = &vao->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled; 78af69d88dSmrg flag = VERT_BIT_NORMAL; 797117f1b4Smrg break; 807117f1b4Smrg case GL_COLOR_ARRAY: 81af69d88dSmrg var = &vao->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled; 82af69d88dSmrg flag = VERT_BIT_COLOR0; 837117f1b4Smrg break; 847117f1b4Smrg case GL_INDEX_ARRAY: 85af69d88dSmrg var = &vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled; 86af69d88dSmrg flag = VERT_BIT_COLOR_INDEX; 877117f1b4Smrg break; 887117f1b4Smrg case GL_TEXTURE_COORD_ARRAY: 89af69d88dSmrg var = &vao->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled; 90af69d88dSmrg flag = VERT_BIT_TEX(ctx->Array.ActiveTexture); 917117f1b4Smrg break; 927117f1b4Smrg case GL_EDGE_FLAG_ARRAY: 93af69d88dSmrg var = &vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled; 94af69d88dSmrg flag = VERT_BIT_EDGEFLAG; 957117f1b4Smrg break; 967117f1b4Smrg case GL_FOG_COORDINATE_ARRAY_EXT: 97af69d88dSmrg var = &vao->VertexAttrib[VERT_ATTRIB_FOG].Enabled; 98af69d88dSmrg flag = VERT_BIT_FOG; 997117f1b4Smrg break; 1007117f1b4Smrg case GL_SECONDARY_COLOR_ARRAY_EXT: 101af69d88dSmrg var = &vao->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled; 102af69d88dSmrg flag = VERT_BIT_COLOR1; 1037117f1b4Smrg break; 1047117f1b4Smrg 105c1f859d4Smrg case GL_POINT_SIZE_ARRAY_OES: 106af69d88dSmrg var = &vao->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled; 107af69d88dSmrg flag = VERT_BIT_POINT_SIZE; 1087117f1b4Smrg break; 1097117f1b4Smrg 1103464ebd5Sriastradh /* GL_NV_primitive_restart */ 1113464ebd5Sriastradh case GL_PRIMITIVE_RESTART_NV: 1123464ebd5Sriastradh if (!ctx->Extensions.NV_primitive_restart) { 1133464ebd5Sriastradh goto invalid_enum_error; 1143464ebd5Sriastradh } 1153464ebd5Sriastradh var = &ctx->Array.PrimitiveRestart; 1163464ebd5Sriastradh flag = 0; 1173464ebd5Sriastradh break; 1183464ebd5Sriastradh 1197117f1b4Smrg default: 1203464ebd5Sriastradh goto invalid_enum_error; 1217117f1b4Smrg } 1227117f1b4Smrg 1237117f1b4Smrg if (*var == state) 1247117f1b4Smrg return; 1257117f1b4Smrg 1267117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_ARRAY); 127c1f859d4Smrg 128c1f859d4Smrg _ae_invalidate_state(ctx, _NEW_ARRAY); 129c1f859d4Smrg 1307117f1b4Smrg *var = state; 1317117f1b4Smrg 132af69d88dSmrg update_derived_primitive_restart_state(ctx); 133af69d88dSmrg 1347117f1b4Smrg if (state) 135af69d88dSmrg vao->_Enabled |= flag; 1367117f1b4Smrg else 137af69d88dSmrg vao->_Enabled &= ~flag; 138af69d88dSmrg 139af69d88dSmrg vao->NewArrays |= flag; 1407117f1b4Smrg 1417117f1b4Smrg if (ctx->Driver.Enable) { 1427117f1b4Smrg ctx->Driver.Enable( ctx, cap, state ); 1437117f1b4Smrg } 1443464ebd5Sriastradh 1453464ebd5Sriastradh return; 1463464ebd5Sriastradh 1473464ebd5Sriastradhinvalid_enum_error: 148af69d88dSmrg _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(%s)", 149af69d88dSmrg state ? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap)); 1507117f1b4Smrg} 1517117f1b4Smrg 1527117f1b4Smrg 1537117f1b4Smrg/** 1547117f1b4Smrg * Enable GL capability. 1557117f1b4Smrg * \param cap state to enable/disable. 1567117f1b4Smrg * 1577117f1b4Smrg * Get's the current context, assures that we're outside glBegin()/glEnd() and 1587117f1b4Smrg * calls client_state(). 1597117f1b4Smrg */ 1607117f1b4Smrgvoid GLAPIENTRY 1617117f1b4Smrg_mesa_EnableClientState( GLenum cap ) 1627117f1b4Smrg{ 1637117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 1647117f1b4Smrg client_state( ctx, cap, GL_TRUE ); 1657117f1b4Smrg} 1667117f1b4Smrg 1677117f1b4Smrg 1687117f1b4Smrg/** 1697117f1b4Smrg * Disable GL capability. 1707117f1b4Smrg * \param cap state to enable/disable. 1717117f1b4Smrg * 1727117f1b4Smrg * Get's the current context, assures that we're outside glBegin()/glEnd() and 1737117f1b4Smrg * calls client_state(). 1747117f1b4Smrg */ 1757117f1b4Smrgvoid GLAPIENTRY 1767117f1b4Smrg_mesa_DisableClientState( GLenum cap ) 1777117f1b4Smrg{ 1787117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 1797117f1b4Smrg client_state( ctx, cap, GL_FALSE ); 1807117f1b4Smrg} 1817117f1b4Smrg 1827117f1b4Smrg 1837117f1b4Smrg#undef CHECK_EXTENSION 1847117f1b4Smrg#define CHECK_EXTENSION(EXTNAME, CAP) \ 1857117f1b4Smrg if (!ctx->Extensions.EXTNAME) { \ 1863464ebd5Sriastradh goto invalid_enum_error; \ 1877117f1b4Smrg } 1887117f1b4Smrg 1897117f1b4Smrg#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ 1907117f1b4Smrg if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ 1913464ebd5Sriastradh goto invalid_enum_error; \ 1927117f1b4Smrg } 1937117f1b4Smrg 194c1f859d4Smrg/** 195c1f859d4Smrg * Return pointer to current texture unit for setting/getting coordinate 196c1f859d4Smrg * state. 1973464ebd5Sriastradh * Note that we'll set GL_INVALID_OPERATION and return NULL if the active 1983464ebd5Sriastradh * texture unit is higher than the number of supported coordinate units. 199c1f859d4Smrg */ 200c1f859d4Smrgstatic struct gl_texture_unit * 2013464ebd5Sriastradhget_texcoord_unit(struct gl_context *ctx) 202c1f859d4Smrg{ 203c1f859d4Smrg if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { 204c1f859d4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)"); 205c1f859d4Smrg return NULL; 206c1f859d4Smrg } 207c1f859d4Smrg else { 208c1f859d4Smrg return &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; 209c1f859d4Smrg } 210c1f859d4Smrg} 211c1f859d4Smrg 212c1f859d4Smrg 2137117f1b4Smrg/** 2147117f1b4Smrg * Helper function to enable or disable a texture target. 2154a49301eSmrg * \param bit one of the TEXTURE_x_BIT values 2164a49301eSmrg * \return GL_TRUE if state is changing or GL_FALSE if no change 2177117f1b4Smrg */ 2187117f1b4Smrgstatic GLboolean 2193464ebd5Sriastradhenable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit) 2207117f1b4Smrg{ 2214a49301eSmrg struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); 2224a49301eSmrg const GLbitfield newenabled = state 2234a49301eSmrg ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit); 2247117f1b4Smrg 2254a49301eSmrg if (texUnit->Enabled == newenabled) 2267117f1b4Smrg return GL_FALSE; 2277117f1b4Smrg 2287117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 2297117f1b4Smrg texUnit->Enabled = newenabled; 2307117f1b4Smrg return GL_TRUE; 2317117f1b4Smrg} 2327117f1b4Smrg 2337117f1b4Smrg 234af69d88dSmrg/** 235af69d88dSmrg * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for 236af69d88dSmrg * whether the API supports it (GLES doesn't). 237af69d88dSmrg */ 238af69d88dSmrgvoid 239af69d88dSmrg_mesa_set_multisample(struct gl_context *ctx, GLboolean state) 240af69d88dSmrg{ 241af69d88dSmrg if (ctx->Multisample.Enabled == state) 242af69d88dSmrg return; 243af69d88dSmrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 244af69d88dSmrg ctx->Multisample.Enabled = state; 245af69d88dSmrg 246af69d88dSmrg if (ctx->Driver.Enable) { 247af69d88dSmrg ctx->Driver.Enable(ctx, GL_MULTISAMPLE, state); 248af69d88dSmrg } 249af69d88dSmrg} 250af69d88dSmrg 251af69d88dSmrg/** 252af69d88dSmrg * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the 253af69d88dSmrg * check for whether the API supports it (GLES doesn't). 254af69d88dSmrg */ 255af69d88dSmrgvoid 256af69d88dSmrg_mesa_set_framebuffer_srgb(struct gl_context *ctx, GLboolean state) 257af69d88dSmrg{ 258af69d88dSmrg if (ctx->Color.sRGBEnabled == state) 259af69d88dSmrg return; 260af69d88dSmrg FLUSH_VERTICES(ctx, _NEW_BUFFERS); 261af69d88dSmrg ctx->Color.sRGBEnabled = state; 262af69d88dSmrg 263af69d88dSmrg if (ctx->Driver.Enable) { 264af69d88dSmrg ctx->Driver.Enable(ctx, GL_FRAMEBUFFER_SRGB, state); 265af69d88dSmrg } 266af69d88dSmrg} 267af69d88dSmrg 2687117f1b4Smrg/** 2697117f1b4Smrg * Helper function to enable or disable state. 2707117f1b4Smrg * 2717117f1b4Smrg * \param ctx GL context. 2727117f1b4Smrg * \param cap the state to enable/disable 2737117f1b4Smrg * \param state whether to enable or disable the specified capability. 2747117f1b4Smrg * 2757117f1b4Smrg * Updates the current context and flushes the vertices as needed. For 2767117f1b4Smrg * capabilities associated with extensions it verifies that those extensions 2777117f1b4Smrg * are effectivly present before updating. Notifies the driver via 2787117f1b4Smrg * dd_function_table::Enable. 2797117f1b4Smrg */ 2807117f1b4Smrgvoid 2813464ebd5Sriastradh_mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) 2827117f1b4Smrg{ 2837117f1b4Smrg if (MESA_VERBOSE & VERBOSE_API) 2847117f1b4Smrg _mesa_debug(ctx, "%s %s (newstate is %x)\n", 2857117f1b4Smrg state ? "glEnable" : "glDisable", 2867117f1b4Smrg _mesa_lookup_enum_by_nr(cap), 2877117f1b4Smrg ctx->NewState); 2887117f1b4Smrg 2897117f1b4Smrg switch (cap) { 2907117f1b4Smrg case GL_ALPHA_TEST: 291af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 292af69d88dSmrg goto invalid_enum_error; 2937117f1b4Smrg if (ctx->Color.AlphaEnabled == state) 2947117f1b4Smrg return; 2957117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 2967117f1b4Smrg ctx->Color.AlphaEnabled = state; 2977117f1b4Smrg break; 2987117f1b4Smrg case GL_AUTO_NORMAL: 299af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 300af69d88dSmrg goto invalid_enum_error; 3017117f1b4Smrg if (ctx->Eval.AutoNormal == state) 3027117f1b4Smrg return; 3037117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 3047117f1b4Smrg ctx->Eval.AutoNormal = state; 3057117f1b4Smrg break; 3067117f1b4Smrg case GL_BLEND: 307cdc920a0Smrg { 3083464ebd5Sriastradh GLbitfield newEnabled = 3093464ebd5Sriastradh state * ((1 << ctx->Const.MaxDrawBuffers) - 1); 310cdc920a0Smrg if (newEnabled != ctx->Color.BlendEnabled) { 311cdc920a0Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 312cdc920a0Smrg ctx->Color.BlendEnabled = newEnabled; 313cdc920a0Smrg } 314cdc920a0Smrg } 3157117f1b4Smrg break; 316af69d88dSmrg case GL_CLIP_DISTANCE0: /* aka GL_CLIP_PLANE0 */ 317af69d88dSmrg case GL_CLIP_DISTANCE1: 318af69d88dSmrg case GL_CLIP_DISTANCE2: 319af69d88dSmrg case GL_CLIP_DISTANCE3: 320af69d88dSmrg case GL_CLIP_DISTANCE4: 321af69d88dSmrg case GL_CLIP_DISTANCE5: 322af69d88dSmrg case GL_CLIP_DISTANCE6: 323af69d88dSmrg case GL_CLIP_DISTANCE7: 3247117f1b4Smrg { 325af69d88dSmrg const GLuint p = cap - GL_CLIP_DISTANCE0; 326af69d88dSmrg 327af69d88dSmrg if (p >= ctx->Const.MaxClipPlanes) 328af69d88dSmrg goto invalid_enum_error; 3297117f1b4Smrg 3303464ebd5Sriastradh if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) 3313464ebd5Sriastradh == ((GLuint) state << p)) 3327117f1b4Smrg return; 3337117f1b4Smrg 3347117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 3357117f1b4Smrg 3367117f1b4Smrg if (state) { 3377117f1b4Smrg ctx->Transform.ClipPlanesEnabled |= (1 << p); 3383464ebd5Sriastradh _mesa_update_clip_plane(ctx, p); 3397117f1b4Smrg } 3407117f1b4Smrg else { 3417117f1b4Smrg ctx->Transform.ClipPlanesEnabled &= ~(1 << p); 3427117f1b4Smrg } 3437117f1b4Smrg } 3447117f1b4Smrg break; 3457117f1b4Smrg case GL_COLOR_MATERIAL: 346af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 347af69d88dSmrg goto invalid_enum_error; 3487117f1b4Smrg if (ctx->Light.ColorMaterialEnabled == state) 3497117f1b4Smrg return; 3507117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LIGHT); 3517117f1b4Smrg FLUSH_CURRENT(ctx, 0); 3527117f1b4Smrg ctx->Light.ColorMaterialEnabled = state; 3537117f1b4Smrg if (state) { 3547117f1b4Smrg _mesa_update_color_material( ctx, 3557117f1b4Smrg ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); 3567117f1b4Smrg } 3577117f1b4Smrg break; 3587117f1b4Smrg case GL_CULL_FACE: 3597117f1b4Smrg if (ctx->Polygon.CullFlag == state) 3607117f1b4Smrg return; 3617117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 3627117f1b4Smrg ctx->Polygon.CullFlag = state; 3637117f1b4Smrg break; 3647117f1b4Smrg case GL_DEPTH_TEST: 3657117f1b4Smrg if (ctx->Depth.Test == state) 3667117f1b4Smrg return; 3677117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_DEPTH); 3687117f1b4Smrg ctx->Depth.Test = state; 3697117f1b4Smrg break; 370af69d88dSmrg case GL_DEBUG_OUTPUT: 371af69d88dSmrg case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB: 372af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 373af69d88dSmrg goto invalid_enum_error; 374af69d88dSmrg else 375af69d88dSmrg _mesa_set_debug_state_int(ctx, cap, state); 376af69d88dSmrg break; 3777117f1b4Smrg case GL_DITHER: 3787117f1b4Smrg if (ctx->Color.DitherFlag == state) 3797117f1b4Smrg return; 3807117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 3817117f1b4Smrg ctx->Color.DitherFlag = state; 3827117f1b4Smrg break; 3837117f1b4Smrg case GL_FOG: 384af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 385af69d88dSmrg goto invalid_enum_error; 3867117f1b4Smrg if (ctx->Fog.Enabled == state) 3877117f1b4Smrg return; 3887117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_FOG); 3897117f1b4Smrg ctx->Fog.Enabled = state; 3907117f1b4Smrg break; 3917117f1b4Smrg case GL_LIGHT0: 3927117f1b4Smrg case GL_LIGHT1: 3937117f1b4Smrg case GL_LIGHT2: 3947117f1b4Smrg case GL_LIGHT3: 3957117f1b4Smrg case GL_LIGHT4: 3967117f1b4Smrg case GL_LIGHT5: 3977117f1b4Smrg case GL_LIGHT6: 3987117f1b4Smrg case GL_LIGHT7: 399af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 400af69d88dSmrg goto invalid_enum_error; 4017117f1b4Smrg if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) 4027117f1b4Smrg return; 4037117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LIGHT); 4047117f1b4Smrg ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; 4057117f1b4Smrg if (state) { 4067117f1b4Smrg insert_at_tail(&ctx->Light.EnabledList, 4077117f1b4Smrg &ctx->Light.Light[cap-GL_LIGHT0]); 4087117f1b4Smrg } 4097117f1b4Smrg else { 4107117f1b4Smrg remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); 4117117f1b4Smrg } 4127117f1b4Smrg break; 4137117f1b4Smrg case GL_LIGHTING: 414af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 415af69d88dSmrg goto invalid_enum_error; 4167117f1b4Smrg if (ctx->Light.Enabled == state) 4177117f1b4Smrg return; 4187117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LIGHT); 4197117f1b4Smrg ctx->Light.Enabled = state; 4207117f1b4Smrg break; 4217117f1b4Smrg case GL_LINE_SMOOTH: 422af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 423af69d88dSmrg goto invalid_enum_error; 4247117f1b4Smrg if (ctx->Line.SmoothFlag == state) 4257117f1b4Smrg return; 4267117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LINE); 4277117f1b4Smrg ctx->Line.SmoothFlag = state; 4287117f1b4Smrg break; 4297117f1b4Smrg case GL_LINE_STIPPLE: 430af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 431af69d88dSmrg goto invalid_enum_error; 4327117f1b4Smrg if (ctx->Line.StippleFlag == state) 4337117f1b4Smrg return; 4347117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LINE); 4357117f1b4Smrg ctx->Line.StippleFlag = state; 4367117f1b4Smrg break; 4377117f1b4Smrg case GL_INDEX_LOGIC_OP: 438af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 439af69d88dSmrg goto invalid_enum_error; 4407117f1b4Smrg if (ctx->Color.IndexLogicOpEnabled == state) 4417117f1b4Smrg return; 4427117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 4437117f1b4Smrg ctx->Color.IndexLogicOpEnabled = state; 4447117f1b4Smrg break; 4457117f1b4Smrg case GL_COLOR_LOGIC_OP: 446af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 447af69d88dSmrg goto invalid_enum_error; 4487117f1b4Smrg if (ctx->Color.ColorLogicOpEnabled == state) 4497117f1b4Smrg return; 4507117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 4517117f1b4Smrg ctx->Color.ColorLogicOpEnabled = state; 4527117f1b4Smrg break; 4537117f1b4Smrg case GL_MAP1_COLOR_4: 454af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 455af69d88dSmrg goto invalid_enum_error; 4567117f1b4Smrg if (ctx->Eval.Map1Color4 == state) 4577117f1b4Smrg return; 4587117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4597117f1b4Smrg ctx->Eval.Map1Color4 = state; 4607117f1b4Smrg break; 4617117f1b4Smrg case GL_MAP1_INDEX: 462af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 463af69d88dSmrg goto invalid_enum_error; 4647117f1b4Smrg if (ctx->Eval.Map1Index == state) 4657117f1b4Smrg return; 4667117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4677117f1b4Smrg ctx->Eval.Map1Index = state; 4687117f1b4Smrg break; 4697117f1b4Smrg case GL_MAP1_NORMAL: 470af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 471af69d88dSmrg goto invalid_enum_error; 4727117f1b4Smrg if (ctx->Eval.Map1Normal == state) 4737117f1b4Smrg return; 4747117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4757117f1b4Smrg ctx->Eval.Map1Normal = state; 4767117f1b4Smrg break; 4777117f1b4Smrg case GL_MAP1_TEXTURE_COORD_1: 478af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 479af69d88dSmrg goto invalid_enum_error; 4807117f1b4Smrg if (ctx->Eval.Map1TextureCoord1 == state) 4817117f1b4Smrg return; 4827117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4837117f1b4Smrg ctx->Eval.Map1TextureCoord1 = state; 4847117f1b4Smrg break; 4857117f1b4Smrg case GL_MAP1_TEXTURE_COORD_2: 486af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 487af69d88dSmrg goto invalid_enum_error; 4887117f1b4Smrg if (ctx->Eval.Map1TextureCoord2 == state) 4897117f1b4Smrg return; 4907117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4917117f1b4Smrg ctx->Eval.Map1TextureCoord2 = state; 4927117f1b4Smrg break; 4937117f1b4Smrg case GL_MAP1_TEXTURE_COORD_3: 494af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 495af69d88dSmrg goto invalid_enum_error; 4967117f1b4Smrg if (ctx->Eval.Map1TextureCoord3 == state) 4977117f1b4Smrg return; 4987117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4997117f1b4Smrg ctx->Eval.Map1TextureCoord3 = state; 5007117f1b4Smrg break; 5017117f1b4Smrg case GL_MAP1_TEXTURE_COORD_4: 502af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 503af69d88dSmrg goto invalid_enum_error; 5047117f1b4Smrg if (ctx->Eval.Map1TextureCoord4 == state) 5057117f1b4Smrg return; 5067117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5077117f1b4Smrg ctx->Eval.Map1TextureCoord4 = state; 5087117f1b4Smrg break; 5097117f1b4Smrg case GL_MAP1_VERTEX_3: 510af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 511af69d88dSmrg goto invalid_enum_error; 5127117f1b4Smrg if (ctx->Eval.Map1Vertex3 == state) 5137117f1b4Smrg return; 5147117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5157117f1b4Smrg ctx->Eval.Map1Vertex3 = state; 5167117f1b4Smrg break; 5177117f1b4Smrg case GL_MAP1_VERTEX_4: 518af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 519af69d88dSmrg goto invalid_enum_error; 5207117f1b4Smrg if (ctx->Eval.Map1Vertex4 == state) 5217117f1b4Smrg return; 5227117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5237117f1b4Smrg ctx->Eval.Map1Vertex4 = state; 5247117f1b4Smrg break; 5257117f1b4Smrg case GL_MAP2_COLOR_4: 526af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 527af69d88dSmrg goto invalid_enum_error; 5287117f1b4Smrg if (ctx->Eval.Map2Color4 == state) 5297117f1b4Smrg return; 5307117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5317117f1b4Smrg ctx->Eval.Map2Color4 = state; 5327117f1b4Smrg break; 5337117f1b4Smrg case GL_MAP2_INDEX: 534af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 535af69d88dSmrg goto invalid_enum_error; 5367117f1b4Smrg if (ctx->Eval.Map2Index == state) 5377117f1b4Smrg return; 5387117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5397117f1b4Smrg ctx->Eval.Map2Index = state; 5407117f1b4Smrg break; 5417117f1b4Smrg case GL_MAP2_NORMAL: 542af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 543af69d88dSmrg goto invalid_enum_error; 5447117f1b4Smrg if (ctx->Eval.Map2Normal == state) 5457117f1b4Smrg return; 5467117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5477117f1b4Smrg ctx->Eval.Map2Normal = state; 5487117f1b4Smrg break; 5497117f1b4Smrg case GL_MAP2_TEXTURE_COORD_1: 550af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 551af69d88dSmrg goto invalid_enum_error; 5527117f1b4Smrg if (ctx->Eval.Map2TextureCoord1 == state) 5537117f1b4Smrg return; 5547117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5557117f1b4Smrg ctx->Eval.Map2TextureCoord1 = state; 5567117f1b4Smrg break; 5577117f1b4Smrg case GL_MAP2_TEXTURE_COORD_2: 558af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 559af69d88dSmrg goto invalid_enum_error; 5607117f1b4Smrg if (ctx->Eval.Map2TextureCoord2 == state) 5617117f1b4Smrg return; 5627117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5637117f1b4Smrg ctx->Eval.Map2TextureCoord2 = state; 5647117f1b4Smrg break; 5657117f1b4Smrg case GL_MAP2_TEXTURE_COORD_3: 566af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 567af69d88dSmrg goto invalid_enum_error; 5687117f1b4Smrg if (ctx->Eval.Map2TextureCoord3 == state) 5697117f1b4Smrg return; 5707117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5717117f1b4Smrg ctx->Eval.Map2TextureCoord3 = state; 5727117f1b4Smrg break; 5737117f1b4Smrg case GL_MAP2_TEXTURE_COORD_4: 574af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 575af69d88dSmrg goto invalid_enum_error; 5767117f1b4Smrg if (ctx->Eval.Map2TextureCoord4 == state) 5777117f1b4Smrg return; 5787117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5797117f1b4Smrg ctx->Eval.Map2TextureCoord4 = state; 5807117f1b4Smrg break; 5817117f1b4Smrg case GL_MAP2_VERTEX_3: 582af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 583af69d88dSmrg goto invalid_enum_error; 5847117f1b4Smrg if (ctx->Eval.Map2Vertex3 == state) 5857117f1b4Smrg return; 5867117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5877117f1b4Smrg ctx->Eval.Map2Vertex3 = state; 5887117f1b4Smrg break; 5897117f1b4Smrg case GL_MAP2_VERTEX_4: 590af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 591af69d88dSmrg goto invalid_enum_error; 5927117f1b4Smrg if (ctx->Eval.Map2Vertex4 == state) 5937117f1b4Smrg return; 5947117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5957117f1b4Smrg ctx->Eval.Map2Vertex4 = state; 5967117f1b4Smrg break; 5977117f1b4Smrg case GL_NORMALIZE: 598af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 599af69d88dSmrg goto invalid_enum_error; 6007117f1b4Smrg if (ctx->Transform.Normalize == state) 6017117f1b4Smrg return; 6027117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 6037117f1b4Smrg ctx->Transform.Normalize = state; 6047117f1b4Smrg break; 6057117f1b4Smrg case GL_POINT_SMOOTH: 606af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 607af69d88dSmrg goto invalid_enum_error; 6087117f1b4Smrg if (ctx->Point.SmoothFlag == state) 6097117f1b4Smrg return; 6107117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POINT); 6117117f1b4Smrg ctx->Point.SmoothFlag = state; 6127117f1b4Smrg break; 6137117f1b4Smrg case GL_POLYGON_SMOOTH: 614af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 615af69d88dSmrg goto invalid_enum_error; 6167117f1b4Smrg if (ctx->Polygon.SmoothFlag == state) 6177117f1b4Smrg return; 6187117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 6197117f1b4Smrg ctx->Polygon.SmoothFlag = state; 6207117f1b4Smrg break; 6217117f1b4Smrg case GL_POLYGON_STIPPLE: 622af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 623af69d88dSmrg goto invalid_enum_error; 6247117f1b4Smrg if (ctx->Polygon.StippleFlag == state) 6257117f1b4Smrg return; 6267117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 6277117f1b4Smrg ctx->Polygon.StippleFlag = state; 6287117f1b4Smrg break; 6297117f1b4Smrg case GL_POLYGON_OFFSET_POINT: 630af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 631af69d88dSmrg goto invalid_enum_error; 6327117f1b4Smrg if (ctx->Polygon.OffsetPoint == state) 6337117f1b4Smrg return; 6347117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 6357117f1b4Smrg ctx->Polygon.OffsetPoint = state; 6367117f1b4Smrg break; 6377117f1b4Smrg case GL_POLYGON_OFFSET_LINE: 638af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 639af69d88dSmrg goto invalid_enum_error; 6407117f1b4Smrg if (ctx->Polygon.OffsetLine == state) 6417117f1b4Smrg return; 6427117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 6437117f1b4Smrg ctx->Polygon.OffsetLine = state; 6447117f1b4Smrg break; 6457117f1b4Smrg case GL_POLYGON_OFFSET_FILL: 6467117f1b4Smrg if (ctx->Polygon.OffsetFill == state) 6477117f1b4Smrg return; 6487117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 6497117f1b4Smrg ctx->Polygon.OffsetFill = state; 6507117f1b4Smrg break; 6517117f1b4Smrg case GL_RESCALE_NORMAL_EXT: 652af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 653af69d88dSmrg goto invalid_enum_error; 6547117f1b4Smrg if (ctx->Transform.RescaleNormals == state) 6557117f1b4Smrg return; 6567117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 6577117f1b4Smrg ctx->Transform.RescaleNormals = state; 6587117f1b4Smrg break; 6597117f1b4Smrg case GL_SCISSOR_TEST: 660af69d88dSmrg { 661af69d88dSmrg /* Must expand glEnable to all scissors */ 662af69d88dSmrg GLbitfield newEnabled = 663af69d88dSmrg state * ((1 << ctx->Const.MaxViewports) - 1); 664af69d88dSmrg if (newEnabled != ctx->Scissor.EnableFlags) { 665af69d88dSmrg FLUSH_VERTICES(ctx, _NEW_SCISSOR); 666af69d88dSmrg ctx->Scissor.EnableFlags = newEnabled; 667af69d88dSmrg } 668af69d88dSmrg } 6697117f1b4Smrg break; 6707117f1b4Smrg case GL_STENCIL_TEST: 6717117f1b4Smrg if (ctx->Stencil.Enabled == state) 6727117f1b4Smrg return; 6737117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_STENCIL); 6747117f1b4Smrg ctx->Stencil.Enabled = state; 6757117f1b4Smrg break; 6767117f1b4Smrg case GL_TEXTURE_1D: 677af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 678af69d88dSmrg goto invalid_enum_error; 6797117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { 6807117f1b4Smrg return; 6817117f1b4Smrg } 6827117f1b4Smrg break; 6837117f1b4Smrg case GL_TEXTURE_2D: 684af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 685af69d88dSmrg goto invalid_enum_error; 6867117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { 6877117f1b4Smrg return; 6887117f1b4Smrg } 6897117f1b4Smrg break; 6907117f1b4Smrg case GL_TEXTURE_3D: 691af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 692af69d88dSmrg goto invalid_enum_error; 6937117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { 6947117f1b4Smrg return; 6957117f1b4Smrg } 6967117f1b4Smrg break; 697c1f859d4Smrg case GL_TEXTURE_GEN_S: 6983464ebd5Sriastradh case GL_TEXTURE_GEN_T: 6993464ebd5Sriastradh case GL_TEXTURE_GEN_R: 7003464ebd5Sriastradh case GL_TEXTURE_GEN_Q: 701c1f859d4Smrg { 702c1f859d4Smrg struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 703af69d88dSmrg 704af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 705af69d88dSmrg goto invalid_enum_error; 706af69d88dSmrg 707c1f859d4Smrg if (texUnit) { 7083464ebd5Sriastradh GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); 7093464ebd5Sriastradh GLbitfield newenabled = texUnit->TexGenEnabled & ~coordBit; 710c1f859d4Smrg if (state) 7113464ebd5Sriastradh newenabled |= coordBit; 712c1f859d4Smrg if (texUnit->TexGenEnabled == newenabled) 713c1f859d4Smrg return; 714c1f859d4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 715c1f859d4Smrg texUnit->TexGenEnabled = newenabled; 716c1f859d4Smrg } 717c1f859d4Smrg } 7187117f1b4Smrg break; 7193464ebd5Sriastradh 7203464ebd5Sriastradh case GL_TEXTURE_GEN_STR_OES: 7213464ebd5Sriastradh /* disable S, T, and R at the same time */ 7223464ebd5Sriastradh { 723c1f859d4Smrg struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 724af69d88dSmrg 725af69d88dSmrg if (ctx->API != API_OPENGLES) 726af69d88dSmrg goto invalid_enum_error; 727af69d88dSmrg 728c1f859d4Smrg if (texUnit) { 7293464ebd5Sriastradh GLuint newenabled = 7303464ebd5Sriastradh texUnit->TexGenEnabled & ~STR_BITS; 731c1f859d4Smrg if (state) 7323464ebd5Sriastradh newenabled |= STR_BITS; 733c1f859d4Smrg if (texUnit->TexGenEnabled == newenabled) 734c1f859d4Smrg return; 735c1f859d4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 736c1f859d4Smrg texUnit->TexGenEnabled = newenabled; 737c1f859d4Smrg } 738c1f859d4Smrg } 7397117f1b4Smrg break; 7407117f1b4Smrg 741af69d88dSmrg /* client-side state */ 7427117f1b4Smrg case GL_VERTEX_ARRAY: 7437117f1b4Smrg case GL_NORMAL_ARRAY: 7447117f1b4Smrg case GL_COLOR_ARRAY: 7457117f1b4Smrg case GL_INDEX_ARRAY: 7467117f1b4Smrg case GL_TEXTURE_COORD_ARRAY: 7477117f1b4Smrg case GL_EDGE_FLAG_ARRAY: 7487117f1b4Smrg case GL_FOG_COORDINATE_ARRAY_EXT: 7497117f1b4Smrg case GL_SECONDARY_COLOR_ARRAY_EXT: 750c1f859d4Smrg case GL_POINT_SIZE_ARRAY_OES: 7517117f1b4Smrg client_state( ctx, cap, state ); 7527117f1b4Smrg return; 7537117f1b4Smrg 7547117f1b4Smrg /* GL_ARB_texture_cube_map */ 7557117f1b4Smrg case GL_TEXTURE_CUBE_MAP_ARB: 756af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 757af69d88dSmrg goto invalid_enum_error; 7587117f1b4Smrg CHECK_EXTENSION(ARB_texture_cube_map, cap); 7597117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { 7607117f1b4Smrg return; 7617117f1b4Smrg } 7627117f1b4Smrg break; 7637117f1b4Smrg 7647117f1b4Smrg /* GL_EXT_secondary_color */ 7657117f1b4Smrg case GL_COLOR_SUM_EXT: 766af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 767af69d88dSmrg goto invalid_enum_error; 7687117f1b4Smrg if (ctx->Fog.ColorSumEnabled == state) 7697117f1b4Smrg return; 7707117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_FOG); 7717117f1b4Smrg ctx->Fog.ColorSumEnabled = state; 7727117f1b4Smrg break; 7737117f1b4Smrg 7747117f1b4Smrg /* GL_ARB_multisample */ 7757117f1b4Smrg case GL_MULTISAMPLE_ARB: 776af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 777af69d88dSmrg goto invalid_enum_error; 778af69d88dSmrg _mesa_set_multisample(ctx, state); 779af69d88dSmrg return; 7807117f1b4Smrg case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: 7817117f1b4Smrg if (ctx->Multisample.SampleAlphaToCoverage == state) 7827117f1b4Smrg return; 7837117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 7847117f1b4Smrg ctx->Multisample.SampleAlphaToCoverage = state; 7857117f1b4Smrg break; 7867117f1b4Smrg case GL_SAMPLE_ALPHA_TO_ONE_ARB: 787af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 788af69d88dSmrg goto invalid_enum_error; 7897117f1b4Smrg if (ctx->Multisample.SampleAlphaToOne == state) 7907117f1b4Smrg return; 7917117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 7927117f1b4Smrg ctx->Multisample.SampleAlphaToOne = state; 7937117f1b4Smrg break; 7947117f1b4Smrg case GL_SAMPLE_COVERAGE_ARB: 7957117f1b4Smrg if (ctx->Multisample.SampleCoverage == state) 7967117f1b4Smrg return; 7977117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 7987117f1b4Smrg ctx->Multisample.SampleCoverage = state; 7997117f1b4Smrg break; 8007117f1b4Smrg case GL_SAMPLE_COVERAGE_INVERT_ARB: 801af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 802af69d88dSmrg goto invalid_enum_error; 8037117f1b4Smrg if (ctx->Multisample.SampleCoverageInvert == state) 8047117f1b4Smrg return; 8057117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 8067117f1b4Smrg ctx->Multisample.SampleCoverageInvert = state; 8077117f1b4Smrg break; 8087117f1b4Smrg 809af69d88dSmrg /* GL_ARB_sample_shading */ 810af69d88dSmrg case GL_SAMPLE_SHADING: 811af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 812af69d88dSmrg goto invalid_enum_error; 813af69d88dSmrg CHECK_EXTENSION(ARB_sample_shading, cap); 814af69d88dSmrg if (ctx->Multisample.SampleShading == state) 815af69d88dSmrg return; 816af69d88dSmrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 817af69d88dSmrg ctx->Multisample.SampleShading = state; 818af69d88dSmrg break; 819af69d88dSmrg 8207117f1b4Smrg /* GL_IBM_rasterpos_clip */ 8217117f1b4Smrg case GL_RASTER_POSITION_UNCLIPPED_IBM: 822af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 823af69d88dSmrg goto invalid_enum_error; 8247117f1b4Smrg if (ctx->Transform.RasterPositionUnclipped == state) 8257117f1b4Smrg return; 8267117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 8277117f1b4Smrg ctx->Transform.RasterPositionUnclipped = state; 8287117f1b4Smrg break; 8297117f1b4Smrg 8307117f1b4Smrg /* GL_NV_point_sprite */ 8317117f1b4Smrg case GL_POINT_SPRITE_NV: 832af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 833af69d88dSmrg goto invalid_enum_error; 8347117f1b4Smrg CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); 8357117f1b4Smrg if (ctx->Point.PointSprite == state) 8367117f1b4Smrg return; 8377117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POINT); 8387117f1b4Smrg ctx->Point.PointSprite = state; 8397117f1b4Smrg break; 8407117f1b4Smrg 8417117f1b4Smrg case GL_VERTEX_PROGRAM_ARB: 842af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 843af69d88dSmrg goto invalid_enum_error; 844af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program, cap); 8457117f1b4Smrg if (ctx->VertexProgram.Enabled == state) 8467117f1b4Smrg return; 8477117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 8487117f1b4Smrg ctx->VertexProgram.Enabled = state; 8497117f1b4Smrg break; 8507117f1b4Smrg case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: 851af69d88dSmrg /* This was added with ARB_vertex_program, but it is also used with 852af69d88dSmrg * GLSL vertex shaders on desktop. 853af69d88dSmrg */ 854af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 855af69d88dSmrg goto invalid_enum_error; 856af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program, cap); 8577117f1b4Smrg if (ctx->VertexProgram.PointSizeEnabled == state) 8587117f1b4Smrg return; 8597117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 8607117f1b4Smrg ctx->VertexProgram.PointSizeEnabled = state; 8617117f1b4Smrg break; 8627117f1b4Smrg case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: 863af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 864af69d88dSmrg goto invalid_enum_error; 865af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program, cap); 8667117f1b4Smrg if (ctx->VertexProgram.TwoSideEnabled == state) 8677117f1b4Smrg return; 8687117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 8697117f1b4Smrg ctx->VertexProgram.TwoSideEnabled = state; 8707117f1b4Smrg break; 8717117f1b4Smrg 8727117f1b4Smrg /* GL_NV_texture_rectangle */ 8737117f1b4Smrg case GL_TEXTURE_RECTANGLE_NV: 874af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 875af69d88dSmrg goto invalid_enum_error; 8767117f1b4Smrg CHECK_EXTENSION(NV_texture_rectangle, cap); 8777117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { 8787117f1b4Smrg return; 8797117f1b4Smrg } 8807117f1b4Smrg break; 8817117f1b4Smrg 8827117f1b4Smrg /* GL_EXT_stencil_two_side */ 8837117f1b4Smrg case GL_STENCIL_TEST_TWO_SIDE_EXT: 884af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 885af69d88dSmrg goto invalid_enum_error; 8867117f1b4Smrg CHECK_EXTENSION(EXT_stencil_two_side, cap); 8877117f1b4Smrg if (ctx->Stencil.TestTwoSide == state) 8887117f1b4Smrg return; 8897117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_STENCIL); 8907117f1b4Smrg ctx->Stencil.TestTwoSide = state; 891c1f859d4Smrg if (state) { 892c1f859d4Smrg ctx->Stencil._BackFace = 2; 893c1f859d4Smrg } else { 894c1f859d4Smrg ctx->Stencil._BackFace = 1; 895c1f859d4Smrg } 8967117f1b4Smrg break; 8977117f1b4Smrg 8987117f1b4Smrg case GL_FRAGMENT_PROGRAM_ARB: 899af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 900af69d88dSmrg goto invalid_enum_error; 9017117f1b4Smrg CHECK_EXTENSION(ARB_fragment_program, cap); 9027117f1b4Smrg if (ctx->FragmentProgram.Enabled == state) 9037117f1b4Smrg return; 9047117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 9057117f1b4Smrg ctx->FragmentProgram.Enabled = state; 9067117f1b4Smrg break; 9077117f1b4Smrg 9087117f1b4Smrg /* GL_EXT_depth_bounds_test */ 9097117f1b4Smrg case GL_DEPTH_BOUNDS_TEST_EXT: 910af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 911af69d88dSmrg goto invalid_enum_error; 9127117f1b4Smrg CHECK_EXTENSION(EXT_depth_bounds_test, cap); 9137117f1b4Smrg if (ctx->Depth.BoundsTest == state) 9147117f1b4Smrg return; 9157117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_DEPTH); 9167117f1b4Smrg ctx->Depth.BoundsTest = state; 9177117f1b4Smrg break; 9187117f1b4Smrg 9194a49301eSmrg case GL_DEPTH_CLAMP: 920af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 921af69d88dSmrg goto invalid_enum_error; 922af69d88dSmrg CHECK_EXTENSION(ARB_depth_clamp, cap); 9234a49301eSmrg if (ctx->Transform.DepthClamp == state) 9244a49301eSmrg return; 9254a49301eSmrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 9264a49301eSmrg ctx->Transform.DepthClamp = state; 9274a49301eSmrg break; 9287117f1b4Smrg 9297117f1b4Smrg case GL_FRAGMENT_SHADER_ATI: 930af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 931af69d88dSmrg goto invalid_enum_error; 9327117f1b4Smrg CHECK_EXTENSION(ATI_fragment_shader, cap); 9337117f1b4Smrg if (ctx->ATIFragmentShader.Enabled == state) 9347117f1b4Smrg return; 9357117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 9367117f1b4Smrg ctx->ATIFragmentShader.Enabled = state; 9377117f1b4Smrg break; 938c1f859d4Smrg 9394a49301eSmrg case GL_TEXTURE_CUBE_MAP_SEAMLESS: 940af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 941af69d88dSmrg goto invalid_enum_error; 9424a49301eSmrg CHECK_EXTENSION(ARB_seamless_cube_map, cap); 9433464ebd5Sriastradh if (ctx->Texture.CubeMapSeamless != state) { 9443464ebd5Sriastradh FLUSH_VERTICES(ctx, _NEW_TEXTURE); 9453464ebd5Sriastradh ctx->Texture.CubeMapSeamless = state; 9463464ebd5Sriastradh } 9474a49301eSmrg break; 9484a49301eSmrg 9493464ebd5Sriastradh case GL_RASTERIZER_DISCARD: 950af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) 951af69d88dSmrg goto invalid_enum_error; 9523464ebd5Sriastradh CHECK_EXTENSION(EXT_transform_feedback, cap); 953af69d88dSmrg if (ctx->RasterDiscard != state) { 954af69d88dSmrg FLUSH_VERTICES(ctx, 0); 955af69d88dSmrg ctx->NewDriverState |= ctx->DriverFlags.NewRasterizerDiscard; 956af69d88dSmrg ctx->RasterDiscard = state; 9573464ebd5Sriastradh } 9583464ebd5Sriastradh break; 9593464ebd5Sriastradh 9603464ebd5Sriastradh /* GL 3.1 primitive restart. Note: this enum is different from 9613464ebd5Sriastradh * GL_PRIMITIVE_RESTART_NV (which is client state). 9623464ebd5Sriastradh */ 9633464ebd5Sriastradh case GL_PRIMITIVE_RESTART: 964af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 31) { 9653464ebd5Sriastradh goto invalid_enum_error; 9663464ebd5Sriastradh } 9673464ebd5Sriastradh if (ctx->Array.PrimitiveRestart != state) { 9683464ebd5Sriastradh FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 9693464ebd5Sriastradh ctx->Array.PrimitiveRestart = state; 970af69d88dSmrg update_derived_primitive_restart_state(ctx); 971af69d88dSmrg } 972af69d88dSmrg break; 973af69d88dSmrg 974af69d88dSmrg case GL_PRIMITIVE_RESTART_FIXED_INDEX: 975af69d88dSmrg if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility) 976af69d88dSmrg goto invalid_enum_error; 977af69d88dSmrg if (ctx->Array.PrimitiveRestartFixedIndex != state) { 978af69d88dSmrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 979af69d88dSmrg ctx->Array.PrimitiveRestartFixedIndex = state; 980af69d88dSmrg update_derived_primitive_restart_state(ctx); 9813464ebd5Sriastradh } 9823464ebd5Sriastradh break; 9833464ebd5Sriastradh 9843464ebd5Sriastradh /* GL3.0 - GL_framebuffer_sRGB */ 9853464ebd5Sriastradh case GL_FRAMEBUFFER_SRGB_EXT: 986af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 987af69d88dSmrg goto invalid_enum_error; 9883464ebd5Sriastradh CHECK_EXTENSION(EXT_framebuffer_sRGB, cap); 989af69d88dSmrg _mesa_set_framebuffer_srgb(ctx, state); 990af69d88dSmrg return; 991af69d88dSmrg 992af69d88dSmrg /* GL_OES_EGL_image_external */ 993af69d88dSmrg case GL_TEXTURE_EXTERNAL_OES: 994af69d88dSmrg if (!_mesa_is_gles(ctx)) 995af69d88dSmrg goto invalid_enum_error; 996af69d88dSmrg CHECK_EXTENSION(OES_EGL_image_external, cap); 997af69d88dSmrg if (!enable_texture(ctx, state, TEXTURE_EXTERNAL_BIT)) { 998af69d88dSmrg return; 999af69d88dSmrg } 1000af69d88dSmrg break; 1001af69d88dSmrg 1002af69d88dSmrg /* ARB_texture_multisample */ 1003af69d88dSmrg case GL_SAMPLE_MASK: 1004af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1005af69d88dSmrg goto invalid_enum_error; 1006af69d88dSmrg CHECK_EXTENSION(ARB_texture_multisample, cap); 1007af69d88dSmrg if (ctx->Multisample.SampleMask == state) 1008af69d88dSmrg return; 1009af69d88dSmrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 1010af69d88dSmrg ctx->Multisample.SampleMask = state; 10113464ebd5Sriastradh break; 10123464ebd5Sriastradh 10137117f1b4Smrg default: 10143464ebd5Sriastradh goto invalid_enum_error; 10157117f1b4Smrg } 10167117f1b4Smrg 10177117f1b4Smrg if (ctx->Driver.Enable) { 10187117f1b4Smrg ctx->Driver.Enable( ctx, cap, state ); 10197117f1b4Smrg } 10203464ebd5Sriastradh 10213464ebd5Sriastradh return; 10223464ebd5Sriastradh 10233464ebd5Sriastradhinvalid_enum_error: 1024af69d88dSmrg _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(%s)", 1025af69d88dSmrg state ? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap)); 10267117f1b4Smrg} 10277117f1b4Smrg 10287117f1b4Smrg 10297117f1b4Smrg/** 10307117f1b4Smrg * Enable GL capability. Called by glEnable() 10317117f1b4Smrg * \param cap state to enable. 10327117f1b4Smrg */ 10337117f1b4Smrgvoid GLAPIENTRY 10347117f1b4Smrg_mesa_Enable( GLenum cap ) 10357117f1b4Smrg{ 10367117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 10377117f1b4Smrg 10387117f1b4Smrg _mesa_set_enable( ctx, cap, GL_TRUE ); 10397117f1b4Smrg} 10407117f1b4Smrg 10417117f1b4Smrg 10427117f1b4Smrg/** 10437117f1b4Smrg * Disable GL capability. Called by glDisable() 10447117f1b4Smrg * \param cap state to disable. 10457117f1b4Smrg */ 10467117f1b4Smrgvoid GLAPIENTRY 10477117f1b4Smrg_mesa_Disable( GLenum cap ) 10487117f1b4Smrg{ 10497117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 10507117f1b4Smrg 10517117f1b4Smrg _mesa_set_enable( ctx, cap, GL_FALSE ); 10527117f1b4Smrg} 10537117f1b4Smrg 10547117f1b4Smrg 1055cdc920a0Smrg 1056cdc920a0Smrg/** 1057cdc920a0Smrg * Enable/disable an indexed state var. 1058cdc920a0Smrg */ 1059cdc920a0Smrgvoid 10603464ebd5Sriastradh_mesa_set_enablei(struct gl_context *ctx, GLenum cap, 10613464ebd5Sriastradh GLuint index, GLboolean state) 1062cdc920a0Smrg{ 1063cdc920a0Smrg ASSERT(state == 0 || state == 1); 1064cdc920a0Smrg switch (cap) { 1065cdc920a0Smrg case GL_BLEND: 1066cdc920a0Smrg if (!ctx->Extensions.EXT_draw_buffers2) { 10673464ebd5Sriastradh goto invalid_enum_error; 1068cdc920a0Smrg } 1069cdc920a0Smrg if (index >= ctx->Const.MaxDrawBuffers) { 1070cdc920a0Smrg _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", 1071cdc920a0Smrg state ? "glEnableIndexed" : "glDisableIndexed", index); 1072cdc920a0Smrg return; 1073cdc920a0Smrg } 1074cdc920a0Smrg if (((ctx->Color.BlendEnabled >> index) & 1) != state) { 1075cdc920a0Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 1076cdc920a0Smrg if (state) 1077cdc920a0Smrg ctx->Color.BlendEnabled |= (1 << index); 1078cdc920a0Smrg else 1079cdc920a0Smrg ctx->Color.BlendEnabled &= ~(1 << index); 1080cdc920a0Smrg } 1081cdc920a0Smrg break; 1082af69d88dSmrg case GL_SCISSOR_TEST: 1083af69d88dSmrg if (index >= ctx->Const.MaxViewports) { 1084af69d88dSmrg _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", 1085af69d88dSmrg state ? "glEnablei" : "glDisablei", index); 1086af69d88dSmrg return; 1087af69d88dSmrg } 1088af69d88dSmrg if (((ctx->Scissor.EnableFlags >> index) & 1) != state) { 1089af69d88dSmrg FLUSH_VERTICES(ctx, _NEW_SCISSOR); 1090af69d88dSmrg if (state) 1091af69d88dSmrg ctx->Scissor.EnableFlags |= (1 << index); 1092af69d88dSmrg else 1093af69d88dSmrg ctx->Scissor.EnableFlags &= ~(1 << index); 1094af69d88dSmrg } 1095af69d88dSmrg break; 1096cdc920a0Smrg default: 10973464ebd5Sriastradh goto invalid_enum_error; 1098cdc920a0Smrg } 1099cdc920a0Smrg return; 1100cdc920a0Smrg 11013464ebd5Sriastradhinvalid_enum_error: 1102cdc920a0Smrg _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", 1103cdc920a0Smrg state ? "glEnablei" : "glDisablei", 1104cdc920a0Smrg _mesa_lookup_enum_by_nr(cap)); 1105cdc920a0Smrg} 1106cdc920a0Smrg 1107cdc920a0Smrg 1108cdc920a0Smrgvoid GLAPIENTRY 1109af69d88dSmrg_mesa_Disablei( GLenum cap, GLuint index ) 1110cdc920a0Smrg{ 1111cdc920a0Smrg GET_CURRENT_CONTEXT(ctx); 1112cdc920a0Smrg _mesa_set_enablei(ctx, cap, index, GL_FALSE); 1113cdc920a0Smrg} 1114cdc920a0Smrg 1115cdc920a0Smrg 1116cdc920a0Smrgvoid GLAPIENTRY 1117af69d88dSmrg_mesa_Enablei( GLenum cap, GLuint index ) 1118cdc920a0Smrg{ 1119cdc920a0Smrg GET_CURRENT_CONTEXT(ctx); 1120cdc920a0Smrg _mesa_set_enablei(ctx, cap, index, GL_TRUE); 1121cdc920a0Smrg} 1122cdc920a0Smrg 1123cdc920a0Smrg 1124cdc920a0SmrgGLboolean GLAPIENTRY 1125af69d88dSmrg_mesa_IsEnabledi( GLenum cap, GLuint index ) 1126cdc920a0Smrg{ 1127cdc920a0Smrg GET_CURRENT_CONTEXT(ctx); 11283464ebd5Sriastradh ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); 1129cdc920a0Smrg switch (cap) { 1130cdc920a0Smrg case GL_BLEND: 1131cdc920a0Smrg if (index >= ctx->Const.MaxDrawBuffers) { 1132cdc920a0Smrg _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", 1133cdc920a0Smrg index); 1134cdc920a0Smrg return GL_FALSE; 1135cdc920a0Smrg } 1136cdc920a0Smrg return (ctx->Color.BlendEnabled >> index) & 1; 1137af69d88dSmrg case GL_SCISSOR_TEST: 1138af69d88dSmrg if (index >= ctx->Const.MaxViewports) { 1139af69d88dSmrg _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", 1140af69d88dSmrg index); 1141af69d88dSmrg return GL_FALSE; 1142af69d88dSmrg } 1143af69d88dSmrg return (ctx->Scissor.EnableFlags >> index) & 1; 1144cdc920a0Smrg default: 1145cdc920a0Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)", 1146cdc920a0Smrg _mesa_lookup_enum_by_nr(cap)); 1147cdc920a0Smrg return GL_FALSE; 1148cdc920a0Smrg } 1149cdc920a0Smrg} 1150cdc920a0Smrg 1151cdc920a0Smrg 1152cdc920a0Smrg 1153cdc920a0Smrg 11547117f1b4Smrg#undef CHECK_EXTENSION 11557117f1b4Smrg#define CHECK_EXTENSION(EXTNAME) \ 11567117f1b4Smrg if (!ctx->Extensions.EXTNAME) { \ 11573464ebd5Sriastradh goto invalid_enum_error; \ 11587117f1b4Smrg } 11597117f1b4Smrg 11607117f1b4Smrg#undef CHECK_EXTENSION2 11617117f1b4Smrg#define CHECK_EXTENSION2(EXT1, EXT2) \ 11627117f1b4Smrg if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ 11633464ebd5Sriastradh goto invalid_enum_error; \ 11647117f1b4Smrg } 11657117f1b4Smrg 11667117f1b4Smrg 11677117f1b4Smrg/** 11687117f1b4Smrg * Helper function to determine whether a texture target is enabled. 11697117f1b4Smrg */ 11707117f1b4Smrgstatic GLboolean 11713464ebd5Sriastradhis_texture_enabled(struct gl_context *ctx, GLbitfield bit) 11727117f1b4Smrg{ 11737117f1b4Smrg const struct gl_texture_unit *const texUnit = 11747117f1b4Smrg &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; 11757117f1b4Smrg return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; 11767117f1b4Smrg} 11777117f1b4Smrg 11787117f1b4Smrg 11797117f1b4Smrg/** 11807117f1b4Smrg * Return simple enable/disable state. 11817117f1b4Smrg * 11827117f1b4Smrg * \param cap state variable to query. 11837117f1b4Smrg * 11847117f1b4Smrg * Returns the state of the specified capability from the current GL context. 11857117f1b4Smrg * For the capabilities associated with extensions verifies that those 11867117f1b4Smrg * extensions are effectively present before reporting. 11877117f1b4Smrg */ 11887117f1b4SmrgGLboolean GLAPIENTRY 11897117f1b4Smrg_mesa_IsEnabled( GLenum cap ) 11907117f1b4Smrg{ 11917117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 11923464ebd5Sriastradh ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); 11933464ebd5Sriastradh 11947117f1b4Smrg switch (cap) { 11957117f1b4Smrg case GL_ALPHA_TEST: 1196af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1197af69d88dSmrg goto invalid_enum_error; 11987117f1b4Smrg return ctx->Color.AlphaEnabled; 11997117f1b4Smrg case GL_AUTO_NORMAL: 1200af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1201af69d88dSmrg goto invalid_enum_error; 12027117f1b4Smrg return ctx->Eval.AutoNormal; 12037117f1b4Smrg case GL_BLEND: 1204cdc920a0Smrg return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */ 1205af69d88dSmrg case GL_CLIP_DISTANCE0: /* aka GL_CLIP_PLANE0 */ 1206af69d88dSmrg case GL_CLIP_DISTANCE1: 1207af69d88dSmrg case GL_CLIP_DISTANCE2: 1208af69d88dSmrg case GL_CLIP_DISTANCE3: 1209af69d88dSmrg case GL_CLIP_DISTANCE4: 1210af69d88dSmrg case GL_CLIP_DISTANCE5: 1211af69d88dSmrg case GL_CLIP_DISTANCE6: 1212af69d88dSmrg case GL_CLIP_DISTANCE7: { 1213af69d88dSmrg const GLuint p = cap - GL_CLIP_DISTANCE0; 1214af69d88dSmrg 1215af69d88dSmrg if (p >= ctx->Const.MaxClipPlanes) 1216af69d88dSmrg goto invalid_enum_error; 1217af69d88dSmrg 1218af69d88dSmrg return (ctx->Transform.ClipPlanesEnabled >> p) & 1; 1219af69d88dSmrg } 12207117f1b4Smrg case GL_COLOR_MATERIAL: 1221af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1222af69d88dSmrg goto invalid_enum_error; 12237117f1b4Smrg return ctx->Light.ColorMaterialEnabled; 12247117f1b4Smrg case GL_CULL_FACE: 12257117f1b4Smrg return ctx->Polygon.CullFlag; 1226af69d88dSmrg case GL_DEBUG_OUTPUT: 1227af69d88dSmrg case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB: 1228af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1229af69d88dSmrg goto invalid_enum_error; 1230af69d88dSmrg else 1231af69d88dSmrg return (GLboolean) _mesa_get_debug_state_int(ctx, cap); 12327117f1b4Smrg case GL_DEPTH_TEST: 12337117f1b4Smrg return ctx->Depth.Test; 12347117f1b4Smrg case GL_DITHER: 12357117f1b4Smrg return ctx->Color.DitherFlag; 12367117f1b4Smrg case GL_FOG: 1237af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1238af69d88dSmrg goto invalid_enum_error; 12397117f1b4Smrg return ctx->Fog.Enabled; 12407117f1b4Smrg case GL_LIGHTING: 1241af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1242af69d88dSmrg goto invalid_enum_error; 12437117f1b4Smrg return ctx->Light.Enabled; 12447117f1b4Smrg case GL_LIGHT0: 12457117f1b4Smrg case GL_LIGHT1: 12467117f1b4Smrg case GL_LIGHT2: 12477117f1b4Smrg case GL_LIGHT3: 12487117f1b4Smrg case GL_LIGHT4: 12497117f1b4Smrg case GL_LIGHT5: 12507117f1b4Smrg case GL_LIGHT6: 12517117f1b4Smrg case GL_LIGHT7: 1252af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1253af69d88dSmrg goto invalid_enum_error; 12547117f1b4Smrg return ctx->Light.Light[cap-GL_LIGHT0].Enabled; 12557117f1b4Smrg case GL_LINE_SMOOTH: 1256af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 1257af69d88dSmrg goto invalid_enum_error; 12587117f1b4Smrg return ctx->Line.SmoothFlag; 12597117f1b4Smrg case GL_LINE_STIPPLE: 1260af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1261af69d88dSmrg goto invalid_enum_error; 12627117f1b4Smrg return ctx->Line.StippleFlag; 12637117f1b4Smrg case GL_INDEX_LOGIC_OP: 1264af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1265af69d88dSmrg goto invalid_enum_error; 12667117f1b4Smrg return ctx->Color.IndexLogicOpEnabled; 12677117f1b4Smrg case GL_COLOR_LOGIC_OP: 1268af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 1269af69d88dSmrg goto invalid_enum_error; 12707117f1b4Smrg return ctx->Color.ColorLogicOpEnabled; 12717117f1b4Smrg case GL_MAP1_COLOR_4: 1272af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1273af69d88dSmrg goto invalid_enum_error; 12747117f1b4Smrg return ctx->Eval.Map1Color4; 12757117f1b4Smrg case GL_MAP1_INDEX: 1276af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1277af69d88dSmrg goto invalid_enum_error; 12787117f1b4Smrg return ctx->Eval.Map1Index; 12797117f1b4Smrg case GL_MAP1_NORMAL: 1280af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1281af69d88dSmrg goto invalid_enum_error; 12827117f1b4Smrg return ctx->Eval.Map1Normal; 12837117f1b4Smrg case GL_MAP1_TEXTURE_COORD_1: 1284af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1285af69d88dSmrg goto invalid_enum_error; 12867117f1b4Smrg return ctx->Eval.Map1TextureCoord1; 12877117f1b4Smrg case GL_MAP1_TEXTURE_COORD_2: 1288af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1289af69d88dSmrg goto invalid_enum_error; 12907117f1b4Smrg return ctx->Eval.Map1TextureCoord2; 12917117f1b4Smrg case GL_MAP1_TEXTURE_COORD_3: 1292af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1293af69d88dSmrg goto invalid_enum_error; 12947117f1b4Smrg return ctx->Eval.Map1TextureCoord3; 12957117f1b4Smrg case GL_MAP1_TEXTURE_COORD_4: 1296af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1297af69d88dSmrg goto invalid_enum_error; 12987117f1b4Smrg return ctx->Eval.Map1TextureCoord4; 12997117f1b4Smrg case GL_MAP1_VERTEX_3: 1300af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1301af69d88dSmrg goto invalid_enum_error; 13027117f1b4Smrg return ctx->Eval.Map1Vertex3; 13037117f1b4Smrg case GL_MAP1_VERTEX_4: 1304af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1305af69d88dSmrg goto invalid_enum_error; 13067117f1b4Smrg return ctx->Eval.Map1Vertex4; 13077117f1b4Smrg case GL_MAP2_COLOR_4: 1308af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1309af69d88dSmrg goto invalid_enum_error; 13107117f1b4Smrg return ctx->Eval.Map2Color4; 13117117f1b4Smrg case GL_MAP2_INDEX: 1312af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1313af69d88dSmrg goto invalid_enum_error; 13147117f1b4Smrg return ctx->Eval.Map2Index; 13157117f1b4Smrg case GL_MAP2_NORMAL: 1316af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1317af69d88dSmrg goto invalid_enum_error; 13187117f1b4Smrg return ctx->Eval.Map2Normal; 13197117f1b4Smrg case GL_MAP2_TEXTURE_COORD_1: 1320af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1321af69d88dSmrg goto invalid_enum_error; 13227117f1b4Smrg return ctx->Eval.Map2TextureCoord1; 13237117f1b4Smrg case GL_MAP2_TEXTURE_COORD_2: 1324af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1325af69d88dSmrg goto invalid_enum_error; 13267117f1b4Smrg return ctx->Eval.Map2TextureCoord2; 13277117f1b4Smrg case GL_MAP2_TEXTURE_COORD_3: 1328af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1329af69d88dSmrg goto invalid_enum_error; 13307117f1b4Smrg return ctx->Eval.Map2TextureCoord3; 13317117f1b4Smrg case GL_MAP2_TEXTURE_COORD_4: 1332af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1333af69d88dSmrg goto invalid_enum_error; 13347117f1b4Smrg return ctx->Eval.Map2TextureCoord4; 13357117f1b4Smrg case GL_MAP2_VERTEX_3: 1336af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1337af69d88dSmrg goto invalid_enum_error; 13387117f1b4Smrg return ctx->Eval.Map2Vertex3; 13397117f1b4Smrg case GL_MAP2_VERTEX_4: 1340af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1341af69d88dSmrg goto invalid_enum_error; 13427117f1b4Smrg return ctx->Eval.Map2Vertex4; 13437117f1b4Smrg case GL_NORMALIZE: 1344af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1345af69d88dSmrg goto invalid_enum_error; 13467117f1b4Smrg return ctx->Transform.Normalize; 13477117f1b4Smrg case GL_POINT_SMOOTH: 1348af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1349af69d88dSmrg goto invalid_enum_error; 13507117f1b4Smrg return ctx->Point.SmoothFlag; 13517117f1b4Smrg case GL_POLYGON_SMOOTH: 1352af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1353af69d88dSmrg goto invalid_enum_error; 13547117f1b4Smrg return ctx->Polygon.SmoothFlag; 13557117f1b4Smrg case GL_POLYGON_STIPPLE: 1356af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1357af69d88dSmrg goto invalid_enum_error; 13587117f1b4Smrg return ctx->Polygon.StippleFlag; 13597117f1b4Smrg case GL_POLYGON_OFFSET_POINT: 1360af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1361af69d88dSmrg goto invalid_enum_error; 13627117f1b4Smrg return ctx->Polygon.OffsetPoint; 13637117f1b4Smrg case GL_POLYGON_OFFSET_LINE: 1364af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1365af69d88dSmrg goto invalid_enum_error; 13667117f1b4Smrg return ctx->Polygon.OffsetLine; 13677117f1b4Smrg case GL_POLYGON_OFFSET_FILL: 13687117f1b4Smrg return ctx->Polygon.OffsetFill; 13697117f1b4Smrg case GL_RESCALE_NORMAL_EXT: 1370af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1371af69d88dSmrg goto invalid_enum_error; 13727117f1b4Smrg return ctx->Transform.RescaleNormals; 13737117f1b4Smrg case GL_SCISSOR_TEST: 1374af69d88dSmrg return ctx->Scissor.EnableFlags & 1; /* return state for index 0 */ 13757117f1b4Smrg case GL_STENCIL_TEST: 13767117f1b4Smrg return ctx->Stencil.Enabled; 13777117f1b4Smrg case GL_TEXTURE_1D: 1378af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1379af69d88dSmrg goto invalid_enum_error; 13807117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_1D_BIT); 13817117f1b4Smrg case GL_TEXTURE_2D: 1382af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1383af69d88dSmrg goto invalid_enum_error; 13847117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_2D_BIT); 13857117f1b4Smrg case GL_TEXTURE_3D: 1386af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1387af69d88dSmrg goto invalid_enum_error; 13887117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_3D_BIT); 13897117f1b4Smrg case GL_TEXTURE_GEN_S: 13903464ebd5Sriastradh case GL_TEXTURE_GEN_T: 13913464ebd5Sriastradh case GL_TEXTURE_GEN_R: 13923464ebd5Sriastradh case GL_TEXTURE_GEN_Q: 13937117f1b4Smrg { 1394c1f859d4Smrg const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 1395af69d88dSmrg 1396af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1397af69d88dSmrg goto invalid_enum_error; 1398af69d88dSmrg 1399c1f859d4Smrg if (texUnit) { 14003464ebd5Sriastradh GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); 14013464ebd5Sriastradh return (texUnit->TexGenEnabled & coordBit) ? GL_TRUE : GL_FALSE; 1402c1f859d4Smrg } 14037117f1b4Smrg } 1404c1f859d4Smrg return GL_FALSE; 14053464ebd5Sriastradh case GL_TEXTURE_GEN_STR_OES: 14063464ebd5Sriastradh { 1407c1f859d4Smrg const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 1408af69d88dSmrg 1409af69d88dSmrg if (ctx->API != API_OPENGLES) 1410af69d88dSmrg goto invalid_enum_error; 1411af69d88dSmrg 1412c1f859d4Smrg if (texUnit) { 14133464ebd5Sriastradh return (texUnit->TexGenEnabled & STR_BITS) == STR_BITS 14143464ebd5Sriastradh ? GL_TRUE : GL_FALSE; 1415c1f859d4Smrg } 14167117f1b4Smrg } 14177117f1b4Smrg 1418af69d88dSmrg /* client-side state */ 14197117f1b4Smrg case GL_VERTEX_ARRAY: 1420af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1421af69d88dSmrg goto invalid_enum_error; 1422af69d88dSmrg return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS].Enabled; 14237117f1b4Smrg case GL_NORMAL_ARRAY: 1424af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1425af69d88dSmrg goto invalid_enum_error; 1426af69d88dSmrg return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled; 14277117f1b4Smrg case GL_COLOR_ARRAY: 1428af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1429af69d88dSmrg goto invalid_enum_error; 1430af69d88dSmrg return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled; 14317117f1b4Smrg case GL_INDEX_ARRAY: 1432af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1433af69d88dSmrg goto invalid_enum_error; 1434af69d88dSmrg return ctx->Array.VAO-> 1435af69d88dSmrg VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled; 14367117f1b4Smrg case GL_TEXTURE_COORD_ARRAY: 1437af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1438af69d88dSmrg goto invalid_enum_error; 1439af69d88dSmrg return ctx->Array.VAO-> 1440af69d88dSmrg VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled; 14417117f1b4Smrg case GL_EDGE_FLAG_ARRAY: 1442af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1443af69d88dSmrg goto invalid_enum_error; 1444af69d88dSmrg return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled; 14457117f1b4Smrg case GL_FOG_COORDINATE_ARRAY_EXT: 1446af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1447af69d88dSmrg goto invalid_enum_error; 1448af69d88dSmrg return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_FOG].Enabled; 14497117f1b4Smrg case GL_SECONDARY_COLOR_ARRAY_EXT: 1450af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1451af69d88dSmrg goto invalid_enum_error; 1452af69d88dSmrg return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled; 1453c1f859d4Smrg case GL_POINT_SIZE_ARRAY_OES: 1454af69d88dSmrg if (ctx->API != API_OPENGLES) 1455af69d88dSmrg goto invalid_enum_error; 1456af69d88dSmrg return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled; 14577117f1b4Smrg 14587117f1b4Smrg /* GL_ARB_texture_cube_map */ 14597117f1b4Smrg case GL_TEXTURE_CUBE_MAP_ARB: 14607117f1b4Smrg CHECK_EXTENSION(ARB_texture_cube_map); 14617117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); 14627117f1b4Smrg 14637117f1b4Smrg /* GL_EXT_secondary_color */ 14647117f1b4Smrg case GL_COLOR_SUM_EXT: 1465af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1466af69d88dSmrg goto invalid_enum_error; 14677117f1b4Smrg return ctx->Fog.ColorSumEnabled; 14687117f1b4Smrg 14697117f1b4Smrg /* GL_ARB_multisample */ 14707117f1b4Smrg case GL_MULTISAMPLE_ARB: 1471af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 1472af69d88dSmrg goto invalid_enum_error; 14737117f1b4Smrg return ctx->Multisample.Enabled; 14747117f1b4Smrg case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: 14757117f1b4Smrg return ctx->Multisample.SampleAlphaToCoverage; 14767117f1b4Smrg case GL_SAMPLE_ALPHA_TO_ONE_ARB: 1477af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 1478af69d88dSmrg goto invalid_enum_error; 14797117f1b4Smrg return ctx->Multisample.SampleAlphaToOne; 14807117f1b4Smrg case GL_SAMPLE_COVERAGE_ARB: 14817117f1b4Smrg return ctx->Multisample.SampleCoverage; 14827117f1b4Smrg case GL_SAMPLE_COVERAGE_INVERT_ARB: 1483af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1484af69d88dSmrg goto invalid_enum_error; 14857117f1b4Smrg return ctx->Multisample.SampleCoverageInvert; 14867117f1b4Smrg 14877117f1b4Smrg /* GL_IBM_rasterpos_clip */ 14887117f1b4Smrg case GL_RASTER_POSITION_UNCLIPPED_IBM: 1489af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1490af69d88dSmrg goto invalid_enum_error; 14917117f1b4Smrg return ctx->Transform.RasterPositionUnclipped; 14927117f1b4Smrg 14937117f1b4Smrg /* GL_NV_point_sprite */ 14947117f1b4Smrg case GL_POINT_SPRITE_NV: 1495af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1496af69d88dSmrg goto invalid_enum_error; 14977117f1b4Smrg CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) 14987117f1b4Smrg return ctx->Point.PointSprite; 14997117f1b4Smrg 15007117f1b4Smrg case GL_VERTEX_PROGRAM_ARB: 1501af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1502af69d88dSmrg goto invalid_enum_error; 1503af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program); 15047117f1b4Smrg return ctx->VertexProgram.Enabled; 15057117f1b4Smrg case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: 1506af69d88dSmrg /* This was added with ARB_vertex_program, but it is also used with 1507af69d88dSmrg * GLSL vertex shaders on desktop. 1508af69d88dSmrg */ 1509af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1510af69d88dSmrg goto invalid_enum_error; 1511af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program); 15127117f1b4Smrg return ctx->VertexProgram.PointSizeEnabled; 15137117f1b4Smrg case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: 1514af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1515af69d88dSmrg goto invalid_enum_error; 1516af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program); 15177117f1b4Smrg return ctx->VertexProgram.TwoSideEnabled; 15187117f1b4Smrg 15197117f1b4Smrg /* GL_NV_texture_rectangle */ 15207117f1b4Smrg case GL_TEXTURE_RECTANGLE_NV: 1521af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1522af69d88dSmrg goto invalid_enum_error; 15237117f1b4Smrg CHECK_EXTENSION(NV_texture_rectangle); 15247117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_RECT_BIT); 15257117f1b4Smrg 15267117f1b4Smrg /* GL_EXT_stencil_two_side */ 15277117f1b4Smrg case GL_STENCIL_TEST_TWO_SIDE_EXT: 1528af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1529af69d88dSmrg goto invalid_enum_error; 15307117f1b4Smrg CHECK_EXTENSION(EXT_stencil_two_side); 15317117f1b4Smrg return ctx->Stencil.TestTwoSide; 15327117f1b4Smrg 15337117f1b4Smrg case GL_FRAGMENT_PROGRAM_ARB: 1534af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1535af69d88dSmrg goto invalid_enum_error; 15367117f1b4Smrg return ctx->FragmentProgram.Enabled; 15377117f1b4Smrg 15387117f1b4Smrg /* GL_EXT_depth_bounds_test */ 15397117f1b4Smrg case GL_DEPTH_BOUNDS_TEST_EXT: 1540af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1541af69d88dSmrg goto invalid_enum_error; 15427117f1b4Smrg CHECK_EXTENSION(EXT_depth_bounds_test); 15437117f1b4Smrg return ctx->Depth.BoundsTest; 15447117f1b4Smrg 15454a49301eSmrg /* GL_ARB_depth_clamp */ 15464a49301eSmrg case GL_DEPTH_CLAMP: 1547af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1548af69d88dSmrg goto invalid_enum_error; 15494a49301eSmrg CHECK_EXTENSION(ARB_depth_clamp); 15504a49301eSmrg return ctx->Transform.DepthClamp; 15514a49301eSmrg 15527117f1b4Smrg case GL_FRAGMENT_SHADER_ATI: 1553af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1554af69d88dSmrg goto invalid_enum_error; 15557117f1b4Smrg CHECK_EXTENSION(ATI_fragment_shader); 15567117f1b4Smrg return ctx->ATIFragmentShader.Enabled; 15574a49301eSmrg 15584a49301eSmrg case GL_TEXTURE_CUBE_MAP_SEAMLESS: 1559af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1560af69d88dSmrg goto invalid_enum_error; 15614a49301eSmrg CHECK_EXTENSION(ARB_seamless_cube_map); 15624a49301eSmrg return ctx->Texture.CubeMapSeamless; 15634a49301eSmrg 15643464ebd5Sriastradh case GL_RASTERIZER_DISCARD: 1565af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) 1566af69d88dSmrg goto invalid_enum_error; 15673464ebd5Sriastradh CHECK_EXTENSION(EXT_transform_feedback); 1568af69d88dSmrg return ctx->RasterDiscard; 15693464ebd5Sriastradh 15703464ebd5Sriastradh /* GL_NV_primitive_restart */ 15713464ebd5Sriastradh case GL_PRIMITIVE_RESTART_NV: 1572af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.NV_primitive_restart) { 15733464ebd5Sriastradh goto invalid_enum_error; 15743464ebd5Sriastradh } 15753464ebd5Sriastradh return ctx->Array.PrimitiveRestart; 15763464ebd5Sriastradh 15773464ebd5Sriastradh /* GL 3.1 primitive restart */ 15783464ebd5Sriastradh case GL_PRIMITIVE_RESTART: 1579af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 31) { 15803464ebd5Sriastradh goto invalid_enum_error; 15813464ebd5Sriastradh } 15823464ebd5Sriastradh return ctx->Array.PrimitiveRestart; 15833464ebd5Sriastradh 1584af69d88dSmrg case GL_PRIMITIVE_RESTART_FIXED_INDEX: 1585af69d88dSmrg if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility) { 1586af69d88dSmrg goto invalid_enum_error; 1587af69d88dSmrg } 1588af69d88dSmrg return ctx->Array.PrimitiveRestartFixedIndex; 1589af69d88dSmrg 15903464ebd5Sriastradh /* GL3.0 - GL_framebuffer_sRGB */ 15913464ebd5Sriastradh case GL_FRAMEBUFFER_SRGB_EXT: 1592af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1593af69d88dSmrg goto invalid_enum_error; 15943464ebd5Sriastradh CHECK_EXTENSION(EXT_framebuffer_sRGB); 15953464ebd5Sriastradh return ctx->Color.sRGBEnabled; 15963464ebd5Sriastradh 1597af69d88dSmrg /* GL_OES_EGL_image_external */ 1598af69d88dSmrg case GL_TEXTURE_EXTERNAL_OES: 1599af69d88dSmrg if (!_mesa_is_gles(ctx)) 1600af69d88dSmrg goto invalid_enum_error; 1601af69d88dSmrg CHECK_EXTENSION(OES_EGL_image_external); 1602af69d88dSmrg return is_texture_enabled(ctx, TEXTURE_EXTERNAL_BIT); 1603af69d88dSmrg 1604af69d88dSmrg /* ARB_texture_multisample */ 1605af69d88dSmrg case GL_SAMPLE_MASK: 1606af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1607af69d88dSmrg goto invalid_enum_error; 1608af69d88dSmrg CHECK_EXTENSION(ARB_texture_multisample); 1609af69d88dSmrg return ctx->Multisample.SampleMask; 1610af69d88dSmrg 1611af69d88dSmrg /* ARB_sample_shading */ 1612af69d88dSmrg case GL_SAMPLE_SHADING: 1613af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1614af69d88dSmrg goto invalid_enum_error; 1615af69d88dSmrg CHECK_EXTENSION(ARB_sample_shading); 1616af69d88dSmrg return ctx->Multisample.SampleShading; 1617af69d88dSmrg 16187117f1b4Smrg default: 16193464ebd5Sriastradh goto invalid_enum_error; 16207117f1b4Smrg } 16213464ebd5Sriastradh 16223464ebd5Sriastradh return GL_FALSE; 16233464ebd5Sriastradh 16243464ebd5Sriastradhinvalid_enum_error: 1625af69d88dSmrg _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(%s)", 1626af69d88dSmrg _mesa_lookup_enum_by_nr(cap)); 16273464ebd5Sriastradh return GL_FALSE; 16287117f1b4Smrg} 1629