mesa: Fix NetBSD compiler macro.
[mesa.git] / src / mesa / main / enable.c
index a5a69a3a68ac1868f13837d2351e1ec94f1894b8..8d33b71df75bce48c701cb8be58e94121e35b62b 100644 (file)
 #include "varray.h"
 
 
-static void
-update_derived_primitive_restart_state(struct gl_context *ctx)
+void
+_mesa_update_derived_primitive_restart_state(struct gl_context *ctx)
 {
-   /* Update derived primitive restart state.
-    */
-   ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart
-      || ctx->Array.PrimitiveRestartFixedIndex;
+   ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart ||
+                                  ctx->Array.PrimitiveRestartFixedIndex;
+   ctx->Array._RestartIndex[0] = _mesa_primitive_restart_index(ctx, 1);
+   ctx->Array._RestartIndex[1] = _mesa_primitive_restart_index(ctx, 2);
+   ctx->Array._RestartIndex[3] = _mesa_primitive_restart_index(ctx, 4);
 }
 
 
@@ -118,7 +119,7 @@ client_state(struct gl_context *ctx, struct gl_vertex_array_object* vao,
 
          FLUSH_VERTICES(ctx, 0);
          ctx->Array.PrimitiveRestart = state;
-         update_derived_primitive_restart_state(ctx);
+         _mesa_update_derived_primitive_restart_state(ctx);
          return;
 
       default:
@@ -275,11 +276,6 @@ _mesa_DisableClientStateiEXT( GLenum cap, GLuint index )
    client_state_i(ctx, ctx->Array.VAO, cap, index, GL_FALSE);
 }
 
-#define CHECK_EXTENSION(EXTNAME)                                       \
-   if (!ctx->Extensions.EXTNAME) {                                     \
-      goto invalid_enum_error;                                         \
-   }
-
 /**
  * Return pointer to current texture unit for setting/getting coordinate
  * state.
@@ -409,7 +405,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.AutoNormal == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.AutoNormal = state;
          break;
       case GL_BLEND:
@@ -608,7 +605,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map1Color4 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map1Color4 = state;
          break;
       case GL_MAP1_INDEX:
@@ -616,7 +614,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map1Index == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map1Index = state;
          break;
       case GL_MAP1_NORMAL:
@@ -624,7 +623,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map1Normal == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map1Normal = state;
          break;
       case GL_MAP1_TEXTURE_COORD_1:
@@ -632,7 +632,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map1TextureCoord1 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map1TextureCoord1 = state;
          break;
       case GL_MAP1_TEXTURE_COORD_2:
@@ -640,7 +641,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map1TextureCoord2 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map1TextureCoord2 = state;
          break;
       case GL_MAP1_TEXTURE_COORD_3:
@@ -648,7 +650,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map1TextureCoord3 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map1TextureCoord3 = state;
          break;
       case GL_MAP1_TEXTURE_COORD_4:
@@ -656,7 +659,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map1TextureCoord4 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map1TextureCoord4 = state;
          break;
       case GL_MAP1_VERTEX_3:
@@ -664,7 +668,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map1Vertex3 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map1Vertex3 = state;
          break;
       case GL_MAP1_VERTEX_4:
@@ -672,7 +677,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map1Vertex4 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map1Vertex4 = state;
          break;
       case GL_MAP2_COLOR_4:
@@ -680,7 +686,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map2Color4 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map2Color4 = state;
          break;
       case GL_MAP2_INDEX:
@@ -688,7 +695,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map2Index == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map2Index = state;
          break;
       case GL_MAP2_NORMAL:
@@ -696,7 +704,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map2Normal == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map2Normal = state;
          break;
       case GL_MAP2_TEXTURE_COORD_1:
@@ -704,7 +713,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map2TextureCoord1 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map2TextureCoord1 = state;
          break;
       case GL_MAP2_TEXTURE_COORD_2:
@@ -712,7 +722,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map2TextureCoord2 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map2TextureCoord2 = state;
          break;
       case GL_MAP2_TEXTURE_COORD_3:
@@ -720,7 +731,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map2TextureCoord3 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map2TextureCoord3 = state;
          break;
       case GL_MAP2_TEXTURE_COORD_4:
@@ -728,7 +740,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map2TextureCoord4 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map2TextureCoord4 = state;
          break;
       case GL_MAP2_VERTEX_3:
@@ -736,7 +749,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map2Vertex3 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map2Vertex3 = state;
          break;
       case GL_MAP2_VERTEX_4:
@@ -744,7 +758,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Eval.Map2Vertex4 == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_EVAL);
+         FLUSH_VERTICES(ctx, 0);
+         vbo_exec_update_eval_maps(ctx);
          ctx->Eval.Map2Vertex4 = state;
          break;
       case GL_NORMALIZE:
@@ -1138,9 +1153,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          break;
 
       case GL_FRAGMENT_SHADER_ATI:
-         if (ctx->API != API_OPENGL_COMPAT)
-            goto invalid_enum_error;
-        CHECK_EXTENSION(ATI_fragment_shader);
+        if (!_mesa_has_ATI_fragment_shader(ctx))
+           goto invalid_enum_error;
         if (ctx->ATIFragmentShader.Enabled == state)
            return;
         FLUSH_VERTICES(ctx, _NEW_PROGRAM);
@@ -1148,9 +1162,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
         break;
 
       case GL_TEXTURE_CUBE_MAP_SEAMLESS:
-         if (!_mesa_is_desktop_gl(ctx))
+         if (!_mesa_has_ARB_seamless_cube_map(ctx))
             goto invalid_enum_error;
-         CHECK_EXTENSION(ARB_seamless_cube_map);
          if (ctx->Texture.CubeMapSeamless != state) {
             FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
             ctx->Texture.CubeMapSeamless = state;
@@ -1158,9 +1171,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          break;
 
       case GL_RASTERIZER_DISCARD:
-         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+         if (!(_mesa_has_EXT_transform_feedback(ctx) || _mesa_is_gles3(ctx)))
             goto invalid_enum_error;
-         CHECK_EXTENSION(EXT_transform_feedback);
          if (ctx->RasterDiscard != state) {
             FLUSH_VERTICES(ctx, 0);
             ctx->NewDriverState |= ctx->DriverFlags.NewRasterizerDiscard;
@@ -1208,7 +1220,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          if (ctx->Array.PrimitiveRestart != state) {
             FLUSH_VERTICES(ctx, 0);
             ctx->Array.PrimitiveRestart = state;
-            update_derived_primitive_restart_state(ctx);
+            _mesa_update_derived_primitive_restart_state(ctx);
          }
          break;
 
@@ -1218,7 +1230,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          if (ctx->Array.PrimitiveRestartFixedIndex != state) {
             FLUSH_VERTICES(ctx, 0);
             ctx->Array.PrimitiveRestartFixedIndex = state;
-            update_derived_primitive_restart_state(ctx);
+            _mesa_update_derived_primitive_restart_state(ctx);
          }
          break;
 
@@ -1232,9 +1244,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
 
       /* GL_OES_EGL_image_external */
       case GL_TEXTURE_EXTERNAL_OES:
