Undo some STATE_POINT/FOG changes. Max length of state token array is now 5.
authorBrian <brian@yutani.localnet.net>
Thu, 22 Feb 2007 16:29:46 +0000 (09:29 -0700)
committerBrian <brian@yutani.localnet.net>
Thu, 22 Feb 2007 16:29:46 +0000 (09:29 -0700)
src/mesa/shader/arbprogparse.c
src/mesa/shader/prog_parameter.c
src/mesa/shader/prog_statevars.c
src/mesa/shader/prog_statevars.h
src/mesa/shader/programopt.c
src/mesa/shader/slang/slang_builtin.c
src/mesa/tnl/t_vp_build.c

index 480fdf512ca4f70d8277b594002e2ab6a4e18daa..9dbcb60a1748d66a57b45f3df6e00d26425cb88d 100644 (file)
@@ -1276,13 +1276,11 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
       case STATE_POINT:
          switch (*(*inst++)) {
             case POINT_SIZE:
-               state_tokens[0] = STATE_POINT;
-               state_tokens[1] = STATE_POINT_SIZE;
+               state_tokens[0] = STATE_POINT_SIZE;
                break;
 
             case POINT_ATTENUATION:
-               state_tokens[0] = STATE_POINT;
-               state_tokens[1] = STATE_POINT_ATTENUATION;
+               state_tokens[0] = STATE_POINT_ATTENUATION;
                break;
          }
          break;
