summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-08-05 13:26:19 -0600
committerBrian Paul <[email protected]>2009-08-05 13:26:19 -0600
commitf792137593b16b850a8a95dbb4859d49effb9f7c (patch)
treef09241780dfb0e011c633e20395d6fc8f7e0a418 /src
parent2cd33afa0081661b68dd25289f8d904125a9923a (diff)
st/mesa: fix Y inversion and optimize st_BlitFramebuffer()
Need to check for Y inversion separately for src/dest buffers. If both the src and dest regions are upside down, make them right-side up for a better chance at a fast path. progs/tests/copypixrate -blit is much faster now.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_cb_blit.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
index 28526234720..98610473b31 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -75,6 +75,11 @@ st_BlitFramebuffer(GLcontext *ctx,
? PIPE_TEX_MIPFILTER_NEAREST
: PIPE_TEX_MIPFILTER_LINEAR);
+ if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1,
+ &dstX0, &dstY0, &dstX1, &dstY1)) {
+ return; /* nothing to draw/blit */
+ }
+
if (mask & GL_COLOR_BUFFER_BIT) {
struct st_renderbuffer *srcRb =
st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
@@ -84,12 +89,29 @@ st_BlitFramebuffer(GLcontext *ctx,
struct pipe_surface *dstSurf = dstRb->surface;
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
- /* invert Y */
+ /* invert Y for dest */
+ dstY0 = dstRb->Base.Height - dstY0;
+ dstY1 = dstRb->Base.Height - dstY1;
+ }
+
+ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
+ /* invert Y for src */
srcY0 = srcRb->Base.Height - srcY0;
srcY1 = srcRb->Base.Height - srcY1;
+ }
- dstY0 = dstRb->Base.Height - dstY0;
- dstY1 = dstRb->Base.Height - dstY1;
+ if (srcY0 > srcY1 && dstY0 > dstY1) {
+ /* Both src and dst are upside down. Swap Y to make it
+ * right-side up to increase odds of using a fast path.
+ * Recall that all Gallium raster coords have Y=0=top.
+ */
+ GLint tmp;
+ tmp = srcY0;
+ srcY0 = srcY1;
+ srcY1 = tmp;
+ tmp = dstY0;
+ dstY0 = dstY1;
+ dstY1 = tmp;
}
util_blit_pixels(st->blit,