utils/testparse.c
changeset 1028 74e7ee46ac93
parent 1019 e8988ca01c6d
child 1030 a407c516e325
equal deleted inserted replaced
1027:3fe5609f3620 1028:74e7ee46ac93
    60         default: return "(bogus value?)";
    60         default: return "(bogus value?)";
    61     } // switch
    61     } // switch
    62 
    62 
    63     return NULL;  // shouldn't hit this.
    63     return NULL;  // shouldn't hit this.
    64 } // shader_type
    64 } // shader_type
       
    65 
       
    66 
       
    67 static void print_typeinfo(const MOJOSHADER_symbolTypeInfo *info,
       
    68                            unsigned int indent)
       
    69 {
       
    70     static const char *symclasses[] = {
       
    71         "scalar", "vector", "row-major matrix",
       
    72         "column-major matrix", "object", "struct"
       
    73     };
       
    74 
       
    75     static const char *symtypes[] = {
       
    76         "void", "bool", "int", "float", "string", "texture",
       
    77         "texture1d", "texture2d", "texture3d", "texturecube",
       
    78         "sampler", "sampler1d", "sampler2d", "sampler3d",
       
    79         "samplercube", "pixelshader", "vertexshader", "unsupported"
       
    80     };
       
    81 
       
    82     INDENT();
       
    83     printf("      symbol class %s\n", symclasses[info->parameter_class]);
       
    84     INDENT();
       
    85     printf("      symbol type %s\n", symtypes[info->parameter_type]);
       
    86     INDENT();
       
    87     printf("      rows %u\n", info->rows);
       
    88     INDENT();
       
    89     printf("      columns %u\n", info->columns);
       
    90     INDENT();
       
    91     printf("      elements %u\n", info->elements);
       
    92 
       
    93     if (info->member_count > 0)
       
    94     {
       
    95         int i;
       
    96         INDENT(); printf("      MEMBERS:\n");
       
    97         for (i = 0; i < info->member_count; i++)
       
    98         {
       
    99             const MOJOSHADER_symbolStructMember *member = &info->members[i];
       
   100             INDENT(); printf("      MEMBERS:\n");
       
   101             indent++;
       
   102             INDENT(); printf("      * %d: \"%s\"\n", i, member->name);
       
   103             print_typeinfo(&member->info, indent);
       
   104             indent--;
       
   105         } // for
       
   106     } // if
       
   107 } // print_typeinfo
    65 
   108 
    66 
   109 
    67 static void print_shader(const char *fname, const MOJOSHADER_parseData *pd,
   110 static void print_shader(const char *fname, const MOJOSHADER_parseData *pd,
    68                          unsigned int indent)
   111                          unsigned int indent)
    69 {
   112 {
   194                     printf(" (\"%s\")", s->name);
   237                     printf(" (\"%s\")", s->name);
   195                 printf("\n");
   238                 printf("\n");
   196             } // for
   239             } // for
   197         } // else
   240         } // else
   198 
   241 
       
   242         INDENT(); printf("SYMBOLS:");
       
   243         if (pd->symbol_count == 0)
       
   244             printf(" (none.)\n");
       
   245         else
       
   246         {
       
   247             int i;
       
   248             printf("\n");
       
   249             for (i = 0; i < pd->symbol_count; i++)
       
   250             {
       
   251                 static const char *regsets[] = {
       
   252                     "bool", "int4", "float4", "sampler"
       
   253                 };
       
   254 
       
   255                 const MOJOSHADER_symbol *sym = &pd->symbols[i];
       
   256                 INDENT(); printf("    * %d: \"%s\"\n", i, sym->name);
       
   257                 INDENT(); printf("      register set %s\n", regsets[sym->register_set]);
       
   258                 INDENT(); printf("      register index %u\n", sym->register_index);
       
   259                 INDENT(); printf("      register count %u\n", sym->register_count);
       
   260                 print_typeinfo(&sym->info, indent);
       
   261             } // for
       
   262             printf("\n");
       
   263         } // else
       
   264 
   199         if (pd->output != NULL)
   265         if (pd->output != NULL)
   200         {
   266         {
   201             int i;
   267             int i;
   202             INDENT();
   268             INDENT();
   203             printf("OUTPUT:\n");
   269             printf("OUTPUT:\n");