Commit de16ffd0 by Alexis Hetu Committed by Alexis Hétu

Texture projection constant folding

Whenever texture projection is used with a constant texture coordinate, folding allows to use the full precision reciprocal and not generate the lower precision reciprocal operation. Change-Id: I6cab6567d63ecd9abe1cedbd7e46e1fd9099a3d3 Reviewed-on: https://swiftshader-review.googlesource.com/5210Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 6c6b4707
......@@ -1229,12 +1229,25 @@ namespace glsl
if(textureFunction.proj)
{
Instruction *rcp = emit(sw::Shader::OPCODE_RCPX, &coord, arg[1]);
rcp->src[0].swizzle = 0x55 * (t->getNominalSize() - 1);
rcp->dst.mask = 0x7;
TIntermConstantUnion* constant = arg[1]->getAsConstantUnion();
if(constant)
{
float projFactor = 1.0f / constant->getFConst(t->getNominalSize() - 1);
Constant projCoord(constant->getFConst(0) * projFactor,
constant->getFConst(1) * projFactor,
constant->getFConst(2) * projFactor,
0.0f);
emit(sw::Shader::OPCODE_MOV, &coord, &projCoord);
}
else
{
Instruction *rcp = emit(sw::Shader::OPCODE_RCPX, &coord, arg[1]);
rcp->src[0].swizzle = 0x55 * (t->getNominalSize() - 1);
rcp->dst.mask = 0x7;
Instruction *mul = emit(sw::Shader::OPCODE_MUL, &coord, arg[1], &coord);
mul->dst.mask = 0x7;
Instruction *mul = emit(sw::Shader::OPCODE_MUL, &coord, arg[1], &coord);
mul->dst.mask = 0x7;
}
}
else
{
......
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