[Mesa-dev] [PATCH 3/4] meta: Split _swrast_BlitFramebuffer out of the meta blit path.
Kenneth Graunke
kenneth at whitecape.org
Sun May 18 23:12:26 PDT 2014
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 at whitecape.org>
Cc: "10.2" <mesa-stable at lists.freedesktop.org>
---
src/mesa/drivers/common/meta.c | 10 ++++----
src/mesa/drivers/common/meta.h | 10 +++++++-
src/mesa/drivers/common/meta_blit.c | 33 ++++++++++++++++++++-------
src/mesa/drivers/dri/i915/intel_fbo.c | 8 +++----
src/mesa/drivers/dri/i965/intel_fbo.c | 14 ++++++++----
src/mesa/drivers/dri/nouveau/nouveau_driver.c | 2 +-
src/mesa/drivers/dri/radeon/radeon_fbo.c | 2 +-
src/mesa/drivers/x11/xm_dd.c | 2 +-
8 files changed, 56 insertions(+), 25 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 3ef3f79..f90d5bd 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -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;
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 2186a39..007f104 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -422,13 +422,21 @@ _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);
extern void
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index bd6118b..e10a181 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -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);
+}
diff --git a/src/mesa/drivers/dri/i915/intel_fbo.c b/src/mesa/drivers/dri/i915/intel_fbo.c
index 2538fac..a77c3d6 100644
--- a/src/mesa/drivers/dri/i915/intel_fbo.c
+++ b/src/mesa/drivers/dri/i915/intel_fbo.c
@@ -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);
}
/**
diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c
index 5ff4263..c010e45 100644
--- a/src/mesa/drivers/dri/i965/intel_fbo.c
+++ b/src/mesa/drivers/dri/i965/intel_fbo.c
@@ -896,11 +896,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);
}
/**
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c
index 1a8afa2..b0afb69 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c
@@ -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;
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 12ad438..5a6d9da 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -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;
}
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index 3fe1f01..10634fe 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -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;
}
--
1.9.2
More information about the mesa-dev
mailing list