Add two new functions: intel_miptree_{map,unmap}_multisample, to which intel_miptree_{map,unmap} dispatch. Only mapping flat, renderbuffer-like miptrees are supported.
CC: Eric Anholt <e...@anholt.net> CC: Paul Berry <stereotype...@gmail.com> Signed-off-by: Chad Versace <chad.vers...@linux.intel.com> --- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 108 +++++++++++++++++++++++-- src/mesa/drivers/dri/intel/intel_mipmap_tree.h | 6 ++ 2 files changed, 108 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 95dc8aa..22af2fa 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -1487,6 +1487,92 @@ intel_miptree_unmap_singlesample(struct intel_context *intel, intel_miptree_release_map(mt, level, slice); } +static void +intel_miptree_map_multisample(struct intel_context *intel, + struct intel_mipmap_tree *mt, + unsigned int level, + unsigned int slice, + unsigned int x, + unsigned int y, + unsigned int w, + unsigned int h, + GLbitfield mode, + void **out_ptr, + int *out_stride) +{ + struct intel_miptree_map *map; + + assert(mt->num_samples > 0); + + /* Only flat, renderbuffer-like miptrees are supported. */ + if (mt->target != GL_TEXTURE_2D || + mt->first_level != 0 || + mt->last_level != 0) { + _mesa_problem(&intel->ctx, "attempt to map a multisample miptree for " + "which (target, first_level, last_level != " + "(GL_TEXTURE_2D, 0, 0)"); + goto fail; + } + + map = intel_miptree_attach_map(mt, level, slice, x, y, w, h, mode); + if (!map) + goto fail; + + if (!mt->singlesample_mt) { + map->singlesample_mt_is_tmp = true; + mt->singlesample_mt = + intel_miptree_create_for_renderbuffer(intel, + mt->format, + mt->singlesample_width0, + mt->singlesample_height0, + 0 /*num_samples*/); + if (!mt->singlesample_mt) + goto fail; + } + + if (!(mode & GL_MAP_INVALIDATE_RANGE_BIT)) { + mt->need_downsample = true; + intel_miptree_downsample(intel, mt); + } + + intel_miptree_map_singlesample(intel, mt->singlesample_mt, + level, slice, + x, y, w, h, + mode, + out_ptr, out_stride); + return; + +fail: + intel_miptree_release_map(mt, level, slice); + *out_ptr = NULL; + *out_stride = 0; +} + +static void +intel_miptree_unmap_multisample(struct intel_context *intel, + struct intel_mipmap_tree *mt, + unsigned int level, + unsigned int slice) +{ + struct intel_miptree_map *map = mt->level[level].slice[slice].map; + + assert(mt->num_samples > 0); + + if (!map) + return; + + intel_miptree_unmap_singlesample(intel, mt->singlesample_mt, level, slice); + + mt->need_downsample = false; + if (map->mode & GL_MAP_WRITE_BIT) + intel_miptree_upsample(intel, mt); + + if (map->singlesample_mt_is_tmp) + intel_miptree_release(&mt->singlesample_mt); + + intel_miptree_release_map(mt, level, slice); +} + void intel_miptree_map(struct intel_context *intel, struct intel_mipmap_tree *mt, @@ -1500,11 +1586,18 @@ intel_miptree_map(struct intel_context *intel, void **out_ptr, int *out_stride) { - intel_miptree_map_singlesample(intel, mt, - level, slice, - x, y, w, h, - mode, - out_ptr, out_stride); + if (mt->num_samples == 0) + intel_miptree_map_singlesample(intel, mt, + level, slice, + x, y, w, h, + mode, + out_ptr, out_stride); + else + intel_miptree_map_multisample(intel, mt, + level, slice, + x, y, w, h, + mode, + out_ptr, out_stride); } void @@ -1513,5 +1606,8 @@ intel_miptree_unmap(struct intel_context *intel, unsigned int level, unsigned int slice) { - intel_miptree_unmap_singlesample(intel, mt, level, slice); + if (mt->num_samples == 0) + intel_miptree_unmap_singlesample(intel, mt, level, slice); + else + intel_miptree_unmap_multisample(intel, mt, level, slice); } diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h index 4ee68be..7a0b5c6 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h @@ -79,6 +79,12 @@ struct intel_miptree_map { void *ptr; /** Stride of the mapping. */ int stride; + + /** + * intel_mipmap_tree::singlesample_mt is temporary storage that persists + * only for the duration of the map. + */ + bool singlesample_mt_is_tmp; }; /** -- 1.7.11.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev