Store all matrices as column-major and transpose when needed
TRAC #11825
Due to the difference in [][] matrix indexing between GLSL and HLSL, all matrices are stored in transposed format (column-major from the HLSL point of view), and transposed back when performing matrix math. Previously some paths didn't follow this principle.
Signed-off-by: Shannon Woods
Signed-off-by: Daniel Koch

Author:    Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/trunk@138 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 0d3af2c..db64eac 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -652,6 +652,21 @@
       case EOpVectorTimesScalarAssign: outputTriplet(visit, "(", " *= ", ")");          break;
       case EOpMatrixTimesScalarAssign: outputTriplet(visit, "(", " *= ", ")");          break;
       case EOpVectorTimesMatrixAssign:
+        if (visit == PreVisit)
+        {
+            out << "(";
+        }
+        else if (visit == InVisit)
+        {
+            out << " = mul(";
+            node->getLeft()->traverse(this);
+            out << ", transpose(";   
+        }
+        else
+        {
+            out << "))";
+        }
+        break;
       case EOpMatrixTimesMatrixAssign:
         if (visit == PreVisit)
         {
@@ -660,34 +675,12 @@
         else if (visit == InVisit)
         {
             out << " = mul(";
-            
-            if (node->getLeft()->getQualifier() == EvqUniform)
-            {
-                out << "transpose(";
-            }
-            
             node->getLeft()->traverse(this);
-            
-            if (node->getLeft()->getQualifier() == EvqUniform)
-            {
-                out << ")";
-            }
-
-            out << ", ";
-
-            if (node->getRight()->getQualifier() == EvqUniform)
-            {
-                out << "transpose(";
-            }
+            out << ", ";   
         }
         else
         {
-            if (node->getRight()->getQualifier() == EvqUniform)
-            {
-                out << ")";
-            }
-
-            out << "))";
+            out << ")";
         }
         break;
       case EOpDivAssign:               outputTriplet(visit, "(", " /= ", ")");          break;
@@ -843,50 +836,9 @@
       case EOpGreaterThanEqual:  outputTriplet(visit, "(", " >= ", ")");  break;
       case EOpVectorTimesScalar: outputTriplet(visit, "(", " * ", ")");   break;
       case EOpMatrixTimesScalar: outputTriplet(visit, "(", " * ", ")");   break;
-      case EOpVectorTimesMatrix:
-          if (node->getRight()->getQualifier() == EvqUniform)
-          {
-              outputTriplet(visit, "mul(", ", transpose(", "))");
-          }
-          else
-          {
-              outputTriplet(visit, "mul(", ", ", ")");
-          }
-          break;
-      case EOpMatrixTimesVector:
-          if (node->getLeft()->getQualifier() == EvqUniform)
-          {
-              outputTriplet(visit, "mul(transpose(", "), ", ")");
-          }
-          else
-          {
-              outputTriplet(visit, "mul(", ", ", ")");
-          }
-          break;
-      case EOpMatrixTimesMatrix:
-          if (node->getLeft()->getQualifier() == EvqUniform)
-          {
-              if (node->getRight()->getQualifier() == EvqUniform)
-              {
-                  outputTriplet(visit, "mul(transpose(", "), transpose(", "))");
-              }
-              else
-              {
-                  outputTriplet(visit, "mul(transpose(", "), ", ")");
-              }
-          }
-          else
-          {
-              if (node->getRight()->getQualifier() == EvqUniform)
-              {
-                  outputTriplet(visit, "mul(", ", transpose(", "))");
-              }
-              else
-              {
-                  outputTriplet(visit, "mul(", ", ", ")");
-              }
-          }
-          break;
+      case EOpVectorTimesMatrix: outputTriplet(visit, "mul(", ", transpose(", "))"); break;
+      case EOpMatrixTimesVector: outputTriplet(visit, "mul(transpose(", "), ", ")"); break;
+      case EOpMatrixTimesMatrix: outputTriplet(visit, "mul(", ", ", ")"); break;
       case EOpLogicalOr:         outputTriplet(visit, "(", " || ", ")");  break;
       case EOpLogicalXor:        outputTriplet(visit, "xor(", ", ", ")"); break;   // FIXME: Prevent name clashes
       case EOpLogicalAnd:        outputTriplet(visit, "(", " && ", ")");  break;