utils/testparse.c
changeset 1055 3295380ce6fc
parent 1051 96a838f4e680
child 1090 636ffcd3f14a
equal deleted inserted replaced
1054:63dd1a46ce13 1055:3295380ce6fc
   232 
   232 
   233     printf("\n");
   233     printf("\n");
   234 } // print_preshader
   234 } // print_preshader
   235 
   235 
   236 
   236 
       
   237 static void print_attrs(const char *category, const int count,
       
   238                         const MOJOSHADER_attribute *attributes,
       
   239                         const int indent)
       
   240 {
       
   241     INDENT(); printf("%s:", category);
       
   242     if (count == 0)
       
   243         printf(" (none.)\n");
       
   244     else
       
   245     {
       
   246         int i;
       
   247         printf("\n");
       
   248         for (i = 0; i < count; i++)
       
   249         {
       
   250             static const char *usagenames[] = {
       
   251                 "position", "blendweight", "blendindices", "normal",
       
   252                 "psize", "texcoord", "tangent", "binormal", "tessfactor",
       
   253                 "positiont", "color", "fog", "depth", "sample"
       
   254             };
       
   255             const MOJOSHADER_attribute *a = &attributes[i];
       
   256             char numstr[16] = { 0 };
       
   257             if (a->index != 0)
       
   258                 snprintf(numstr, sizeof (numstr), "%d", a->index);
       
   259             INDENT();
       
   260             printf("    * %s%s", usagenames[(int) a->usage], numstr);
       
   261             if (a->name != NULL)
       
   262                 printf(" (\"%s\")", a->name);
       
   263             printf("\n");
       
   264         } // for
       
   265     } // else
       
   266 } // print_attrs
       
   267 
       
   268 
   237 static void print_shader(const char *fname, const MOJOSHADER_parseData *pd,
   269 static void print_shader(const char *fname, const MOJOSHADER_parseData *pd,
   238                          unsigned int indent)
   270                          unsigned int indent)
   239 {
   271 {
   240     INDENT(); printf("PROFILE: %s\n", pd->profile);
   272     INDENT(); printf("PROFILE: %s\n", pd->profile);
   241     if (pd->error_count > 0)
   273     if (pd->error_count > 0)
   253     else
   285     else
   254     {
   286     {
   255         INDENT(); printf("SHADER TYPE: %s\n", shader_type(pd->shader_type));
   287         INDENT(); printf("SHADER TYPE: %s\n", shader_type(pd->shader_type));
   256         INDENT(); printf("VERSION: %d.%d\n", pd->major_ver, pd->minor_ver);
   288         INDENT(); printf("VERSION: %d.%d\n", pd->major_ver, pd->minor_ver);
   257         INDENT(); printf("INSTRUCTION COUNT: %d\n", (int) pd->instruction_count);
   289         INDENT(); printf("INSTRUCTION COUNT: %d\n", (int) pd->instruction_count);
   258 
   290         print_attrs("INPUTS", pd->attribute_count, pd->attributes, indent);
   259         INDENT(); printf("ATTRIBUTES:");
   291         print_attrs("OUTPUTS", pd->output_count, pd->outputs, indent);
   260         if (pd->attribute_count == 0)
       
   261             printf(" (none.)\n");
       
   262         else
       
   263         {
       
   264             int i;
       
   265             printf("\n");
       
   266             for (i = 0; i < pd->attribute_count; i++)
       
   267             {
       
   268                 static const char *usagenames[] = {
       
   269                     "position", "blendweight", "blendindices", "normal",
       
   270                     "psize", "texcoord", "tangent", "binormal", "tessfactor",
       
   271                     "positiont", "color", "fog", "depth", "sample"
       
   272                 };
       
   273                 const MOJOSHADER_attribute *a = &pd->attributes[i];
       
   274                 char numstr[16] = { 0 };
       
   275                 if (a->index != 0)
       
   276                     snprintf(numstr, sizeof (numstr), "%d", a->index);
       
   277                 INDENT();
       
   278                 printf("    * %s%s", usagenames[(int) a->usage], numstr);
       
   279                 if (a->name != NULL)
       
   280                     printf(" (\"%s\")", a->name);
       
   281                 printf("\n");
       
   282             } // for
       
   283         } // else
       
   284 
   292 
   285         INDENT(); printf("CONSTANTS:");
   293         INDENT(); printf("CONSTANTS:");
   286         if (pd->constant_count == 0)
   294         if (pd->constant_count == 0)
   287             printf(" (none.)\n");
   295             printf(" (none.)\n");
   288         else
   296         else