i965g: add dumping for our new pass_fp output
authorKeith Whitwell <keithw@vmware.com>
Fri, 6 Nov 2009 11:56:52 +0000 (11:56 +0000)
committerKeith Whitwell <keithw@vmware.com>
Fri, 6 Nov 2009 11:56:52 +0000 (11:56 +0000)
src/gallium/drivers/i965/brw_screen.c
src/gallium/drivers/i965/brw_wm.h
src/gallium/drivers/i965/brw_wm_debug.c
src/gallium/drivers/i965/brw_wm_fp.c
src/gallium/drivers/i965/brw_wm_glsl.c
src/gallium/drivers/i965/brw_wm_pass0.c

index 9d8066442be96780ac206f5d358d76796a280293..575a418b7dcae81cba17a48ffde5ba08ccd37333 100644 (file)
@@ -293,7 +293,7 @@ brw_create_screen(struct brw_winsys_screen *sws, uint pci_id)
 #ifdef DEBUG
    BRW_DEBUG = debug_get_flags_option("BRW_DEBUG", debug_names, 0);
    BRW_DEBUG |= debug_get_flags_option("INTEL_DEBUG", debug_names, 0);
-   BRW_DEBUG |= DEBUG_STATS | DEBUG_MIN_URB;
+   BRW_DEBUG |= DEBUG_STATS | DEBUG_MIN_URB | DEBUG_WM;
 #endif
 
    memset(&chipset, 0, sizeof chipset);
