| 1087 | return ExpressionType(str, ag::Type::Object, 1, 1); |
| 1088 | } |
| 1089 | GLSLCompiler::ExpressionType GLSLCompiler::m_mergeExprType(int op, const GLSLCompiler::ExpressionType& left, const GLSLCompiler::ExpressionType& right) |
| 1090 | { |
| 1091 | if (left.Type == ag::Type::Object) |
| 1092 | return left; |
| 1093 | else if (right.Type == ag::Type::Object) |
| 1094 | return right; |
| 1095 | else if (right.Type == ag::Type::Void || left.Type == ag::Type::Void) |
| 1096 | return GLSLCompiler::ExpressionType("void", ag::Type::Void, 1, 1); |
| 1097 | else { |
| 1098 | int compLeft = left.Columns * left.Rows; |
| 1099 | int compRight = right.Columns * right.Rows; |
| 1100 | |
| 1101 | switch (op) |
| 1102 | { |
| 1103 | case glsl::kOperator_multiply: { |
| 1104 | if (compLeft > 1 || compRight > 1) { |
| 1105 | // matrix * ... |
| 1106 | if (left.Rows != 1) { |
| 1107 | // matrix * matrix |
| 1108 | if (right.Rows != 1) { |
| 1109 | ag::Type newType = m_mergeBaseType(left.Type, right.Type); |
| 1110 | |
| 1111 | int rows = left.Rows; |
| 1112 | int cols = right.Columns; |
| 1113 | |
| 1114 | std::string newName = "mat"; |
| 1115 | if (rows == cols) |
| 1116 | newName += std::to_string(cols); |
| 1117 | else |
| 1118 | newName += std::to_string(cols) + "x" + std::to_string(rows); |
| 1119 | |
| 1120 | return GLSLCompiler::ExpressionType(newName, newType, cols, rows); |
| 1121 | } |
| 1122 | // matrix * vector |
| 1123 | else if (right.Columns != 1) { |
| 1124 | ag::Type newType = m_mergeBaseType(left.Type, right.Type); |
| 1125 | |
| 1126 | int rows = 1; |
| 1127 | int cols = right.Columns; |
| 1128 | |
| 1129 | std::string newName = "vec" + std::to_string(cols); |
| 1130 | |
| 1131 | if (newType == ag::Type::Int) |
| 1132 | newName = "i" + newName; |
| 1133 | else if (newType == ag::Type::UInt) |
| 1134 | newName = "u" + newName; |
| 1135 | else if (newType == ag::Type::UChar) |
| 1136 | newName = "b" + newName; |
| 1137 | |
| 1138 | return GLSLCompiler::ExpressionType(newName, newType, cols, rows); |
| 1139 | } |
| 1140 | // matrix * scalar |
| 1141 | else { |
| 1142 | ag::Type newType = m_mergeBaseType(left.Type, right.Type); |
| 1143 | |
| 1144 | int rows = left.Rows; |
| 1145 | int cols = left.Columns; |
| 1146 |
nothing calls this directly
no test coverage detected