aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2013-05-24 11:42:10 -0700
committerEric Anholt <[email protected]>2013-05-28 13:06:57 -0700
commit5f29dca0700c7bc87c891b1d7653ae3d798407d4 (patch)
tree1fa3c1902583f782e87debe6b9b48cd79811c030 /src/mesa/drivers/dri
parent3c3e83014b185791a99a0a2b793ecda7576aa4d1 (diff)
intel: Rebuild PBO blit glTexImage() on top of miptrees.
This will ensure that we have resolves if we ever extend this to glTexSubImage(), and fixes missing image start offset handling. The texture buffer alloc ended up getting moved up, because we want to look at the format of the image's actual mt to see if we'll end up blitting the right thing, in the case of packed depth/stencil uploads. This is the last caller of intelEmitCopyBlit() on a miptree-wrapped BO. Reviewed-and-tested-by: Ian Romanick <[email protected]> Acked-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c62
1 files changed, 32 insertions, 30 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index d3e905b3073..fba02c2b7d1 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -6,6 +6,7 @@
#include "main/bufferobj.h"
#include "main/context.h"
#include "main/formats.h"
+#include "main/image.h"
#include "main/pbo.h"
#include "main/renderbuffer.h"
#include "main/texcompress.h"
@@ -117,9 +118,8 @@ try_pbo_upload(struct gl_context *ctx,
struct intel_texture_image *intelImage = intel_texture_image(image);
struct intel_context *intel = intel_context(ctx);
struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
- GLuint src_offset, src_stride;
- GLuint dst_x, dst_y;
- drm_intel_bo *dst_buffer, *src_buffer;
+ GLuint src_offset;
+ drm_intel_bo *src_buffer;
if (!_mesa_is_bufferobj(unpack->BufferObj))
return false;
@@ -132,14 +132,6 @@ try_pbo_upload(struct gl_context *ctx,
return false;
}
- if (!_mesa_format_matches_format_and_type(image->TexFormat,
- format, type, false)) {
- DBG("%s: format mismatch (upload to %s with format 0x%x, type 0x%x)\n",
- __FUNCTION__, _mesa_get_format_name(image->TexFormat),
- format, type);
- return false;
- }
-
ctx->Driver.AllocTextureImageBuffer(ctx, image);
if (!intelImage->mt) {
@@ -147,39 +139,49 @@ try_pbo_upload(struct gl_context *ctx,
return false;
}
+ if (!_mesa_format_matches_format_and_type(intelImage->mt->format,
+ format, type, false)) {
+ DBG("%s: format mismatch (upload to %s with format 0x%x, type 0x%x)\n",
+ __FUNCTION__, _mesa_get_format_name(intelImage->mt->format),
+ format, type);
+ return false;
+ }
+
if (image->TexObject->Target == GL_TEXTURE_1D_ARRAY ||
image->TexObject->Target == GL_TEXTURE_2D_ARRAY) {
DBG("%s: no support for array textures\n", __FUNCTION__);
return false;
}
- dst_buffer = intelImage->mt->region->bo;
src_buffer = intel_bufferobj_source(intel, pbo, 64, &src_offset);
/* note: potential 64-bit ptr to 32-bit int cast */
src_offset += (GLuint) (unsigned long) pixels;
- if (unpack->RowLength > 0)
- src_stride = unpack->RowLength;
- else
- src_stride = image->Width;
- src_stride *= intelImage->mt->region->cpp;
-
- intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Base.Level,
- intelImage->base.Base.Face,
- &dst_x, &dst_y);
-
- if (!intelEmitCopyBlit(intel,
- intelImage->mt->cpp,
- src_stride, src_buffer,
- src_offset, false,
- intelImage->mt->region->pitch, dst_buffer, 0,
- intelImage->mt->region->tiling,
- 0, 0, dst_x, dst_y, image->Width, image->Height,
- GL_COPY)) {
+ int src_stride =
+ _mesa_image_row_stride(unpack, image->Width, format, type);
+
+ struct intel_mipmap_tree *pbo_mt =
+ intel_miptree_create_for_bo(intel,
+ src_buffer,
+ intelImage->mt->format,
+ src_offset,
+ image->Width, image->Height,
+ src_stride, I915_TILING_NONE);
+ if (!pbo_mt)
+ return false;
+
+ if (!intel_miptree_blit(intel,
+ pbo_mt, 0, 0,
+ 0, 0, false,
+ intelImage->mt, image->Level, image->Face,
+ 0, 0, false,
+ image->Width, image->Height, GL_COPY)) {
DBG("%s: blit failed\n", __FUNCTION__);
return false;
}
+ intel_miptree_release(&pbo_mt);
+
DBG("%s: success\n", __FUNCTION__);
return true;
}