diff options
author | Ian Romanick <[email protected]> | 2010-08-13 20:22:46 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2010-08-13 20:22:46 -0700 |
commit | 443a7e4e9a360acbc3e662c098be436f180bf81d (patch) | |
tree | 71125fc394bdcbc17cd7ed74c592b9a7761541f8 /src/mesa/program/prog_execute.c | |
parent | 2f8ee757ab324d599fcb8287789eb5f1a7890d74 (diff) | |
parent | 27041d7cb3faeaed483538a228573466363ec1c7 (diff) |
Merge branch 'master' into glsl2
Diffstat (limited to 'src/mesa/program/prog_execute.c')
-rw-r--r-- | src/mesa/program/prog_execute.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c index b6da3449b26..1222a0f4c8c 100644 --- a/src/mesa/program/prog_execute.c +++ b/src/mesa/program/prog_execute.c @@ -37,7 +37,7 @@ #include "main/glheader.h" #include "main/colormac.h" -#include "main/context.h" +#include "main/macros.h" #include "prog_execute.h" #include "prog_instruction.h" #include "prog_parameter.h" @@ -81,6 +81,22 @@ static const GLfloat ZeroVec[4] = { 0.0F, 0.0F, 0.0F, 0.0F }; /** + * Return TRUE for +0 and other positive values, FALSE otherwise. + * Used for RCC opcode. + */ +static INLINE GLboolean +positive(float x) +{ + fi_type fi; + fi.f = x; + if (fi.i & 0x80000000) + return GL_FALSE; + return GL_TRUE; +} + + + +/** * Return a pointer to the 4-element float vector specified by the given * source register. */ @@ -1340,6 +1356,44 @@ _mesa_execute_program(GLcontext * ctx, store_vector4(inst, machine, result); } break; + case OPCODE_RCC: /* clamped riciprocal */ + { + const float largest = 1.884467e+19, smallest = 5.42101e-20; + GLfloat a[4], r, result[4]; + fetch_vector1(&inst->SrcReg[0], machine, a); + if (DEBUG_PROG) { + if (a[0] == 0) + printf("RCC(0)\n"); + else if (IS_INF_OR_NAN(a[0])) + printf("RCC(inf)\n"); + } + if (a[0] == 1.0F) { + r = 1.0F; + } + else { + r = 1.0F / a[0]; + } + if (positive(r)) { + if (r > largest) { + r = largest; + } + else if (r < smallest) { + r = smallest; + } + } + else { + if (r < -largest) { + r = -largest; + } + else if (r > -smallest) { + r = -smallest; + } + } + result[0] = result[1] = result[2] = result[3] = r; + store_vector4(inst, machine, result); + } + break; + case OPCODE_RCP: { GLfloat a[4], result[4]; |