mesa: remove unneeded swizzle init code in glsl compiler
[mesa.git] / src / mesa / shader / prog_print.c
index 969b9757ccf26e805d04b69e9c5114a69f43858c..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"
@@ -99,7 +99,23 @@ arb_input_attrib_string(GLint index, GLenum progType)
       "vertex.texcoord[4]",
       "vertex.texcoord[5]",
       "vertex.texcoord[6]",
-      "vertex.texcoord[7]"
+      "vertex.texcoord[7]",
+      "vertex.attrib[0]",
+      "vertex.attrib[1]",
+      "vertex.attrib[2]",
+      "vertex.attrib[3]",
+      "vertex.attrib[4]",
+      "vertex.attrib[5]",
+      "vertex.attrib[6]",
+      "vertex.attrib[7]",
+      "vertex.attrib[8]",
+      "vertex.attrib[9]",
+      "vertex.attrib[10]",
+      "vertex.attrib[11]",
+      "vertex.attrib[12]",
+      "vertex.attrib[13]",
+      "vertex.attrib[14]",
+      "vertex.attrib[15]"
    };
    const char *fragAttribs[] = {
       "fragment.position",
@@ -190,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];
 
@@ -198,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:
@@ -231,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:
@@ -294,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;
 
@@ -304,7 +325,7 @@ _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended)
    if (!extended)
       s[i++] = '.';
 
-   if (negateBase & 0x1)
+   if (negateBase & NEGATE_X)
       s[i++] = '-';
    s[i++] = swz[GET_SWZ(swizzle, 0)];
 
@@ -312,7 +333,7 @@ _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended)
       s[i++] = ',';
    }
 
-   if (negateBase & 0x2)
+   if (negateBase & NEGATE_Y)
       s[i++] = '-';
    s[i++] = swz[GET_SWZ(swizzle, 1)];
 
@@ -320,7 +341,7 @@ _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended)
       s[i++] = ',';
    }
 
-   if (negateBase & 0x4)
+   if (negateBase & NEGATE_Z)
       s[i++] = '-';
    s[i++] = swz[GET_SWZ(swizzle, 2)];
 
@@ -328,7 +349,7 @@ _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended)
       s[i++] = ',';
    }
 
-   if (negateBase & 0x8)
+   if (negateBase & NEGATE_W)
       s[i++] = '-';
    s[i++] = swz[GET_SWZ(swizzle, 3)];
 
@@ -337,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;
@@ -385,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)",
@@ -398,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
 }
 
@@ -408,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),
@@ -574,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;
@@ -751,9 +787,9 @@ _mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog)
       _mesa_printf("%d ", prog->SamplerUnits[i]);
    }
    _mesa_printf("]\n");
-       
+
    _mesa_load_state_parameters(ctx, prog->Parameters);
-                       
+
 #if 0
    _mesa_printf("Local Params:\n");
    for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){
@@ -778,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");
    }
 }