---
 src/compiler/compiler.c    |    4 ++--
 src/compiler/compiler.h    |    3 +++
 src/compiler/ptest/ptest.c |   32 ++++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c
index 8ee534b..b60d5e5 100644
--- a/src/compiler/compiler.c
+++ b/src/compiler/compiler.c
@@ -62,7 +62,7 @@ static void comp_report(struct compiler_sc *sc, const char 
*format, ...)
 /* PER-FRAME VARIABLES                                          */
 /****************************************************************/
 
-static const char pfv_names[COMP_PFV_COUNT][FPVM_MAXSYMLEN] = {
+const char pfv_names[COMP_PFV_COUNT][FPVM_MAXSYMLEN] = {
        "sx",
        "sy",
        "cx",
@@ -332,7 +332,7 @@ static bool schedule_pfv(struct compiler_sc *sc)
 /* PER-VERTEX VARIABLES                                         */
 /****************************************************************/
 
-static const char pvv_names[COMP_PVV_COUNT][FPVM_MAXSYMLEN] = {
+const char pvv_names[COMP_PVV_COUNT][FPVM_MAXSYMLEN] = {
        /* System */
        "_texsize",
        "_hmeshsize",
diff --git a/src/compiler/compiler.h b/src/compiler/compiler.h
index 5f6be43..95f2dc7 100644
--- a/src/compiler/compiler.h
+++ b/src/compiler/compiler.h
@@ -234,6 +234,9 @@ struct patch {
 
 typedef void (*report_message)(const char *);
 
+extern const char pfv_names[COMP_PFV_COUNT][FPVM_MAXSYMLEN];
+extern const char pvv_names[COMP_PVV_COUNT][FPVM_MAXSYMLEN];
+
 struct patch *patch_compile(const char *basedir, const char *patch_code, 
report_message rmc);
 struct patch *patch_compile_filename(const char *filename, const char 
*patch_code, report_message rmc);
 struct patch *patch_copy(struct patch *p);
diff --git a/src/compiler/ptest/ptest.c b/src/compiler/ptest/ptest.c
index 6ef9b60..86539cf 100644
--- a/src/compiler/ptest/ptest.c
+++ b/src/compiler/ptest/ptest.c
@@ -244,18 +244,50 @@ static void parse_only(const char *pgm)
 }
 
 
+static void dump_regs(const int *alloc, const char (*names)[FPVM_MAXSYMLEN],
+    const float *values, int n)
+{
+       const char *mapped[n];
+       int i;
+
+       for (i = 0; i != n; i++)
+               mapped[i] = NULL;
+       for (i = 0; i != n; i++)
+               if (alloc[i] != -1)
+                       mapped[alloc[i]] = names[i];
+       for (i = 0; i != n; i++) {
+               if (!values[i] && !mapped[i])
+                       continue;
+               printf("R%03d = %f", i, values[i]);
+               if (mapped[i])
+                       printf(" %s", mapped[i]);
+               printf("\n");
+       }
+}
+
+
 static void compile(const char *pgm)
 {
        struct patch *patch;
+       int i;
 
        patch = patch_compile("/", pgm, report);
        if (!patch)
                exit(1);
        if (quiet)
                return;
+       printf("global:\n");
+       for (i = 0; i != COMP_PFV_COUNT; i++)
+               if (patch->pfv_initial[i])
+                       printf("R%03d = %f %s\n", i, patch->pfv_initial[i],
+                           pfv_names[i]);
        printf("per-frame PFPU fragment:\n");
+       dump_regs(patch->pfv_allocation, pfv_names, patch->perframe_regs,
+           COMP_PFV_COUNT);
        pfpu_dump(patch->perframe_prog, patch->perframe_prog_length);
        printf("per-vertex PFPU fragment:\n");
+       dump_regs(patch->pvv_allocation, pvv_names, patch->pervertex_regs,
+           COMP_PVV_COUNT);
        pfpu_dump(patch->pervertex_prog, patch->pervertex_prog_length);
 }
 
-- 
1.7.1

_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode

Reply via email to