meta: Split _swrast_BlitFramebuffer out of the meta blit path.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 19 May 2014 05:16:01 +0000 (22:16 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 20 May 2014 00:18:55 +0000 (17:18 -0700)
Separating the software fallbacks from the rest of the meta path (which
is usually hardware accelerated) gives callers better control over their
blitting options.

For example, i965 might want to try meta blit, hardware blits, then
swrast as a last resort.  Splitting it makes that possible.

This updates all callers to maintain the existing behavior (even in the
few cases where it isn't desirable behavior - later patches can change
that).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
src/mesa/drivers/common/meta.c
src/mesa/drivers/common/meta.h
src/mesa/drivers/common/meta_blit.c
src/mesa/drivers/dri/i915/intel_fbo.c
src/mesa/drivers/dri/i965/intel_fbo.c
src/mesa/drivers/dri/nouveau/nouveau_driver.c
src/mesa/drivers/dri/radeon/radeon_fbo.c
src/mesa/drivers/x11/xm_dd.c

index 3ef3f79714e12f82990adb8dcce3be1003d1e313..f90d5bd424e1ac111a65f2c3f46f339862d126ed 100644 (file)
@@ -2860,11 +2860,11 @@ copytexsubimage_using_blit_framebuffer(struct gl_context *ctx, GLuint dims,
     * are too strict for CopyTexImage.  We know meta will be fine with format
     * changes.
     */
-   _mesa_meta_BlitFramebuffer(ctx, x, y,
-                              x + width, y + height,
-                              xoffset, yoffset,
-                              xoffset + width, yoffset + height,
-                              mask, GL_NEAREST);
+   _mesa_meta_and_swrast_BlitFramebuffer(ctx, x, y,
+                                         x + width, y + height,
+                                         xoffset, yoffset,
+                                         xoffset + width, yoffset + height,
+                                         mask, GL_NEAREST);
    ctx->Meta->Blit.no_ctsi_fallback = false;
    success = true;
 
index 2186a39f8d93a383557168a54bfad63ae050d8c1..007f1040bdb371eed0a1ed82348e7d22a4b3c34d 100644 (file)
@@ -422,12 +422,20 @@ _mesa_meta_setup_sampler(struct gl_context *ctx,
                          const struct gl_texture_object *texObj,
                          GLenum target, GLenum filter, GLuint srcLevel);
 
-extern void
+extern GLbitfield
 _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
                            GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
                            GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
                            GLbitfield mask, GLenum filter);
 
+extern void
+_mesa_meta_and_swrast_BlitFramebuffer(struct gl_context *ctx,
+                                      GLint srcX0, GLint srcY0,
+                                      GLint srcX1, GLint srcY1,
+                                      GLint dstX0, GLint dstY0,
+                                      GLint dstX1, GLint dstY1,
+                                      GLbitfield mask, GLenum filter);
+
 extern void
 _mesa_meta_Clear(struct gl_context *ctx, GLbitfield buffers);
 
index bd6118b945568388c30d3e5f9ef3586ee018febb..e10a181d68bf8a1d8a947a7cdb7d1f128bd3ecde 100644 (file)
@@ -644,7 +644,7 @@ _mesa_meta_setup_sampler(struct gl_context *ctx,
  * Meta implementation of ctx->Driver.BlitFramebuffer() in terms
  * of texture mapping and polygon rendering.
  */
-void
+GLbitfield
 _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
                            GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
                            GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
@@ -669,7 +669,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
    /* Multisample texture blit support requires texture multisample. */
    if (ctx->ReadBuffer->Visual.samples > 0 &&
        !ctx->Extensions.ARB_texture_multisample) {
-      goto fallback;
+      return mask;
    }
 
    /* Clip a copy of the blit coordinates. If these differ from the input
@@ -678,7 +678,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
    if (!_mesa_clip_blit(ctx, &clip.srcX0, &clip.srcY0, &clip.srcX1, &clip.srcY1,
                         &clip.dstX0, &clip.dstY0, &clip.dstX1, &clip.dstY1)) {
       /* clipped/scissored everything away */
-      return;
+      return 0;
    }
 
    /* Only scissor affects blit, but we're doing to set a custom scissor if
@@ -723,11 +723,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
 
    _mesa_meta_end(ctx);
 
-fallback:
-   if (mask) {
-      _swrast_BlitFramebuffer(ctx, srcX0, srcY0, srcX1, srcY1,
-                              dstX0, dstY0, dstX1, dstY1, mask, filter);
-   }
+   return mask;
 }
 
 void
@@ -745,3 +741,24 @@ _mesa_meta_glsl_blit_cleanup(struct blit_state *blit)
    _mesa_DeleteTextures(1, &blit->depthTex.TexObj);
    blit->depthTex.TexObj = 0;
 }
+
+void
+_mesa_meta_and_swrast_BlitFramebuffer(struct gl_context *ctx,
+                                      GLint srcX0, GLint srcY0,
+                                      GLint srcX1, GLint srcY1,
+                                      GLint dstX0, GLint dstY0,
+                                      GLint dstX1, GLint dstY1,
+                                      GLbitfield mask, GLenum filter)
+{
+   mask = _mesa_meta_BlitFramebuffer(ctx,
+                                     srcX0, srcY0, srcX1, srcY1,
+                                     dstX0, dstY0, dstX1, dstY1,
+                                     mask, filter);
+   if (mask == 0x0)
+      return;
+
+   _swrast_BlitFramebuffer(ctx,
+                           srcX0, srcY0, srcX1, srcY1,
+                           dstX0, dstY0, dstX1, dstY1,
+                           mask, filter);
+}
index 2538facf141c07cf148ac2dfc4669c8e25d495c2..a77c3d6064b4fc94f551635b07306a380126bcfa 100644 (file)
@@ -741,10 +741,10 @@ intel_blit_framebuffer(struct gl_context *ctx,
       return;
 
 
-   _mesa_meta_BlitFramebuffer(ctx,
-                              srcX0, srcY0, srcX1, srcY1,
-                              dstX0, dstY0, dstX1, dstY1,
-                              mask, filter);
+   _mesa_meta_and_swrast_BlitFramebuffer(ctx,
+                                         srcX0, srcY0, srcX1, srcY1,
+                                         dstX0, dstY0, dstX1, dstY1,
+                                         mask, filter);
 }
 
 /**
index 6c99de9513bada6d20a86acb73306ff61b78f1a4..e43e18b78a2ede21b20361dc14461e373aa5d515 100644 (file)
@@ -898,11 +898,17 @@ intel_blit_framebuffer(struct gl_context *ctx,
    if (mask == 0x0)
       return;
 
+   mask = _mesa_meta_BlitFramebuffer(ctx,
+                                     srcX0, srcY0, srcX1, srcY1,
+                                     dstX0, dstY0, dstX1, dstY1,
+                                     mask, filter);
+   if (mask == 0x0)
+      return;
 
-   _mesa_meta_BlitFramebuffer(ctx,
-                              srcX0, srcY0, srcX1, srcY1,
-                              dstX0, dstY0, dstX1, dstY1,
-                              mask, filter);
+   _swrast_BlitFramebuffer(ctx,
+                           srcX0, srcY0, srcX1, srcY1,
+                           dstX0, dstY0, dstX1, dstY1,
+                           mask, filter);
 }
 
 /**
index 1a8afa2af121488f42e5df5ea1eb2b7cf1239dfc..b0afb69e221de95a48954783e733fa5e06a6789b 100644 (file)
@@ -155,5 +155,5 @@ nouveau_driver_functions_init(struct dd_function_table *functions)
        functions->DrawPixels = _mesa_meta_DrawPixels;
        functions->CopyPixels = _mesa_meta_CopyPixels;
        functions->Bitmap = _mesa_meta_Bitmap;
-       functions->BlitFramebuffer = _mesa_meta_BlitFramebuffer;
+       functions->BlitFramebuffer = _mesa_meta_and_swrast_BlitFramebuffer;
 }
index 12ad438771c3c5c489aba78c6cb66629af09640d..5a6d9da771cb065c1514c599ad39c8a933262433 100644 (file)
@@ -873,7 +873,7 @@ void radeon_fbo_init(struct radeon_context *radeon)
   radeon->glCtx.Driver.RenderTexture = radeon_render_texture;
   radeon->glCtx.Driver.FinishRenderTexture = radeon_finish_render_texture;
   radeon->glCtx.Driver.ValidateFramebuffer = radeon_validate_framebuffer;
-  radeon->glCtx.Driver.BlitFramebuffer = _mesa_meta_BlitFramebuffer;
+  radeon->glCtx.Driver.BlitFramebuffer = _mesa_meta_and_swrast_BlitFramebuffer;
   radeon->glCtx.Driver.EGLImageTargetRenderbufferStorage =
          radeon_image_target_renderbuffer_storage;
 }
index 3fe1f01c4ed7311f89c7adfb2617c00eef4883f1..10634fe73c0e76c2fbe7dbbc3c69f01d252fc543 100644 (file)
@@ -841,7 +841,7 @@ xmesa_init_driver_functions( XMesaVisual xmvisual,
    if (TEST_META_FUNCS) {
       driver->Clear = _mesa_meta_Clear;
       driver->CopyPixels = _mesa_meta_CopyPixels;
-      driver->BlitFramebuffer = _mesa_meta_BlitFramebuffer;
+      driver->BlitFramebuffer = _mesa_meta_and_swrast_BlitFramebuffer;
       driver->DrawPixels = _mesa_meta_DrawPixels;
       driver->Bitmap = _mesa_meta_Bitmap;
    }