summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2013-01-03 08:02:57 -0700
committerAndreas Boll <andreas.boll.dev@gmail.com>2013-02-13 18:46:39 +0100
commit96c1678c3ad2dd460d8a5e8787d3dc7a0d9588c9 (patch)
tree3b8b9c19f71fe1574902de3935453dadd7dcf2e0
parentaf41a1d49107f5020bfceda8ea930601bb6b92b9 (diff)
util: add get/put_tile_z() support for PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=58972 Note: This is a candidate for the stable branches. (cherry picked from commit 073a53fe2f39cfa42090b223cbaf287b48cefe8e)
-rw-r--r--src/gallium/auxiliary/util/u_tile.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c
index a1d55adf7a..ac2a950b5e 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -701,6 +701,28 @@ pipe_get_tile_z(struct pipe_context *pipe,
}
}
break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+ {
+ const float *ptrc = (const float *)(map + y * pt->stride + x*8);
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ /* convert float Z to 32-bit Z */
+ if (ptrc[j] <= 0.0) {
+ pDest[j*2] = 0;
+ }
+ else if (ptrc[j] >= 1.0) {
+ pDest[j*2] = 0xffffffff;
+ }
+ else {
+ double z = ptrc[j] * 0xffffffff;
+ pDest[j*2] = (uint) z;
+ }
+ }
+ pDest += dstStride;
+ ptrc += pt->stride/4;
+ }
+ }
+ break;
default:
assert(0);
}
@@ -822,6 +844,20 @@ pipe_put_tile_z(struct pipe_context *pipe,
}
}
break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+ {
+ float *pDest = (float *) (map + y * pt->stride + x*8);
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ /* convert 32-bit integer Z to float Z */
+ const double scale = 1.0 / 0xffffffffU;
+ pDest[j*2] = ptrc[j] * scale;
+ }
+ pDest += pt->stride/4;
+ ptrc += srcStride;
+ }
+ }
+ break;
default:
assert(0);
}