Since we can distinguish when mapping between READ and WRITE, we can pass along the map mode to avoid stalls and flushes where possible.
Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk> Reviewed-by: Kenneth Graunke <kenn...@whitecape.org> --- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 28 ++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index 6f3bcaa..1bd9fa2 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -1345,7 +1345,9 @@ intel_miptree_copy_teximage(struct brw_context *brw, } static void * -intel_miptree_map_raw(struct brw_context *brw, struct intel_mipmap_tree *mt) +intel_miptree_map_raw(struct brw_context *brw, + struct intel_mipmap_tree *mt, + GLbitfield mode) { /* CPU accesses to color buffers don't understand fast color clears, so * resolve any pending fast color clears before we map. @@ -1360,7 +1362,7 @@ intel_miptree_map_raw(struct brw_context *brw, struct intel_mipmap_tree *mt) if (mt->tiling != I915_TILING_NONE) brw_bo_map_gtt(brw, bo, "miptree"); else - brw_bo_map(brw, bo, true, "miptree"); + brw_bo_map(brw, bo, mode & GL_MAP_WRITE_BIT, "miptree"); return bo->virtual; } @@ -1432,7 +1434,7 @@ intel_miptree_alloc_mcs(struct brw_context *brw, * * Note: the clear value for MCS buffers is all 1's, so we memset to 0xff. */ - void *data = intel_miptree_map_raw(brw, mt->mcs_mt); + void *data = intel_miptree_map_raw(brw, mt->mcs_mt, GL_MAP_WRITE_BIT); memset(data, 0xff, mt->mcs_mt->total_height * mt->mcs_mt->pitch); intel_miptree_unmap_raw(brw, mt->mcs_mt); mt->fast_clear_state = INTEL_FAST_CLEAR_STATE_CLEAR; @@ -2104,7 +2106,7 @@ intel_miptree_map_gtt(struct brw_context *brw, assert(y % bh == 0); y /= bh; - base = intel_miptree_map_raw(brw, mt) + mt->offset; + base = intel_miptree_map_raw(brw, mt, map->mode) + mt->offset; if (base == NULL) map->ptr = NULL; @@ -2171,7 +2173,7 @@ intel_miptree_map_blit(struct brw_context *brw, } } - map->ptr = intel_miptree_map_raw(brw, map->mt); + map->ptr = intel_miptree_map_raw(brw, map->mt, map->mode); DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __func__, map->x, map->y, map->w, map->h, @@ -2235,7 +2237,7 @@ intel_miptree_map_movntdqa(struct brw_context *brw, image_x += map->x; image_y += map->y; - void *src = intel_miptree_map_raw(brw, mt); + void *src = intel_miptree_map_raw(brw, mt, map->mode); if (!src) return; src += image_y * mt->pitch; @@ -2301,7 +2303,7 @@ intel_miptree_map_s8(struct brw_context *brw, */ if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) { uint8_t *untiled_s8_map = map->ptr; - uint8_t *tiled_s8_map = intel_miptree_map_raw(brw, mt); + uint8_t *tiled_s8_map = intel_miptree_map_raw(brw, mt, GL_MAP_READ_BIT); unsigned int image_x, image_y; intel_miptree_get_image_offset(mt, level, slice, &image_x, &image_y); @@ -2338,7 +2340,7 @@ intel_miptree_unmap_s8(struct brw_context *brw, if (map->mode & GL_MAP_WRITE_BIT) { unsigned int image_x, image_y; uint8_t *untiled_s8_map = map->ptr; - uint8_t *tiled_s8_map = intel_miptree_map_raw(brw, mt); + uint8_t *tiled_s8_map = intel_miptree_map_raw(brw, mt, GL_MAP_WRITE_BIT); intel_miptree_get_image_offset(mt, level, slice, &image_x, &image_y); @@ -2393,7 +2395,7 @@ intel_miptree_unmap_etc(struct brw_context *brw, image_x += map->x; image_y += map->y; - uint8_t *dst = intel_miptree_map_raw(brw, mt) + uint8_t *dst = intel_miptree_map_raw(brw, mt, GL_MAP_WRITE_BIT) + image_y * mt->pitch + image_x * mt->cpp; @@ -2444,8 +2446,8 @@ intel_miptree_map_depthstencil(struct brw_context *brw, */ if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) { uint32_t *packed_map = map->ptr; - uint8_t *s_map = intel_miptree_map_raw(brw, s_mt); - uint32_t *z_map = intel_miptree_map_raw(brw, z_mt); + uint8_t *s_map = intel_miptree_map_raw(brw, s_mt, GL_MAP_READ_BIT); + uint32_t *z_map = intel_miptree_map_raw(brw, z_mt, GL_MAP_READ_BIT); unsigned int s_image_x, s_image_y; unsigned int z_image_x, z_image_y; @@ -2505,8 +2507,8 @@ intel_miptree_unmap_depthstencil(struct brw_context *brw, if (map->mode & GL_MAP_WRITE_BIT) { uint32_t *packed_map = map->ptr; - uint8_t *s_map = intel_miptree_map_raw(brw, s_mt); - uint32_t *z_map = intel_miptree_map_raw(brw, z_mt); + uint8_t *s_map = intel_miptree_map_raw(brw, s_mt, GL_MAP_WRITE_BIT); + uint32_t *z_map = intel_miptree_map_raw(brw, z_mt, GL_MAP_WRITE_BIT); unsigned int s_image_x, s_image_y; unsigned int z_image_x, z_image_y; -- 2.5.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev