[Mesa-dev] [PATCH 10/17] intel: Make a temporary miptree when doing blit uploads for glTexSubImage().
Ian Romanick
idr at freedesktop.org
Fri May 24 15:35:13 PDT 2013
On 05/24/2013 01:56 PM, Eric Anholt wrote:
> While this is a bit more CPU work, it also is less code to handle this
> path, and fixes problems with 32k-pitch textures and missing resolves.
> ---
> src/mesa/drivers/dri/intel/intel_tex_subimage.c | 62 +++++++------------------
> 1 file changed, 18 insertions(+), 44 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
> index 42cc739..e436dc1 100644
> --- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c
> +++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
> @@ -53,12 +53,6 @@ intel_blit_texsubimage(struct gl_context * ctx,
> {
> struct intel_context *intel = intel_context(ctx);
> struct intel_texture_image *intelImage = intel_texture_image(texImage);
> - GLuint dstRowStride = 0;
> - drm_intel_bo *temp_bo = NULL;
> - unsigned int blit_x = 0, blit_y = 0;
> - unsigned long pitch;
> - uint32_t tiling_mode = I915_TILING_NONE;
> - GLubyte *dstMap;
>
> /* Try to do a blit upload of the subimage if the texture is
> * currently busy.
> @@ -93,57 +87,37 @@ intel_blit_texsubimage(struct gl_context * ctx,
> if (!pixels)
> return false;
>
> - temp_bo = drm_intel_bo_alloc_tiled(intel->bufmgr,
> - "subimage blit bo",
> - width, height,
> - intelImage->mt->cpp,
> - &tiling_mode,
> - &pitch,
> - 0);
> - if (temp_bo == NULL) {
> - _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
> - return false;
> - }
> + struct intel_mipmap_tree *temp_mt =
> + intel_miptree_create(intel, GL_TEXTURE_2D, texImage->TexFormat,
> + 0, 0,
> + width, height, 1,
> + false, 0,
> + (1 << I915_TILING_NONE) /* force_tiling_mask */);
The old code did error checking. Should we continue to error check
temp_mt and dst (below)?
>
> - if (drm_intel_gem_bo_map_gtt(temp_bo)) {
> - _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
> - return false;
> - }
> -
> - dstMap = temp_bo->virtual;
> - dstRowStride = pitch;
> -
> - intel_miptree_get_image_offset(intelImage->mt, texImage->Level,
> - intelImage->base.Base.Face,
> - &blit_x, &blit_y);
> - blit_x += xoffset;
> - blit_y += yoffset;
> + GLubyte *dst = intel_miptree_map_raw(intel, temp_mt);
>
> if (!_mesa_texstore(ctx, 2, texImage->_BaseFormat,
> texImage->TexFormat,
> - dstRowStride,
> - &dstMap,
> + temp_mt->region->pitch,
> + &dst,
> width, height, 1,
> format, type, pixels, packing)) {
> _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
Since this code doesn't bail (and never has), we blit garbage into the
texture, right?
> }
>
> + intel_miptree_unmap_raw(intel, temp_mt);
> +
> bool ret;
>
> - drm_intel_gem_bo_unmap_gtt(temp_bo);
> -
> - ret = intelEmitCopyBlit(intel,
> - intelImage->mt->cpp,
> - dstRowStride,
> - temp_bo, 0, false,
> - intelImage->mt->region->pitch,
> - intelImage->mt->region->bo, 0,
> - intelImage->mt->region->tiling,
> - 0, 0, blit_x, blit_y, width, height,
> - GL_COPY);
> + ret = intel_miptree_blit(intel,
> + temp_mt, 0, 0,
> + 0, 0, false,
> + intelImage->mt, texImage->Level, texImage->Face,
> + xoffset, yoffset, false,
> + width, height, GL_COPY);
> assert(ret);
>
> - drm_intel_bo_unreference(temp_bo);
> + intel_miptree_release(&temp_mt);
> _mesa_unmap_teximage_pbo(ctx, packing);
>
> return ret;
>
More information about the mesa-dev
mailing list