index 28d216260e52d363a1b2c97efa637fba3b08ff38..7d044ff6ec813401d4ff03627cb3f44b23f892fe 100644 (file)
@@ -181,7 +181,6 @@ struct brw_wm_instruction {
 #define Y    1
 #define Z    2
 #define W    3
-#define GET_SWZ(swz, comp) (((swz) >> ((comp)*2)) & 0x3)
 
 
 struct brw_fp_src {
@@ -333,6 +332,9 @@ void brw_wm_print_insn( struct brw_wm_compile *c,
 void brw_wm_print_program( struct brw_wm_compile *c,
                           const char *stage );
 
+void brw_wm_print_fp_program( struct brw_wm_compile *c,
+                              const char *stage );
+
 void brw_wm_lookup_iz( GLuint line_aa,
                       GLuint lookup,
                       GLboolean ps_uses_depth,
index 65d7626eea9d86f1814be092905aedbe5b17e6be..3d11fa074cccd43154b63c718d24c842729aa4ab 100644 (file)
 #include "brw_context.h"
 #include "brw_wm.h"
 
+static void print_writemask( unsigned writemask )
+{
+   if (writemask != BRW_WRITEMASK_XYZW)
+      debug_printf(".%s%s%s%s", 
+                  (writemask & BRW_WRITEMASK_X) ? "x" : "",
+                  (writemask & BRW_WRITEMASK_Y) ? "y" : "",
+                  (writemask & BRW_WRITEMASK_Z) ? "z" : "",
+                  (writemask & BRW_WRITEMASK_W) ? "w" : "");
+}
+
+static void print_swizzle( unsigned swizzle )
+{
+   char *swz = "xyzw";
+   if (swizzle != BRW_SWIZZLE_XYZW)
+      debug_printf(".%c%c%c%c", 
+                  swz[BRW_GET_SWZ(swizzle, X)],
+                  swz[BRW_GET_SWZ(swizzle, Y)],
+                  swz[BRW_GET_SWZ(swizzle, Z)],
+                  swz[BRW_GET_SWZ(swizzle, W)]);
+}
+
+static void print_opcode( unsigned opcode )
+{
+   switch (opcode) {
+   case WM_PIXELXY:
+      debug_printf("PIXELXY");
+      break;
+   case WM_DELTAXY:
+      debug_printf("DELTAXY");
+      break;
+   case WM_PIXELW:
+      debug_printf("PIXELW");
+      break;
+   case WM_WPOSXY:
+      debug_printf("WPOSXY");
+      break;
+   case WM_PINTERP:
+      debug_printf("PINTERP");
+      break;
+   case WM_LINTERP:
+      debug_printf("LINTERP");
+      break;
+   case WM_CINTERP:
+      debug_printf("CINTERP");
+      break;
+   case WM_FB_WRITE:
+      debug_printf("FB_WRITE");
+      break;
+   case WM_FRONTFACING:
+      debug_printf("FRONTFACING");
+      break;
+   default:
+      debug_printf("%s", tgsi_get_opcode_info(opcode)->mnemonic);
+      break;
+   }
+}
 
 void brw_wm_print_value( struct brw_wm_compile *c,
                       struct brw_wm_value *value )
@@ -98,47 +154,11 @@ void brw_wm_print_insn( struct brw_wm_compile *c,
         debug_printf(",");
    }
    debug_printf("]");
-
-   if (inst->writemask != BRW_WRITEMASK_XYZW)
-      debug_printf(".%s%s%s%s", 
-                  (inst->writemask & BRW_WRITEMASK_X) ? "x" : "",
-                  (inst->writemask & BRW_WRITEMASK_Y) ? "y" : "",
-                  (inst->writemask & BRW_WRITEMASK_Z) ? "z" : "",
-                  (inst->writemask & BRW_WRITEMASK_W) ? "w" : "");
-
-   switch (inst->opcode) {
-   case WM_PIXELXY:
-      debug_printf(" = PIXELXY");
-      break;
-   case WM_DELTAXY:
-      debug_printf(" = DELTAXY");
-      break;
-   case WM_PIXELW:
-      debug_printf(" = PIXELW");
-      break;
-   case WM_WPOSXY:
-      debug_printf(" = WPOSXY");
-      break;
-   case WM_PINTERP:
-      debug_printf(" = PINTERP");
-      break;
-   case WM_LINTERP:
-      debug_printf(" = LINTERP");
-      break;
-   case WM_CINTERP:
-      debug_printf(" = CINTERP");
-      break;
-   case WM_FB_WRITE:
-      debug_printf(" = FB_WRITE");
-      break;
-   case WM_FRONTFACING:
-      debug_printf(" = FRONTFACING");
-      break;
-   default:
-      debug_printf(" = %s", tgsi_get_opcode_info(inst->opcode)->mnemonic);
-      break;
-   }
-
+   print_writemask(inst->writemask);
+   
+   debug_printf(" = ");
+   print_opcode(inst->opcode);
+  
    if (inst->saturate)
       debug_printf("_SAT");
 
@@ -173,3 +193,64 @@ void brw_wm_print_program( struct brw_wm_compile *c,
    debug_printf("\n");
 }
 
+static const char *file_strings[TGSI_FILE_COUNT+1] = {
+   "NULL",
+   "CONST",
+   "IN",
+   "OUT",
+   "TEMP",
+   "SAMPLER",
+   "ADDR",
+   "IMM",
+   "LOOP",
+   "PAYLOAD"
+};
+
+static void brw_wm_print_fp_insn( struct brw_wm_compile *c,
+                                  struct brw_fp_instruction *inst )
+{
+   GLuint i;
+   GLuint nr_args = brw_wm_nr_args(inst->opcode);
+
+   print_opcode(inst->opcode);
+   if (inst->dst.saturate)
+      debug_printf("_SAT");
+   debug_printf(" ");
+
+   if (inst->dst.indirect)
+      debug_printf("[");
+
+   debug_printf("%s[%d]",
+                file_strings[inst->dst.file],
+                inst->dst.index );
+   print_writemask(inst->dst.writemask);
+
+   if (inst->dst.indirect)
+      debug_printf("]");
+
+   debug_printf(nr_args ? ", " : "\n");
+   
+   for (i = 0; i < nr_args; i++) {
+      debug_printf("%s%s%s[%d]%s",
+                   inst->src[i].negate ? "-" : "",
+                   inst->src[i].abs ? "ABS(" : "",
+                   file_strings[inst->src[i].file],
+                   inst->src[i].index,
+                   inst->src[i].abs ? ")" : "");
+      print_swizzle(inst->src[i].swizzle);
+      debug_printf("%s", i == nr_args - 1 ? "\n" : ", ");
+   }
+}
+
+
+void brw_wm_print_fp_program( struct brw_wm_compile *c,
+                              const char *stage )
+{
+   GLuint insn;
+
+   debug_printf("%s:\n", stage);
+   for (insn = 0; insn < c->nr_fp_insns; insn++)
+      brw_wm_print_fp_insn(c, &c->fp_instructions[insn]);
+   debug_printf("\n");
+}
+
index bba448815b6dddf01d9454e30cc97ddef4c993cf..74aa02f19836f5fd79858aad771e48b392b5d140 100644 (file)
 #include "brw_debug.h"
 
 
-
-
-static const char *wm_opcode_strings[] = {
-   "PIXELXY",
-   "DELTAXY",
-   "PIXELW",
-   "LINTERP",
-   "PINTERP",
-   "CINTERP",
-   "WPOSXY",
-   "FB_WRITE",
-   "FRONTFACING",
-};
-
 /***********************************************************************
  * Source regs
  */
@@ -94,10 +80,10 @@ static struct brw_fp_src src_swizzle( struct brw_fp_src reg, int x, int y, int z
 {
    unsigned swz = reg.swizzle;
 
-   reg.swizzle = ( GET_SWZ(swz, x) << 0 |
-                  GET_SWZ(swz, y) << 2 |
-                  GET_SWZ(swz, z) << 4 |
-                  GET_SWZ(swz, w) << 6 );
+   reg.swizzle = ( BRW_GET_SWZ(swz, x) << 0 |
+                  BRW_GET_SWZ(swz, y) << 2 |
+                  BRW_GET_SWZ(swz, z) << 4 |
+                  BRW_GET_SWZ(swz, w) << 6 );
 
    return reg;
 }
@@ -200,10 +186,10 @@ out:
       swizzle |= (swizzle & 0x3) << (j * 2);
 
    return src_swizzle( src_reg( TGSI_FILE_IMMEDIATE, i ),
-                      GET_SWZ(swizzle, X),
-                      GET_SWZ(swizzle, Y),
-                      GET_SWZ(swizzle, Z),
-                      GET_SWZ(swizzle, W) );
+                      BRW_GET_SWZ(swizzle, X),
+                      BRW_GET_SWZ(swizzle, Y),
+                      BRW_GET_SWZ(swizzle, Z),
+                      BRW_GET_SWZ(swizzle, W) );
 }
 
 
@@ -843,7 +829,7 @@ static GLboolean projtex( struct brw_wm_compile *c,
       return GL_FALSE;  /* ut2004 gun rendering !?! */
    
    if (src.file == TGSI_FILE_INPUT && 
-       GET_SWZ(src.swizzle, W) == W &&
+       BRW_GET_SWZ(src.swizzle, W) == W &&
        c->fp->info.input_interpolate[src.index] != TGSI_INTERPOLATE_PERSPECTIVE)
       return GL_FALSE;
 
@@ -1214,8 +1200,7 @@ int brw_wm_pass_fp( struct brw_wm_compile *c )
    }
 
    if (BRW_DEBUG & DEBUG_WM) {
-      debug_printf("pass_fp:\n");
-      //brw_print_program( c->fp_brw_program );
+      brw_wm_print_fp_program( c, "pass_fp" );
       debug_printf("\n");
    }
 
index 284f819bf897b8f55503187bad20e948c29ff2ae..3b3afc39d3c3ddbd4b835a588b9646cde597a113 100644 (file)
@@ -558,7 +558,7 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c,
 {
     const struct prog_src_register *src = &inst->SrcReg[srcRegIndex];
     const GLuint nr = 1;
-    const GLuint component = GET_SWZ(src->Swizzle, channel);
+    const GLuint component = BRW_GET_SWZ(src->Swizzle, channel);
 
     /* Extended swizzle terms */
     if (component == SWIZZLE_ZERO) {
@@ -598,7 +598,7 @@ static struct brw_reg get_src_reg_imm(struct brw_wm_compile *c,
     const struct prog_src_register *src = &inst->SrcReg[srcRegIndex];
     if (src->File == TGSI_FILE_IMMEDIATE) {
        /* an immediate */
-       const int component = GET_SWZ(src->Swizzle, channel);
+       const int component = BRW_GET_SWZ(src->Swizzle, channel);
        const GLfloat *param =
           c->fp->program.Base.Parameters->ParameterValues[src->Index];
        GLfloat value = param[component];
index 7b18335dec711a8ce434cfb7845dfc2e0d78589d..53232325d27f624922f4fb703b659434da936da5 100644 (file)
@@ -227,7 +227,7 @@ static const struct brw_wm_ref *get_fp_src_reg_ref( struct brw_wm_compile *c,
                                                    struct brw_fp_src src,
                                                    GLuint i )
 {
-   return pass0_get_reg(c, src.file, src.index, GET_SWZ(src.swizzle,i));
+   return pass0_get_reg(c, src.file, src.index, BRW_GET_SWZ(src.swizzle,i));
 }