summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/softpipe/sp_surface.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-11-20 08:36:06 -0700
committerBrian <[email protected]>2007-11-20 08:36:06 -0700
commit5a6017d496ccce94d7e3cf9a6cfe1db886dcc767 (patch)
tree8a7baab5fcb3e80eb9924a22d3e57921380023ec /src/mesa/pipe/softpipe/sp_surface.c
parent0191570f024ba787799ca2bccd46549a8af74aa9 (diff)
add PIPE_FORMAT_Z24_S8 support to softpipe patsh
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_surface.c')
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c
index ccaf38de3e4..b7c9d4f0045 100644
--- a/src/mesa/pipe/softpipe/sp_surface.c
+++ b/src/mesa/pipe/softpipe/sp_surface.c
@@ -461,6 +461,40 @@ s8z24_get_tile(struct pipe_surface *ps,
}
+/*** PIPE_FORMAT_Z24_S8 ***/
+
+/**
+ * Return Z component as four float in [0,1]. Stencil part ignored.
+ */
+static void
+z24s8_get_tile(struct pipe_surface *ps,
+ unsigned x, unsigned y, unsigned w, unsigned h, float *p)
+{
+ const uint *src
+ = ((const uint *) (ps->region->map + ps->offset))
+ + y * ps->region->pitch + x;
+ const double scale = 1.0 / ((1 << 24) - 1);
+ unsigned i, j;
+ unsigned w0 = w;
+
+ assert(ps->format == PIPE_FORMAT_Z24_S8);
+
+ CLIP_TILE;
+
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++) {
+ pRow[j * 4 + 0] =
+ pRow[j * 4 + 1] =
+ pRow[j * 4 + 2] =
+ pRow[j * 4 + 3] = (float) (scale * (src[j] >> 8));
+ }
+ src += ps->region->pitch;
+ p += 4 * w0;
+ }
+}
+
+
/**
* Called via pipe->get_tex_surface()
* XXX is this in the right place?
@@ -601,6 +635,9 @@ softpipe_get_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_S8_Z24:
s8z24_get_tile(ps, x, y, w, h, p);
break;
+ case PIPE_FORMAT_Z24_S8:
+ z24s8_get_tile(ps, x, y, w, h, p);
+ break;
default:
assert(0);
}
@@ -645,6 +682,9 @@ softpipe_put_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_S8_Z24:
/*s8z24_put_tile(ps, x, y, w, h, p);*/
break;
+ case PIPE_FORMAT_Z24_S8:
+ /*z24s8_put_tile(ps, x, y, w, h, p);*/
+ break;
default:
assert(0);
}