enable.c revision a8bb7a65
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" 3201e04c3fSmrg#include "arrayobj.h" 3301e04c3fSmrg#include "blend.h" 343464ebd5Sriastradh#include "clip.h" 357117f1b4Smrg#include "context.h" 3601e04c3fSmrg#include "debug_output.h" 377117f1b4Smrg#include "enable.h" 38af69d88dSmrg#include "errors.h" 397117f1b4Smrg#include "light.h" 407117f1b4Smrg#include "mtypes.h" 417117f1b4Smrg#include "enums.h" 4201e04c3fSmrg#include "state.h" 434a49301eSmrg#include "texstate.h" 4401e04c3fSmrg#include "varray.h" 457117f1b4Smrg 467117f1b4Smrg 477117f1b4Smrg 487117f1b4Smrg#define CHECK_EXTENSION(EXTNAME, CAP) \ 497117f1b4Smrg if (!ctx->Extensions.EXTNAME) { \ 503464ebd5Sriastradh goto invalid_enum_error; \ 517117f1b4Smrg } 527117f1b4Smrg 537117f1b4Smrg 54af69d88dSmrgstatic void 55af69d88dSmrgupdate_derived_primitive_restart_state(struct gl_context *ctx) 56af69d88dSmrg{ 57af69d88dSmrg /* Update derived primitive restart state. 58af69d88dSmrg */ 59af69d88dSmrg ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart 60af69d88dSmrg || ctx->Array.PrimitiveRestartFixedIndex; 61af69d88dSmrg} 62af69d88dSmrg 6301e04c3fSmrg 6401e04c3fSmrg/** 6501e04c3fSmrg * Helper to enable/disable VAO client-side state. 6601e04c3fSmrg */ 6701e04c3fSmrgstatic void 6801e04c3fSmrgvao_state(struct gl_context *ctx, gl_vert_attrib attr, GLboolean state) 6901e04c3fSmrg{ 7001e04c3fSmrg if (state) 7101e04c3fSmrg _mesa_enable_vertex_array_attrib(ctx, ctx->Array.VAO, attr); 7201e04c3fSmrg else 7301e04c3fSmrg _mesa_disable_vertex_array_attrib(ctx, ctx->Array.VAO, attr); 7401e04c3fSmrg} 7501e04c3fSmrg 7601e04c3fSmrg 777117f1b4Smrg/** 787117f1b4Smrg * Helper to enable/disable client-side state. 797117f1b4Smrg */ 807117f1b4Smrgstatic void 813464ebd5Sriastradhclient_state(struct gl_context *ctx, GLenum cap, GLboolean state) 827117f1b4Smrg{ 837117f1b4Smrg switch (cap) { 847117f1b4Smrg case GL_VERTEX_ARRAY: 8501e04c3fSmrg vao_state(ctx, VERT_ATTRIB_POS, state); 867117f1b4Smrg break; 877117f1b4Smrg case GL_NORMAL_ARRAY: 8801e04c3fSmrg vao_state(ctx, VERT_ATTRIB_NORMAL, state); 897117f1b4Smrg break; 907117f1b4Smrg case GL_COLOR_ARRAY: 9101e04c3fSmrg vao_state(ctx, VERT_ATTRIB_COLOR0, state); 927117f1b4Smrg break; 937117f1b4Smrg case GL_INDEX_ARRAY: 9401e04c3fSmrg vao_state(ctx, VERT_ATTRIB_COLOR_INDEX, state); 957117f1b4Smrg break; 967117f1b4Smrg case GL_TEXTURE_COORD_ARRAY: 9701e04c3fSmrg vao_state(ctx, VERT_ATTRIB_TEX(ctx->Array.ActiveTexture), state); 987117f1b4Smrg break; 997117f1b4Smrg case GL_EDGE_FLAG_ARRAY: 10001e04c3fSmrg vao_state(ctx, VERT_ATTRIB_EDGEFLAG, state); 1017117f1b4Smrg break; 1027117f1b4Smrg case GL_FOG_COORDINATE_ARRAY_EXT: 10301e04c3fSmrg vao_state(ctx, VERT_ATTRIB_FOG, state); 1047117f1b4Smrg break; 1057117f1b4Smrg case GL_SECONDARY_COLOR_ARRAY_EXT: 10601e04c3fSmrg vao_state(ctx, VERT_ATTRIB_COLOR1, state); 1077117f1b4Smrg break; 1087117f1b4Smrg 109c1f859d4Smrg case GL_POINT_SIZE_ARRAY_OES: 11001e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 11101e04c3fSmrg ctx->VertexProgram.PointSizeEnabled = state; 11201e04c3fSmrg vao_state(ctx, VERT_ATTRIB_POINT_SIZE, state); 1137117f1b4Smrg break; 1147117f1b4Smrg 1153464ebd5Sriastradh /* GL_NV_primitive_restart */ 1163464ebd5Sriastradh case GL_PRIMITIVE_RESTART_NV: 11701e04c3fSmrg if (!ctx->Extensions.NV_primitive_restart) 1183464ebd5Sriastradh goto invalid_enum_error; 11901e04c3fSmrg if (ctx->Array.PrimitiveRestart == state) 12001e04c3fSmrg return; 12101e04c3fSmrg 12201e04c3fSmrg FLUSH_VERTICES(ctx, 0); 12301e04c3fSmrg ctx->Array.PrimitiveRestart = state; 12401e04c3fSmrg update_derived_primitive_restart_state(ctx); 12501e04c3fSmrg return; 1263464ebd5Sriastradh 1277117f1b4Smrg default: 1283464ebd5Sriastradh goto invalid_enum_error; 1297117f1b4Smrg } 1307117f1b4Smrg 1317117f1b4Smrg if (ctx->Driver.Enable) { 1327117f1b4Smrg ctx->Driver.Enable( ctx, cap, state ); 1337117f1b4Smrg } 1343464ebd5Sriastradh 1353464ebd5Sriastradh return; 1363464ebd5Sriastradh 1373464ebd5Sriastradhinvalid_enum_error: 138af69d88dSmrg _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(%s)", 13901e04c3fSmrg state ? "Enable" : "Disable", _mesa_enum_to_string(cap)); 1407117f1b4Smrg} 1417117f1b4Smrg 1427117f1b4Smrg 1437117f1b4Smrg/** 1447117f1b4Smrg * Enable GL capability. 1457117f1b4Smrg * \param cap state to enable/disable. 1467117f1b4Smrg * 1477117f1b4Smrg * Get's the current context, assures that we're outside glBegin()/glEnd() and 1487117f1b4Smrg * calls client_state(). 1497117f1b4Smrg */ 1507117f1b4Smrgvoid GLAPIENTRY 1517117f1b4Smrg_mesa_EnableClientState( GLenum cap ) 1527117f1b4Smrg{ 1537117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 1547117f1b4Smrg client_state( ctx, cap, GL_TRUE ); 1557117f1b4Smrg} 1567117f1b4Smrg 1577117f1b4Smrg 1587117f1b4Smrg/** 1597117f1b4Smrg * Disable GL capability. 1607117f1b4Smrg * \param cap state to enable/disable. 1617117f1b4Smrg * 1627117f1b4Smrg * Get's the current context, assures that we're outside glBegin()/glEnd() and 1637117f1b4Smrg * calls client_state(). 1647117f1b4Smrg */ 1657117f1b4Smrgvoid GLAPIENTRY 1667117f1b4Smrg_mesa_DisableClientState( GLenum cap ) 1677117f1b4Smrg{ 1687117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 1697117f1b4Smrg client_state( ctx, cap, GL_FALSE ); 1707117f1b4Smrg} 1717117f1b4Smrg 1727117f1b4Smrg 1737117f1b4Smrg#undef CHECK_EXTENSION 1747117f1b4Smrg#define CHECK_EXTENSION(EXTNAME, CAP) \ 1757117f1b4Smrg if (!ctx->Extensions.EXTNAME) { \ 1763464ebd5Sriastradh goto invalid_enum_error; \ 1777117f1b4Smrg } 1787117f1b4Smrg 1797117f1b4Smrg#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ 1807117f1b4Smrg if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ 1813464ebd5Sriastradh goto invalid_enum_error; \ 1827117f1b4Smrg } 1837117f1b4Smrg 184c1f859d4Smrg/** 185c1f859d4Smrg * Return pointer to current texture unit for setting/getting coordinate 186c1f859d4Smrg * state. 1873464ebd5Sriastradh * Note that we'll set GL_INVALID_OPERATION and return NULL if the active 1883464ebd5Sriastradh * texture unit is higher than the number of supported coordinate units. 189c1f859d4Smrg */ 19001e04c3fSmrgstatic struct gl_fixedfunc_texture_unit * 1913464ebd5Sriastradhget_texcoord_unit(struct gl_context *ctx) 192c1f859d4Smrg{ 193c1f859d4Smrg if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { 194c1f859d4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)"); 195c1f859d4Smrg return NULL; 196c1f859d4Smrg } 197c1f859d4Smrg else { 19801e04c3fSmrg return &ctx->Texture.FixedFuncUnit[ctx->Texture.CurrentUnit]; 199c1f859d4Smrg } 200c1f859d4Smrg} 201c1f859d4Smrg 202c1f859d4Smrg 2037117f1b4Smrg/** 2047117f1b4Smrg * Helper function to enable or disable a texture target. 2054a49301eSmrg * \param bit one of the TEXTURE_x_BIT values 2064a49301eSmrg * \return GL_TRUE if state is changing or GL_FALSE if no change 2077117f1b4Smrg */ 2087117f1b4Smrgstatic GLboolean 2093464ebd5Sriastradhenable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit) 2107117f1b4Smrg{ 21101e04c3fSmrg struct gl_fixedfunc_texture_unit *texUnit = 21201e04c3fSmrg _mesa_get_current_fixedfunc_tex_unit(ctx); 21301e04c3fSmrg if (!texUnit) 21401e04c3fSmrg return GL_FALSE; 21501e04c3fSmrg 2164a49301eSmrg const GLbitfield newenabled = state 2174a49301eSmrg ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit); 2187117f1b4Smrg 2194a49301eSmrg if (texUnit->Enabled == newenabled) 2207117f1b4Smrg return GL_FALSE; 2217117f1b4Smrg 22201e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); 2237117f1b4Smrg texUnit->Enabled = newenabled; 2247117f1b4Smrg return GL_TRUE; 2257117f1b4Smrg} 2267117f1b4Smrg 2277117f1b4Smrg 228af69d88dSmrg/** 229af69d88dSmrg * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for 230af69d88dSmrg * whether the API supports it (GLES doesn't). 231af69d88dSmrg */ 232af69d88dSmrgvoid 233af69d88dSmrg_mesa_set_multisample(struct gl_context *ctx, GLboolean state) 234af69d88dSmrg{ 235af69d88dSmrg if (ctx->Multisample.Enabled == state) 236af69d88dSmrg return; 23701e04c3fSmrg 23801e04c3fSmrg /* GL compatibility needs Multisample.Enable to determine program state 23901e04c3fSmrg * constants. 24001e04c3fSmrg */ 24101e04c3fSmrg if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES || 24201e04c3fSmrg !ctx->DriverFlags.NewMultisampleEnable) { 24301e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 24401e04c3fSmrg } else { 24501e04c3fSmrg FLUSH_VERTICES(ctx, 0); 24601e04c3fSmrg } 24701e04c3fSmrg 24801e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewMultisampleEnable; 249af69d88dSmrg ctx->Multisample.Enabled = state; 250af69d88dSmrg 251af69d88dSmrg if (ctx->Driver.Enable) { 252af69d88dSmrg ctx->Driver.Enable(ctx, GL_MULTISAMPLE, state); 253af69d88dSmrg } 254af69d88dSmrg} 255af69d88dSmrg 256af69d88dSmrg/** 257af69d88dSmrg * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the 258af69d88dSmrg * check for whether the API supports it (GLES doesn't). 259af69d88dSmrg */ 260af69d88dSmrgvoid 261af69d88dSmrg_mesa_set_framebuffer_srgb(struct gl_context *ctx, GLboolean state) 262af69d88dSmrg{ 263af69d88dSmrg if (ctx->Color.sRGBEnabled == state) 264af69d88dSmrg return; 26501e04c3fSmrg 26601e04c3fSmrg /* TODO: Switch i965 to the new flag and remove the conditional */ 26701e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewFramebufferSRGB ? 0 : _NEW_BUFFERS); 26801e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewFramebufferSRGB; 269af69d88dSmrg ctx->Color.sRGBEnabled = state; 270af69d88dSmrg 271af69d88dSmrg if (ctx->Driver.Enable) { 272af69d88dSmrg ctx->Driver.Enable(ctx, GL_FRAMEBUFFER_SRGB, state); 273af69d88dSmrg } 274af69d88dSmrg} 275af69d88dSmrg 2767117f1b4Smrg/** 2777117f1b4Smrg * Helper function to enable or disable state. 2787117f1b4Smrg * 2797117f1b4Smrg * \param ctx GL context. 2807117f1b4Smrg * \param cap the state to enable/disable 2817117f1b4Smrg * \param state whether to enable or disable the specified capability. 2827117f1b4Smrg * 2837117f1b4Smrg * Updates the current context and flushes the vertices as needed. For 2847117f1b4Smrg * capabilities associated with extensions it verifies that those extensions 2857117f1b4Smrg * are effectivly present before updating. Notifies the driver via 2867117f1b4Smrg * dd_function_table::Enable. 2877117f1b4Smrg */ 2887117f1b4Smrgvoid 2893464ebd5Sriastradh_mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) 2907117f1b4Smrg{ 2917117f1b4Smrg if (MESA_VERBOSE & VERBOSE_API) 2927117f1b4Smrg _mesa_debug(ctx, "%s %s (newstate is %x)\n", 2937117f1b4Smrg state ? "glEnable" : "glDisable", 29401e04c3fSmrg _mesa_enum_to_string(cap), 2957117f1b4Smrg ctx->NewState); 2967117f1b4Smrg 2977117f1b4Smrg switch (cap) { 2987117f1b4Smrg case GL_ALPHA_TEST: 299af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 300af69d88dSmrg goto invalid_enum_error; 3017117f1b4Smrg if (ctx->Color.AlphaEnabled == state) 3027117f1b4Smrg return; 30301e04c3fSmrg /* AlphaEnabled is used by the fixed-func fragment program */ 3047117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 30501e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewAlphaTest; 3067117f1b4Smrg ctx->Color.AlphaEnabled = state; 3077117f1b4Smrg break; 3087117f1b4Smrg case GL_AUTO_NORMAL: 309af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 310af69d88dSmrg goto invalid_enum_error; 3117117f1b4Smrg if (ctx->Eval.AutoNormal == state) 3127117f1b4Smrg return; 3137117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 3147117f1b4Smrg ctx->Eval.AutoNormal = state; 3157117f1b4Smrg break; 3167117f1b4Smrg case GL_BLEND: 317cdc920a0Smrg { 3183464ebd5Sriastradh GLbitfield newEnabled = 3193464ebd5Sriastradh state * ((1 << ctx->Const.MaxDrawBuffers) - 1); 320cdc920a0Smrg if (newEnabled != ctx->Color.BlendEnabled) { 32101e04c3fSmrg _mesa_flush_vertices_for_blend_adv(ctx, newEnabled, 32201e04c3fSmrg ctx->Color._AdvancedBlendMode); 323cdc920a0Smrg ctx->Color.BlendEnabled = newEnabled; 324cdc920a0Smrg } 325cdc920a0Smrg } 3267117f1b4Smrg break; 327af69d88dSmrg case GL_CLIP_DISTANCE0: /* aka GL_CLIP_PLANE0 */ 328af69d88dSmrg case GL_CLIP_DISTANCE1: 329af69d88dSmrg case GL_CLIP_DISTANCE2: 330af69d88dSmrg case GL_CLIP_DISTANCE3: 331af69d88dSmrg case GL_CLIP_DISTANCE4: 332af69d88dSmrg case GL_CLIP_DISTANCE5: 333af69d88dSmrg case GL_CLIP_DISTANCE6: 334af69d88dSmrg case GL_CLIP_DISTANCE7: 3357117f1b4Smrg { 336af69d88dSmrg const GLuint p = cap - GL_CLIP_DISTANCE0; 337af69d88dSmrg 338af69d88dSmrg if (p >= ctx->Const.MaxClipPlanes) 339af69d88dSmrg goto invalid_enum_error; 3407117f1b4Smrg 3413464ebd5Sriastradh if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) 3423464ebd5Sriastradh == ((GLuint) state << p)) 3437117f1b4Smrg return; 3447117f1b4Smrg 34501e04c3fSmrg /* The compatibility profile needs _NEW_TRANSFORM to transform 34601e04c3fSmrg * clip planes according to the projection matrix. 34701e04c3fSmrg */ 34801e04c3fSmrg if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES || 34901e04c3fSmrg !ctx->DriverFlags.NewClipPlaneEnable) { 35001e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 35101e04c3fSmrg } else { 35201e04c3fSmrg FLUSH_VERTICES(ctx, 0); 35301e04c3fSmrg } 35401e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewClipPlaneEnable; 3557117f1b4Smrg 3567117f1b4Smrg if (state) { 3577117f1b4Smrg ctx->Transform.ClipPlanesEnabled |= (1 << p); 35801e04c3fSmrg 35901e04c3fSmrg /* The projection matrix transforms the clip plane. */ 36001e04c3fSmrg /* TODO: glEnable might not be the best place to do it. */ 36101e04c3fSmrg if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) { 36201e04c3fSmrg _mesa_update_clip_plane(ctx, p); 36301e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewClipPlane; 36401e04c3fSmrg } 3657117f1b4Smrg } 3667117f1b4Smrg else { 3677117f1b4Smrg ctx->Transform.ClipPlanesEnabled &= ~(1 << p); 36801e04c3fSmrg } 3697117f1b4Smrg } 3707117f1b4Smrg break; 3717117f1b4Smrg case GL_COLOR_MATERIAL: 372af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 373af69d88dSmrg goto invalid_enum_error; 3747117f1b4Smrg if (ctx->Light.ColorMaterialEnabled == state) 3757117f1b4Smrg return; 3767117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LIGHT); 3777117f1b4Smrg FLUSH_CURRENT(ctx, 0); 3787117f1b4Smrg ctx->Light.ColorMaterialEnabled = state; 3797117f1b4Smrg if (state) { 3807117f1b4Smrg _mesa_update_color_material( ctx, 3817117f1b4Smrg ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); 3827117f1b4Smrg } 3837117f1b4Smrg break; 3847117f1b4Smrg case GL_CULL_FACE: 3857117f1b4Smrg if (ctx->Polygon.CullFlag == state) 3867117f1b4Smrg return; 38701e04c3fSmrg FLUSH_VERTICES(ctx, 38801e04c3fSmrg ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON); 38901e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState; 3907117f1b4Smrg ctx->Polygon.CullFlag = state; 3917117f1b4Smrg break; 3927117f1b4Smrg case GL_DEPTH_TEST: 3937117f1b4Smrg if (ctx->Depth.Test == state) 3947117f1b4Smrg return; 39501e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewDepth ? 0 : _NEW_DEPTH); 39601e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewDepth; 3977117f1b4Smrg ctx->Depth.Test = state; 3987117f1b4Smrg break; 399af69d88dSmrg case GL_DEBUG_OUTPUT: 400af69d88dSmrg case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB: 40101e04c3fSmrg _mesa_set_debug_state_int(ctx, cap, state); 402af69d88dSmrg break; 4037117f1b4Smrg case GL_DITHER: 4047117f1b4Smrg if (ctx->Color.DitherFlag == state) 4057117f1b4Smrg return; 40601e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlend ? 0 : _NEW_COLOR); 40701e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewBlend; 4087117f1b4Smrg ctx->Color.DitherFlag = state; 4097117f1b4Smrg break; 4107117f1b4Smrg case GL_FOG: 411af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 412af69d88dSmrg goto invalid_enum_error; 4137117f1b4Smrg if (ctx->Fog.Enabled == state) 4147117f1b4Smrg return; 4157117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_FOG); 4167117f1b4Smrg ctx->Fog.Enabled = state; 41701e04c3fSmrg ctx->Fog._PackedEnabledMode = state ? ctx->Fog._PackedMode : FOG_NONE; 4187117f1b4Smrg break; 4197117f1b4Smrg case GL_LIGHT0: 4207117f1b4Smrg case GL_LIGHT1: 4217117f1b4Smrg case GL_LIGHT2: 4227117f1b4Smrg case GL_LIGHT3: 4237117f1b4Smrg case GL_LIGHT4: 4247117f1b4Smrg case GL_LIGHT5: 4257117f1b4Smrg case GL_LIGHT6: 4267117f1b4Smrg case GL_LIGHT7: 427af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 428af69d88dSmrg goto invalid_enum_error; 4297117f1b4Smrg if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) 4307117f1b4Smrg return; 4317117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LIGHT); 4327117f1b4Smrg ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; 4337117f1b4Smrg if (state) { 43401e04c3fSmrg ctx->Light._EnabledLights |= 1u << (cap - GL_LIGHT0); 4357117f1b4Smrg } 4367117f1b4Smrg else { 43701e04c3fSmrg ctx->Light._EnabledLights &= ~(1u << (cap - GL_LIGHT0)); 4387117f1b4Smrg } 4397117f1b4Smrg break; 4407117f1b4Smrg case GL_LIGHTING: 441af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 442af69d88dSmrg goto invalid_enum_error; 4437117f1b4Smrg if (ctx->Light.Enabled == state) 4447117f1b4Smrg return; 4457117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LIGHT); 4467117f1b4Smrg ctx->Light.Enabled = state; 4477117f1b4Smrg break; 4487117f1b4Smrg case GL_LINE_SMOOTH: 449af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 450af69d88dSmrg goto invalid_enum_error; 4517117f1b4Smrg if (ctx->Line.SmoothFlag == state) 4527117f1b4Smrg return; 45301e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLineState ? 0 : _NEW_LINE); 45401e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewLineState; 4557117f1b4Smrg ctx->Line.SmoothFlag = state; 4567117f1b4Smrg break; 4577117f1b4Smrg case GL_LINE_STIPPLE: 458af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 459af69d88dSmrg goto invalid_enum_error; 4607117f1b4Smrg if (ctx->Line.StippleFlag == state) 4617117f1b4Smrg return; 46201e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLineState ? 0 : _NEW_LINE); 46301e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewLineState; 4647117f1b4Smrg ctx->Line.StippleFlag = state; 4657117f1b4Smrg break; 4667117f1b4Smrg case GL_INDEX_LOGIC_OP: 467af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 468af69d88dSmrg goto invalid_enum_error; 4697117f1b4Smrg if (ctx->Color.IndexLogicOpEnabled == state) 4707117f1b4Smrg return; 47101e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLogicOp ? 0 : _NEW_COLOR); 47201e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewLogicOp; 4737117f1b4Smrg ctx->Color.IndexLogicOpEnabled = state; 4747117f1b4Smrg break; 47501e04c3fSmrg case GL_CONSERVATIVE_RASTERIZATION_INTEL: 47601e04c3fSmrg if (!_mesa_has_INTEL_conservative_rasterization(ctx)) 47701e04c3fSmrg goto invalid_enum_error; 47801e04c3fSmrg if (ctx->IntelConservativeRasterization == state) 47901e04c3fSmrg return; 48001e04c3fSmrg FLUSH_VERTICES(ctx, 0); 48101e04c3fSmrg ctx->NewDriverState |= 48201e04c3fSmrg ctx->DriverFlags.NewIntelConservativeRasterization; 48301e04c3fSmrg ctx->IntelConservativeRasterization = state; 48401e04c3fSmrg break; 48501e04c3fSmrg case GL_CONSERVATIVE_RASTERIZATION_NV: 48601e04c3fSmrg if (!_mesa_has_NV_conservative_raster(ctx)) 48701e04c3fSmrg goto invalid_enum_error; 48801e04c3fSmrg if (ctx->ConservativeRasterization == state) 48901e04c3fSmrg return; 49001e04c3fSmrg FLUSH_VERTICES(ctx, 0); 49101e04c3fSmrg ctx->NewDriverState |= 49201e04c3fSmrg ctx->DriverFlags.NewNvConservativeRasterization; 49301e04c3fSmrg ctx->ConservativeRasterization = state; 49401e04c3fSmrg break; 4957117f1b4Smrg case GL_COLOR_LOGIC_OP: 496af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 497af69d88dSmrg goto invalid_enum_error; 4987117f1b4Smrg if (ctx->Color.ColorLogicOpEnabled == state) 4997117f1b4Smrg return; 50001e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLogicOp ? 0 : _NEW_COLOR); 50101e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewLogicOp; 5027117f1b4Smrg ctx->Color.ColorLogicOpEnabled = state; 5037117f1b4Smrg break; 5047117f1b4Smrg case GL_MAP1_COLOR_4: 505af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 506af69d88dSmrg goto invalid_enum_error; 5077117f1b4Smrg if (ctx->Eval.Map1Color4 == state) 5087117f1b4Smrg return; 5097117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5107117f1b4Smrg ctx->Eval.Map1Color4 = state; 5117117f1b4Smrg break; 5127117f1b4Smrg case GL_MAP1_INDEX: 513af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 514af69d88dSmrg goto invalid_enum_error; 5157117f1b4Smrg if (ctx->Eval.Map1Index == state) 5167117f1b4Smrg return; 5177117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5187117f1b4Smrg ctx->Eval.Map1Index = state; 5197117f1b4Smrg break; 5207117f1b4Smrg case GL_MAP1_NORMAL: 521af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 522af69d88dSmrg goto invalid_enum_error; 5237117f1b4Smrg if (ctx->Eval.Map1Normal == state) 5247117f1b4Smrg return; 5257117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5267117f1b4Smrg ctx->Eval.Map1Normal = state; 5277117f1b4Smrg break; 5287117f1b4Smrg case GL_MAP1_TEXTURE_COORD_1: 529af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 530af69d88dSmrg goto invalid_enum_error; 5317117f1b4Smrg if (ctx->Eval.Map1TextureCoord1 == state) 5327117f1b4Smrg return; 5337117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5347117f1b4Smrg ctx->Eval.Map1TextureCoord1 = state; 5357117f1b4Smrg break; 5367117f1b4Smrg case GL_MAP1_TEXTURE_COORD_2: 537af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 538af69d88dSmrg goto invalid_enum_error; 5397117f1b4Smrg if (ctx->Eval.Map1TextureCoord2 == state) 5407117f1b4Smrg return; 5417117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5427117f1b4Smrg ctx->Eval.Map1TextureCoord2 = state; 5437117f1b4Smrg break; 5447117f1b4Smrg case GL_MAP1_TEXTURE_COORD_3: 545af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 546af69d88dSmrg goto invalid_enum_error; 5477117f1b4Smrg if (ctx->Eval.Map1TextureCoord3 == state) 5487117f1b4Smrg return; 5497117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5507117f1b4Smrg ctx->Eval.Map1TextureCoord3 = state; 5517117f1b4Smrg break; 5527117f1b4Smrg case GL_MAP1_TEXTURE_COORD_4: 553af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 554af69d88dSmrg goto invalid_enum_error; 5557117f1b4Smrg if (ctx->Eval.Map1TextureCoord4 == state) 5567117f1b4Smrg return; 5577117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5587117f1b4Smrg ctx->Eval.Map1TextureCoord4 = state; 5597117f1b4Smrg break; 5607117f1b4Smrg case GL_MAP1_VERTEX_3: 561af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 562af69d88dSmrg goto invalid_enum_error; 5637117f1b4Smrg if (ctx->Eval.Map1Vertex3 == state) 5647117f1b4Smrg return; 5657117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5667117f1b4Smrg ctx->Eval.Map1Vertex3 = state; 5677117f1b4Smrg break; 5687117f1b4Smrg case GL_MAP1_VERTEX_4: 569af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 570af69d88dSmrg goto invalid_enum_error; 5717117f1b4Smrg if (ctx->Eval.Map1Vertex4 == state) 5727117f1b4Smrg return; 5737117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5747117f1b4Smrg ctx->Eval.Map1Vertex4 = state; 5757117f1b4Smrg break; 5767117f1b4Smrg case GL_MAP2_COLOR_4: 577af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 578af69d88dSmrg goto invalid_enum_error; 5797117f1b4Smrg if (ctx->Eval.Map2Color4 == state) 5807117f1b4Smrg return; 5817117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5827117f1b4Smrg ctx->Eval.Map2Color4 = state; 5837117f1b4Smrg break; 5847117f1b4Smrg case GL_MAP2_INDEX: 585af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 586af69d88dSmrg goto invalid_enum_error; 5877117f1b4Smrg if (ctx->Eval.Map2Index == state) 5887117f1b4Smrg return; 5897117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5907117f1b4Smrg ctx->Eval.Map2Index = state; 5917117f1b4Smrg break; 5927117f1b4Smrg case GL_MAP2_NORMAL: 593af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 594af69d88dSmrg goto invalid_enum_error; 5957117f1b4Smrg if (ctx->Eval.Map2Normal == state) 5967117f1b4Smrg return; 5977117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5987117f1b4Smrg ctx->Eval.Map2Normal = state; 5997117f1b4Smrg break; 6007117f1b4Smrg case GL_MAP2_TEXTURE_COORD_1: 601af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 602af69d88dSmrg goto invalid_enum_error; 6037117f1b4Smrg if (ctx->Eval.Map2TextureCoord1 == state) 6047117f1b4Smrg return; 6057117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 6067117f1b4Smrg ctx->Eval.Map2TextureCoord1 = state; 6077117f1b4Smrg break; 6087117f1b4Smrg case GL_MAP2_TEXTURE_COORD_2: 609af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 610af69d88dSmrg goto invalid_enum_error; 6117117f1b4Smrg if (ctx->Eval.Map2TextureCoord2 == state) 6127117f1b4Smrg return; 6137117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 6147117f1b4Smrg ctx->Eval.Map2TextureCoord2 = state; 6157117f1b4Smrg break; 6167117f1b4Smrg case GL_MAP2_TEXTURE_COORD_3: 617af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 618af69d88dSmrg goto invalid_enum_error; 6197117f1b4Smrg if (ctx->Eval.Map2TextureCoord3 == state) 6207117f1b4Smrg return; 6217117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 6227117f1b4Smrg ctx->Eval.Map2TextureCoord3 = state; 6237117f1b4Smrg break; 6247117f1b4Smrg case GL_MAP2_TEXTURE_COORD_4: 625af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 626af69d88dSmrg goto invalid_enum_error; 6277117f1b4Smrg if (ctx->Eval.Map2TextureCoord4 == state) 6287117f1b4Smrg return; 6297117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 6307117f1b4Smrg ctx->Eval.Map2TextureCoord4 = state; 6317117f1b4Smrg break; 6327117f1b4Smrg case GL_MAP2_VERTEX_3: 633af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 634af69d88dSmrg goto invalid_enum_error; 6357117f1b4Smrg if (ctx->Eval.Map2Vertex3 == state) 6367117f1b4Smrg return; 6377117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 6387117f1b4Smrg ctx->Eval.Map2Vertex3 = state; 6397117f1b4Smrg break; 6407117f1b4Smrg case GL_MAP2_VERTEX_4: 641af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 642af69d88dSmrg goto invalid_enum_error; 6437117f1b4Smrg if (ctx->Eval.Map2Vertex4 == state) 6447117f1b4Smrg return; 6457117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 6467117f1b4Smrg ctx->Eval.Map2Vertex4 = state; 6477117f1b4Smrg break; 6487117f1b4Smrg case GL_NORMALIZE: 649af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 650af69d88dSmrg goto invalid_enum_error; 6517117f1b4Smrg if (ctx->Transform.Normalize == state) 6527117f1b4Smrg return; 6537117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 6547117f1b4Smrg ctx->Transform.Normalize = state; 6557117f1b4Smrg break; 6567117f1b4Smrg case GL_POINT_SMOOTH: 657af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 658af69d88dSmrg goto invalid_enum_error; 6597117f1b4Smrg if (ctx->Point.SmoothFlag == state) 6607117f1b4Smrg return; 6617117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POINT); 6627117f1b4Smrg ctx->Point.SmoothFlag = state; 6637117f1b4Smrg break; 6647117f1b4Smrg case GL_POLYGON_SMOOTH: 665af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 666af69d88dSmrg goto invalid_enum_error; 6677117f1b4Smrg if (ctx->Polygon.SmoothFlag == state) 6687117f1b4Smrg return; 66901e04c3fSmrg FLUSH_VERTICES(ctx, 67001e04c3fSmrg ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON); 67101e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState; 6727117f1b4Smrg ctx->Polygon.SmoothFlag = state; 6737117f1b4Smrg break; 6747117f1b4Smrg case GL_POLYGON_STIPPLE: 675af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 676af69d88dSmrg goto invalid_enum_error; 6777117f1b4Smrg if (ctx->Polygon.StippleFlag == state) 6787117f1b4Smrg return; 67901e04c3fSmrg FLUSH_VERTICES(ctx, 68001e04c3fSmrg ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON); 68101e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState; 6827117f1b4Smrg ctx->Polygon.StippleFlag = state; 6837117f1b4Smrg break; 6847117f1b4Smrg case GL_POLYGON_OFFSET_POINT: 685af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 686af69d88dSmrg goto invalid_enum_error; 6877117f1b4Smrg if (ctx->Polygon.OffsetPoint == state) 6887117f1b4Smrg return; 68901e04c3fSmrg FLUSH_VERTICES(ctx, 69001e04c3fSmrg ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON); 69101e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState; 6927117f1b4Smrg ctx->Polygon.OffsetPoint = state; 6937117f1b4Smrg break; 6947117f1b4Smrg case GL_POLYGON_OFFSET_LINE: 695af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 696af69d88dSmrg goto invalid_enum_error; 6977117f1b4Smrg if (ctx->Polygon.OffsetLine == state) 6987117f1b4Smrg return; 69901e04c3fSmrg FLUSH_VERTICES(ctx, 70001e04c3fSmrg ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON); 70101e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState; 7027117f1b4Smrg ctx->Polygon.OffsetLine = state; 7037117f1b4Smrg break; 7047117f1b4Smrg case GL_POLYGON_OFFSET_FILL: 7057117f1b4Smrg if (ctx->Polygon.OffsetFill == state) 7067117f1b4Smrg return; 70701e04c3fSmrg FLUSH_VERTICES(ctx, 70801e04c3fSmrg ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON); 70901e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState; 7107117f1b4Smrg ctx->Polygon.OffsetFill = state; 7117117f1b4Smrg break; 7127117f1b4Smrg case GL_RESCALE_NORMAL_EXT: 713af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 714af69d88dSmrg goto invalid_enum_error; 7157117f1b4Smrg if (ctx->Transform.RescaleNormals == state) 7167117f1b4Smrg return; 7177117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 7187117f1b4Smrg ctx->Transform.RescaleNormals = state; 7197117f1b4Smrg break; 7207117f1b4Smrg case GL_SCISSOR_TEST: 721af69d88dSmrg { 722af69d88dSmrg /* Must expand glEnable to all scissors */ 723af69d88dSmrg GLbitfield newEnabled = 724af69d88dSmrg state * ((1 << ctx->Const.MaxViewports) - 1); 725af69d88dSmrg if (newEnabled != ctx->Scissor.EnableFlags) { 72601e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewScissorTest ? 0 : 72701e04c3fSmrg _NEW_SCISSOR); 72801e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewScissorTest; 729af69d88dSmrg ctx->Scissor.EnableFlags = newEnabled; 730af69d88dSmrg } 731af69d88dSmrg } 7327117f1b4Smrg break; 7337117f1b4Smrg case GL_STENCIL_TEST: 7347117f1b4Smrg if (ctx->Stencil.Enabled == state) 7357117f1b4Smrg return; 73601e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewStencil ? 0 : _NEW_STENCIL); 73701e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewStencil; 7387117f1b4Smrg ctx->Stencil.Enabled = state; 7397117f1b4Smrg break; 7407117f1b4Smrg case GL_TEXTURE_1D: 741af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 742af69d88dSmrg goto invalid_enum_error; 7437117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { 7447117f1b4Smrg return; 7457117f1b4Smrg } 7467117f1b4Smrg break; 7477117f1b4Smrg case GL_TEXTURE_2D: 748af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 749af69d88dSmrg goto invalid_enum_error; 7507117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { 7517117f1b4Smrg return; 7527117f1b4Smrg } 7537117f1b4Smrg break; 7547117f1b4Smrg case GL_TEXTURE_3D: 755af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 756af69d88dSmrg goto invalid_enum_error; 7577117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { 7587117f1b4Smrg return; 7597117f1b4Smrg } 7607117f1b4Smrg break; 761c1f859d4Smrg case GL_TEXTURE_GEN_S: 7623464ebd5Sriastradh case GL_TEXTURE_GEN_T: 7633464ebd5Sriastradh case GL_TEXTURE_GEN_R: 7643464ebd5Sriastradh case GL_TEXTURE_GEN_Q: 765c1f859d4Smrg { 76601e04c3fSmrg struct gl_fixedfunc_texture_unit *texUnit = get_texcoord_unit(ctx); 767af69d88dSmrg 768af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 769af69d88dSmrg goto invalid_enum_error; 770af69d88dSmrg 771c1f859d4Smrg if (texUnit) { 7723464ebd5Sriastradh GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); 7733464ebd5Sriastradh GLbitfield newenabled = texUnit->TexGenEnabled & ~coordBit; 774c1f859d4Smrg if (state) 7753464ebd5Sriastradh newenabled |= coordBit; 776c1f859d4Smrg if (texUnit->TexGenEnabled == newenabled) 777c1f859d4Smrg return; 77801e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); 779c1f859d4Smrg texUnit->TexGenEnabled = newenabled; 780c1f859d4Smrg } 781c1f859d4Smrg } 7827117f1b4Smrg break; 7833464ebd5Sriastradh 7843464ebd5Sriastradh case GL_TEXTURE_GEN_STR_OES: 78501e04c3fSmrg /* disable S, T, and R at the same time */ 78601e04c3fSmrg { 78701e04c3fSmrg struct gl_fixedfunc_texture_unit *texUnit = get_texcoord_unit(ctx); 788af69d88dSmrg 789af69d88dSmrg if (ctx->API != API_OPENGLES) 790af69d88dSmrg goto invalid_enum_error; 791af69d88dSmrg 792c1f859d4Smrg if (texUnit) { 7933464ebd5Sriastradh GLuint newenabled = 79401e04c3fSmrg texUnit->TexGenEnabled & ~STR_BITS; 795c1f859d4Smrg if (state) 7963464ebd5Sriastradh newenabled |= STR_BITS; 797c1f859d4Smrg if (texUnit->TexGenEnabled == newenabled) 798c1f859d4Smrg return; 79901e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); 800c1f859d4Smrg texUnit->TexGenEnabled = newenabled; 801c1f859d4Smrg } 802c1f859d4Smrg } 8037117f1b4Smrg break; 8047117f1b4Smrg 805af69d88dSmrg /* client-side state */ 8067117f1b4Smrg case GL_VERTEX_ARRAY: 8077117f1b4Smrg case GL_NORMAL_ARRAY: 8087117f1b4Smrg case GL_COLOR_ARRAY: 8097117f1b4Smrg case GL_TEXTURE_COORD_ARRAY: 81001e04c3fSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 81101e04c3fSmrg goto invalid_enum_error; 81201e04c3fSmrg client_state( ctx, cap, state ); 81301e04c3fSmrg return; 81401e04c3fSmrg case GL_INDEX_ARRAY: 8157117f1b4Smrg case GL_EDGE_FLAG_ARRAY: 8167117f1b4Smrg case GL_FOG_COORDINATE_ARRAY_EXT: 8177117f1b4Smrg case GL_SECONDARY_COLOR_ARRAY_EXT: 81801e04c3fSmrg if (ctx->API != API_OPENGL_COMPAT) 81901e04c3fSmrg goto invalid_enum_error; 82001e04c3fSmrg client_state( ctx, cap, state ); 82101e04c3fSmrg return; 822c1f859d4Smrg case GL_POINT_SIZE_ARRAY_OES: 82301e04c3fSmrg if (ctx->API != API_OPENGLES) 82401e04c3fSmrg goto invalid_enum_error; 8257117f1b4Smrg client_state( ctx, cap, state ); 8267117f1b4Smrg return; 8277117f1b4Smrg 8287117f1b4Smrg /* GL_ARB_texture_cube_map */ 82901e04c3fSmrg case GL_TEXTURE_CUBE_MAP: 830af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 831af69d88dSmrg goto invalid_enum_error; 8327117f1b4Smrg CHECK_EXTENSION(ARB_texture_cube_map, cap); 8337117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { 8347117f1b4Smrg return; 8357117f1b4Smrg } 8367117f1b4Smrg break; 8377117f1b4Smrg 8387117f1b4Smrg /* GL_EXT_secondary_color */ 8397117f1b4Smrg case GL_COLOR_SUM_EXT: 840af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 841af69d88dSmrg goto invalid_enum_error; 8427117f1b4Smrg if (ctx->Fog.ColorSumEnabled == state) 8437117f1b4Smrg return; 8447117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_FOG); 8457117f1b4Smrg ctx->Fog.ColorSumEnabled = state; 8467117f1b4Smrg break; 8477117f1b4Smrg 8487117f1b4Smrg /* GL_ARB_multisample */ 8497117f1b4Smrg case GL_MULTISAMPLE_ARB: 850af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 851af69d88dSmrg goto invalid_enum_error; 852af69d88dSmrg _mesa_set_multisample(ctx, state); 853af69d88dSmrg return; 8547117f1b4Smrg case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: 8557117f1b4Smrg if (ctx->Multisample.SampleAlphaToCoverage == state) 8567117f1b4Smrg return; 85701e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleAlphaToXEnable ? 0 : 85801e04c3fSmrg _NEW_MULTISAMPLE); 85901e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewSampleAlphaToXEnable; 8607117f1b4Smrg ctx->Multisample.SampleAlphaToCoverage = state; 8617117f1b4Smrg break; 8627117f1b4Smrg case GL_SAMPLE_ALPHA_TO_ONE_ARB: 863af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 864af69d88dSmrg goto invalid_enum_error; 8657117f1b4Smrg if (ctx->Multisample.SampleAlphaToOne == state) 8667117f1b4Smrg return; 86701e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleAlphaToXEnable ? 0 : 86801e04c3fSmrg _NEW_MULTISAMPLE); 86901e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewSampleAlphaToXEnable; 8707117f1b4Smrg ctx->Multisample.SampleAlphaToOne = state; 8717117f1b4Smrg break; 8727117f1b4Smrg case GL_SAMPLE_COVERAGE_ARB: 8737117f1b4Smrg if (ctx->Multisample.SampleCoverage == state) 8747117f1b4Smrg return; 87501e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 : 87601e04c3fSmrg _NEW_MULTISAMPLE); 87701e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask; 8787117f1b4Smrg ctx->Multisample.SampleCoverage = state; 8797117f1b4Smrg break; 8807117f1b4Smrg case GL_SAMPLE_COVERAGE_INVERT_ARB: 881af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 882af69d88dSmrg goto invalid_enum_error; 8837117f1b4Smrg if (ctx->Multisample.SampleCoverageInvert == state) 8847117f1b4Smrg return; 88501e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 : 88601e04c3fSmrg _NEW_MULTISAMPLE); 88701e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask; 8887117f1b4Smrg ctx->Multisample.SampleCoverageInvert = state; 8897117f1b4Smrg break; 8907117f1b4Smrg 891af69d88dSmrg /* GL_ARB_sample_shading */ 892af69d88dSmrg case GL_SAMPLE_SHADING: 89301e04c3fSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) 894af69d88dSmrg goto invalid_enum_error; 895af69d88dSmrg CHECK_EXTENSION(ARB_sample_shading, cap); 896af69d88dSmrg if (ctx->Multisample.SampleShading == state) 897af69d88dSmrg return; 89801e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleShading ? 0 : 89901e04c3fSmrg _NEW_MULTISAMPLE); 90001e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewSampleShading; 901af69d88dSmrg ctx->Multisample.SampleShading = state; 902af69d88dSmrg break; 903af69d88dSmrg 9047117f1b4Smrg /* GL_IBM_rasterpos_clip */ 9057117f1b4Smrg case GL_RASTER_POSITION_UNCLIPPED_IBM: 906af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 907af69d88dSmrg goto invalid_enum_error; 9087117f1b4Smrg if (ctx->Transform.RasterPositionUnclipped == state) 9097117f1b4Smrg return; 91001e04c3fSmrg FLUSH_VERTICES(ctx, 0); 9117117f1b4Smrg ctx->Transform.RasterPositionUnclipped = state; 9127117f1b4Smrg break; 9137117f1b4Smrg 9147117f1b4Smrg /* GL_NV_point_sprite */ 9157117f1b4Smrg case GL_POINT_SPRITE_NV: 916af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 917af69d88dSmrg goto invalid_enum_error; 9187117f1b4Smrg CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); 9197117f1b4Smrg if (ctx->Point.PointSprite == state) 9207117f1b4Smrg return; 9217117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POINT); 9227117f1b4Smrg ctx->Point.PointSprite = state; 9237117f1b4Smrg break; 9247117f1b4Smrg 9257117f1b4Smrg case GL_VERTEX_PROGRAM_ARB: 926af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 927af69d88dSmrg goto invalid_enum_error; 928af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program, cap); 9297117f1b4Smrg if (ctx->VertexProgram.Enabled == state) 9307117f1b4Smrg return; 93101e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 9327117f1b4Smrg ctx->VertexProgram.Enabled = state; 93301e04c3fSmrg _mesa_update_vertex_processing_mode(ctx); 9347117f1b4Smrg break; 9357117f1b4Smrg case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: 936af69d88dSmrg /* This was added with ARB_vertex_program, but it is also used with 937af69d88dSmrg * GLSL vertex shaders on desktop. 938af69d88dSmrg */ 939af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 940af69d88dSmrg goto invalid_enum_error; 941af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program, cap); 9427117f1b4Smrg if (ctx->VertexProgram.PointSizeEnabled == state) 9437117f1b4Smrg return; 9447117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 9457117f1b4Smrg ctx->VertexProgram.PointSizeEnabled = state; 9467117f1b4Smrg break; 9477117f1b4Smrg case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: 948af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 949af69d88dSmrg goto invalid_enum_error; 950af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program, cap); 9517117f1b4Smrg if (ctx->VertexProgram.TwoSideEnabled == state) 9527117f1b4Smrg return; 95301e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 9547117f1b4Smrg ctx->VertexProgram.TwoSideEnabled = state; 9557117f1b4Smrg break; 9567117f1b4Smrg 9577117f1b4Smrg /* GL_NV_texture_rectangle */ 9587117f1b4Smrg case GL_TEXTURE_RECTANGLE_NV: 959af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 960af69d88dSmrg goto invalid_enum_error; 9617117f1b4Smrg CHECK_EXTENSION(NV_texture_rectangle, cap); 9627117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { 9637117f1b4Smrg return; 9647117f1b4Smrg } 9657117f1b4Smrg break; 9667117f1b4Smrg 9677117f1b4Smrg /* GL_EXT_stencil_two_side */ 9687117f1b4Smrg case GL_STENCIL_TEST_TWO_SIDE_EXT: 969af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 970af69d88dSmrg goto invalid_enum_error; 9717117f1b4Smrg CHECK_EXTENSION(EXT_stencil_two_side, cap); 9727117f1b4Smrg if (ctx->Stencil.TestTwoSide == state) 9737117f1b4Smrg return; 97401e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewStencil ? 0 : _NEW_STENCIL); 97501e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewStencil; 9767117f1b4Smrg ctx->Stencil.TestTwoSide = state; 977c1f859d4Smrg if (state) { 978c1f859d4Smrg ctx->Stencil._BackFace = 2; 979c1f859d4Smrg } else { 980c1f859d4Smrg ctx->Stencil._BackFace = 1; 981c1f859d4Smrg } 9827117f1b4Smrg break; 9837117f1b4Smrg 9847117f1b4Smrg case GL_FRAGMENT_PROGRAM_ARB: 985af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 986af69d88dSmrg goto invalid_enum_error; 9877117f1b4Smrg CHECK_EXTENSION(ARB_fragment_program, cap); 9887117f1b4Smrg if (ctx->FragmentProgram.Enabled == state) 9897117f1b4Smrg return; 9907117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 9917117f1b4Smrg ctx->FragmentProgram.Enabled = state; 9927117f1b4Smrg break; 9937117f1b4Smrg 9947117f1b4Smrg /* GL_EXT_depth_bounds_test */ 9957117f1b4Smrg case GL_DEPTH_BOUNDS_TEST_EXT: 996af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 997af69d88dSmrg goto invalid_enum_error; 9987117f1b4Smrg CHECK_EXTENSION(EXT_depth_bounds_test, cap); 9997117f1b4Smrg if (ctx->Depth.BoundsTest == state) 10007117f1b4Smrg return; 100101e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewDepth ? 0 : _NEW_DEPTH); 100201e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewDepth; 10037117f1b4Smrg ctx->Depth.BoundsTest = state; 10047117f1b4Smrg break; 10057117f1b4Smrg 10064a49301eSmrg case GL_DEPTH_CLAMP: 1007a8bb7a65Smaya if (!_mesa_has_ARB_depth_clamp(ctx) && 1008a8bb7a65Smaya !_mesa_has_EXT_depth_clamp(ctx)) 1009af69d88dSmrg goto invalid_enum_error; 101001e04c3fSmrg if (ctx->Transform.DepthClampNear == state && 101101e04c3fSmrg ctx->Transform.DepthClampFar == state) 10124a49301eSmrg return; 101301e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewDepthClamp ? 0 : 101401e04c3fSmrg _NEW_TRANSFORM); 101501e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewDepthClamp; 101601e04c3fSmrg ctx->Transform.DepthClampNear = state; 101701e04c3fSmrg ctx->Transform.DepthClampFar = state; 101801e04c3fSmrg break; 101901e04c3fSmrg 102001e04c3fSmrg case GL_DEPTH_CLAMP_NEAR_AMD: 102101e04c3fSmrg if (!_mesa_is_desktop_gl(ctx)) 102201e04c3fSmrg goto invalid_enum_error; 102301e04c3fSmrg CHECK_EXTENSION(AMD_depth_clamp_separate, cap); 102401e04c3fSmrg if (ctx->Transform.DepthClampNear == state) 102501e04c3fSmrg return; 102601e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewDepthClamp ? 0 : 102701e04c3fSmrg _NEW_TRANSFORM); 102801e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewDepthClamp; 102901e04c3fSmrg ctx->Transform.DepthClampNear = state; 103001e04c3fSmrg break; 103101e04c3fSmrg 103201e04c3fSmrg case GL_DEPTH_CLAMP_FAR_AMD: 103301e04c3fSmrg if (!_mesa_is_desktop_gl(ctx)) 103401e04c3fSmrg goto invalid_enum_error; 103501e04c3fSmrg CHECK_EXTENSION(AMD_depth_clamp_separate, cap); 103601e04c3fSmrg if (ctx->Transform.DepthClampFar == state) 103701e04c3fSmrg return; 103801e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewDepthClamp ? 0 : 103901e04c3fSmrg _NEW_TRANSFORM); 104001e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewDepthClamp; 104101e04c3fSmrg ctx->Transform.DepthClampFar = state; 104201e04c3fSmrg break; 10437117f1b4Smrg 10447117f1b4Smrg case GL_FRAGMENT_SHADER_ATI: 1045af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1046af69d88dSmrg goto invalid_enum_error; 10477117f1b4Smrg CHECK_EXTENSION(ATI_fragment_shader, cap); 104801e04c3fSmrg if (ctx->ATIFragmentShader.Enabled == state) 104901e04c3fSmrg return; 105001e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 105101e04c3fSmrg ctx->ATIFragmentShader.Enabled = state; 10527117f1b4Smrg break; 1053c1f859d4Smrg 10544a49301eSmrg case GL_TEXTURE_CUBE_MAP_SEAMLESS: 1055af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1056af69d88dSmrg goto invalid_enum_error; 105701e04c3fSmrg CHECK_EXTENSION(ARB_seamless_cube_map, cap); 105801e04c3fSmrg if (ctx->Texture.CubeMapSeamless != state) { 105901e04c3fSmrg FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); 106001e04c3fSmrg ctx->Texture.CubeMapSeamless = state; 106101e04c3fSmrg } 106201e04c3fSmrg break; 10634a49301eSmrg 10643464ebd5Sriastradh case GL_RASTERIZER_DISCARD: 1065af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) 1066af69d88dSmrg goto invalid_enum_error; 106701e04c3fSmrg CHECK_EXTENSION(EXT_transform_feedback, cap); 1068af69d88dSmrg if (ctx->RasterDiscard != state) { 1069af69d88dSmrg FLUSH_VERTICES(ctx, 0); 1070af69d88dSmrg ctx->NewDriverState |= ctx->DriverFlags.NewRasterizerDiscard; 1071af69d88dSmrg ctx->RasterDiscard = state; 10723464ebd5Sriastradh } 10733464ebd5Sriastradh break; 10743464ebd5Sriastradh 107501e04c3fSmrg case GL_TILE_RASTER_ORDER_FIXED_MESA: 107601e04c3fSmrg CHECK_EXTENSION(MESA_tile_raster_order, cap); 107701e04c3fSmrg if (ctx->TileRasterOrderFixed != state) { 107801e04c3fSmrg FLUSH_VERTICES(ctx, 0); 107901e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewTileRasterOrder; 108001e04c3fSmrg ctx->TileRasterOrderFixed = state; 108101e04c3fSmrg } 108201e04c3fSmrg break; 108301e04c3fSmrg 108401e04c3fSmrg case GL_TILE_RASTER_ORDER_INCREASING_X_MESA: 108501e04c3fSmrg CHECK_EXTENSION(MESA_tile_raster_order, cap); 108601e04c3fSmrg if (ctx->TileRasterOrderIncreasingX != state) { 108701e04c3fSmrg FLUSH_VERTICES(ctx, 0); 108801e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewTileRasterOrder; 108901e04c3fSmrg ctx->TileRasterOrderIncreasingX = state; 109001e04c3fSmrg } 109101e04c3fSmrg break; 109201e04c3fSmrg 109301e04c3fSmrg case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA: 109401e04c3fSmrg CHECK_EXTENSION(MESA_tile_raster_order, cap); 109501e04c3fSmrg if (ctx->TileRasterOrderIncreasingY != state) { 109601e04c3fSmrg FLUSH_VERTICES(ctx, 0); 109701e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewTileRasterOrder; 109801e04c3fSmrg ctx->TileRasterOrderIncreasingY = state; 109901e04c3fSmrg } 110001e04c3fSmrg break; 110101e04c3fSmrg 11023464ebd5Sriastradh /* GL 3.1 primitive restart. Note: this enum is different from 11033464ebd5Sriastradh * GL_PRIMITIVE_RESTART_NV (which is client state). 11043464ebd5Sriastradh */ 11053464ebd5Sriastradh case GL_PRIMITIVE_RESTART: 1106af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 31) { 11073464ebd5Sriastradh goto invalid_enum_error; 11083464ebd5Sriastradh } 11093464ebd5Sriastradh if (ctx->Array.PrimitiveRestart != state) { 111001e04c3fSmrg FLUSH_VERTICES(ctx, 0); 11113464ebd5Sriastradh ctx->Array.PrimitiveRestart = state; 1112af69d88dSmrg update_derived_primitive_restart_state(ctx); 1113af69d88dSmrg } 1114af69d88dSmrg break; 1115af69d88dSmrg 1116af69d88dSmrg case GL_PRIMITIVE_RESTART_FIXED_INDEX: 111701e04c3fSmrg if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility) 1118af69d88dSmrg goto invalid_enum_error; 1119af69d88dSmrg if (ctx->Array.PrimitiveRestartFixedIndex != state) { 112001e04c3fSmrg FLUSH_VERTICES(ctx, 0); 1121af69d88dSmrg ctx->Array.PrimitiveRestartFixedIndex = state; 1122af69d88dSmrg update_derived_primitive_restart_state(ctx); 11233464ebd5Sriastradh } 11243464ebd5Sriastradh break; 11253464ebd5Sriastradh 11263464ebd5Sriastradh /* GL3.0 - GL_framebuffer_sRGB */ 11273464ebd5Sriastradh case GL_FRAMEBUFFER_SRGB_EXT: 11283464ebd5Sriastradh CHECK_EXTENSION(EXT_framebuffer_sRGB, cap); 1129af69d88dSmrg _mesa_set_framebuffer_srgb(ctx, state); 1130af69d88dSmrg return; 1131af69d88dSmrg 1132af69d88dSmrg /* GL_OES_EGL_image_external */ 1133af69d88dSmrg case GL_TEXTURE_EXTERNAL_OES: 1134af69d88dSmrg if (!_mesa_is_gles(ctx)) 1135af69d88dSmrg goto invalid_enum_error; 1136af69d88dSmrg CHECK_EXTENSION(OES_EGL_image_external, cap); 1137af69d88dSmrg if (!enable_texture(ctx, state, TEXTURE_EXTERNAL_BIT)) { 1138af69d88dSmrg return; 1139af69d88dSmrg } 1140af69d88dSmrg break; 1141af69d88dSmrg 1142af69d88dSmrg /* ARB_texture_multisample */ 1143af69d88dSmrg case GL_SAMPLE_MASK: 114401e04c3fSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx)) 1145af69d88dSmrg goto invalid_enum_error; 1146af69d88dSmrg CHECK_EXTENSION(ARB_texture_multisample, cap); 1147af69d88dSmrg if (ctx->Multisample.SampleMask == state) 1148af69d88dSmrg return; 114901e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 : 115001e04c3fSmrg _NEW_MULTISAMPLE); 115101e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask; 1152af69d88dSmrg ctx->Multisample.SampleMask = state; 11533464ebd5Sriastradh break; 11543464ebd5Sriastradh 115501e04c3fSmrg case GL_BLEND_ADVANCED_COHERENT_KHR: 115601e04c3fSmrg CHECK_EXTENSION(KHR_blend_equation_advanced_coherent, cap); 115701e04c3fSmrg if (ctx->Color.BlendCoherent == state) 115801e04c3fSmrg return; 115901e04c3fSmrg FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlend ? 0 : _NEW_COLOR); 116001e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewBlend; 116101e04c3fSmrg ctx->Color.BlendCoherent = state; 116201e04c3fSmrg break; 116301e04c3fSmrg 11647117f1b4Smrg default: 11653464ebd5Sriastradh goto invalid_enum_error; 11667117f1b4Smrg } 11677117f1b4Smrg 11687117f1b4Smrg if (ctx->Driver.Enable) { 11697117f1b4Smrg ctx->Driver.Enable( ctx, cap, state ); 11707117f1b4Smrg } 11713464ebd5Sriastradh 11723464ebd5Sriastradh return; 11733464ebd5Sriastradh 11743464ebd5Sriastradhinvalid_enum_error: 1175af69d88dSmrg _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(%s)", 117601e04c3fSmrg state ? "Enable" : "Disable", _mesa_enum_to_string(cap)); 11777117f1b4Smrg} 11787117f1b4Smrg 11797117f1b4Smrg 11807117f1b4Smrg/** 11817117f1b4Smrg * Enable GL capability. Called by glEnable() 11827117f1b4Smrg * \param cap state to enable. 11837117f1b4Smrg */ 11847117f1b4Smrgvoid GLAPIENTRY 11857117f1b4Smrg_mesa_Enable( GLenum cap ) 11867117f1b4Smrg{ 11877117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 11887117f1b4Smrg 11897117f1b4Smrg _mesa_set_enable( ctx, cap, GL_TRUE ); 11907117f1b4Smrg} 11917117f1b4Smrg 11927117f1b4Smrg 11937117f1b4Smrg/** 11947117f1b4Smrg * Disable GL capability. Called by glDisable() 11957117f1b4Smrg * \param cap state to disable. 11967117f1b4Smrg */ 11977117f1b4Smrgvoid GLAPIENTRY 11987117f1b4Smrg_mesa_Disable( GLenum cap ) 11997117f1b4Smrg{ 12007117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 12017117f1b4Smrg 12027117f1b4Smrg _mesa_set_enable( ctx, cap, GL_FALSE ); 12037117f1b4Smrg} 12047117f1b4Smrg 12057117f1b4Smrg 1206cdc920a0Smrg 1207cdc920a0Smrg/** 1208cdc920a0Smrg * Enable/disable an indexed state var. 1209cdc920a0Smrg */ 1210cdc920a0Smrgvoid 12113464ebd5Sriastradh_mesa_set_enablei(struct gl_context *ctx, GLenum cap, 12123464ebd5Sriastradh GLuint index, GLboolean state) 1213cdc920a0Smrg{ 121401e04c3fSmrg assert(state == 0 || state == 1); 1215cdc920a0Smrg switch (cap) { 1216cdc920a0Smrg case GL_BLEND: 1217cdc920a0Smrg if (!ctx->Extensions.EXT_draw_buffers2) { 12183464ebd5Sriastradh goto invalid_enum_error; 1219cdc920a0Smrg } 1220cdc920a0Smrg if (index >= ctx->Const.MaxDrawBuffers) { 1221cdc920a0Smrg _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", 1222cdc920a0Smrg state ? "glEnableIndexed" : "glDisableIndexed", index); 1223cdc920a0Smrg return; 1224cdc920a0Smrg } 1225cdc920a0Smrg if (((ctx->Color.BlendEnabled >> index) & 1) != state) { 122601e04c3fSmrg GLbitfield enabled = ctx->Color.BlendEnabled; 122701e04c3fSmrg 1228cdc920a0Smrg if (state) 122901e04c3fSmrg enabled |= (1 << index); 1230cdc920a0Smrg else 123101e04c3fSmrg enabled &= ~(1 << index); 123201e04c3fSmrg 123301e04c3fSmrg _mesa_flush_vertices_for_blend_adv(ctx, enabled, 123401e04c3fSmrg ctx->Color._AdvancedBlendMode); 123501e04c3fSmrg ctx->Color.BlendEnabled = enabled; 1236cdc920a0Smrg } 1237cdc920a0Smrg break; 1238af69d88dSmrg case GL_SCISSOR_TEST: 1239af69d88dSmrg if (index >= ctx->Const.MaxViewports) { 1240af69d88dSmrg _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", 1241af69d88dSmrg state ? "glEnablei" : "glDisablei", index); 1242af69d88dSmrg return; 1243af69d88dSmrg } 1244af69d88dSmrg if (((ctx->Scissor.EnableFlags >> index) & 1) != state) { 124501e04c3fSmrg FLUSH_VERTICES(ctx, 124601e04c3fSmrg ctx->DriverFlags.NewScissorTest ? 0 : _NEW_SCISSOR); 124701e04c3fSmrg ctx->NewDriverState |= ctx->DriverFlags.NewScissorTest; 1248af69d88dSmrg if (state) 1249af69d88dSmrg ctx->Scissor.EnableFlags |= (1 << index); 1250af69d88dSmrg else 1251af69d88dSmrg ctx->Scissor.EnableFlags &= ~(1 << index); 1252af69d88dSmrg } 1253af69d88dSmrg break; 1254cdc920a0Smrg default: 12553464ebd5Sriastradh goto invalid_enum_error; 1256cdc920a0Smrg } 1257cdc920a0Smrg return; 1258cdc920a0Smrg 12593464ebd5Sriastradhinvalid_enum_error: 1260cdc920a0Smrg _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", 1261cdc920a0Smrg state ? "glEnablei" : "glDisablei", 126201e04c3fSmrg _mesa_enum_to_string(cap)); 1263cdc920a0Smrg} 1264cdc920a0Smrg 1265cdc920a0Smrg 1266cdc920a0Smrgvoid GLAPIENTRY 1267af69d88dSmrg_mesa_Disablei( GLenum cap, GLuint index ) 1268cdc920a0Smrg{ 1269cdc920a0Smrg GET_CURRENT_CONTEXT(ctx); 1270cdc920a0Smrg _mesa_set_enablei(ctx, cap, index, GL_FALSE); 1271cdc920a0Smrg} 1272cdc920a0Smrg 1273cdc920a0Smrg 1274cdc920a0Smrgvoid GLAPIENTRY 1275af69d88dSmrg_mesa_Enablei( GLenum cap, GLuint index ) 1276cdc920a0Smrg{ 1277cdc920a0Smrg GET_CURRENT_CONTEXT(ctx); 1278cdc920a0Smrg _mesa_set_enablei(ctx, cap, index, GL_TRUE); 1279cdc920a0Smrg} 1280cdc920a0Smrg 1281cdc920a0Smrg 1282cdc920a0SmrgGLboolean GLAPIENTRY 1283af69d88dSmrg_mesa_IsEnabledi( GLenum cap, GLuint index ) 1284cdc920a0Smrg{ 1285cdc920a0Smrg GET_CURRENT_CONTEXT(ctx); 12863464ebd5Sriastradh ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); 1287cdc920a0Smrg switch (cap) { 1288cdc920a0Smrg case GL_BLEND: 1289cdc920a0Smrg if (index >= ctx->Const.MaxDrawBuffers) { 1290cdc920a0Smrg _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", 1291cdc920a0Smrg index); 1292cdc920a0Smrg return GL_FALSE; 1293cdc920a0Smrg } 1294cdc920a0Smrg return (ctx->Color.BlendEnabled >> index) & 1; 1295af69d88dSmrg case GL_SCISSOR_TEST: 1296af69d88dSmrg if (index >= ctx->Const.MaxViewports) { 1297af69d88dSmrg _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", 1298af69d88dSmrg index); 1299af69d88dSmrg return GL_FALSE; 1300af69d88dSmrg } 1301af69d88dSmrg return (ctx->Scissor.EnableFlags >> index) & 1; 1302cdc920a0Smrg default: 1303cdc920a0Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)", 130401e04c3fSmrg _mesa_enum_to_string(cap)); 1305cdc920a0Smrg return GL_FALSE; 1306cdc920a0Smrg } 1307cdc920a0Smrg} 1308cdc920a0Smrg 1309cdc920a0Smrg 1310cdc920a0Smrg 1311cdc920a0Smrg 13127117f1b4Smrg#undef CHECK_EXTENSION 13137117f1b4Smrg#define CHECK_EXTENSION(EXTNAME) \ 13147117f1b4Smrg if (!ctx->Extensions.EXTNAME) { \ 13153464ebd5Sriastradh goto invalid_enum_error; \ 13167117f1b4Smrg } 13177117f1b4Smrg 13187117f1b4Smrg#undef CHECK_EXTENSION2 13197117f1b4Smrg#define CHECK_EXTENSION2(EXT1, EXT2) \ 13207117f1b4Smrg if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ 13213464ebd5Sriastradh goto invalid_enum_error; \ 13227117f1b4Smrg } 13237117f1b4Smrg 13247117f1b4Smrg 13257117f1b4Smrg/** 13267117f1b4Smrg * Helper function to determine whether a texture target is enabled. 13277117f1b4Smrg */ 13287117f1b4Smrgstatic GLboolean 13293464ebd5Sriastradhis_texture_enabled(struct gl_context *ctx, GLbitfield bit) 13307117f1b4Smrg{ 133101e04c3fSmrg const struct gl_fixedfunc_texture_unit *const texUnit = 133201e04c3fSmrg _mesa_get_current_fixedfunc_tex_unit(ctx); 133301e04c3fSmrg 133401e04c3fSmrg if (!texUnit) 133501e04c3fSmrg return GL_FALSE; 133601e04c3fSmrg 13377117f1b4Smrg return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; 13387117f1b4Smrg} 13397117f1b4Smrg 13407117f1b4Smrg 13417117f1b4Smrg/** 13427117f1b4Smrg * Return simple enable/disable state. 13437117f1b4Smrg * 13447117f1b4Smrg * \param cap state variable to query. 13457117f1b4Smrg * 13467117f1b4Smrg * Returns the state of the specified capability from the current GL context. 13477117f1b4Smrg * For the capabilities associated with extensions verifies that those 13487117f1b4Smrg * extensions are effectively present before reporting. 13497117f1b4Smrg */ 13507117f1b4SmrgGLboolean GLAPIENTRY 13517117f1b4Smrg_mesa_IsEnabled( GLenum cap ) 13527117f1b4Smrg{ 13537117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 13543464ebd5Sriastradh ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); 13553464ebd5Sriastradh 13567117f1b4Smrg switch (cap) { 13577117f1b4Smrg case GL_ALPHA_TEST: 1358af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1359af69d88dSmrg goto invalid_enum_error; 13607117f1b4Smrg return ctx->Color.AlphaEnabled; 13617117f1b4Smrg case GL_AUTO_NORMAL: 1362af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1363af69d88dSmrg goto invalid_enum_error; 136401e04c3fSmrg return ctx->Eval.AutoNormal; 13657117f1b4Smrg case GL_BLEND: 1366cdc920a0Smrg return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */ 1367af69d88dSmrg case GL_CLIP_DISTANCE0: /* aka GL_CLIP_PLANE0 */ 1368af69d88dSmrg case GL_CLIP_DISTANCE1: 1369af69d88dSmrg case GL_CLIP_DISTANCE2: 1370af69d88dSmrg case GL_CLIP_DISTANCE3: 1371af69d88dSmrg case GL_CLIP_DISTANCE4: 1372af69d88dSmrg case GL_CLIP_DISTANCE5: 1373af69d88dSmrg case GL_CLIP_DISTANCE6: 1374af69d88dSmrg case GL_CLIP_DISTANCE7: { 1375af69d88dSmrg const GLuint p = cap - GL_CLIP_DISTANCE0; 1376af69d88dSmrg 1377af69d88dSmrg if (p >= ctx->Const.MaxClipPlanes) 1378af69d88dSmrg goto invalid_enum_error; 1379af69d88dSmrg 138001e04c3fSmrg return (ctx->Transform.ClipPlanesEnabled >> p) & 1; 1381af69d88dSmrg } 13827117f1b4Smrg case GL_COLOR_MATERIAL: 1383af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1384af69d88dSmrg goto invalid_enum_error; 138501e04c3fSmrg return ctx->Light.ColorMaterialEnabled; 13867117f1b4Smrg case GL_CULL_FACE: 13877117f1b4Smrg return ctx->Polygon.CullFlag; 1388af69d88dSmrg case GL_DEBUG_OUTPUT: 1389af69d88dSmrg case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB: 139001e04c3fSmrg return (GLboolean) _mesa_get_debug_state_int(ctx, cap); 13917117f1b4Smrg case GL_DEPTH_TEST: 13927117f1b4Smrg return ctx->Depth.Test; 13937117f1b4Smrg case GL_DITHER: 139401e04c3fSmrg return ctx->Color.DitherFlag; 13957117f1b4Smrg case GL_FOG: 1396af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1397af69d88dSmrg goto invalid_enum_error; 139801e04c3fSmrg return ctx->Fog.Enabled; 13997117f1b4Smrg case GL_LIGHTING: 1400af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1401af69d88dSmrg goto invalid_enum_error; 14027117f1b4Smrg return ctx->Light.Enabled; 14037117f1b4Smrg case GL_LIGHT0: 14047117f1b4Smrg case GL_LIGHT1: 14057117f1b4Smrg case GL_LIGHT2: 14067117f1b4Smrg case GL_LIGHT3: 14077117f1b4Smrg case GL_LIGHT4: 14087117f1b4Smrg case GL_LIGHT5: 14097117f1b4Smrg case GL_LIGHT6: 14107117f1b4Smrg case GL_LIGHT7: 1411af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1412af69d88dSmrg goto invalid_enum_error; 14137117f1b4Smrg return ctx->Light.Light[cap-GL_LIGHT0].Enabled; 14147117f1b4Smrg case GL_LINE_SMOOTH: 1415af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 1416af69d88dSmrg goto invalid_enum_error; 141701e04c3fSmrg return ctx->Line.SmoothFlag; 14187117f1b4Smrg case GL_LINE_STIPPLE: 1419af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1420af69d88dSmrg goto invalid_enum_error; 142101e04c3fSmrg return ctx->Line.StippleFlag; 14227117f1b4Smrg case GL_INDEX_LOGIC_OP: 1423af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1424af69d88dSmrg goto invalid_enum_error; 142501e04c3fSmrg return ctx->Color.IndexLogicOpEnabled; 14267117f1b4Smrg case GL_COLOR_LOGIC_OP: 1427af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 1428af69d88dSmrg goto invalid_enum_error; 142901e04c3fSmrg return ctx->Color.ColorLogicOpEnabled; 14307117f1b4Smrg case GL_MAP1_COLOR_4: 1431af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1432af69d88dSmrg goto invalid_enum_error; 143301e04c3fSmrg return ctx->Eval.Map1Color4; 14347117f1b4Smrg case GL_MAP1_INDEX: 1435af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1436af69d88dSmrg goto invalid_enum_error; 143701e04c3fSmrg return ctx->Eval.Map1Index; 14387117f1b4Smrg case GL_MAP1_NORMAL: 1439af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1440af69d88dSmrg goto invalid_enum_error; 144101e04c3fSmrg return ctx->Eval.Map1Normal; 14427117f1b4Smrg case GL_MAP1_TEXTURE_COORD_1: 1443af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1444af69d88dSmrg goto invalid_enum_error; 144501e04c3fSmrg return ctx->Eval.Map1TextureCoord1; 14467117f1b4Smrg case GL_MAP1_TEXTURE_COORD_2: 1447af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1448af69d88dSmrg goto invalid_enum_error; 144901e04c3fSmrg return ctx->Eval.Map1TextureCoord2; 14507117f1b4Smrg case GL_MAP1_TEXTURE_COORD_3: 1451af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1452af69d88dSmrg goto invalid_enum_error; 145301e04c3fSmrg return ctx->Eval.Map1TextureCoord3; 14547117f1b4Smrg case GL_MAP1_TEXTURE_COORD_4: 1455af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1456af69d88dSmrg goto invalid_enum_error; 145701e04c3fSmrg return ctx->Eval.Map1TextureCoord4; 14587117f1b4Smrg case GL_MAP1_VERTEX_3: 1459af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1460af69d88dSmrg goto invalid_enum_error; 146101e04c3fSmrg return ctx->Eval.Map1Vertex3; 14627117f1b4Smrg case GL_MAP1_VERTEX_4: 1463af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1464af69d88dSmrg goto invalid_enum_error; 146501e04c3fSmrg return ctx->Eval.Map1Vertex4; 14667117f1b4Smrg case GL_MAP2_COLOR_4: 1467af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1468af69d88dSmrg goto invalid_enum_error; 146901e04c3fSmrg return ctx->Eval.Map2Color4; 14707117f1b4Smrg case GL_MAP2_INDEX: 1471af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1472af69d88dSmrg goto invalid_enum_error; 147301e04c3fSmrg return ctx->Eval.Map2Index; 14747117f1b4Smrg case GL_MAP2_NORMAL: 1475af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1476af69d88dSmrg goto invalid_enum_error; 147701e04c3fSmrg return ctx->Eval.Map2Normal; 14787117f1b4Smrg case GL_MAP2_TEXTURE_COORD_1: 1479af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1480af69d88dSmrg goto invalid_enum_error; 148101e04c3fSmrg return ctx->Eval.Map2TextureCoord1; 14827117f1b4Smrg case GL_MAP2_TEXTURE_COORD_2: 1483af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1484af69d88dSmrg goto invalid_enum_error; 148501e04c3fSmrg return ctx->Eval.Map2TextureCoord2; 14867117f1b4Smrg case GL_MAP2_TEXTURE_COORD_3: 1487af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1488af69d88dSmrg goto invalid_enum_error; 148901e04c3fSmrg return ctx->Eval.Map2TextureCoord3; 14907117f1b4Smrg case GL_MAP2_TEXTURE_COORD_4: 1491af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1492af69d88dSmrg goto invalid_enum_error; 149301e04c3fSmrg return ctx->Eval.Map2TextureCoord4; 14947117f1b4Smrg case GL_MAP2_VERTEX_3: 1495af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1496af69d88dSmrg goto invalid_enum_error; 149701e04c3fSmrg return ctx->Eval.Map2Vertex3; 14987117f1b4Smrg case GL_MAP2_VERTEX_4: 1499af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1500af69d88dSmrg goto invalid_enum_error; 150101e04c3fSmrg return ctx->Eval.Map2Vertex4; 15027117f1b4Smrg case GL_NORMALIZE: 1503af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1504af69d88dSmrg goto invalid_enum_error; 150501e04c3fSmrg return ctx->Transform.Normalize; 15067117f1b4Smrg case GL_POINT_SMOOTH: 1507af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1508af69d88dSmrg goto invalid_enum_error; 150901e04c3fSmrg return ctx->Point.SmoothFlag; 15107117f1b4Smrg case GL_POLYGON_SMOOTH: 1511af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1512af69d88dSmrg goto invalid_enum_error; 151301e04c3fSmrg return ctx->Polygon.SmoothFlag; 15147117f1b4Smrg case GL_POLYGON_STIPPLE: 1515af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1516af69d88dSmrg goto invalid_enum_error; 151701e04c3fSmrg return ctx->Polygon.StippleFlag; 15187117f1b4Smrg case GL_POLYGON_OFFSET_POINT: 1519af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1520af69d88dSmrg goto invalid_enum_error; 152101e04c3fSmrg return ctx->Polygon.OffsetPoint; 15227117f1b4Smrg case GL_POLYGON_OFFSET_LINE: 1523af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1524af69d88dSmrg goto invalid_enum_error; 152501e04c3fSmrg return ctx->Polygon.OffsetLine; 15267117f1b4Smrg case GL_POLYGON_OFFSET_FILL: 152701e04c3fSmrg return ctx->Polygon.OffsetFill; 15287117f1b4Smrg case GL_RESCALE_NORMAL_EXT: 1529af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1530af69d88dSmrg goto invalid_enum_error; 15317117f1b4Smrg return ctx->Transform.RescaleNormals; 15327117f1b4Smrg case GL_SCISSOR_TEST: 153301e04c3fSmrg return ctx->Scissor.EnableFlags & 1; /* return state for index 0 */ 15347117f1b4Smrg case GL_STENCIL_TEST: 153501e04c3fSmrg return ctx->Stencil.Enabled; 15367117f1b4Smrg case GL_TEXTURE_1D: 1537af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1538af69d88dSmrg goto invalid_enum_error; 15397117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_1D_BIT); 15407117f1b4Smrg case GL_TEXTURE_2D: 1541af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1542af69d88dSmrg goto invalid_enum_error; 15437117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_2D_BIT); 15447117f1b4Smrg case GL_TEXTURE_3D: 1545af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1546af69d88dSmrg goto invalid_enum_error; 15477117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_3D_BIT); 15487117f1b4Smrg case GL_TEXTURE_GEN_S: 15493464ebd5Sriastradh case GL_TEXTURE_GEN_T: 15503464ebd5Sriastradh case GL_TEXTURE_GEN_R: 15513464ebd5Sriastradh case GL_TEXTURE_GEN_Q: 15527117f1b4Smrg { 155301e04c3fSmrg const struct gl_fixedfunc_texture_unit *texUnit = 155401e04c3fSmrg get_texcoord_unit(ctx); 1555af69d88dSmrg 1556af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1557af69d88dSmrg goto invalid_enum_error; 1558af69d88dSmrg 1559c1f859d4Smrg if (texUnit) { 15603464ebd5Sriastradh GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); 15613464ebd5Sriastradh return (texUnit->TexGenEnabled & coordBit) ? GL_TRUE : GL_FALSE; 1562c1f859d4Smrg } 15637117f1b4Smrg } 1564c1f859d4Smrg return GL_FALSE; 15653464ebd5Sriastradh case GL_TEXTURE_GEN_STR_OES: 156601e04c3fSmrg { 156701e04c3fSmrg const struct gl_fixedfunc_texture_unit *texUnit = 156801e04c3fSmrg get_texcoord_unit(ctx); 1569af69d88dSmrg 1570af69d88dSmrg if (ctx->API != API_OPENGLES) 1571af69d88dSmrg goto invalid_enum_error; 1572af69d88dSmrg 1573c1f859d4Smrg if (texUnit) { 15743464ebd5Sriastradh return (texUnit->TexGenEnabled & STR_BITS) == STR_BITS 15753464ebd5Sriastradh ? GL_TRUE : GL_FALSE; 1576c1f859d4Smrg } 15777117f1b4Smrg } 15787117f1b4Smrg 1579af69d88dSmrg /* client-side state */ 15807117f1b4Smrg case GL_VERTEX_ARRAY: 1581af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1582af69d88dSmrg goto invalid_enum_error; 1583a8bb7a65Smaya return !!(ctx->Array.VAO->Enabled & VERT_BIT_POS); 15847117f1b4Smrg case GL_NORMAL_ARRAY: 1585af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1586af69d88dSmrg goto invalid_enum_error; 1587a8bb7a65Smaya return !!(ctx->Array.VAO->Enabled & VERT_BIT_NORMAL); 15887117f1b4Smrg case GL_COLOR_ARRAY: 1589af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1590af69d88dSmrg goto invalid_enum_error; 1591a8bb7a65Smaya return !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR0); 15927117f1b4Smrg case GL_INDEX_ARRAY: 1593af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1594af69d88dSmrg goto invalid_enum_error; 1595a8bb7a65Smaya return !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR_INDEX); 15967117f1b4Smrg case GL_TEXTURE_COORD_ARRAY: 1597af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1598af69d88dSmrg goto invalid_enum_error; 1599a8bb7a65Smaya return !!(ctx->Array.VAO->Enabled & 1600a8bb7a65Smaya VERT_BIT_TEX(ctx->Array.ActiveTexture)); 16017117f1b4Smrg case GL_EDGE_FLAG_ARRAY: 1602af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1603af69d88dSmrg goto invalid_enum_error; 1604a8bb7a65Smaya return !!(ctx->Array.VAO->Enabled & VERT_BIT_EDGEFLAG); 16057117f1b4Smrg case GL_FOG_COORDINATE_ARRAY_EXT: 1606af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1607af69d88dSmrg goto invalid_enum_error; 1608a8bb7a65Smaya return !!(ctx->Array.VAO->Enabled & VERT_BIT_FOG); 16097117f1b4Smrg case GL_SECONDARY_COLOR_ARRAY_EXT: 1610af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1611af69d88dSmrg goto invalid_enum_error; 1612a8bb7a65Smaya return !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR1); 1613c1f859d4Smrg case GL_POINT_SIZE_ARRAY_OES: 1614af69d88dSmrg if (ctx->API != API_OPENGLES) 1615af69d88dSmrg goto invalid_enum_error; 1616a8bb7a65Smaya return !!(ctx->Array.VAO->Enabled & VERT_BIT_POINT_SIZE); 16177117f1b4Smrg 16187117f1b4Smrg /* GL_ARB_texture_cube_map */ 161901e04c3fSmrg case GL_TEXTURE_CUBE_MAP: 16207117f1b4Smrg CHECK_EXTENSION(ARB_texture_cube_map); 16217117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); 16227117f1b4Smrg 16237117f1b4Smrg /* GL_EXT_secondary_color */ 16247117f1b4Smrg case GL_COLOR_SUM_EXT: 1625af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1626af69d88dSmrg goto invalid_enum_error; 16277117f1b4Smrg return ctx->Fog.ColorSumEnabled; 16287117f1b4Smrg 16297117f1b4Smrg /* GL_ARB_multisample */ 16307117f1b4Smrg case GL_MULTISAMPLE_ARB: 1631af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 1632af69d88dSmrg goto invalid_enum_error; 16337117f1b4Smrg return ctx->Multisample.Enabled; 16347117f1b4Smrg case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: 16357117f1b4Smrg return ctx->Multisample.SampleAlphaToCoverage; 16367117f1b4Smrg case GL_SAMPLE_ALPHA_TO_ONE_ARB: 1637af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 1638af69d88dSmrg goto invalid_enum_error; 16397117f1b4Smrg return ctx->Multisample.SampleAlphaToOne; 16407117f1b4Smrg case GL_SAMPLE_COVERAGE_ARB: 16417117f1b4Smrg return ctx->Multisample.SampleCoverage; 16427117f1b4Smrg case GL_SAMPLE_COVERAGE_INVERT_ARB: 1643af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1644af69d88dSmrg goto invalid_enum_error; 16457117f1b4Smrg return ctx->Multisample.SampleCoverageInvert; 16467117f1b4Smrg 16477117f1b4Smrg /* GL_IBM_rasterpos_clip */ 16487117f1b4Smrg case GL_RASTER_POSITION_UNCLIPPED_IBM: 1649af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1650af69d88dSmrg goto invalid_enum_error; 16517117f1b4Smrg return ctx->Transform.RasterPositionUnclipped; 16527117f1b4Smrg 16537117f1b4Smrg /* GL_NV_point_sprite */ 16547117f1b4Smrg case GL_POINT_SPRITE_NV: 1655af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 1656af69d88dSmrg goto invalid_enum_error; 16577117f1b4Smrg CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) 16587117f1b4Smrg return ctx->Point.PointSprite; 16597117f1b4Smrg 16607117f1b4Smrg case GL_VERTEX_PROGRAM_ARB: 1661af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1662af69d88dSmrg goto invalid_enum_error; 1663af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program); 16647117f1b4Smrg return ctx->VertexProgram.Enabled; 16657117f1b4Smrg case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: 1666af69d88dSmrg /* This was added with ARB_vertex_program, but it is also used with 1667af69d88dSmrg * GLSL vertex shaders on desktop. 1668af69d88dSmrg */ 1669af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1670af69d88dSmrg goto invalid_enum_error; 1671af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program); 16727117f1b4Smrg return ctx->VertexProgram.PointSizeEnabled; 16737117f1b4Smrg case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: 1674af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1675af69d88dSmrg goto invalid_enum_error; 1676af69d88dSmrg CHECK_EXTENSION(ARB_vertex_program); 16777117f1b4Smrg return ctx->VertexProgram.TwoSideEnabled; 16787117f1b4Smrg 16797117f1b4Smrg /* GL_NV_texture_rectangle */ 16807117f1b4Smrg case GL_TEXTURE_RECTANGLE_NV: 1681af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1682af69d88dSmrg goto invalid_enum_error; 16837117f1b4Smrg CHECK_EXTENSION(NV_texture_rectangle); 16847117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_RECT_BIT); 16857117f1b4Smrg 16867117f1b4Smrg /* GL_EXT_stencil_two_side */ 16877117f1b4Smrg case GL_STENCIL_TEST_TWO_SIDE_EXT: 1688af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1689af69d88dSmrg goto invalid_enum_error; 16907117f1b4Smrg CHECK_EXTENSION(EXT_stencil_two_side); 16917117f1b4Smrg return ctx->Stencil.TestTwoSide; 16927117f1b4Smrg 16937117f1b4Smrg case GL_FRAGMENT_PROGRAM_ARB: 1694af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1695af69d88dSmrg goto invalid_enum_error; 16967117f1b4Smrg return ctx->FragmentProgram.Enabled; 16977117f1b4Smrg 16987117f1b4Smrg /* GL_EXT_depth_bounds_test */ 16997117f1b4Smrg case GL_DEPTH_BOUNDS_TEST_EXT: 1700af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1701af69d88dSmrg goto invalid_enum_error; 17027117f1b4Smrg CHECK_EXTENSION(EXT_depth_bounds_test); 17037117f1b4Smrg return ctx->Depth.BoundsTest; 17047117f1b4Smrg 17054a49301eSmrg /* GL_ARB_depth_clamp */ 17064a49301eSmrg case GL_DEPTH_CLAMP: 1707a8bb7a65Smaya if (!_mesa_has_ARB_depth_clamp(ctx) && 1708a8bb7a65Smaya !_mesa_has_EXT_depth_clamp(ctx)) 1709af69d88dSmrg goto invalid_enum_error; 171001e04c3fSmrg return ctx->Transform.DepthClampNear || 171101e04c3fSmrg ctx->Transform.DepthClampFar; 171201e04c3fSmrg 171301e04c3fSmrg case GL_DEPTH_CLAMP_NEAR_AMD: 171401e04c3fSmrg if (!_mesa_is_desktop_gl(ctx)) 171501e04c3fSmrg goto invalid_enum_error; 171601e04c3fSmrg CHECK_EXTENSION(AMD_depth_clamp_separate); 171701e04c3fSmrg return ctx->Transform.DepthClampNear; 171801e04c3fSmrg 171901e04c3fSmrg case GL_DEPTH_CLAMP_FAR_AMD: 172001e04c3fSmrg if (!_mesa_is_desktop_gl(ctx)) 172101e04c3fSmrg goto invalid_enum_error; 172201e04c3fSmrg CHECK_EXTENSION(AMD_depth_clamp_separate); 172301e04c3fSmrg return ctx->Transform.DepthClampFar; 17244a49301eSmrg 17257117f1b4Smrg case GL_FRAGMENT_SHADER_ATI: 1726af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT) 1727af69d88dSmrg goto invalid_enum_error; 172801e04c3fSmrg CHECK_EXTENSION(ATI_fragment_shader); 172901e04c3fSmrg return ctx->ATIFragmentShader.Enabled; 17304a49301eSmrg 17314a49301eSmrg case GL_TEXTURE_CUBE_MAP_SEAMLESS: 1732af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 1733af69d88dSmrg goto invalid_enum_error; 173401e04c3fSmrg CHECK_EXTENSION(ARB_seamless_cube_map); 173501e04c3fSmrg return ctx->Texture.CubeMapSeamless; 17364a49301eSmrg 17373464ebd5Sriastradh case GL_RASTERIZER_DISCARD: 1738af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) 1739af69d88dSmrg goto invalid_enum_error; 174001e04c3fSmrg CHECK_EXTENSION(EXT_transform_feedback); 1741af69d88dSmrg return ctx->RasterDiscard; 17423464ebd5Sriastradh 17433464ebd5Sriastradh /* GL_NV_primitive_restart */ 17443464ebd5Sriastradh case GL_PRIMITIVE_RESTART_NV: 1745af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.NV_primitive_restart) { 17463464ebd5Sriastradh goto invalid_enum_error; 17473464ebd5Sriastradh } 17483464ebd5Sriastradh return ctx->Array.PrimitiveRestart; 17493464ebd5Sriastradh 17503464ebd5Sriastradh /* GL 3.1 primitive restart */ 17513464ebd5Sriastradh case GL_PRIMITIVE_RESTART: 1752af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 31) { 17533464ebd5Sriastradh goto invalid_enum_error; 17543464ebd5Sriastradh } 17553464ebd5Sriastradh return ctx->Array.PrimitiveRestart; 17563464ebd5Sriastradh 1757af69d88dSmrg case GL_PRIMITIVE_RESTART_FIXED_INDEX: 175801e04c3fSmrg if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility) { 1759af69d88dSmrg goto invalid_enum_error; 1760af69d88dSmrg } 1761af69d88dSmrg return ctx->Array.PrimitiveRestartFixedIndex; 1762af69d88dSmrg 17633464ebd5Sriastradh /* GL3.0 - GL_framebuffer_sRGB */ 17643464ebd5Sriastradh case GL_FRAMEBUFFER_SRGB_EXT: 176501e04c3fSmrg CHECK_EXTENSION(EXT_framebuffer_sRGB); 176601e04c3fSmrg return ctx->Color.sRGBEnabled; 17673464ebd5Sriastradh 1768af69d88dSmrg /* GL_OES_EGL_image_external */ 1769af69d88dSmrg case GL_TEXTURE_EXTERNAL_OES: 1770af69d88dSmrg if (!_mesa_is_gles(ctx)) 1771af69d88dSmrg goto invalid_enum_error; 177201e04c3fSmrg CHECK_EXTENSION(OES_EGL_image_external); 1773af69d88dSmrg return is_texture_enabled(ctx, TEXTURE_EXTERNAL_BIT); 1774af69d88dSmrg 1775af69d88dSmrg /* ARB_texture_multisample */ 1776af69d88dSmrg case GL_SAMPLE_MASK: 177701e04c3fSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx)) 1778af69d88dSmrg goto invalid_enum_error; 1779af69d88dSmrg CHECK_EXTENSION(ARB_texture_multisample); 1780af69d88dSmrg return ctx->Multisample.SampleMask; 1781af69d88dSmrg 1782af69d88dSmrg /* ARB_sample_shading */ 1783af69d88dSmrg case GL_SAMPLE_SHADING: 178401e04c3fSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) 1785af69d88dSmrg goto invalid_enum_error; 1786af69d88dSmrg CHECK_EXTENSION(ARB_sample_shading); 1787af69d88dSmrg return ctx->Multisample.SampleShading; 1788af69d88dSmrg 178901e04c3fSmrg case GL_BLEND_ADVANCED_COHERENT_KHR: 179001e04c3fSmrg CHECK_EXTENSION(KHR_blend_equation_advanced_coherent); 179101e04c3fSmrg return ctx->Color.BlendCoherent; 179201e04c3fSmrg 179301e04c3fSmrg case GL_CONSERVATIVE_RASTERIZATION_INTEL: 179401e04c3fSmrg CHECK_EXTENSION(INTEL_conservative_rasterization); 179501e04c3fSmrg return ctx->IntelConservativeRasterization; 179601e04c3fSmrg 179701e04c3fSmrg case GL_CONSERVATIVE_RASTERIZATION_NV: 179801e04c3fSmrg CHECK_EXTENSION(NV_conservative_raster); 179901e04c3fSmrg return ctx->ConservativeRasterization; 180001e04c3fSmrg 180101e04c3fSmrg case GL_TILE_RASTER_ORDER_FIXED_MESA: 180201e04c3fSmrg CHECK_EXTENSION(MESA_tile_raster_order); 180301e04c3fSmrg return ctx->TileRasterOrderFixed; 180401e04c3fSmrg 180501e04c3fSmrg case GL_TILE_RASTER_ORDER_INCREASING_X_MESA: 180601e04c3fSmrg CHECK_EXTENSION(MESA_tile_raster_order); 180701e04c3fSmrg return ctx->TileRasterOrderIncreasingX; 180801e04c3fSmrg 180901e04c3fSmrg case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA: 181001e04c3fSmrg CHECK_EXTENSION(MESA_tile_raster_order); 181101e04c3fSmrg return ctx->TileRasterOrderIncreasingY; 181201e04c3fSmrg 18137117f1b4Smrg default: 18143464ebd5Sriastradh goto invalid_enum_error; 18157117f1b4Smrg } 18163464ebd5Sriastradh 18173464ebd5Sriastradh return GL_FALSE; 18183464ebd5Sriastradh 18193464ebd5Sriastradhinvalid_enum_error: 1820af69d88dSmrg _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(%s)", 182101e04c3fSmrg _mesa_enum_to_string(cap)); 18223464ebd5Sriastradh return GL_FALSE; 18237117f1b4Smrg} 1824