mesa: remove unneeded swizzle init code in glsl compiler
[mesa.git] / src / mesa / shader / prog_print.c
index 1c35ce3fecf35ecbd5b9e1261b02080507978a45..29b4d90a3e8b65ee113afb50a97ff5742bf30fb2 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
+ * Version:  7.3
  *
- * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -28,9 +28,9 @@
  * \author Brian Paul
  */
 
-#include "glheader.h"
-#include "context.h"
-#include "imports.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/imports.h"
 #include "prog_instruction.h"
 #include "prog_parameter.h"
 #include "prog_print.h"
@@ -206,7 +206,7 @@ arb_output_attrib_string(GLint index, GLenum progType)
  */
 static const char *
 reg_string(enum register_file f, GLint index, gl_prog_print_mode mode,
-           const struct gl_program *prog)
+           GLboolean relAddr, const struct gl_program *prog)
 {
    static char str[100];
 
@@ -214,7 +214,10 @@ reg_string(enum register_file f, GLint index, gl_prog_print_mode mode,
 
    switch (mode) {
    case PROG_PRINT_DEBUG:
-      sprintf(str, "%s[%d]", file_string(f, mode), index);
+      if (relAddr)
+         sprintf(str, "%s[ADDR+%d]", file_string(f, mode), index);
+      else
+         sprintf(str, "%s[%d]", file_string(f, mode), index);
       break;
 
    case PROG_PRINT_ARB:
@@ -247,7 +250,9 @@ reg_string(enum register_file f, GLint index, gl_prog_print_mode mode,
          {
             struct gl_program_parameter *param
                = prog->Parameters->Parameters + index;
-            sprintf(str, _mesa_program_state_string(param->StateIndexes));
+            char *state = _mesa_program_state_string(param->StateIndexes);
+            sprintf(str, state);
+            _mesa_free(state);
          }
          break;
       case PROGRAM_ADDRESS:
@@ -310,7 +315,7 @@ reg_string(enum register_file f, GLint index, gl_prog_print_mode mode,
 const char *
 _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended)
 {
-   static const char swz[] = "xyzw01?!";
+   static const char swz[] = "xyzw01!?";  /* See SWIZZLE_x definitions */
    static char s[20];
    GLuint i = 0;
 
@@ -353,8 +358,21 @@ _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended)
 }
 
 
-static const char *
-writemask_string(GLuint writeMask)
+void
+_mesa_print_swizzle(GLuint swizzle)
+{
+   if (swizzle == SWIZZLE_XYZW) {
+      _mesa_printf(".xyzw\n");
+   }
+   else {
+      const char *s = _mesa_swizzle_string(swizzle, 0, 0);
+      _mesa_printf("%s\n", s);
+   }
+}
+
+
+const char *
+_mesa_writemask_string(GLuint writeMask)
 {
    static char s[10];
    GLuint i = 0;
@@ -401,8 +419,8 @@ print_dst_reg(const struct prog_dst_register *dstReg, gl_prog_print_mode mode,
 {
    _mesa_printf("%s%s",
                 reg_string((enum register_file) dstReg->File,
-                           dstReg->Index, mode, prog),
-                writemask_string(dstReg->WriteMask));
+                           dstReg->Index, mode, dstReg->RelAddr, prog),
+                _mesa_writemask_string(dstReg->WriteMask));
 
    if (dstReg->CondMask != COND_TR) {
       _mesa_printf(" (%s.%s)",
@@ -414,7 +432,7 @@ print_dst_reg(const struct prog_dst_register *dstReg, gl_prog_print_mode mode,
    _mesa_printf("%s[%d]%s",
                 file_string((enum register_file) dstReg->File, mode),
                 dstReg->Index,
-                writemask_string(dstReg->WriteMask));
+                _mesa_writemask_string(dstReg->WriteMask));
 #endif
 }
 
@@ -424,9 +442,9 @@ print_src_reg(const struct prog_src_register *srcReg, gl_prog_print_mode mode,
 {
    _mesa_printf("%s%s",
                 reg_string((enum register_file) srcReg->File,
-                           srcReg->Index, mode, prog),
+                           srcReg->Index, mode, srcReg->RelAddr, prog),
                 _mesa_swizzle_string(srcReg->Swizzle,
-                               srcReg->NegateBase, GL_FALSE));
+                                     srcReg->NegateBase, GL_FALSE));
 #if 0
    _mesa_printf("%s[%d]%s",
                 file_string((enum register_file) srcReg->File, mode),
@@ -590,7 +608,9 @@ _mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent,
       break;
 
    case OPCODE_ARL:
-      _mesa_printf("ARL addr.x, ");
+      _mesa_printf("ARL ");
+      print_dst_reg(&inst->DstReg, mode, prog);
+      _mesa_printf(", ");
       print_src_reg(&inst->SrcReg[0], mode, prog);
       print_comment(inst);
       break;
@@ -794,9 +814,18 @@ _mesa_print_parameter_list(const struct gl_program_parameter_list *list)
    for (i = 0; i < list->NumParameters; i++){
       struct gl_program_parameter *param = list->Parameters + i;
       const GLfloat *v = list->ParameterValues[i];
-      _mesa_printf("param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g};\n",
+      _mesa_printf("param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}",
                    i, param->Size,
                    file_string(list->Parameters[i].Type, mode),
                    param->Name, v[0], v[1], v[2], v[3]);
+      if (param->Flags & PROG_PARAM_BIT_CENTROID)
+         _mesa_printf(" Centroid");
+      if (param->Flags & PROG_PARAM_BIT_INVARIANT)
+         _mesa_printf(" Invariant");
+      if (param->Flags & PROG_PARAM_BIT_FLAT)
+         _mesa_printf(" Flat");
+      if (param->Flags & PROG_PARAM_BIT_LINEAR)
+         _mesa_printf(" Linear");
+      _mesa_printf("\n");
    }
 }