diff options
author | Eric Anholt <[email protected]> | 2013-05-23 14:16:15 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2013-05-28 13:06:56 -0700 |
commit | 4a13beef886a1d4ce190fe29d3ef94db0c2e60b8 (patch) | |
tree | b2a3353c4aacf109f58cc914fe31e922f768b6f0 /src/mesa | |
parent | da2880bea05bfc87109477ab026a7f5401fc8f0c (diff) |
intel: Make a temporary miptree when doing blit uploads for glTexSubImage().
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.
v2: Add error checking in new code.
Reviewed-and-tested-by: Ian Romanick <[email protected]> (v1)
Reviewed-by: Kenneth Graunke <[email protected]> (v1)
Acked-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex_subimage.c | 72 |
1 files changed, 28 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 42cc7392927..834288ba2b1 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,60 +87,50 @@ 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 */); + if (!temp_mt) + goto err; - 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 (!dst) + goto err; 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"); } + 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; + +err: + _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage"); + intel_miptree_release(&temp_mt); + _mesa_unmap_teximage_pbo(ctx, packing); + return false; } /** |