summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/intel_copy_image.c
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2016-05-19 20:46:22 -0700
committerKenneth Graunke <kenneth@whitecape.org>2016-05-25 14:17:29 -0700
commit45d6818021409f61ccbbd92faa3d2af35499509f (patch)
tree757fb5dba905da1cb544bdfab114b8b13afff073 /src/mesa/drivers/dri/i965/intel_copy_image.c
parent2dc98d9a15ba2ca48e6e50f2232f4a9fcd4c312f (diff)
downloadexternal_mesa3d-45d6818021409f61ccbbd92faa3d2af35499509f.zip
external_mesa3d-45d6818021409f61ccbbd92faa3d2af35499509f.tar.gz
external_mesa3d-45d6818021409f61ccbbd92faa3d2af35499509f.tar.bz2
i965: Make a helper function for CopyImage of a miptree.
Currently, it only contains the BLT/CPU fallbacks, so the name is a bit too generic. But eventually this will use BLORP as well, at which point the name will make more sense. The next patch will introduce a second call. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com> Reviewed-by: Chris Forbes <chrisforbes@google.com>
Diffstat (limited to 'src/mesa/drivers/dri/i965/intel_copy_image.c')
-rw-r--r--src/mesa/drivers/dri/i965/intel_copy_image.c95
1 files changed, 54 insertions, 41 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_copy_image.c b/src/mesa/drivers/dri/i965/intel_copy_image.c
index a94f171..d114534 100644
--- a/src/mesa/drivers/dri/i965/intel_copy_image.c
+++ b/src/mesa/drivers/dri/i965/intel_copy_image.c
@@ -198,6 +198,57 @@ copy_image_with_memcpy(struct brw_context *brw,
}
}
+static void
+copy_miptrees(struct brw_context *brw,
+ struct intel_mipmap_tree *src_mt,
+ int src_x, int src_y, int src_z, unsigned src_level,
+ struct intel_mipmap_tree *dst_mt,
+ int dst_x, int dst_y, int dst_z, unsigned dst_level,
+ int src_width, int src_height)
+{
+ unsigned bw, bh;
+
+ /* We are now going to try and copy the texture using the blitter. If
+ * that fails, we will fall back mapping the texture and using memcpy.
+ * In either case, we need to do a full resolve.
+ */
+ intel_miptree_all_slices_resolve_hiz(brw, src_mt);
+ intel_miptree_all_slices_resolve_depth(brw, src_mt);
+ intel_miptree_resolve_color(brw, src_mt, 0);
+
+ intel_miptree_all_slices_resolve_hiz(brw, dst_mt);
+ intel_miptree_all_slices_resolve_depth(brw, dst_mt);
+ intel_miptree_resolve_color(brw, dst_mt, 0);
+
+ _mesa_get_format_block_size(src_mt->format, &bw, &bh);
+
+ /* It's legal to have a WxH that's smaller than a compressed block. This
+ * happens for example when you are using a higher level LOD. For this case,
+ * we still want to copy the entire block, or else the decompression will be
+ * incorrect.
+ */
+ if (src_width < bw)
+ src_width = ALIGN_NPOT(src_width, bw);
+
+ if (src_height < bh)
+ src_height = ALIGN_NPOT(src_height, bh);
+
+ if (copy_image_with_blitter(brw, src_mt, src_level,
+ src_x, src_y, src_z,
+ dst_mt, dst_level,
+ dst_x, dst_y, dst_z,
+ src_width, src_height))
+ return;
+
+ /* This is a worst-case scenario software fallback that maps the two
+ * textures and does a memcpy between them.
+ */
+ copy_image_with_memcpy(brw, src_mt, src_level,
+ src_x, src_y, src_z,
+ dst_mt, dst_level,
+ dst_x, dst_y, dst_z,
+ src_width, src_height);
+}
static void
intel_copy_image_sub_data(struct gl_context *ctx,
@@ -212,7 +263,6 @@ intel_copy_image_sub_data(struct gl_context *ctx,
struct brw_context *brw = brw_context(ctx);
struct intel_mipmap_tree *src_mt, *dst_mt;
unsigned src_level, dst_level;
- GLuint bw, bh;
if (_mesa_meta_CopyImageSubData_uncompressed(ctx,
src_image, src_renderbuffer,
@@ -261,46 +311,9 @@ intel_copy_image_sub_data(struct gl_context *ctx,
return;
}
- /* We are now going to try and copy the texture using the blitter. If
- * that fails, we will fall back mapping the texture and using memcpy.
- * In either case, we need to do a full resolve.
- */
- intel_miptree_all_slices_resolve_hiz(brw, src_mt);
- intel_miptree_all_slices_resolve_depth(brw, src_mt);
- intel_miptree_resolve_color(brw, src_mt, 0);
-
- intel_miptree_all_slices_resolve_hiz(brw, dst_mt);
- intel_miptree_all_slices_resolve_depth(brw, dst_mt);
- intel_miptree_resolve_color(brw, dst_mt, 0);
-
- _mesa_get_format_block_size(src_mt->format, &bw, &bh);
-
- /* It's legal to have a WxH that's smaller than a compressed block. This
- * happens for example when you are using a higher level LOD. For this case,
- * we still want to copy the entire block, or else the decompression will be
- * incorrect.
- */
- if (src_width < bw)
- src_width = ALIGN_NPOT(src_width, bw);
-
- if (src_height < bh)
- src_height = ALIGN_NPOT(src_height, bh);
-
- if (copy_image_with_blitter(brw, src_mt, src_level,
- src_x, src_y, src_z,
- dst_mt, dst_level,
- dst_x, dst_y, dst_z,
- src_width, src_height))
- return;
-
- /* This is a worst-case scenario software fallback that maps the two
- * textures and does a memcpy between them.
- */
- copy_image_with_memcpy(brw, src_mt, src_level,
- src_x, src_y, src_z,
- dst_mt, dst_level,
- dst_x, dst_y, dst_z,
- src_width, src_height);
+ copy_miptrees(brw, src_mt, src_x, src_y, src_z, src_level,
+ dst_mt, dst_x, dst_y, dst_z, dst_level,
+ src_width, src_height);
}
void