diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-11-19 18:15:21 -0700 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-11-19 18:15:21 -0700 |
commit | 0204cbb4f17ef24a3c1ae1e426d5da3dd3744f92 (patch) | |
tree | e74bf974efe746fb6260c202e2fc8ac34908ddb8 /src | |
parent | 7f718f047676e88b660618784f256a96f7e8ed58 (diff) |
optimize linear_interpolation(), perspective_interpolation() functions
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/pipe/tgsi/exec/tgsi_exec.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.c b/src/mesa/pipe/tgsi/exec/tgsi_exec.c index 5c2fecb3e3..ea6c5021b3 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_exec.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.c @@ -1346,17 +1346,15 @@ linear_interpolation( unsigned attrib, unsigned chan ) { - unsigned i; - - for( i = 0; i < QUAD_SIZE; i++ ) { - const float x = mach->Inputs[0].xyzw[0].f[i]; - const float y = mach->Inputs[0].xyzw[1].f[i]; - - mach->Inputs[attrib].xyzw[chan].f[i] = - mach->InterpCoefs[attrib].a0[chan] + - mach->InterpCoefs[attrib].dadx[chan] * x + - mach->InterpCoefs[attrib].dady[chan] * y; - } + const float x = mach->Inputs[0].xyzw[0].f[0]; + const float y = mach->Inputs[0].xyzw[1].f[0]; + const float dadx = mach->InterpCoefs[attrib].dadx[chan]; + const float dady = mach->InterpCoefs[attrib].dady[chan]; + const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y; + mach->Inputs[attrib].xyzw[chan].f[0] = a0; + mach->Inputs[attrib].xyzw[chan].f[1] = a0 + dadx; + mach->Inputs[attrib].xyzw[chan].f[2] = a0 + dady; + mach->Inputs[attrib].xyzw[chan].f[3] = a0 + dadx + dady; } static void @@ -1365,20 +1363,15 @@ perspective_interpolation( unsigned attrib, unsigned chan ) { - unsigned i; - - for( i = 0; i < QUAD_SIZE; i++ ) { - const float x = mach->Inputs[0].xyzw[0].f[i]; - const float y = mach->Inputs[0].xyzw[1].f[i]; - /* WPOS.w here is really 1/w */ - const float w = 1.0f / mach->Inputs[0].xyzw[3].f[i]; - assert(mach->Inputs[0].xyzw[3].f[i] != 0.0); - - mach->Inputs[attrib].xyzw[chan].f[i] = - (mach->InterpCoefs[attrib].a0[chan] + - mach->InterpCoefs[attrib].dadx[chan] * x + - mach->InterpCoefs[attrib].dady[chan] * y) * w; - } + const float x = mach->Inputs[0].xyzw[0].f[0]; + const float y = mach->Inputs[0].xyzw[1].f[0]; + const float dadx = mach->InterpCoefs[attrib].dadx[chan]; + const float dady = mach->InterpCoefs[attrib].dady[chan]; + const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y; + mach->Inputs[attrib].xyzw[chan].f[0] = a0 / mach->Inputs[0].xyzw[3].f[0]; + mach->Inputs[attrib].xyzw[chan].f[1] = (a0 + dadx) / mach->Inputs[0].xyzw[3].f[1]; + mach->Inputs[attrib].xyzw[chan].f[2] = (a0 + dady) / mach->Inputs[0].xyzw[3].f[2]; + mach->Inputs[attrib].xyzw[chan].f[3] = (a0 + dadx + dady) / mach->Inputs[0].xyzw[3].f[3]; } |