Skip to content

Commit

Permalink
Report preshader symbol table in testparse.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jun 1, 2011
1 parent 69df21a commit 1872b59
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions utils/testparse.c
Expand Up @@ -107,6 +107,34 @@ static void print_typeinfo(const MOJOSHADER_symbolTypeInfo *info,
} // print_typeinfo


static void print_symbols(const MOJOSHADER_symbol *sym,
const unsigned int symbol_count,
const unsigned int indent)
{
INDENT(); printf("SYMBOLS:");
if (symbol_count == 0)
printf(" (none.)\n");
else
{
int i;
printf("\n");
for (i = 0; i < symbol_count; i++, sym++)
{
static const char *regsets[] = {
"bool", "int4", "float4", "sampler"
};

INDENT(); printf(" * %d: \"%s\"\n", i, sym->name);
INDENT(); printf(" register set %s\n", regsets[sym->register_set]);
INDENT(); printf(" register index %u\n", sym->register_index);
INDENT(); printf(" register count %u\n", sym->register_count);
print_typeinfo(&sym->info, indent);
} // for
printf("\n");
} // else
} // print_symbols


static void print_preshader(const MOJOSHADER_preshader *preshader,
const int indent)
{
Expand All @@ -123,6 +151,9 @@ static void print_preshader(const MOJOSHADER_preshader *preshader,
static char mask[] = { 'x', 'y', 'z', 'w' };

INDENT(); printf("PRESHADER:\n");

print_symbols(preshader->symbols, preshader->symbol_count, indent + 1);

for (i = 0; i < preshader->instruction_count; i++, inst++)
{
const MOJOSHADER_preshaderOperand *operand = inst->operands;
Expand Down Expand Up @@ -329,28 +360,7 @@ static void print_shader(const char *fname, const MOJOSHADER_parseData *pd,
} // for
} // else

INDENT(); printf("SYMBOLS:");
if (pd->symbol_count == 0)
printf(" (none.)\n");
else
{
int i;
printf("\n");
for (i = 0; i < pd->symbol_count; i++)
{
static const char *regsets[] = {
"bool", "int4", "float4", "sampler"
};

const MOJOSHADER_symbol *sym = &pd->symbols[i];
INDENT(); printf(" * %d: \"%s\"\n", i, sym->name);
INDENT(); printf(" register set %s\n", regsets[sym->register_set]);
INDENT(); printf(" register index %u\n", sym->register_index);
INDENT(); printf(" register count %u\n", sym->register_count);
print_typeinfo(&sym->info, indent);
} // for
printf("\n");
} // else
print_symbols(pd->symbols, pd->symbol_count, indent);

if (pd->preshader != NULL)
print_preshader(pd->preshader, indent);
Expand Down

0 comments on commit 1872b59

Please sign in to comment.