For scaled blits, this is not correct. For example, if you blit a 10x10 texture to another 10x10 texture with horizontal scaling of 1.5x, the X texture coordinate of the rightmost pixel should be 6.666666. Mesa clip blit doesn't return floating-point coordinates of the source, so you can't use them. You can however take the clipped destination coordinates and set them as a scissor rectangle, keeping the original coordinates unmodified. That way, you'll get correct clipping (in hardware though) with correct source coordinates for scaled blits.
See st_BlitFramebuffer. Marek On Mon, Apr 14, 2014 at 10:20 AM, Chris Forbes <chr...@ijw.co.nz> wrote: > Nothing was bothering to clip the blit. If the src rect was partially > outside the framebuffer, we'd end up picking up more copies of the > edge texels due to clamping. > > Note that this is slight overkill -- we could get away with clipping src > only, since fragments outside the destination surface will be discarded > anyway. > > Fixes piglit's fbo-blit-stretch test on drivers which use the meta path. > (i965: should fix Broadwell, but also fixes Sandybridge/Ivybridge/Haswell > since this test falls off the blorp path now due to format conversion) > > Signed-off-by: Chris Forbes <chr...@ijw.co.nz> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77414 > --- > src/mesa/drivers/common/meta_blit.c | 31 +++++++++++++++++++++++++------ > 1 file changed, 25 insertions(+), 6 deletions(-) > > diff --git a/src/mesa/drivers/common/meta_blit.c > b/src/mesa/drivers/common/meta_blit.c > index 31e494f..38d53ef 100644 > --- a/src/mesa/drivers/common/meta_blit.c > +++ b/src/mesa/drivers/common/meta_blit.c > @@ -33,6 +33,7 @@ > #include "main/enable.h" > #include "main/enums.h" > #include "main/fbobject.h" > +#include "main/image.h" > #include "main/macros.h" > #include "main/matrix.h" > #include "main/multisample.h" > @@ -590,12 +591,9 @@ blitframebuffer_texture(struct gl_context *ctx, > return true; > } > > -/** > - * Meta implementation of ctx->Driver.BlitFramebuffer() in terms > - * of texture mapping and polygon rendering. > - */ > -void > -_mesa_meta_BlitFramebuffer(struct gl_context *ctx, > + > +static void > +_mesa_meta_blit_preclipped(struct gl_context *ctx, > GLint srcX0, GLint srcY0, GLint srcX1, GLint > srcY1, > GLint dstX0, GLint dstY0, GLint dstX1, GLint > dstY1, > GLbitfield mask, GLenum filter) > @@ -804,6 +802,27 @@ fallback: > } > } > > +/** > + * Meta implementation of ctx->Driver.BlitFramebuffer() in terms > + * of texture mapping and polygon rendering. > + */ > +void > +_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) > +{ > + if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1, > + &dstX0, &dstY0, &dstX1, &dstY1)) { > + /* nothing left! */ > + return; > + } > + > + _mesa_meta_blit_preclipped(ctx, srcX0, srcY0, srcX1, srcY1, > + dstX0, dstY0, dstX1, dstY1, > + mask, filter); > +} > + > void > _mesa_meta_glsl_blit_cleanup(struct blit_state *blit) > { > -- > 1.9.1 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev