Commit f7f7616b by Nicolas Capens

Fix constructing vectors from matrices.

BUG=380353 Change-Id: I3b0fe55b829602554bb63bbd281ad58d47364502 Reviewed-on: https://chromium-review.googlesource.com/202966Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org>
parent 906744ac
......@@ -3669,7 +3669,14 @@ void OutputHLSL::addConstructor(const TType &type, const TString &name, const TI
constructor += "x" + str(parameterIndex);
if (parameter.isScalar())
if (ctorType.getStruct())
{
ASSERT(remainingComponents == parameterSize || moreParameters);
ASSERT(parameterSize <= remainingComponents);
remainingComponents -= parameterSize;
}
else if (parameter.isScalar())
{
remainingComponents -= parameter.getObjectSize();
}
......@@ -3695,12 +3702,37 @@ void OutputHLSL::addConstructor(const TType &type, const TString &name, const TI
}
else UNREACHABLE();
}
else if (parameter.isMatrix() || parameter.getStruct())
else if (parameter.isMatrix())
{
ASSERT(remainingComponents == parameterSize || moreParameters);
ASSERT(parameterSize <= remainingComponents);
remainingComponents -= parameterSize;
int column = 0;
while (remainingComponents > 0 && column < parameter.getCols())
{
constructor += "[" + str(column) + "]";
if (remainingComponents < static_cast<size_t>(parameter.getRows()))
{
switch (remainingComponents)
{
case 1: constructor += ".x"; break;
case 2: constructor += ".xy"; break;
case 3: constructor += ".xyz"; break;
default: UNREACHABLE();
}
remainingComponents = 0;
}
else
{
remainingComponents -= parameter.getRows();
if (remainingComponents > 0)
{
constructor += ", x" + str(parameterIndex);
}
}
column++;
}
}
else UNREACHABLE();
......
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