Microsoft DirectX 8.0 (Visual Basic) |
Computes the reciprocal of the source scalar.
rcp vDest, vSrc0
The following code fragment shows the operations performed by the rcp instruction to write a result to the destination.
SetDestReg(); SetSrcReg(0); if( m_Source[0].w == 1.0f ) { // Must be exactly 1.0 m_TmpReg.x = m_TmpReg.y = m_TmpReg.z = m_TmpReg.w = 1.0f; } else if( m_Source[0].w == 0 ) { m_TmpReg.x = m_TmpReg.y = m_TmpReg.z = m_TmpReg.w = PLUS_INFINITY(); } else { m_TmpReg.x = m_TmpReg.y = m_TmpReg.z = m_TmpReg.w = 1.0f/m_Source[0].w; } WriteResult();
If the source has no subscripts, the x-component is used. The output must be exactly 1.0 if the input is exactly 1.0.
Precision should be at least 1.0/(222) absolute error over the range (1.0, 2.0) because common implementations will separate mantissa and exponent. A source of 0.0 yields infinity.
The following example illustrates how the rcp instruction might be used.
rcp r1, r2 rcp r1, r2.y