From: Brian Paul Date: Tue, 25 Aug 2009 22:11:39 +0000 (-0600) Subject: mesa: print some program fields in binary too X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f9ce0a91dccdfc8b4fcb3020965cb6b2d0d2f6d0;p=mesa.git mesa: print some program fields in binary too --- diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index 1763a358e93..c8346d4293c 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -820,6 +820,29 @@ _mesa_print_program(const struct gl_program *prog) } +/** + * Return binary representation of value (as a string). + * Insert a comma to separate each group of 8 bits. + * XXX move to imports.[ch] if useful elsewhere. + */ +static const char * +binary(GLbitfield val) +{ + static char buf[50]; + GLint i, len = 0; + for (i = 31; i >= 0; --i) { + if (val & (1 << i)) + buf[len++] = '1'; + else if (len > 0 || i == 0) + buf[len++] = '0'; + if (len > 0 && ((i-1) % 8) == 7) + buf[len++] = ','; + } + buf[len] = '\0'; + return buf; +} + + /** * Print all of a program's parameters/fields to given file. */ @@ -830,13 +853,17 @@ _mesa_fprint_program_parameters(FILE *f, { GLuint i; - _mesa_fprintf(f, "InputsRead: 0x%x\n", prog->InputsRead); - _mesa_fprintf(f, "OutputsWritten: 0x%x\n", prog->OutputsWritten); + _mesa_fprintf(f, "InputsRead: 0x%x (0b%s)\n", + prog->InputsRead, binary(prog->InputsRead)); + _mesa_fprintf(f, "OutputsWritten: 0x%x (0b%s)\n", + prog->OutputsWritten, binary(prog->OutputsWritten)); _mesa_fprintf(f, "NumInstructions=%d\n", prog->NumInstructions); _mesa_fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries); _mesa_fprintf(f, "NumParameters=%d\n", prog->NumParameters); _mesa_fprintf(f, "NumAttributes=%d\n", prog->NumAttributes); _mesa_fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs); + _mesa_fprintf(f, "SamplersUsed: 0x%x (0b%s)\n", + prog->SamplersUsed, binary(prog->SamplersUsed)); _mesa_fprintf(f, "Samplers=[ "); for (i = 0; i < MAX_SAMPLERS; i++) { _mesa_fprintf(f, "%d ", prog->SamplerUnits[i]);