From b4ad7c28430e4084d843cd99cf68209e95363963 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 29 Jul 2010 08:23:59 -0600 Subject: mesa: implement RCC opcode --- src/mesa/program/prog_execute.c | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/mesa/program/prog_execute.c') diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c index f85c6513f31..6c50f409d29 100644 --- a/src/mesa/program/prog_execute.c +++ b/src/mesa/program/prog_execute.c @@ -80,6 +80,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]; -- cgit v1.2.3 From 3fdd9fa556e9ba48244cb2b3966d3bfb0b84731b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 30 Jul 2010 00:41:08 -0700 Subject: mesa: Include macros.h in files that use symbols from macros.h. Don't rely on inclusion of other files that already include macros.h. --- src/mesa/main/clear.c | 1 + src/mesa/main/convolve.c | 1 + src/mesa/main/fog.c | 1 + src/mesa/main/histogram.c | 1 + src/mesa/main/texcompress_fxt1.c | 1 + src/mesa/main/texcompress_s3tc.c | 1 + src/mesa/main/texfetch.c | 1 + src/mesa/main/texrender.c | 1 + src/mesa/math/m_translate.c | 1 + src/mesa/program/prog_execute.c | 1 + src/mesa/vf/vf_generic.c | 1 + 11 files changed, 11 insertions(+) (limited to 'src/mesa/program/prog_execute.c') diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c index e76ab5527b0..49d86b3b1f1 100644 --- a/src/mesa/main/clear.c +++ b/src/mesa/main/clear.c @@ -35,6 +35,7 @@ #include "context.h" #include "colormac.h" #include "enums.h" +#include "macros.h" #include "state.h" diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 15e8dffc230..f63bddc44d5 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -37,6 +37,7 @@ #include "convolve.h" #include "context.h" #include "image.h" +#include "macros.h" #include "mtypes.h" #include "state.h" #include "main/dispatch.h" diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c index 269ff3f8b99..9f26c012d66 100644 --- a/src/mesa/main/fog.c +++ b/src/mesa/main/fog.c @@ -27,6 +27,7 @@ #include "colormac.h" #include "context.h" #include "fog.h" +#include "macros.h" #include "mtypes.h" diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c index 3a65bb19260..4e482bcd54b 100644 --- a/src/mesa/main/histogram.c +++ b/src/mesa/main/histogram.c @@ -29,6 +29,7 @@ #include "context.h" #include "image.h" #include "histogram.h" +#include "macros.h" #include "main/dispatch.h" diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 04acf05e528..85d53a860c0 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -35,6 +35,7 @@ #include "context.h" #include "convolve.h" #include "image.h" +#include "macros.h" #include "mipmap.h" #include "texcompress.h" #include "texcompress_fxt1.h" diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 85c394b051f..3d26feca5bb 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -40,6 +40,7 @@ #include "convolve.h" #include "dlopen.h" #include "image.h" +#include "macros.h" #include "texcompress.h" #include "texcompress_s3tc.h" #include "texstore.h" diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index fe002082cca..9d797cd6ad5 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -35,6 +35,7 @@ #include "colormac.h" #include "context.h" +#include "macros.h" #include "texcompress.h" #include "texcompress_fxt1.h" #include "texcompress_s3tc.h" diff --git a/src/mesa/main/texrender.c b/src/mesa/main/texrender.c index d29af5a5b2f..c68105b3951 100644 --- a/src/mesa/main/texrender.c +++ b/src/mesa/main/texrender.c @@ -1,6 +1,7 @@ #include "context.h" #include "colormac.h" +#include "macros.h" #include "texfetch.h" #include "texrender.h" #include "renderbuffer.h" diff --git a/src/mesa/math/m_translate.c b/src/mesa/math/m_translate.c index b12b07957cb..1d26fa147dd 100644 --- a/src/mesa/math/m_translate.c +++ b/src/mesa/math/m_translate.c @@ -29,6 +29,7 @@ #include "main/glheader.h" +#include "main/macros.h" #include "main/mtypes.h" /* GLchan hack */ #include "main/colormac.h" diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c index 6c50f409d29..fe14ba36b7c 100644 --- a/src/mesa/program/prog_execute.c +++ b/src/mesa/program/prog_execute.c @@ -38,6 +38,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" diff --git a/src/mesa/vf/vf_generic.c b/src/mesa/vf/vf_generic.c index 0af8893c302..95a317e99db 100644 --- a/src/mesa/vf/vf_generic.c +++ b/src/mesa/vf/vf_generic.c @@ -29,6 +29,7 @@ #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" +#include "main/macros.h" #include "main/simple_list.h" #include "vf/vf.h" -- cgit v1.2.3 From 245d5a8913f6f4487e837d112a97093c06b639ea Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 31 Jul 2010 14:37:32 -0700 Subject: mesa: Remove unnecessary headers. --- src/mesa/main/image.c | 1 - src/mesa/main/texcompress.c | 1 - src/mesa/main/texcompress_fxt1.c | 1 - src/mesa/main/texcompress_s3tc.c | 1 - src/mesa/main/texfetch.c | 1 - src/mesa/program/prog_execute.c | 1 - 6 files changed, 6 deletions(-) (limited to 'src/mesa/program/prog_execute.c') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 63c28342f26..86aa6d0d702 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -32,7 +32,6 @@ #include "glheader.h" #include "colormac.h" -#include "context.h" #include "enums.h" #include "image.h" #include "imports.h" diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index f4b1119eb17..e911524cbc5 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -33,7 +33,6 @@ #include "glheader.h" #include "imports.h" #include "colormac.h" -#include "context.h" #include "formats.h" #include "texcompress.h" diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 85d53a860c0..c8b45bd3a55 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -32,7 +32,6 @@ #include "glheader.h" #include "imports.h" #include "colormac.h" -#include "context.h" #include "convolve.h" #include "image.h" #include "macros.h" diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 3d26feca5bb..c70792cab61 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -36,7 +36,6 @@ #include "glheader.h" #include "imports.h" #include "colormac.h" -#include "context.h" #include "convolve.h" #include "dlopen.h" #include "image.h" diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index 9d797cd6ad5..c03bc71cd7a 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -34,7 +34,6 @@ #include "colormac.h" -#include "context.h" #include "macros.h" #include "texcompress.h" #include "texcompress_fxt1.h" diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c index fe14ba36b7c..1670c91b6ad 100644 --- a/src/mesa/program/prog_execute.c +++ b/src/mesa/program/prog_execute.c @@ -37,7 +37,6 @@ #include "main/glheader.h" #include "main/colormac.h" -#include "main/context.h" #include "main/macros.h" #include "prog_execute.h" #include "prog_instruction.h" -- cgit v1.2.3