diff options
author | Laura Ekstrand <[email protected]> | 2015-01-30 14:03:53 -0800 |
---|---|---|
committer | Laura Ekstrand <[email protected]> | 2015-02-02 13:21:20 -0800 |
commit | e187c2f5432466c7b49dba266026fb9b01f5f667 (patch) | |
tree | 6232bca416174ed9c15bdbc69b8c6e650cad76c8 /src/mesa/drivers/common | |
parent | ad2c64abbd7326be35fa1f94c7e056e868ee6185 (diff) |
DD: Refactor BlitFramebuffer.
In preparation for glBlitNamedFramebuffer, the DD table function
BlitFramebuffer needs to accept two arbitrary framebuffer objects rather
than assuming ctx->ReadBuffer and ctx->DrawBuffer.
Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/drivers/common')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/common/meta.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/common/meta_blit.c | 32 | ||||
-rw-r--r-- | src/mesa/drivers/common/meta_copy_image.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/common/meta_tex_subimage.c | 12 |
5 files changed, 37 insertions, 17 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 8b73cb99f3f..bb0073074e7 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -2793,7 +2793,8 @@ copytexsubimage_using_blit_framebuffer(struct gl_context *ctx, GLuint dims, * are too strict for CopyTexImage. We know meta will be fine with format * changes. */ - mask = _mesa_meta_BlitFramebuffer(ctx, x, y, + mask = _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, + x, y, x + width, y + height, xoffset, yoffset, xoffset + width, yoffset + height, diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h index 3b9e05e0176..e7d894df1d7 100644 --- a/src/mesa/drivers/common/meta.h +++ b/src/mesa/drivers/common/meta.h @@ -475,12 +475,16 @@ _mesa_meta_setup_sampler(struct gl_context *ctx, extern GLbitfield _mesa_meta_BlitFramebuffer(struct gl_context *ctx, + const struct gl_framebuffer *readFb, + const struct gl_framebuffer *drawFb, 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, + struct gl_framebuffer *readFb, + struct gl_framebuffer *drawFb, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c index 4212d94333a..3406be1ed1c 100644 --- a/src/mesa/drivers/common/meta_blit.c +++ b/src/mesa/drivers/common/meta_blit.c @@ -232,6 +232,7 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, static void setup_glsl_msaa_blit_shader(struct gl_context *ctx, struct blit_state *blit, + const struct gl_framebuffer *drawFb, struct gl_renderbuffer *src_rb, GLenum target) { @@ -267,7 +268,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, /* Update the assert if we plan to support more than 16X MSAA. */ assert(shader_offset >= 0 && shader_offset <= 4); - if (ctx->DrawBuffer->Visual.samples > 1) { + if (drawFb->Visual.samples > 1) { /* If you're calling meta_BlitFramebuffer with the destination * multisampled, this is the only path that will work -- swrast and * CopyTexImage won't work on it either. @@ -508,6 +509,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, static void setup_glsl_blit_framebuffer(struct gl_context *ctx, struct blit_state *blit, + const struct gl_framebuffer *drawFb, struct gl_renderbuffer *src_rb, GLenum target, GLenum filter, bool is_scaled_blit, @@ -530,7 +532,7 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx, if (is_target_multisample && is_filter_scaled_resolve && is_scaled_blit) { setup_glsl_msaa_blit_scaled_shader(ctx, blit, src_rb, target, filter); } else if (is_target_multisample) { - setup_glsl_msaa_blit_shader(ctx, blit, src_rb, target); + setup_glsl_msaa_blit_shader(ctx, blit, drawFb, src_rb, target); } else { _mesa_meta_setup_blit_shader(ctx, target, do_depth, do_depth ? &blit->shaders_with_depth @@ -546,12 +548,13 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx, */ static bool blitframebuffer_texture(struct gl_context *ctx, + const struct gl_framebuffer *readFb, + const struct gl_framebuffer *drawFb, 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 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[att_index]; @@ -645,7 +648,7 @@ blitframebuffer_texture(struct gl_context *ctx, scaled_blit = dstW != srcW || dstH != srcH; if (glsl_version) { - setup_glsl_blit_framebuffer(ctx, blit, rb, target, filter, scaled_blit, + setup_glsl_blit_framebuffer(ctx, blit, drawFb, rb, target, filter, scaled_blit, do_depth); } else { @@ -681,7 +684,7 @@ blitframebuffer_texture(struct gl_context *ctx, */ if (ctx->Extensions.EXT_texture_sRGB_decode) { if (_mesa_get_format_color_encoding(rb->Format) == GL_SRGB && - ctx->DrawBuffer->Visual.sRGBCapable) { + drawFb->Visual.sRGBCapable) { _mesa_SamplerParameteri(fb_tex_blit.sampler, GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); _mesa_set_framebuffer_srgb(ctx, GL_TRUE); @@ -873,6 +876,8 @@ _mesa_meta_setup_sampler(struct gl_context *ctx, */ GLbitfield _mesa_meta_BlitFramebuffer(struct gl_context *ctx, + const struct gl_framebuffer *readFb, + const struct gl_framebuffer *drawFb, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) @@ -894,7 +899,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, ctx->Extensions.ARB_fragment_shader; /* Multisample texture blit support requires texture multisample. */ - if (ctx->ReadBuffer->Visual.samples > 0 && + if (readFb->Visual.samples > 0 && !ctx->Extensions.ARB_texture_multisample) { return mask; } @@ -902,7 +907,8 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, /* Clip a copy of the blit coordinates. If these differ from the input * coordinates, then we'll set the scissor. */ - if (!_mesa_clip_blit(ctx, &clip.srcX0, &clip.srcY0, &clip.srcX1, &clip.srcY1, + if (!_mesa_clip_blit(ctx, readFb, drawFb, + &clip.srcX0, &clip.srcY0, &clip.srcX1, &clip.srcY1, &clip.dstX0, &clip.dstY0, &clip.dstX1, &clip.dstY1)) { /* clipped/scissored everything away */ return 0; @@ -930,7 +936,8 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, /* Try faster, direct texture approach first */ if (mask & GL_COLOR_BUFFER_BIT) { - if (blitframebuffer_texture(ctx, srcX0, srcY0, srcX1, srcY1, + if (blitframebuffer_texture(ctx, readFb, drawFb, + srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, filter, dstFlipX, dstFlipY, use_glsl_version, false)) { @@ -939,7 +946,8 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, } if (mask & GL_DEPTH_BUFFER_BIT && use_glsl_version) { - if (blitframebuffer_texture(ctx, srcX0, srcY0, srcX1, srcY1, + if (blitframebuffer_texture(ctx, readFb, drawFb, + srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, filter, dstFlipX, dstFlipY, use_glsl_version, true)) { @@ -975,20 +983,22 @@ _mesa_meta_glsl_blit_cleanup(struct blit_state *blit) void _mesa_meta_and_swrast_BlitFramebuffer(struct gl_context *ctx, + struct gl_framebuffer *readFb, + struct gl_framebuffer *drawFb, 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, + mask = _mesa_meta_BlitFramebuffer(ctx, readFb, drawFb, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); if (mask == 0x0) return; - _swrast_BlitFramebuffer(ctx, + _swrast_BlitFramebuffer(ctx, readFb, drawFb, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); diff --git a/src/mesa/drivers/common/meta_copy_image.c b/src/mesa/drivers/common/meta_copy_image.c index fc0cbaf1bd8..1729766f78d 100644 --- a/src/mesa/drivers/common/meta_copy_image.c +++ b/src/mesa/drivers/common/meta_copy_image.c @@ -189,7 +189,8 @@ _mesa_meta_CopyImageSubData_uncompressed(struct gl_context *ctx, * We have already created views to ensure that the texture formats * match. */ - ctx->Driver.BlitFramebuffer(ctx, src_x, src_y, + ctx->Driver.BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, + src_x, src_y, src_x + src_width, src_y + src_height, dst_x, dst_y, dst_x + src_width, dst_y + src_height, diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c index 977ee5ad93e..68c8273fe4f 100644 --- a/src/mesa/drivers/common/meta_tex_subimage.c +++ b/src/mesa/drivers/common/meta_tex_subimage.c @@ -206,7 +206,8 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, _mesa_update_state(ctx); - if (_mesa_meta_BlitFramebuffer(ctx, 0, 0, width, height, + if (_mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, + 0, 0, width, height, xoffset, yoffset, xoffset + width, yoffset + height, GL_COLOR_BUFFER_BIT, GL_NEAREST)) @@ -220,7 +221,8 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, _mesa_update_state(ctx); - _mesa_meta_BlitFramebuffer(ctx, 0, 0, width, height, + _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, + 0, 0, width, height, xoffset, yoffset, xoffset + width, yoffset + height, GL_COLOR_BUFFER_BIT, GL_NEAREST); @@ -324,7 +326,8 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, _mesa_update_state(ctx); - if (_mesa_meta_BlitFramebuffer(ctx, xoffset, yoffset, + if (_mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, + xoffset, yoffset, xoffset + width, yoffset + height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST)) @@ -338,7 +341,8 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, _mesa_update_state(ctx); - _mesa_meta_BlitFramebuffer(ctx, xoffset, yoffset, + _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, + xoffset, yoffset, xoffset + width, yoffset + height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST); |