[Mesa-dev] [PATCH 1/2] softpipe: fix shadow 2d texture array sampling

Dave Airlie airlied at gmail.com
Mon Dec 19 03:53:58 PST 2011


From: Dave Airlie <airlied at redhat.com>

The 4th texcoord is used in this case for the comparison.

This fixes piglit glsl-fs-shadow2DArray* on softpipe.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/auxiliary/tgsi/tgsi_exec.c       |   11 ++++++++++-
 src/gallium/drivers/softpipe/sp_tex_sample.c |   17 ++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index a44ba80..4115e35 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -1822,7 +1822,6 @@ exec_tex(struct tgsi_exec_machine *mach,
       break;
 
    case TGSI_TEXTURE_2D_ARRAY:
-   case TGSI_TEXTURE_SHADOW2D_ARRAY:
       FETCH(&r[0], 0, CHAN_X);
       FETCH(&r[1], 0, CHAN_Y);
       FETCH(&r[2], 0, CHAN_Z);
@@ -1837,7 +1836,17 @@ exec_tex(struct tgsi_exec_machine *mach,
                   control,
                   &r[0], &r[1], &r[2], &r[3]);  /* outputs */
       break;
+   case TGSI_TEXTURE_SHADOW2D_ARRAY:
+      FETCH(&r[0], 0, CHAN_X);
+      FETCH(&r[1], 0, CHAN_Y);
+      FETCH(&r[2], 0, CHAN_Z);
+      FETCH(&r[3], 0, CHAN_W);
 
+      fetch_texel(mach->Samplers[unit],
+                  &r[0], &r[1], &r[2], &r[3],     /* S, T, P, LOD */
+                  control,
+                  &r[0], &r[1], &r[2], &r[3]);  /* outputs */
+      break;
    case TGSI_TEXTURE_3D:
    case TGSI_TEXTURE_CUBE:
       FETCH(&r[0], 0, CHAN_X);
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 43f201f..8123d7b 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -2113,15 +2113,22 @@ sample_compare(struct tgsi_sampler *tgsi_sampler,
 
    /**
     * Compare texcoord 'p' (aka R) against texture value 'rgba[0]'
+    * for 2D Array texture we need to use the 'c0' (aka Q).
     * When we sampled the depth texture, the depth value was put into all
     * RGBA channels.  We look at the red channel here.
     */
 
-   pc0 = CLAMP(p[0], 0.0F, 1.0F);
-   pc1 = CLAMP(p[1], 0.0F, 1.0F);
-   pc2 = CLAMP(p[2], 0.0F, 1.0F);
-   pc3 = CLAMP(p[3], 0.0F, 1.0F);
-
+   if (samp->view->texture->target == PIPE_TEXTURE_2D_ARRAY) {
+      pc0 = CLAMP(c0[0], 0.0F, 1.0F);
+      pc1 = CLAMP(c0[1], 0.0F, 1.0F);
+      pc2 = CLAMP(c0[2], 0.0F, 1.0F);
+      pc3 = CLAMP(c0[3], 0.0F, 1.0F);
+   } else {
+      pc0 = CLAMP(p[0], 0.0F, 1.0F);
+      pc1 = CLAMP(p[1], 0.0F, 1.0F);
+      pc2 = CLAMP(p[2], 0.0F, 1.0F);
+      pc3 = CLAMP(p[3], 0.0F, 1.0F);
+   }
    /* compare four texcoords vs. four texture samples */
    switch (sampler->compare_func) {
    case PIPE_FUNC_LESS:
-- 
1.7.7.3



More information about the mesa-dev mailing list