In intel_map_renderbuffer_s8(), detile and copy the stencil buffer into the temporary buffer only if the renderbuffer is mapped in read mode. If the caller never going to read the bits but just clobber them, then it's wasted effort to detile the stencil buffer.
CC: Eric Anholt <e...@anholt.net> Signed-off-by: Chad Versace <chad.vers...@linux.intel.com> --- src/mesa/drivers/dri/intel/intel_fbo.c | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index dbd5163..6ca4bd5 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -273,16 +273,21 @@ intel_map_renderbuffer_s8(struct gl_context *ctx, irb->map_buffer = malloc(w * h); untiled_s8_map = irb->map_buffer; - tiled_s8_map = intel_region_map(intel, irb->region, mode); - - for (uint32_t pix_y = 0; pix_y < h; pix_y++) { - for (uint32_t pix_x = 0; pix_x < w; pix_x++) { - uint32_t flipped_y = y_flip * (int32_t)(y + pix_y) + y_bias; - ptrdiff_t offset = intel_offset_S8(irb->region->pitch, - x + pix_x, - flipped_y); - untiled_s8_map[pix_y * w + pix_x] = tiled_s8_map[offset]; + + if (mode & GL_MAP_READ_BIT) { + tiled_s8_map = intel_region_map(intel, irb->region, GL_MAP_READ_BIT); + + for (uint32_t pix_y = 0; pix_y < h; pix_y++) { + for (uint32_t pix_x = 0; pix_x < w; pix_x++) { + uint32_t flipped_y = y_flip * (int32_t)(y + pix_y) + y_bias; + ptrdiff_t offset = intel_offset_S8(irb->region->pitch, + x + pix_x, + flipped_y); + untiled_s8_map[pix_y * w + pix_x] = tiled_s8_map[offset]; + } } + + intel_region_unmap(intel, irb->region); } *out_map = untiled_s8_map; @@ -439,7 +444,8 @@ intel_unmap_renderbuffer_s8(struct gl_context *ctx, * the real buffer. */ uint8_t *untiled_s8_map = irb->map_buffer; - uint8_t *tiled_s8_map = irb->region->bo->virtual; + uint8_t *tiled_s8_map = intel_region_map(intel, irb->region, + GL_MAP_WRITE_BIT); /* Flip the Y axis for the default framebuffer. */ int region_h = irb->region->height; @@ -456,9 +462,10 @@ intel_unmap_renderbuffer_s8(struct gl_context *ctx, untiled_s8_map[pix_y * irb->map_w + pix_x]; } } + + intel_region_unmap(intel, irb->region); } - intel_region_unmap(intel, irb->region); free(irb->map_buffer); irb->map_buffer = NULL; } -- 1.7.7.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev