gallium: pipe->surface_copy can flip the contents vertically when necessary.
authorMichel Dänzer <michel@tungstengraphics.com>
Wed, 13 Feb 2008 11:39:58 +0000 (11:39 +0000)
committerMichel Dänzer <michel@tungstengraphics.com>
Wed, 13 Feb 2008 11:39:58 +0000 (11:39 +0000)
Fixes gears being upside down on the box in demos/gearbox.

15 files changed:
src/mesa/pipe/cell/ppu/cell_surface.c
src/mesa/pipe/i915simple/i915_blit.c
src/mesa/pipe/i915simple/i915_blit.h
src/mesa/pipe/i915simple/i915_surface.c
src/mesa/pipe/i965simple/brw_blit.c
src/mesa/pipe/i965simple/brw_blit.h
src/mesa/pipe/i965simple/brw_surface.c
src/mesa/pipe/p_context.h
src/mesa/pipe/p_util.h
src/mesa/pipe/softpipe/sp_surface.c
src/mesa/pipe/util/p_util.c
src/mesa/pipe/xlib/xm_api.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_texture.c

index 6b7b9181282e3d198281dd240a29c59972460ec2..fca93e474248c42e1a930b8aed6e456b3ce51eec 100644 (file)
@@ -60,6 +60,7 @@ cell_surface_data(struct pipe_context *pipe,
 
 static void
 cell_surface_copy(struct pipe_context *pipe,
+                  unsigned do_flip,
                   struct pipe_surface *dst,
                   unsigned dstx, unsigned dsty,
                   struct pipe_surface *src,
@@ -74,8 +75,8 @@ cell_surface_copy(struct pipe_context *pipe,
                   dstx, dsty,
                   width, height,
                   pipe_surface_map(src),
-                  src->pitch,
-                  srcx, srcy);
+                  do_flip ? -src->pitch : src->pitch,
+                  srcx, do_flip ? 1 - srcy - height : srcy);
 
    pipe_surface_unmap(src);
    pipe_surface_unmap(dst);
index d49876f970809684a97cc8bdb3bf36d31ed9debe..db4671ff553bce9c760a0855dd5a2b1642133afd 100644 (file)
@@ -85,6 +85,7 @@ i915_fill_blit(struct i915_context *i915,
 
 void
 i915_copy_blit( struct i915_context *i915,
+                  unsigned do_flip,
                   unsigned cpp,
                   short src_pitch,
                   struct pipe_buffer *src_buffer,
index d7a66be10ae131824eec0c2547e3a00865a8b842..6e5b44e12479d1921898ceffbdf7ba75177039b1 100644 (file)
@@ -31,6 +31,7 @@
 #include "i915_context.h"
 
 extern void i915_copy_blit(struct i915_context *i915,
+                           unsigned do_flip,
                           unsigned cpp,
                           short src_pitch,
                           struct pipe_buffer *src_buffer,
index 1bdaba773f1c39d197cf2a6d53dff41e09930dcd..6d4b8a0aa9f7a2202f0e1ebcf58794211fc86cbd 100644 (file)
@@ -83,6 +83,7 @@ i915_get_tex_surface(struct pipe_context *pipe,
  */
 static void
 i915_surface_copy(struct pipe_context *pipe,
+                  unsigned do_flip,
                  struct pipe_surface *dst,
                  unsigned dstx, unsigned dsty,
                  struct pipe_surface *src,
@@ -98,14 +99,15 @@ i915_surface_copy(struct pipe_context *pipe,
                      dstx, dsty, 
                      width, height, 
                      pipe_surface_map(src), 
-                     src->pitch, 
-                     srcx, srcy);
+                     do_flip ? -src->pitch : src->pitch, 
+                     srcx, do_flip ? 1 - srcy - height : srcy);
 
       pipe_surface_unmap(src);
       pipe_surface_unmap(dst);
    }
    else {
       i915_copy_blit( i915_context(pipe),
+                      do_flip,
                      dst->cpp,
                      (short) src->pitch, src->buffer, src->offset,
                      (short) dst->pitch, dst->buffer, dst->offset,
index bbd366294f5fe341d7a15377a522424de881d2d9..8494f70493c3c17e9abb7378d77efc75c9de13ec 100644 (file)
@@ -111,6 +111,7 @@ static unsigned translate_raster_op(unsigned logicop)
 /* Copy BitBlt
  */
 void brw_copy_blit(struct brw_context *brw,
+                   unsigned do_flip,
                    unsigned cpp,
                    short src_pitch,
                    struct pipe_buffer *src_buffer,
index 7f17a7017325d5bc0ebaf3bd7dc3bda61d113282..111c5d91d3990a5c3cb6ca231affd07371792cc6 100644 (file)
@@ -16,6 +16,7 @@ void brw_fill_blit(struct brw_context *intel,
                    short w, short h,
                    unsigned color);
 void brw_copy_blit(struct brw_context *intel,
+                   unsigned do_flip,
                    unsigned cpp,
                    short src_pitch,
                    struct pipe_buffer *src_buffer,
index eb7835836ee210b7891ffd6952e4d0ca0783fa4b..518845e4b2e33caf050c68ddb65cd1e8bff40b0d 100644 (file)
@@ -103,6 +103,7 @@ brw_surface_data(struct pipe_context *pipe,
  */
 static void
 brw_surface_copy(struct pipe_context *pipe,
+                 unsigned do_flip,
                  struct pipe_surface *dst,
                  unsigned dstx, unsigned dsty,
                  struct pipe_surface *src,
@@ -118,14 +119,15 @@ brw_surface_copy(struct pipe_context *pipe,
                      dstx, dsty,
                      width, height,
                      pipe_surface_map(src) + src->offset,
-                     src->pitch,
-                     srcx, srcy);
+                     do_flip ? -src->pitch : src->pitch,
+                     srcx, do_flip ? 1 - srcy - height : srcy);
 
       pipe_surface_unmap(src);
       pipe_surface_unmap(dst);
    }
    else {
       brw_copy_blit(brw_context(pipe),
+                    do_flip,
                     dst->cpp,
                     (short) src->pitch, src->buffer, src->offset, FALSE,
                     (short) dst->pitch, dst->buffer, dst->offset, FALSE,
index 92a1cd70c42588139bd832f23c00d2d2d5fc183c..39f95695fb68f142087c89289dbbaf137ad8099c 100644 (file)
@@ -178,6 +178,7 @@ struct pipe_context {
     */
 
    void (*surface_copy)(struct pipe_context *pipe,
+                        unsigned do_flip,      /*<< flip surface contents vertically */
                        struct pipe_surface *dest,
                        unsigned destx, unsigned desty,
                        struct pipe_surface *src, /* don't make this const - 
index 469920efee32429f4c4dc210ea90e51cc15bea49..a8938a7e43b3104558102dccbc6f73ecf486734e 100644 (file)
@@ -402,7 +402,7 @@ static INLINE int align(int value, int alignment)
 extern void pipe_copy_rect(ubyte * dst, unsigned cpp, unsigned dst_pitch,
                            unsigned dst_x, unsigned dst_y, unsigned width,
                            unsigned height, const ubyte * src,
-                           unsigned src_pitch, unsigned src_x, unsigned src_y);
+                           int src_pitch, unsigned src_x, int src_y);
 
 
 #endif
index 5978ee48bd4a56df6b3ca4e09646f77a992af272..5c6ed3b8d9450028845e3c8c04fa65f3838ef000 100644 (file)
@@ -40,6 +40,7 @@
  */
 static void
 sp_surface_copy(struct pipe_context *pipe,
+                unsigned do_flip,
                struct pipe_surface *dst,
                unsigned dstx, unsigned dsty,
                struct pipe_surface *src,
@@ -53,8 +54,8 @@ sp_surface_copy(struct pipe_context *pipe,
                   dstx, dsty,
                   width, height,
                   pipe_surface_map(src),
-                  src->pitch,
-                  srcx, srcy);
+                  do_flip ? -src->pitch : src->pitch,
+                  srcx, do_flip ? 1 - srcy - height : srcy);
 
    pipe_surface_unmap(src);
    pipe_surface_unmap(dst);
index c4882b77d2dcdf5b9ebe49f53235c234268114b6..2a92f8e408b68691e46ff84f506e8fef48a8bee9 100644 (file)
@@ -47,9 +47,9 @@ pipe_copy_rect(ubyte * dst,
                unsigned width,
                unsigned height,
                const ubyte * src,
-               unsigned src_pitch,
+               int src_pitch,
                unsigned src_x, 
-               unsigned src_y)
+               int src_y)
 {
    unsigned i;
 
index 03985eab5a60ebc883e21605368e3bdde73d33fe..e5fef1d7a81abcb2684f137b6b0ffb97a8b62ad0 100644 (file)
@@ -1229,6 +1229,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
       return;
 
    pipe->surface_copy(pipe,
+                      FALSE,
                       surf_front, x, y,  /* dest */
                       surf_back, x, y,   /* src */
                       width, height);
index 3245a7488bce783af505bf050d237507d4593fc4..f13199a3c0fe787d76cb8306dfcb5a5df1ecf247 100644 (file)
@@ -1259,6 +1259,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
    if (st->haveFramebufferSurfaces) {
       /* copy source framebuffer surface into mipmap/texture */
       pipe->surface_copy(pipe,
+                         FALSE,
                         psTex, /* dest */
                         0, 0, /* destx/y */
                         psRead,
index 0ea367549b824156ec344ab79c37cccfe3030f77..91a40288cc7e39d87466e90e19d49b2ad8fb69f2 100644 (file)
@@ -1132,6 +1132,7 @@ do_copy_texsubimage(GLcontext *ctx,
    struct pipe_context *pipe = ctx->st->pipe;
    struct pipe_surface *dest_surface;
    uint dest_format, src_format;
+   uint do_flip = FALSE;
 
    (void) texImage;
 
@@ -1153,6 +1154,7 @@ do_copy_texsubimage(GLcontext *ctx,
 
    if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
       srcY = strb->Base.Height - srcY - height;
+      do_flip = TRUE;
    }
 
    src_format = strb->surface->format;
@@ -1190,6 +1192,7 @@ do_copy_texsubimage(GLcontext *ctx,
 #else
 
       pipe->surface_copy(pipe,
+                         do_flip,
                         /* dest */
                         dest_surface,
                         destX, destY,
index 2622d009530179883c6d443d423ff6b7a2e18841..b86f416c9b435d88c3c9b749bda3c443ea2f29c0 100644 (file)
@@ -300,6 +300,7 @@ st_texture_image_copy(struct pipe_context *pipe,
       src_surface = pipe->get_tex_surface(pipe, src, face, srcLevel, i);
 
       pipe->surface_copy(pipe,
+                         FALSE,
                         dst_surface,
                         0, 0, /* destX, Y */
                         src_surface,