aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2015-08-28 00:42:00 -0600
committerBrian Paul <[email protected]>2015-09-24 07:52:42 -0600
commit200aee424790f3167fcb175f4798af27783fe364 (patch)
tree91b4724c5503637359b8068f94d35cdbdabe00df /src/mesa/drivers/dri/i965
parentc8cb5ed93c8e7343390f188bbf1a8459380a5739 (diff)
mesa: rework Driver.CopyImageSubData() and related code
Previously, core Mesa's _mesa_CopyImageSubData() created temporary textures to wrap renderbuffer sources/destinations. This caused a bit of a mess in the Mesa/gallium state tracker because we had to basically undo that wrapping. Instead, change ctx->Driver.CopyImageSubData() to take both gl_renderbuffer and gl_texture_image src/dst pointers (one being null, the other non-null) so the driver can handle renderbuffer vs. texture as needed. For the i965 driver, we basically moved the code that wrapped textures around renderbuffers from copyimage.c down into the met and driver code. The old code in copyimage.c also made some questionable calls to _mesa_BindTexture(), etc. which weren't undone at the end. v2 (Jason Ekstrand): Rework the intel bits v3 (Brian Paul): Update the temporary st_CopyImageSubData() function. Reviewed-by: Topi Pohjolainen <[email protected]> Tested-by: Kai Wasserbäch <[email protected]> Tested-by: Nick Sarnie <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965')
-rw-r--r--src/mesa/drivers/dri/i965/intel_copy_image.c80
1 files changed, 57 insertions, 23 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_copy_image.c b/src/mesa/drivers/dri/i965/intel_copy_image.c
index ac2738f59a0..d57651cef5f 100644
--- a/src/mesa/drivers/dri/i965/intel_copy_image.c
+++ b/src/mesa/drivers/dri/i965/intel_copy_image.c
@@ -25,10 +25,12 @@
* Jason Ekstrand <[email protected]>
*/
+#include "intel_fbo.h"
#include "intel_tex.h"
#include "intel_blit.h"
#include "intel_mipmap_tree.h"
#include "main/formats.h"
+#include "main/teximage.h"
#include "drivers/common/meta.h"
static bool
@@ -196,54 +198,86 @@ copy_image_with_memcpy(struct brw_context *brw,
}
}
+
static void
intel_copy_image_sub_data(struct gl_context *ctx,
struct gl_texture_image *src_image,
+ struct gl_renderbuffer *src_renderbuffer,
int src_x, int src_y, int src_z,
struct gl_texture_image *dst_image,
+ struct gl_renderbuffer *dst_renderbuffer,
int dst_x, int dst_y, int dst_z,
int src_width, int src_height)
{
struct brw_context *brw = brw_context(ctx);
- struct intel_texture_image *intel_src_image = intel_texture_image(src_image);
- struct intel_texture_image *intel_dst_image = intel_texture_image(dst_image);
+ struct intel_mipmap_tree *src_mt, *dst_mt;
+ unsigned src_level, dst_level;
if (_mesa_meta_CopyImageSubData_uncompressed(ctx,
- src_image, src_x, src_y, src_z,
- dst_image, dst_x, dst_y, dst_z,
+ src_image, src_renderbuffer,
+ src_x, src_y, src_z,
+ dst_image, dst_renderbuffer,
+ dst_x, dst_y, dst_z,
src_width, src_height)) {
return;
}
- if (intel_src_image->mt->num_samples > 0 ||
- intel_dst_image->mt->num_samples > 0) {
+ if (src_image) {
+ src_mt = intel_texture_image(src_image)->mt;
+ } else {
+ assert(src_renderbuffer);
+ src_mt = intel_renderbuffer(src_renderbuffer)->mt;
+ src_image = src_renderbuffer->TexImage;
+ }
+
+ if (dst_image) {
+ dst_mt = intel_texture_image(dst_image)->mt;
+ } else {
+ assert(dst_renderbuffer);
+ dst_mt = intel_renderbuffer(dst_renderbuffer)->mt;
+ src_image = src_renderbuffer->TexImage;
+ }
+
+ if (src_mt->num_samples > 0 || dst_mt->num_samples > 0) {
_mesa_problem(ctx, "Failed to copy multisampled texture with meta path\n");
return;
}
- /* Cube maps actually have different images per face */
- if (src_image->TexObject->Target == GL_TEXTURE_CUBE_MAP)
- src_z = src_image->Face;
- if (dst_image->TexObject->Target == GL_TEXTURE_CUBE_MAP)
- dst_z = dst_image->Face;
+ if (src_image) {
+ src_level = src_image->Level + src_image->TexObject->MinLevel;
+
+ /* Cube maps actually have different images per face */
+ if (src_image->TexObject->Target == GL_TEXTURE_CUBE_MAP)
+ src_z = src_image->Face;
+ } else {
+ src_level = 0;
+ }
+
+ if (dst_image) {
+ dst_level = dst_image->Level + dst_image->TexObject->MinLevel;
+
+ /* Cube maps actually have different images per face */
+ if (dst_image->TexObject->Target == GL_TEXTURE_CUBE_MAP)
+ dst_z = dst_image->Face;
+ } else {
+ dst_level = 0;
+ }
/* 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, intel_src_image->mt);
- intel_miptree_all_slices_resolve_depth(brw, intel_src_image->mt);
- intel_miptree_resolve_color(brw, intel_src_image->mt);
+ 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);
- intel_miptree_all_slices_resolve_hiz(brw, intel_dst_image->mt);
- intel_miptree_all_slices_resolve_depth(brw, intel_dst_image->mt);
- intel_miptree_resolve_color(brw, intel_dst_image->mt);
+ 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);
- unsigned src_level = src_image->Level + src_image->TexObject->MinLevel;
- unsigned dst_level = dst_image->Level + dst_image->TexObject->MinLevel;
- if (copy_image_with_blitter(brw, intel_src_image->mt, src_level,
+ if (copy_image_with_blitter(brw, src_mt, src_level,
src_x, src_y, src_z,
- intel_dst_image->mt, dst_level,
+ dst_mt, dst_level,
dst_x, dst_y, dst_z,
src_width, src_height))
return;
@@ -251,9 +285,9 @@ intel_copy_image_sub_data(struct gl_context *ctx,
/* This is a worst-case scenario software fallback that maps the two
* textures and does a memcpy between them.
*/
- copy_image_with_memcpy(brw, intel_src_image->mt, src_level,
+ copy_image_with_memcpy(brw, src_mt, src_level,
src_x, src_y, src_z,
- intel_dst_image->mt, dst_level,
+ dst_mt, dst_level,
dst_x, dst_y, dst_z,
src_width, src_height);
}