-         if (!_mesa_is_gles(ctx))
+         if (!_mesa_has_OES_EGL_image_external(ctx))
             goto invalid_enum_error;
-         CHECK_EXTENSION(OES_EGL_image_external);
          if (!enable_texture(ctx, state, TEXTURE_EXTERNAL_BIT)) {
             return;
          }
@@ -1862,21 +1873,18 @@ _mesa_IsEnabled( GLenum cap )
          return ctx->Transform.DepthClampFar;
 
       case GL_FRAGMENT_SHADER_ATI:
-         if (ctx->API != API_OPENGL_COMPAT)
+         if (!_mesa_has_ATI_fragment_shader(ctx))
             goto invalid_enum_error;
-         CHECK_EXTENSION(ATI_fragment_shader);
          return ctx->ATIFragmentShader.Enabled;
 
       case GL_TEXTURE_CUBE_MAP_SEAMLESS:
-         if (!_mesa_is_desktop_gl(ctx))
+         if (!_mesa_has_ARB_seamless_cube_map(ctx))
             goto invalid_enum_error;
-         CHECK_EXTENSION(ARB_seamless_cube_map);
          return ctx->Texture.CubeMapSeamless;
 
       case GL_RASTERIZER_DISCARD:
-         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+         if (!(_mesa_has_EXT_transform_feedback(ctx) || _mesa_is_gles3(ctx)))
             goto invalid_enum_error;
-         CHECK_EXTENSION(EXT_transform_feedback);
          return ctx->RasterDiscard;
 
       /* GL_NV_primitive_restart */
@@ -1906,9 +1914,8 @@ _mesa_IsEnabled( GLenum cap )
 
       /* GL_OES_EGL_image_external */
       case GL_TEXTURE_EXTERNAL_OES:
-         if (!_mesa_is_gles(ctx))
+         if (!_mesa_has_OES_EGL_image_external(ctx))
             goto invalid_enum_error;
-         CHECK_EXTENSION(OES_EGL_image_external);
          return is_texture_enabled(ctx, TEXTURE_EXTERNAL_BIT);
 
       /* ARB_texture_multisample */