Commit 81b9ca65 by Nicolas Capens Committed by Nicolas Capens

Implement constructing vectors from matrices and matrices from scalars.

BUG=15415045 Change-Id: I97355dab2890bcf3c1bf39d149960e53e4fed325 Reviewed-on: https://swiftshader-review.googlesource.com/1115Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 9958acf0
......@@ -640,6 +640,8 @@ namespace sh
return false;
}
Constant zero(0.0f, 0.0f, 0.0f, 0.0f);
TIntermTyped *result = node;
const TType &resultType = node->getType();
TIntermSequence &arg = node->getSequence();
......@@ -862,14 +864,31 @@ namespace sh
{
TIntermTyped *argi = arg[i]->getAsTyped();
int size = argi->getNominalSize();
ASSERT(!argi->isMatrix());
if(!argi->isMatrix())
{
Instruction *mov = emitCast(result, argi);
mov->dst.mask = (0xF << component) & 0xF;
mov->src[0].swizzle = readSwizzle(argi, size) << (component * 2);
component += size;
}
else // Matrix
{
int column = 0;
while(component < resultType.getNominalSize())
{
Instruction *mov = emitCast(result, argi);
mov->dst.mask = (0xF << component) & 0xF;
mov->src[0].index += column;
mov->src[0].swizzle = readSwizzle(argi, size) << (component * 2);
column++;
component += size;
}
}
}
}
break;
case EOpConstructMat2:
......@@ -880,7 +899,19 @@ namespace sh
TIntermTyped *arg0 = arg[0]->getAsTyped();
const int dim = result->getNominalSize();
if(arg0->isMatrix())
if(arg0->isScalar() && arg.size() == 1) // Construct scale matrix
{
for(int i = 0; i < dim; i++)
{
Instruction *init = emit(sw::Shader::OPCODE_MOV, result, &zero);
init->dst.index += i;
Instruction *mov = emitCast(result, arg0);
mov->dst.index += i;
mov->dst.mask = 1 << i;
ASSERT(mov->src[0].swizzle == 0x00);
}
}
else if(arg0->isMatrix())
{
for(int i = 0; i < dim; i++)
{
......
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