mojoshader_assembler.c
changeset 504 d79ae3b98f47
parent 502 3cb501248990
child 505 fd397ceab529
equal deleted inserted replaced
503:ec8e7739cf5d 504:d79ae3b98f47
  1041         return fail(ctx, "Expected 'true' or 'false'");
  1041         return fail(ctx, "Expected 'true' or 'false'");
  1042     return 3;
  1042     return 3;
  1043 } // parse_args_DEFB
  1043 } // parse_args_DEFB
  1044 
  1044 
  1045 
  1045 
  1046 static int parse_dcl_usage(const char *token, uint32 *val, int *issampler)
  1046 static int parse_dcl_usage(Context *ctx, uint32 *val, int *issampler)
  1047 {
  1047 {
  1048     int i;
  1048     int i;
  1049     static const char *samplerusagestrs[] = { "2d", "cube", "volume" };
  1049     static const char *samplerusagestrs[] = { "2d", "cube", "volume" };
  1050     static const char *usagestrs[] = {
  1050     static const char *usagestrs[] = {
  1051         "position", "blendweight", "blendindices", "normal", "psize",
  1051         "position", "blendweight", "blendindices", "normal", "psize",
  1052         "texcoord", "tangent", "binormal", "tessfactor", "positiont",
  1052         "texcoord", "tangent", "binormal", "tessfactor", "positiont",
  1053         "color", "fog", "depth", "sample"
  1053         "color", "fog", "depth", "sample"
  1054     };
  1054     };
  1055 
  1055 
       
  1056     // !!! FIXME: we need to clean this out in the tokenizer.
       
  1057     char token[sizeof (ctx->token)];
       
  1058     strcpy(token, ctx->token);
       
  1059     if (strcmp(token, "2") == 0)  // "2d" is two tokens.
       
  1060     {
       
  1061         if (nexttoken(ctx, 0, 0, 1, 1) == FAIL)
       
  1062             return FAIL;
       
  1063         else if (strcasecmp(ctx->token, "d") != 0)
       
  1064             pushback(ctx);
       
  1065         else
       
  1066             strcpy(token, "2d");
       
  1067     } // if
       
  1068 
  1056     for (i = 0; i < STATICARRAYLEN(usagestrs); i++)
  1069     for (i = 0; i < STATICARRAYLEN(usagestrs); i++)
  1057     {
  1070     {
  1058         if (strcasecmp(usagestrs[i], token) == 0)
  1071         if (strcasecmp(usagestrs[i], token) == 0)
  1059         {
  1072         {
  1060             *issampler = 0;
  1073             *issampler = 0;
  1091         pushback(ctx);
  1104         pushback(ctx);
  1092     else if (strcmp(ctx->token, "_") != 0)
  1105     else if (strcmp(ctx->token, "_") != 0)
  1093         return fail(ctx, "Expected register or usage");
  1106         return fail(ctx, "Expected register or usage");
  1094     else if (nexttoken(ctx, 0, 0, 0, 0) == FAIL)
  1107     else if (nexttoken(ctx, 0, 0, 0, 0) == FAIL)
  1095         return FAIL;
  1108         return FAIL;
  1096     else if (parse_dcl_usage(ctx->token, &usage, &issampler) == FAIL)
  1109     else if (parse_dcl_usage(ctx, &usage, &issampler) == FAIL)
  1097         return FAIL;
  1110         return FAIL;
  1098 
  1111 
  1099     if (nexttoken(ctx, 0, 0, 0, 0) == FAIL)
  1112     if (nexttoken(ctx, 0, 0, 0, 0) == FAIL)
  1100         return FAIL;
  1113         return FAIL;
  1101     else if (strcmp(ctx->token, " ") == 0)
  1114     else if (strcmp(ctx->token, " ") == 0)