<div dir="ltr">On 5 June 2013 10:14, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This gets us support for blitting to attachment types other than<br>
textures.<br></blockquote><div><br></div><div>I don't follow everything in this patch, but I trust Ken's review, so consider it<br><br></div><div>Acked-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
<br></div><div>I already made comments on patches 1 and 2. Patches 3, 4, 6, and 7 are:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
src/mesa/drivers/dri/intel/intel_fbo.c | 129 +++++++++++++++-------------<br>
src/mesa/drivers/dri/intel/intel_tex.h | 7 --<br>
src/mesa/drivers/dri/intel/intel_tex_copy.c | 2 +-<br>
3 files changed, 69 insertions(+), 69 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c<br>
index 9f892a9..9a24a55 100644<br>
--- a/src/mesa/drivers/dri/intel/intel_fbo.c<br>
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c<br>
@@ -737,76 +737,83 @@ intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)<br>
* normal path.<br>
*/<br>
static GLbitfield<br>
-intel_blit_framebuffer_copy_tex_sub_image(struct gl_context *ctx,<br>
- GLint srcX0, GLint srcY0,<br>
- GLint srcX1, GLint srcY1,<br>
- GLint dstX0, GLint dstY0,<br>
- GLint dstX1, GLint dstY1,<br>
- GLbitfield mask, GLenum filter)<br>
+intel_blit_framebuffer_with_blitter(struct gl_context *ctx,<br>
+ GLint srcX0, GLint srcY0,<br>
+ GLint srcX1, GLint srcY1,<br>
+ GLint dstX0, GLint dstY0,<br>
+ GLint dstX1, GLint dstY1,<br>
+ GLbitfield mask, GLenum filter)<br>
{<br>
+ struct intel_context *intel = intel_context(ctx);<br>
+<br>
if (mask & GL_COLOR_BUFFER_BIT) {<br>
GLint i;<br>
const struct gl_framebuffer *drawFb = ctx->DrawBuffer;<br>
const struct gl_framebuffer *readFb = ctx->ReadBuffer;<br>
- const struct gl_renderbuffer_attachment *drawAtt;<br>
- struct intel_renderbuffer *srcRb =<br>
- intel_renderbuffer(readFb->_ColorReadBuffer);<br>
+ struct gl_renderbuffer *src_rb = readFb->_ColorReadBuffer;<br>
+ struct intel_renderbuffer *src_irb = intel_renderbuffer(src_rb);<br>
+<br>
+ if (!src_irb) {<br>
+ perf_debug("glBlitFramebuffer(): missing src renderbuffer. "<br>
+ "Falling back to software rendering.\n");<br>
+ return mask;<br>
+ }<br>
<br>
/* If the source and destination are the same size with no mirroring,<br>
* the rectangles are within the size of the texture and there is no<br>
- * scissor then we can use glCopyTexSubimage2D to implement the blit.<br>
- * This will end up as a fast hardware blit on some drivers.<br>
+ * scissor, then we can probably use the blit engine.<br>
*/<br>
- const GLboolean use_intel_copy_texsubimage =<br>
- srcX0 - srcX1 == dstX0 - dstX1 &&<br>
- srcY0 - srcY1 == dstY0 - dstY1 &&<br>
- srcX1 >= srcX0 &&<br>
- srcY1 >= srcY0 &&<br>
- srcX0 >= 0 && srcX1 <= readFb->Width &&<br>
- srcY0 >= 0 && srcY1 <= readFb->Height &&<br>
- dstX0 >= 0 && dstX1 <= drawFb->Width &&<br>
- dstY0 >= 0 && dstY1 <= drawFb->Height &&<br>
- !ctx->Scissor.Enabled;<br>
-<br>
- /* Verify that all the draw buffers can be blitted using<br>
- * intel_copy_texsubimage().<br>
+ if (!(srcX0 - srcX1 == dstX0 - dstX1 &&<br>
+ srcY0 - srcY1 == dstY0 - dstY1 &&<br>
+ srcX1 >= srcX0 &&<br>
+ srcY1 >= srcY0 &&<br>
+ srcX0 >= 0 && srcX1 <= readFb->Width &&<br>
+ srcY0 >= 0 && srcY1 <= readFb->Height &&<br>
+ dstX0 >= 0 && dstX1 <= drawFb->Width &&<br>
+ dstY0 >= 0 && dstY1 <= drawFb->Height &&<br>
+ !ctx->Scissor.Enabled)) {<br>
+ perf_debug("glBlitFramebuffer(): non-1:1 blit. "<br>
+ "Falling back to software rendering.\n");<br>
+ return mask;<br>
+ }<br>
+<br>
+ /* Blit to all active draw buffers. We don't do any pre-checking,<br>
+ * because we assume that copying to MRTs is rare, and failure midway<br>
+ * through copying is even more rare. Given that feedback loops in<br>
+ * glFramebufferBlit() are undefined, we can safely fail out after<br>
+ * having partially completed our copies.<br>
*/<br>
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {<br>
- int idx = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];<br>
- if (idx == -1)<br>
- continue;<br>
- drawAtt = &drawFb->Attachment[idx];<br>
-<br>
- if (srcRb && drawAtt && drawAtt->Texture &&<br>
- use_intel_copy_texsubimage)<br>
- continue;<br>
- else<br>
+ struct gl_renderbuffer *dst_rb = ctx->DrawBuffer->_ColorDrawBuffers[i];<br>
+ struct intel_renderbuffer *dst_irb = intel_renderbuffer(dst_rb);<br>
+<br>
+ if (!dst_irb) {<br>
+ perf_debug("glBlitFramebuffer(): missing dst renderbuffer. "<br>
+ "Falling back to software rendering.\n");<br>
return mask;<br>
- }<br>
+ }<br>
<br>
- /* Blit to all active draw buffers */<br>
- for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {<br>
- int idx = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];<br>
- if (idx == -1)<br>
- continue;<br>
- drawAtt = &drawFb->Attachment[idx];<br>
-<br>
- {<br>
- const struct gl_texture_object *texObj = drawAtt->Texture;<br>
- const GLuint dstLevel = drawAtt->TextureLevel;<br>
- const GLenum target = texObj->Target;<br>
-<br>
- struct gl_texture_image *texImage =<br>
- _mesa_select_tex_image(ctx, texObj, target, dstLevel);<br>
-<br>
- if (!intel_copy_texsubimage(intel_context(ctx),<br>
- intel_texture_image(texImage),<br>
- dstX0, dstY0,<br>
- srcRb,<br>
- srcX0, srcY0,<br>
- srcX1 - srcX0, /* width */<br>
- srcY1 - srcY0))<br>
- return mask;<br>
+ gl_format src_format = _mesa_get_srgb_format_linear(src_rb->Format);<br>
+ gl_format dst_format = _mesa_get_srgb_format_linear(dst_rb->Format);<br>
+ if (src_format != dst_format) {<br>
+ perf_debug("glBlitFramebuffer(): unsupported blit from %s to %s. "<br>
+ "Falling back to software rendering.\n",<br>
+ _mesa_get_format_name(src_format),<br>
+ _mesa_get_format_name(dst_format));<br>
+ return mask;<br>
+ }<br>
+<br>
+ if (!intel_miptree_blit(intel,<br>
+ src_irb->mt,<br>
+ src_irb->mt_level, src_irb->mt_layer,<br>
+ srcX0, srcY0, src_rb->Name == 0,<br>
+ dst_irb->mt,<br>
+ dst_irb->mt_level, dst_irb->mt_layer,<br>
+ dstX0, dstY0, dst_rb->Name == 0,<br>
+ dstX1 - dstX0, dstY1 - dstY0, GL_COPY)) {<br>
+ perf_debug("glBlitFramebuffer(): unknown blit failure. "<br>
+ "Falling back to software rendering.\n");<br>
+ return mask;<br>
}<br>
}<br>
<br>
@@ -832,10 +839,10 @@ intel_blit_framebuffer(struct gl_context *ctx,<br>
#endif<br>
<br>
/* Try glCopyTexSubImage2D approach which uses the BLT. */<br>
- mask = intel_blit_framebuffer_copy_tex_sub_image(ctx,<br>
- srcX0, srcY0, srcX1, srcY1,<br>
- dstX0, dstY0, dstX1, dstY1,<br>
- mask, filter);<br>
+ mask = intel_blit_framebuffer_with_blitter(ctx,<br>
+ srcX0, srcY0, srcX1, srcY1,<br>
+ dstX0, dstY0, dstX1, dstY1,<br>
+ mask, filter);<br>
if (mask == 0x0)<br>
return;<br>
<br>
diff --git a/src/mesa/drivers/dri/intel/intel_tex.h b/src/mesa/drivers/dri/intel/intel_tex.h<br>
index e038115..a08fdf4 100644<br>
--- a/src/mesa/drivers/dri/intel/intel_tex.h<br>
+++ b/src/mesa/drivers/dri/intel/intel_tex.h<br>
@@ -68,13 +68,6 @@ bool<br>
intel_tex_image_s8z24_create_renderbuffers(struct intel_context *intel,<br>
struct intel_texture_image *image);<br>
<br>
-bool intel_copy_texsubimage(struct intel_context *intel,<br>
- struct intel_texture_image *intelImage,<br>
- GLint dstx, GLint dsty,<br>
- struct intel_renderbuffer *irb,<br>
- GLint x, GLint y,<br>
- GLsizei width, GLsizei height);<br>
-<br>
bool<br>
intel_texsubimage_tiled_memcpy(struct gl_context *ctx,<br>
GLuint dims,<br>
diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c<br>
index 4f01c58..f9e03fa 100644<br>
--- a/src/mesa/drivers/dri/intel/intel_tex_copy.c<br>
+++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c<br>
@@ -48,7 +48,7 @@<br>
#define FILE_DEBUG_FLAG DEBUG_TEXTURE<br>
<br>
<br>
-bool<br>
+static bool<br>
intel_copy_texsubimage(struct intel_context *intel,<br>
struct intel_texture_image *intelImage,<br>
GLint dstx, GLint dsty,<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.rc0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>