summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2013-04-30 11:15:05 -0700
committerEric Anholt <[email protected]>2013-05-06 14:33:33 -0700
commit5b9609f59ac4e9079a6dea1212178070a45ab8e9 (patch)
tree698849a63babb23cc25254e62055ddc2eafa3204
parent40956c55196aa9494e27593e17910be35b26c3b8 (diff)
i965: Use brw_blorp_blit_miptrees() for CopyTexSubImage().
Now that depth resolves are handled there, we don't need to make the temporary renderbuffer. Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_blorp_blit.cpp84
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c30
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.h4
3 files changed, 41 insertions, 77 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 32da1415fd2..c3ef054b2b4 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -169,19 +169,9 @@ do_blorp_blit(struct intel_context *intel, GLbitfield buffer_bit,
intel_renderbuffer_set_needs_downsample(dst_irb);
}
-
static bool
-formats_match(GLbitfield buffer_bit, struct intel_renderbuffer *src_irb,
- struct intel_renderbuffer *dst_irb)
+color_formats_match(gl_format src_format, gl_format dst_format)
{
- /* Note: don't just check gl_renderbuffer::Format, because in some cases
- * multiple gl_formats resolve to the same native type in the miptree (for
- * example MESA_FORMAT_X8_Z24 and MESA_FORMAT_S8_Z24), and we can blit
- * between those formats.
- */
- gl_format src_format = find_miptree(buffer_bit, src_irb)->format;
- gl_format dst_format = find_miptree(buffer_bit, dst_irb)->format;
-
gl_format linear_src_format = _mesa_get_srgb_format_linear(src_format);
gl_format linear_dst_format = _mesa_get_srgb_format_linear(dst_format);
@@ -197,6 +187,21 @@ formats_match(GLbitfield buffer_bit, struct intel_renderbuffer *src_irb,
}
static bool
+formats_match(GLbitfield buffer_bit, struct intel_renderbuffer *src_irb,
+ struct intel_renderbuffer *dst_irb)
+{
+ /* Note: don't just check gl_renderbuffer::Format, because in some cases
+ * multiple gl_formats resolve to the same native type in the miptree (for
+ * example MESA_FORMAT_X8_Z24 and MESA_FORMAT_S8_Z24), and we can blit
+ * between those formats.
+ */
+ gl_format src_format = find_miptree(buffer_bit, src_irb)->format;
+ gl_format dst_format = find_miptree(buffer_bit, dst_irb)->format;
+
+ return color_formats_match(src_format, dst_format);
+}
+
+static bool
try_blorp_blit(struct intel_context *intel,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
@@ -313,29 +318,21 @@ brw_blorp_copytexsubimage(struct intel_context *intel,
{
struct gl_context *ctx = &intel->ctx;
struct intel_renderbuffer *src_irb = intel_renderbuffer(src_rb);
- struct intel_renderbuffer *dst_irb;
+ struct intel_texture_image *intel_image = intel_texture_image(dst_image);
+
+ /* Sync up the state of window system buffers. We need to do this before
+ * we go looking at the src renderbuffer's miptree.
+ */
+ intel_prepare_render(intel);
+
+ struct intel_mipmap_tree *src_mt = src_irb->mt;
+ struct intel_mipmap_tree *dst_mt = intel_image->mt;
/* BLORP is not supported before Gen6. */
if (intel->gen < 6)
return false;
- /* Create a fake/wrapper renderbuffer to allow us to use do_blorp_blit(). */
- dst_irb = intel_create_fake_renderbuffer_wrapper(intel, dst_image);
- if (!dst_irb)
- return false;
-
- struct gl_renderbuffer *dst_rb = &dst_irb->Base.Base;
-
- /* Unlike BlitFramebuffer, CopyTexSubImage doesn't have a buffer bit.
- * It's only used by find_miptee() to decide whether to dereference the
- * separate stencil miptree. In the case of packed depth/stencil, core
- * Mesa hands us the depth attachment as src_rb (not stencil), so assume
- * non-stencil for now. A buffer bit of 0 works for both color and depth.
- */
- GLbitfield buffer_bit = 0;
-
- if (!formats_match(buffer_bit, src_irb, dst_irb)) {
- dst_rb->Delete(ctx, dst_rb);
+ if (!color_formats_match(src_mt->format, dst_mt->format)) {
return false;
}
@@ -353,11 +350,6 @@ brw_blorp_copytexsubimage(struct intel_context *intel,
int dstX1 = dstX0 + width;
int dstY1 = dstY0 + height;
- /* Sync up the state of window system buffers. We need to do this before
- * we go looking for the buffers.
- */
- intel_prepare_render(intel);
-
/* Account for the fact that in the system framebuffer, the origin is at
* the lower left.
*/
@@ -369,23 +361,29 @@ brw_blorp_copytexsubimage(struct intel_context *intel,
mirror_y = true;
}
- do_blorp_blit(intel, buffer_bit, src_irb, dst_irb,
- srcX0, srcY0, dstX0, dstY0, dstX1, dstY1, false, mirror_y);
+ brw_blorp_blit_miptrees(intel,
+ src_mt, src_irb->mt_level, src_irb->mt_layer,
+ dst_mt, dst_image->Level, dst_image->Face,
+ srcX0, srcY0, dstX0, dstY0, dstX1, dstY1,
+ false, mirror_y);
- /* If we're copying a packed depth stencil texture, the above do_blorp_blit
- * copied depth (since buffer_bit != GL_STENCIL_BIT). Now copy stencil as
- * well. There's no need to do a formats_match() check because the separate
- * stencil buffer is always S8.
+ /* If we're copying to a packed depth stencil texture and the source
+ * framebuffer has separate stencil, we need to also copy the stencil data
+ * over.
*/
src_rb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
if (_mesa_get_format_bits(dst_image->TexFormat, GL_STENCIL_BITS) > 0 &&
src_rb != NULL) {
src_irb = intel_renderbuffer(src_rb);
- do_blorp_blit(intel, GL_STENCIL_BUFFER_BIT, src_irb, dst_irb,
- srcX0, srcY0, dstX0, dstY0, dstX1, dstY1, false, mirror_y);
+ if (src_irb->mt != src_mt)
+
+ brw_blorp_blit_miptrees(intel,
+ src_irb->mt, src_irb->mt_level, src_irb->mt_layer,
+ dst_mt, dst_image->Level, dst_image->Face,
+ srcX0, srcY0, dstX0, dstY0, dstX1, dstY1,
+ false, mirror_y);
}
- dst_rb->Delete(ctx, dst_rb);
return true;
}
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 6730d263fa2..bf440a12c83 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -534,36 +534,6 @@ intel_renderbuffer_update_wrapper(struct intel_context *intel,
return true;
}
-/**
- * Create a fake intel_renderbuffer that wraps a gl_texture_image.
- */
-struct intel_renderbuffer *
-intel_create_fake_renderbuffer_wrapper(struct intel_context *intel,
- struct gl_texture_image *image)
-{
- struct gl_context *ctx = &intel->ctx;
- struct intel_renderbuffer *irb;
- struct gl_renderbuffer *rb;
-
- irb = CALLOC_STRUCT(intel_renderbuffer);
- if (!irb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
- return NULL;
- }
-
- rb = &irb->Base.Base;
-
- _mesa_init_renderbuffer(rb, 0);
- rb->ClassID = INTEL_RB_CLASS;
-
- if (!intel_renderbuffer_update_wrapper(intel, irb, image, image->Face)) {
- intel_delete_renderbuffer(ctx, rb);
- return NULL;
- }
-
- return irb;
-}
-
void
intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb)
{
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h
index 19edbe7b0b0..0e0806b63bb 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.h
+++ b/src/mesa/drivers/dri/intel/intel_fbo.h
@@ -141,10 +141,6 @@ intel_create_wrapped_renderbuffer(struct gl_context * ctx,
int width, int height,
gl_format format);
-struct intel_renderbuffer *
-intel_create_fake_renderbuffer_wrapper(struct intel_context *intel,
- struct gl_texture_image *image);
-
extern void
intel_fbo_init(struct intel_context *intel);