Compiler - fix mat3 conformance

TRAC #11723 Matrix elements are accessed as [col][row] in GLSL and [row][col] in HLSL. Fixed this by transposing all matrix uniforms so they have a row-major layout. Then transpose them in the shader every time they're used in matrix math. Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@96 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 57a0bab8
......@@ -553,12 +553,24 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
else if (visit == InVisit)
{
out << " = mul(";
if (node->getOp() == EOpMatrixTimesMatrixAssign)
{
out << "transpose(";
}
node->getLeft()->traverse(this);
out << ", ";
if (node->getOp() == EOpMatrixTimesMatrixAssign)
{
out << ")";
}
out << ", transpose(";
}
else
{
out << "))";
out << ")))";
}
break;
case EOpDivAssign: outputTriplet(visit, "(", " /= ", ")"); break;
......@@ -631,9 +643,9 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
case EOpGreaterThanEqual: outputTriplet(visit, "(", " >= ", ")"); break;
case EOpVectorTimesScalar: outputTriplet(visit, "(", " * ", ")"); break;
case EOpMatrixTimesScalar: outputTriplet(visit, "(", " * ", ")"); break;
case EOpVectorTimesMatrix: outputTriplet(visit, "mul(", ", ", ")"); break;
case EOpMatrixTimesVector: outputTriplet(visit, "mul(", ", ", ")"); break;
case EOpMatrixTimesMatrix: outputTriplet(visit, "mul(", ", ", ")"); break;
case EOpVectorTimesMatrix: outputTriplet(visit, "mul(", ", transpose(", "))"); break;
case EOpMatrixTimesVector: outputTriplet(visit, "mul(transpose(", "), ", ")"); break;
case EOpMatrixTimesMatrix: outputTriplet(visit, "mul(transpose(", "), transpose(", "))"); break;
case EOpLogicalOr: outputTriplet(visit, "(", " || ", ")"); break;
case EOpLogicalXor: outputTriplet(visit, "xor(", ", ", ")"); break; // FIXME: Prevent name clashes
case EOpLogicalAnd: outputTriplet(visit, "(", " && ", ")"); break;
......
......@@ -789,12 +789,12 @@ bool Program::applyUniformMatrix2fv(GLint location, GLsizei count, const GLfloat
if (constantPS)
{
mConstantTablePS->SetMatrixArray(device, constantPS, matrix, count);
mConstantTablePS->SetMatrixTransposeArray(device, constantPS, matrix, count);
}
if (constantVS)
{
mConstantTableVS->SetMatrixArray(device, constantVS, matrix, count);
mConstantTableVS->SetMatrixTransposeArray(device, constantVS, matrix, count);
}
delete[] matrix;
......@@ -822,12 +822,12 @@ bool Program::applyUniformMatrix3fv(GLint location, GLsizei count, const GLfloat
if (constantPS)
{
mConstantTablePS->SetMatrixArray(device, constantPS, matrix, count);
mConstantTablePS->SetMatrixTransposeArray(device, constantPS, matrix, count);
}
if (constantVS)
{
mConstantTableVS->SetMatrixArray(device, constantVS, matrix, count);
mConstantTableVS->SetMatrixTransposeArray(device, constantVS, matrix, count);
}
delete[] matrix;
......@@ -855,12 +855,12 @@ bool Program::applyUniformMatrix4fv(GLint location, GLsizei count, const GLfloat
if (constantPS)
{
mConstantTablePS->SetMatrixArray(device, constantPS, matrix, count);
mConstantTablePS->SetMatrixTransposeArray(device, constantPS, matrix, count);
}
if (constantVS)
{
mConstantTableVS->SetMatrixArray(device, constantVS, matrix, count);
mConstantTableVS->SetMatrixTransposeArray(device, constantVS, matrix, count);
}
delete[] matrix;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment