diff options
author | Eric Anholt <[email protected]> | 2011-12-02 16:00:10 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-12-19 13:20:11 -0800 |
commit | 353f7ba4abbfd15d1e4e4b7a38f88e64ce85f6a2 (patch) | |
tree | 8937c4d9c1b7ba2acfdf90b0dddf19d1d5bea135 | |
parent | 0c498467104e361e50bbb95adf2b2c0e799591dc (diff) |
i965: Add support for mapping Z32_FLOAT_X24S8 fake packed depth/stencil.
The format handling here is tricky, because we're not actually
generating a Z32_FLOAT_X24S8 miptree, so we're guessing the format
that GL wants based on seeing Z32_FLOAT with a separate stencil.
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index ee2d1e03ad2..0d49fec43d4 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -876,7 +876,8 @@ intel_miptree_map_depthstencil(struct intel_context *intel, { struct intel_mipmap_tree *z_mt = mt; struct intel_mipmap_tree *s_mt = mt->stencil_mt; - int packed_bpp = 4; + bool map_z32f_x24s8 = mt->format == MESA_FORMAT_Z32_FLOAT; + int packed_bpp = map_z32f_x24s8 ? 8 : 4; map->stride = map->w * packed_bpp; map->buffer = map->ptr = malloc(map->stride * map->h); @@ -911,7 +912,12 @@ intel_miptree_map_depthstencil(struct intel_context *intel, uint8_t s = s_map[s_offset]; uint32_t z = z_map[z_offset]; - packed_map[y * map->w + x] = (s << 24) | (z & 0x00ffffff); + if (map_z32f_x24s8) { + packed_map[(y * map->w + x) * 2 + 0] = z; + packed_map[(y * map->w + x) * 2 + 1] = s; + } else { + packed_map[y * map->w + x] = (s << 24) | (z & 0x00ffffff); + } } } @@ -940,6 +946,7 @@ intel_miptree_unmap_depthstencil(struct intel_context *intel, { struct intel_mipmap_tree *z_mt = mt; struct intel_mipmap_tree *s_mt = mt->stencil_mt; + bool map_z32f_x24s8 = mt->format == MESA_FORMAT_Z32_FLOAT; if (map->mode & GL_MAP_WRITE_BIT) { uint32_t *packed_map = map->ptr; @@ -960,10 +967,15 @@ intel_miptree_unmap_depthstencil(struct intel_context *intel, y + s_image_y + map->y); ptrdiff_t z_offset = ((y + z_image_y) * z_mt->region->pitch + (x + z_image_x)); - uint32_t packed = packed_map[y * map->w + x]; - s_map[s_offset] = packed >> 24; - z_map[z_offset] = packed; + if (map_z32f_x24s8) { + z_map[z_offset] = packed_map[(y * map->w + x) * 2 + 0]; + s_map[s_offset] = packed_map[(y * map->w + x) * 2 + 1]; + } else { + uint32_t packed = packed_map[y * map->w + x]; + s_map[s_offset] = packed >> 24; + z_map[z_offset] = packed; + } } } |