[Mesa-dev] [PATCH 10/11] meta: Add acceleration for depth glBlitFramebuffer().
Eric Anholt
eric at anholt.net
Wed Feb 5 17:20:13 PST 2014
Surprisingly, the GLSL shaders already wrote the sampled r value to
FragDepth.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51600
---
src/mesa/drivers/common/meta_blit.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index 9c3ff9b..46c8efd 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -264,7 +264,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 expposes BindRenderbufferTexImage().
@@ -274,11 +274,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);
@@ -441,8 +442,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
@@ -520,7 +524,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);
@@ -529,6 +533,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.
*/
--
1.9.rc1
More information about the mesa-dev
mailing list