Mesa (master): softpipe: Implement cylindrical wrapping for linear interpolator.

Michał Król michal at kemper.freedesktop.org
Tue Feb 9 14:35:32 UTC 2010


Module: Mesa
Branch: master
Commit: e04c8ecc61dfe05d0e17cbffd2f758b0861083bd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e04c8ecc61dfe05d0e17cbffd2f758b0861083bd

Author: Michal Krol <michal at vmware.com>
Date:   Wed Feb  3 15:30:17 2010 +0100

softpipe: Implement cylindrical wrapping for linear interpolator.

---

 src/gallium/drivers/softpipe/sp_setup.c |   46 +++++++++++++++++++++++-------
 1 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index bb1bff5..b7b52b1 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -419,19 +419,38 @@ static void const_coeff( struct setup_context *setup,
  * Compute a0, dadx and dady for a linearly interpolated coefficient,
  * for a triangle.
  */
-static void tri_linear_coeff( struct setup_context *setup,
-                              struct tgsi_interp_coef *coef,
-                              uint vertSlot, uint i)
+static void
+tri_linear_coeff(struct setup_context *setup,
+                 struct tgsi_interp_coef *coef,
+                 uint vertSlot,
+                 uint i,
+                 uint cylindrical_wrap)
 {
    float botda = setup->vmid[vertSlot][i] - setup->vmin[vertSlot][i];
    float majda = setup->vmax[vertSlot][i] - setup->vmin[vertSlot][i];
-   float a = setup->ebot.dy * majda - botda * setup->emaj.dy;
-   float b = setup->emaj.dx * botda - majda * setup->ebot.dx;
-   float dadx = a * setup->oneoverarea;
-   float dady = b * setup->oneoverarea;
+   float a, b;
+   float dadx, dady;
 
    assert(i <= 3);
 
+   if (cylindrical_wrap) {
+      if (botda > 0.5f) {
+         botda -= 1.0f;
+      } else if (botda < -0.5f) {
+         botda += 1.0f;
+      }
+      if (majda > 0.5f) {
+         majda -= 1.0f;
+      } else if (majda < -0.5f) {
+         majda += 1.0f;
+      }
+   }
+
+   a = setup->ebot.dy * majda - botda * setup->emaj.dy;
+   b = setup->emaj.dx * botda - majda * setup->ebot.dx;
+   dadx = a * setup->oneoverarea;
+   dady = b * setup->oneoverarea;
+
    coef->dadx[i] = dadx;
    coef->dady[i] = dady;
 
@@ -547,8 +566,8 @@ static void setup_tri_coefficients( struct setup_context *setup )
 
    /* z and w are done by linear interpolation:
     */
-   tri_linear_coeff(setup, &setup->posCoef, 0, 2);
-   tri_linear_coeff(setup, &setup->posCoef, 0, 3);
+   tri_linear_coeff(setup, &setup->posCoef, 0, 2, 0);
+   tri_linear_coeff(setup, &setup->posCoef, 0, 3, 0);
 
    /* setup interpolation for all the remaining attributes:
     */
@@ -562,8 +581,13 @@ static void setup_tri_coefficients( struct setup_context *setup )
             const_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
          break;
       case INTERP_LINEAR:
-         for (j = 0; j < NUM_CHANNELS; j++)
-            tri_linear_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
+         for (j = 0; j < NUM_CHANNELS; j++) {
+            tri_linear_coeff(setup,
+                             &setup->coef[fragSlot],
+                             vertSlot,
+                             j,
+                             spfs->info.input_cylindrical_wrap[fragSlot] & (1 << j));
+         }
          break;
       case INTERP_PERSPECTIVE:
          for (j = 0; j < NUM_CHANNELS; j++)




More information about the mesa-commit mailing list