PowerVR Rogue¶
Exp and Log¶
On PowerVR Rogue architecture, the 2^n
operation is directly supported by an instruction (EXP
):
fragColor.x = exp2(t.x); // one cycle
{fexp}
The same is true with the log2()
function (LOG
):
fragColor.x = log2(t.x); // one cycle
{flog}
exp
is implemented as:
float exp2( float x )
{
return exp2(x * 1.442695); // two cycles
{sop, sop}
{fexp}
}
log
is implemented as:
float log2( float x )
{
return log2(x * 0.693147); // two cycles
{sop, sop}
{flog}
}
pow(x, y)
is implemented as:
float pow( float x, float y )
{
return exp2(log2(x) * y); // three cycles
{flog}
{sop, sop}
{fexp}
}
Sin, Cos, Sinh, and Cosh¶
Sin, cos, sinh, and cosh on PowerVR architecture have a reasonably low cost of four cycles.
This is broken down as:
Two cycles of reduction
sinc
One conditional.
fragColor.x = sin(t.x); // four cycles
{fred}
{fred}
{fsinc}
{fmul, mov} // plus conditional
fragColor.x = cos(t.x); // four cycles
{fred}
{fred}
{fsinc}
{fmul, mov} // plus conditional
fragColor.x = cosh(t.x); // three cycles
{fmul, fmul, mov, mov}
{fexp}
{sop, sop}
fragColor.x = sinh(t.x); // three cycles
{fmul, fmul, mov, mov}
{fexp}
{sop, sop}
Asin, Acos, Atan, Degrees, and Radians¶
If the math expressions’ simplifications are completed, then these functions are usually not needed. Therefore they do not map to the hardware exactly. This means that these functions have a very high cost, and should be avoided at all times.
asin()
costs a massive 67 cycles:
fragColor.x = asin(t.x); // 67 cycles
// USC code omitted due to length
acos()
costs a massive 79 cycles:
fragColor.x = acos(t.x); // 79 cycles
// USC code omitted due to length
atan()
is still costly, but can be used if needed:
fragColor.x = atan(t.x); // 12 cycles (lots of conditionals)
// USC code omitted due to length
While degrees and radians take only one cycle, they can usually be avoided if only radians are used:
fragColor.x = degrees(t.x); // one cycle
{sop, sop}
fragColor.x = radians(t.x); // one cycle
{sop, sop}