summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/common
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-02-04 23:57:29 -0800
committerEric Anholt <[email protected]>2014-02-12 16:17:11 -0800
commit255bd9c0b83e3cb3914ee5a1386c8d5acdbc046a (patch)
tree85b3aea4d1b2b098b7cfc68ec45ac20cb9bbea1d /src/mesa/drivers/common
parent067c7b67e8080bb2ad9ed857f1e62ddae8da6e6d (diff)
meta: Add acceleration for depth glBlitFramebuffer().
Surprisingly, the GLSL shaders already wrote the sampled r value to FragDepth. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51600 Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers/common')
-rw-r--r--src/mesa/drivers/common/meta_blit.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index bfbf6ac0d33..456fa16491e 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -94,7 +94,7 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx,
}
/**
- * Try to do a color-only glBlitFramebuffer using texturing.
+ * Try to do a color or depth glBlitFramebuffer using texturing.
*
* We can do this when the src renderbuffer is actually a texture, or when the
* driver exposes BindRenderbufferTexImage().
@@ -104,11 +104,12 @@ blitframebuffer_texture(struct gl_context *ctx,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLenum filter, GLint flipX, GLint flipY,
- GLboolean glsl_version)
+ GLboolean glsl_version, GLboolean do_depth)
{
const struct gl_framebuffer *readFb = ctx->ReadBuffer;
+ int att_index = do_depth ? BUFFER_DEPTH : readFb->_ColorReadBufferIndex;
const struct gl_renderbuffer_attachment *readAtt =
- &readFb->Attachment[readFb->_ColorReadBufferIndex];
+ &readFb->Attachment[att_index];
struct blit_state *blit = &ctx->Meta->Blit;
const GLint dstX = MIN2(dstX0, dstX1);
const GLint dstY = MIN2(dstY0, dstY1);
@@ -263,8 +264,11 @@ blitframebuffer_texture(struct gl_context *ctx,
/* setup viewport */
_mesa_set_viewport(ctx, 0, dstX, dstY, dstW, dstH);
- _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- _mesa_DepthMask(GL_FALSE);
+ _mesa_ColorMask(!do_depth, !do_depth, !do_depth, !do_depth);
+ _mesa_set_enable(ctx, GL_DEPTH_TEST, do_depth);
+ _mesa_DepthMask(do_depth);
+ _mesa_DepthFunc(GL_ALWAYS);
+
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
/* Restore texture object state, the texture binding will
@@ -338,7 +342,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
if (blitframebuffer_texture(ctx, srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
filter, dstFlipX, dstFlipY,
- use_glsl_version)) {
+ use_glsl_version, false)) {
mask &= ~GL_COLOR_BUFFER_BIT;
if (mask == 0x0) {
_mesa_meta_end(ctx);
@@ -347,6 +351,19 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
}
}
+ if (mask & GL_DEPTH_BUFFER_BIT && use_glsl_version) {
+ if (blitframebuffer_texture(ctx, srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ filter, dstFlipX, dstFlipY,
+ use_glsl_version, true)) {
+ mask &= ~GL_DEPTH_BUFFER_BIT;
+ if (mask == 0x0) {
+ _mesa_meta_end(ctx);
+ return;
+ }
+ }
+ }
+
/* Choose between glsl version and fixed function version of
* BlitFramebuffer function.
*/