gallium: pipe->surface_copy can flip the contents vertically when necessary.

Fixes gears being upside down on the box in demos/gearbox.
This commit is contained in:
Michel Dänzer
2008-02-13 11:39:58 +00:00
parent 4bb1a14d90
commit e922adbe1d
15 changed files with 28 additions and 11 deletions

View File

@@ -60,6 +60,7 @@ cell_surface_data(struct pipe_context *pipe,
static void static void
cell_surface_copy(struct pipe_context *pipe, cell_surface_copy(struct pipe_context *pipe,
unsigned do_flip,
struct pipe_surface *dst, struct pipe_surface *dst,
unsigned dstx, unsigned dsty, unsigned dstx, unsigned dsty,
struct pipe_surface *src, struct pipe_surface *src,
@@ -74,8 +75,8 @@ cell_surface_copy(struct pipe_context *pipe,
dstx, dsty, dstx, dsty,
width, height, width, height,
pipe_surface_map(src), pipe_surface_map(src),
src->pitch, do_flip ? -src->pitch : src->pitch,
srcx, srcy); srcx, do_flip ? 1 - srcy - height : srcy);
pipe_surface_unmap(src); pipe_surface_unmap(src);
pipe_surface_unmap(dst); pipe_surface_unmap(dst);

View File

@@ -85,6 +85,7 @@ i915_fill_blit(struct i915_context *i915,
void void
i915_copy_blit( struct i915_context *i915, i915_copy_blit( struct i915_context *i915,
unsigned do_flip,
unsigned cpp, unsigned cpp,
short src_pitch, short src_pitch,
struct pipe_buffer *src_buffer, struct pipe_buffer *src_buffer,

View File

@@ -31,6 +31,7 @@
#include "i915_context.h" #include "i915_context.h"
extern void i915_copy_blit(struct i915_context *i915, extern void i915_copy_blit(struct i915_context *i915,
unsigned do_flip,
unsigned cpp, unsigned cpp,
short src_pitch, short src_pitch,
struct pipe_buffer *src_buffer, struct pipe_buffer *src_buffer,

View File

@@ -83,6 +83,7 @@ i915_get_tex_surface(struct pipe_context *pipe,
*/ */
static void static void
i915_surface_copy(struct pipe_context *pipe, i915_surface_copy(struct pipe_context *pipe,
unsigned do_flip,
struct pipe_surface *dst, struct pipe_surface *dst,
unsigned dstx, unsigned dsty, unsigned dstx, unsigned dsty,
struct pipe_surface *src, struct pipe_surface *src,
@@ -98,14 +99,15 @@ i915_surface_copy(struct pipe_context *pipe,
dstx, dsty, dstx, dsty,
width, height, width, height,
pipe_surface_map(src), pipe_surface_map(src),
src->pitch, do_flip ? -src->pitch : src->pitch,
srcx, srcy); srcx, do_flip ? 1 - srcy - height : srcy);
pipe_surface_unmap(src); pipe_surface_unmap(src);
pipe_surface_unmap(dst); pipe_surface_unmap(dst);
} }
else { else {
i915_copy_blit( i915_context(pipe), i915_copy_blit( i915_context(pipe),
do_flip,
dst->cpp, dst->cpp,
(short) src->pitch, src->buffer, src->offset, (short) src->pitch, src->buffer, src->offset,
(short) dst->pitch, dst->buffer, dst->offset, (short) dst->pitch, dst->buffer, dst->offset,

View File

@@ -111,6 +111,7 @@ static unsigned translate_raster_op(unsigned logicop)
/* Copy BitBlt /* Copy BitBlt
*/ */
void brw_copy_blit(struct brw_context *brw, void brw_copy_blit(struct brw_context *brw,
unsigned do_flip,
unsigned cpp, unsigned cpp,
short src_pitch, short src_pitch,
struct pipe_buffer *src_buffer, struct pipe_buffer *src_buffer,

View File

@@ -16,6 +16,7 @@ void brw_fill_blit(struct brw_context *intel,
short w, short h, short w, short h,
unsigned color); unsigned color);
void brw_copy_blit(struct brw_context *intel, void brw_copy_blit(struct brw_context *intel,
unsigned do_flip,
unsigned cpp, unsigned cpp,
short src_pitch, short src_pitch,
struct pipe_buffer *src_buffer, struct pipe_buffer *src_buffer,

View File

@@ -103,6 +103,7 @@ brw_surface_data(struct pipe_context *pipe,
*/ */
static void static void
brw_surface_copy(struct pipe_context *pipe, brw_surface_copy(struct pipe_context *pipe,
unsigned do_flip,
struct pipe_surface *dst, struct pipe_surface *dst,
unsigned dstx, unsigned dsty, unsigned dstx, unsigned dsty,
struct pipe_surface *src, struct pipe_surface *src,
@@ -118,14 +119,15 @@ brw_surface_copy(struct pipe_context *pipe,
dstx, dsty, dstx, dsty,
width, height, width, height,
pipe_surface_map(src) + src->offset, pipe_surface_map(src) + src->offset,
src->pitch, do_flip ? -src->pitch : src->pitch,
srcx, srcy); srcx, do_flip ? 1 - srcy - height : srcy);
pipe_surface_unmap(src); pipe_surface_unmap(src);
pipe_surface_unmap(dst); pipe_surface_unmap(dst);
} }
else { else {
brw_copy_blit(brw_context(pipe), brw_copy_blit(brw_context(pipe),
do_flip,
dst->cpp, dst->cpp,
(short) src->pitch, src->buffer, src->offset, FALSE, (short) src->pitch, src->buffer, src->offset, FALSE,
(short) dst->pitch, dst->buffer, dst->offset, FALSE, (short) dst->pitch, dst->buffer, dst->offset, FALSE,

View File

@@ -178,6 +178,7 @@ struct pipe_context {
*/ */
void (*surface_copy)(struct pipe_context *pipe, void (*surface_copy)(struct pipe_context *pipe,
unsigned do_flip, /*<< flip surface contents vertically */
struct pipe_surface *dest, struct pipe_surface *dest,
unsigned destx, unsigned desty, unsigned destx, unsigned desty,
struct pipe_surface *src, /* don't make this const - struct pipe_surface *src, /* don't make this const -

View 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, extern void pipe_copy_rect(ubyte * dst, unsigned cpp, unsigned dst_pitch,
unsigned dst_x, unsigned dst_y, unsigned width, unsigned dst_x, unsigned dst_y, unsigned width,
unsigned height, const ubyte * src, unsigned height, const ubyte * src,
unsigned src_pitch, unsigned src_x, unsigned src_y); int src_pitch, unsigned src_x, int src_y);
#endif #endif

View File

@@ -40,6 +40,7 @@
*/ */
static void static void
sp_surface_copy(struct pipe_context *pipe, sp_surface_copy(struct pipe_context *pipe,
unsigned do_flip,
struct pipe_surface *dst, struct pipe_surface *dst,
unsigned dstx, unsigned dsty, unsigned dstx, unsigned dsty,
struct pipe_surface *src, struct pipe_surface *src,
@@ -53,8 +54,8 @@ sp_surface_copy(struct pipe_context *pipe,
dstx, dsty, dstx, dsty,
width, height, width, height,
pipe_surface_map(src), pipe_surface_map(src),
src->pitch, do_flip ? -src->pitch : src->pitch,
srcx, srcy); srcx, do_flip ? 1 - srcy - height : srcy);
pipe_surface_unmap(src); pipe_surface_unmap(src);
pipe_surface_unmap(dst); pipe_surface_unmap(dst);

View File

@@ -47,9 +47,9 @@ pipe_copy_rect(ubyte * dst,
unsigned width, unsigned width,
unsigned height, unsigned height,
const ubyte * src, const ubyte * src,
unsigned src_pitch, int src_pitch,
unsigned src_x, unsigned src_x,
unsigned src_y) int src_y)
{ {
unsigned i; unsigned i;

View File

@@ -1229,6 +1229,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
return; return;
pipe->surface_copy(pipe, pipe->surface_copy(pipe,
FALSE,
surf_front, x, y, /* dest */ surf_front, x, y, /* dest */
surf_back, x, y, /* src */ surf_back, x, y, /* src */
width, height); width, height);

View File

@@ -1259,6 +1259,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (st->haveFramebufferSurfaces) { if (st->haveFramebufferSurfaces) {
/* copy source framebuffer surface into mipmap/texture */ /* copy source framebuffer surface into mipmap/texture */
pipe->surface_copy(pipe, pipe->surface_copy(pipe,
FALSE,
psTex, /* dest */ psTex, /* dest */
0, 0, /* destx/y */ 0, 0, /* destx/y */
psRead, psRead,

View File

@@ -1132,6 +1132,7 @@ do_copy_texsubimage(GLcontext *ctx,
struct pipe_context *pipe = ctx->st->pipe; struct pipe_context *pipe = ctx->st->pipe;
struct pipe_surface *dest_surface; struct pipe_surface *dest_surface;
uint dest_format, src_format; uint dest_format, src_format;
uint do_flip = FALSE;
(void) texImage; (void) texImage;
@@ -1153,6 +1154,7 @@ do_copy_texsubimage(GLcontext *ctx,
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
srcY = strb->Base.Height - srcY - height; srcY = strb->Base.Height - srcY - height;
do_flip = TRUE;
} }
src_format = strb->surface->format; src_format = strb->surface->format;
@@ -1190,6 +1192,7 @@ do_copy_texsubimage(GLcontext *ctx,
#else #else
pipe->surface_copy(pipe, pipe->surface_copy(pipe,
do_flip,
/* dest */ /* dest */
dest_surface, dest_surface,
destX, destY, destX, destY,

View File

@@ -300,6 +300,7 @@ st_texture_image_copy(struct pipe_context *pipe,
src_surface = pipe->get_tex_surface(pipe, src, face, srcLevel, i); src_surface = pipe->get_tex_surface(pipe, src, face, srcLevel, i);
pipe->surface_copy(pipe, pipe->surface_copy(pipe,
FALSE,
dst_surface, dst_surface,
0, 0, /* destX, Y */ 0, 0, /* destX, Y */
src_surface, src_surface,