diff options
author | Brian Paul <[email protected]> | 2012-08-27 09:31:18 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-08-27 13:32:53 -0600 |
commit | f308c804905ef7f2a976397c8d48a295d8f6853c (patch) | |
tree | ccf9c06323c80e08f4e3ef5fbd0662c2fed18b27 /src/gallium/auxiliary | |
parent | a971476cc7913edde1944f33f164cd507199e1dd (diff) |
gallium/util: implement tile code for PIPE_FORMAT_Z32_FLOAT
Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/util/u_tile.c | 36 |
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 ea4b91f959a..48e73c40ba7 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -679,6 +679,28 @@ pipe_get_tile_z(struct pipe_context *pipe, } } break; + case PIPE_FORMAT_Z32_FLOAT: + { + const float *ptrc = (const float *)(map + y * pt->stride + x*4); + 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] = 0; + } + else if (ptrc[j] >= 1.0) { + pDest[j] = 0xffffffff; + } + else { + double z = ptrc[j] * 0xffffffff; + pDest[j] = (uint) z; + } + } + pDest += dstStride; + ptrc += pt->stride/4; + } + } + break; default: assert(0); } @@ -786,6 +808,20 @@ pipe_put_tile_z(struct pipe_context *pipe, } } break; + case PIPE_FORMAT_Z32_FLOAT: + { + float *pDest = (float *) (map + y * pt->stride + x*2); + 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] = ptrc[j] * scale; + } + pDest += pt->stride/4; + ptrc += srcStride; + } + } + break; default: assert(0); } |