index 3ebd559119c6be5572c6674ef1fd6b6a90b737d4..505c5016ac2ff9826bfada30868d737d45a2da90 100644 (file)
@@ -379,7 +379,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
    /* Check if the state reference is already in the list */
    for (index = 0; index < (GLint) paramList->NumParameters; index++) {
       GLuint i, match = 0;
-      for (i = 0; i < 6; i++) {
+      for (i = 0; i < STATE_LENGTH; i++) {
          if (paramList->Parameters[index].StateIndexes[i] == stateTokens[i]) {
             match++;
          }
index 53778183c5028c2dd4aa644833f4f0df3b35dbde..0d70af3b2787ab936e995cc8860f9a750842d190 100644 (file)
@@ -246,17 +246,14 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
          COPY_4V(value, ctx->Texture.Unit[unit].EnvColor);
       }                        
       return;
-   case STATE_FOG:
-      if (state[1] == STATE_FOG_COLOR) {
-         COPY_4V(value, ctx->Fog.Color);
-      }
-      else {
-         ASSERT(state[1] == STATE_FOG_PARAMS);
-         value[0] = ctx->Fog.Density;
-         value[1] = ctx->Fog.Start;
-         value[2] = ctx->Fog.End;
-         value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
-      }
+   case STATE_FOG_COLOR:
+      COPY_4V(value, ctx->Fog.Color);
+      return;
+   case STATE_FOG_PARAMS:
+      value[0] = ctx->Fog.Density;
+      value[1] = ctx->Fog.Start;
+      value[2] = ctx->Fog.End;
+      value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
       return;
    case STATE_CLIPPLANE:
       {
@@ -264,20 +261,17 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
          COPY_4V(value, ctx->Transform.EyeUserPlane[plane]);
       }
       return;
-   case STATE_POINT:
-      if (state[1] == STATE_POINT_SIZE) {
-         value[0] = ctx->Point.Size;
-         value[1] = ctx->Point.MinSize;
-         value[2] = ctx->Point.MaxSize;
-         value[3] = ctx->Point.Threshold;
-      }
-      else {
-         ASSERT(state[1] == STATE_POINT_ATTENUATION);
-         value[0] = ctx->Point.Params[0];
-         value[1] = ctx->Point.Params[1];
-         value[2] = ctx->Point.Params[2];
-         value[3] = 1.0F;
-      }
+   case STATE_POINT_SIZE:
+      value[0] = ctx->Point.Size;
+      value[1] = ctx->Point.MinSize;
+      value[2] = ctx->Point.MaxSize;
+      value[3] = ctx->Point.Threshold;
+      return;
+   case STATE_POINT_ATTENUATION:
+      value[0] = ctx->Point.Params[0];
+      value[1] = ctx->Point.Params[1];
+      value[2] = ctx->Point.Params[2];
+      value[3] = 1.0F;
       return;
    case STATE_MODELVIEW_MATRIX:
    case STATE_PROJECTION_MATRIX:
@@ -459,17 +453,15 @@ _mesa_program_state_flags(const GLint state[STATE_LENGTH])
    case STATE_TEXENV_COLOR:
       return _NEW_TEXTURE;
 
-   case STATE_FOG:
-#if 0
    case STATE_FOG_COLOR:
    case STATE_FOG_PARAMS:
-#endif
       return _NEW_FOG;
 
    case STATE_CLIPPLANE:
       return _NEW_TRANSFORM;
 
-   case STATE_POINT:
+   case STATE_POINT_SIZE:
+   case STATE_POINT_ATTENUATION:
       return _NEW_POINT;
 
    case STATE_MODELVIEW_MATRIX:
@@ -543,26 +535,20 @@ append_token(char *dst, gl_state_index k)
    case STATE_TEXGEN:
       append(dst, "texgen");
       break;
-   case STATE_FOG:
-      append(dst, "fog");
-      break;
    case STATE_FOG_COLOR:
-      append(dst, ".color");
+      append(dst, "fog.color");
       break;
    case STATE_FOG_PARAMS:
-      append(dst, ".params");
+      append(dst, "fog.params");
       break;
    case STATE_CLIPPLANE:
       append(dst, "clip");
       break;
-   case STATE_POINT:
-      append(dst, "point");
-      break;
    case STATE_POINT_SIZE:
-      append(dst, "size");
+      append(dst, "point.size");
       break;
    case STATE_POINT_ATTENUATION:
-      append(dst, "attenuation");
+      append(dst, "point.attenuation");
       break;
    case STATE_MODELVIEW_MATRIX:
       append(dst, "matrix.modelview");
@@ -733,17 +719,10 @@ _mesa_program_state_string(const GLint state[STATE_LENGTH])
       append_index(str, state[1]); /* tex unit [i] */
       append(str, "color");
       break;
-   case STATE_FOG:
-      append(str, "fog");
-      append_token(str, (gl_state_index) state[1]); /* color or params */
-      break;
    case STATE_CLIPPLANE:
       append_index(str, state[1]); /* plane [i] */
       append(str, ".plane");
       break;
-   case STATE_POINT:
-      append_token(str, state[1]);
-      break;
    case STATE_MODELVIEW_MATRIX:
    case STATE_PROJECTION_MATRIX:
    case STATE_MVP_MATRIX:
index 91713f3d1d204469bf90caa1bb650333f68b2d68..82169342cd3e514db1209459f16e2c4c3e039017 100644 (file)
@@ -32,7 +32,7 @@
  * Number of STATE_* values we need to address any GL state.
  * Used to dimension arrays.
  */
-#define STATE_LENGTH 6
+#define STATE_LENGTH 5
 
 
 /**
@@ -54,13 +54,11 @@ typedef enum gl_state_index_ {
 
    STATE_TEXGEN,
 
-   STATE_FOG,
    STATE_FOG_COLOR,
    STATE_FOG_PARAMS,
 
    STATE_CLIPPLANE,
 
-   STATE_POINT,
    STATE_POINT_SIZE,
    STATE_POINT_ATTENUATION,
 
index 05a05cd369714f6f0d3b2ee027ad5a3e25d4fb24..18da39c2d31f29db020ca99296af30d0c9ba9c5c 100644 (file)
@@ -56,7 +56,7 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog)
     * Setup state references for the modelview/projection matrix.
     * XXX we should check if these state vars are already declared.
     */
-   static const GLint mvpState[4][5] = {
+   static const GLint mvpState[4][STATE_LENGTH] = {
       { STATE_MVP_MATRIX, 0, 0, 0, 0 },  /* state.matrix.mvp.row[0] */
       { STATE_MVP_MATRIX, 0, 1, 1, 0 },  /* state.matrix.mvp.row[1] */
       { STATE_MVP_MATRIX, 0, 2, 2, 0 },  /* state.matrix.mvp.row[2] */
@@ -125,9 +125,10 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog)
 void
 _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
 {
-   static const GLint fogPStateOpt[] = { STATE_INTERNAL,
-                                        STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 };
-   static const GLint fogColorState[] = { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0};
+   static const GLint fogPStateOpt[STATE_LENGTH]
+      = { STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 };
+   static const GLint fogColorState[STATE_LENGTH]
+      = { STATE_FOG_COLOR, 0, 0, 0, 0};
    struct prog_instruction *newInst, *inst;
    const GLuint origLen = fprog->Base.NumInstructions;
    const GLuint newLen = origLen + 5;
index 47e6bcbcc48fef2763036f7d135b4bf354c58467..7f4290b91fab492c62e4d376c20ab3e5f6ab981c 100644 (file)
@@ -99,6 +99,13 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
       tokens[0] = STATE_CLIPPLANE;
       tokens[1] = index1;
    }
+   else if (strcmp(var, "gl_Point") == 0) {
+      if (strcmp(field, "size") == 0) {
+         tokens[0] = STATE_POINT_SIZE;
+         *swizzleOut = SWIZZLE_XXXX;
+      }
+         /* XXX finish */
+   }
    else if (strcmp(var, "gl_FrontMaterial") == 0 ||
             strcmp(var, "gl_BackMaterial") == 0) {
       tokens[0] = STATE_MATERIAL;
@@ -269,24 +276,23 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
       tokens[2] = STATE_TEXGEN_OBJECT_Q;
    }
    else if (strcmp(var, "gl_Fog") == 0) {
-      tokens[0] = STATE_FOG;
       if (strcmp(field, "color") == 0) {
-         tokens[1] = STATE_FOG_COLOR;
+         tokens[0] = STATE_FOG_COLOR;
       }
       else if (strcmp(field, "density") == 0) {
-         tokens[1] = STATE_FOG_PARAMS;
+         tokens[0] = STATE_FOG_PARAMS;
          *swizzleOut = SWIZZLE_XXXX;
       }
       else if (strcmp(field, "start") == 0) {
-         tokens[1] = STATE_FOG_PARAMS;
+         tokens[0] = STATE_FOG_PARAMS;
          *swizzleOut = SWIZZLE_YYYY;
       }
       else if (strcmp(field, "end") == 0) {
-         tokens[1] = STATE_FOG_PARAMS;
+         tokens[0] = STATE_FOG_PARAMS;
          *swizzleOut = SWIZZLE_ZZZZ;
       }
       else if (strcmp(field, "scale") == 0) {
-         tokens[1] = STATE_FOG_PARAMS;
+         tokens[0] = STATE_FOG_PARAMS;
          *swizzleOut = SWIZZLE_WWWW;
       }
       else {
index 283782588aa15850d40cd1f60af5c39b5bf47735..17f115f4a213df71766ebb20fffeb7cb74b5537b 100644 (file)
@@ -1323,8 +1323,8 @@ static void build_texture_transform( struct tnl_program *p )
 static void build_pointsize( struct tnl_program *p )
 {
    struct ureg eye = get_eye_position(p);
-   struct ureg state_size = register_param2(p, STATE_POINT, STATE_POINT_SIZE);
-   struct ureg state_attenuation = register_param2(p, STATE_POINT, STATE_POINT_ATTENUATION);
+   struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
+   struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
    struct ureg out = register_output(p, VERT_RESULT_PSIZ);
    struct ureg ut = get_temp(p);