brw_blit.c File Reference

Include dependency graph for brw_blit.c:

Go to the source code of this file.

Defines

#define FILE_DEBUG_FLAG   DEBUG_BLIT

Functions

void brw_fill_blit (struct brw_context *brw, unsigned cpp, short dst_pitch, struct pipe_buffer *dst_buffer, unsigned dst_offset, boolean dst_tiled, short x, short y, short w, short h, unsigned color)
static unsigned translate_raster_op (unsigned logicop)
void brw_copy_blit (struct brw_context *brw, unsigned do_flip, unsigned cpp, short src_pitch, struct pipe_buffer *src_buffer, unsigned src_offset, boolean src_tiled, short dst_pitch, struct pipe_buffer *dst_buffer, unsigned dst_offset, boolean dst_tiled, short src_x, short src_y, short dst_x, short dst_y, short w, short h, unsigned logic_op)


Define Documentation

#define FILE_DEBUG_FLAG   DEBUG_BLIT

Definition at line 40 of file brw_blit.c.


Function Documentation

void brw_copy_blit ( struct brw_context brw,
unsigned  do_flip,
unsigned  cpp,
short  src_pitch,
struct pipe_buffer src_buffer,
unsigned  src_offset,
boolean  src_tiled,
short  dst_pitch,
struct pipe_buffer dst_buffer,
unsigned  dst_offset,
boolean  dst_tiled,
short  src_x,
short  src_y,
short  dst_x,
short  dst_y,
short  w,
short  h,
unsigned  logic_op 
)

Definition at line 113 of file brw_blit.c.

References ADVANCE_BATCH, assert, BATCH_LOCALS, BEGIN_BATCH, BR13(), BRW_BUFFER_ACCESS_READ, BRW_BUFFER_ACCESS_WRITE, DBG, INTEL_BATCH_NO_CLIPRECTS, OUT_BATCH, OUT_RELOC, PIPE_LOGICOP_CLEAR, translate_raster_op(), XY_BLT_WRITE_ALPHA, XY_BLT_WRITE_RGB, XY_DST_TILED, XY_SRC_COPY_BLT_CMD, and XY_SRC_TILED.

00128 {
00129    unsigned CMD, BR13;
00130    int dst_y2 = dst_y + h;
00131    int dst_x2 = dst_x + w;
00132    BATCH_LOCALS;
00133 
00134 
00135    DBG("%s src:buf(%d)/%d %d,%d dst:buf(%d)/%d %d,%d sz:%dx%d op:%d\n",
00136        __FUNCTION__,
00137        src_buffer, src_pitch, src_x, src_y,
00138        dst_buffer, dst_pitch, dst_x, dst_y,
00139        w,h,logic_op);
00140 
00141    assert( logic_op - PIPE_LOGICOP_CLEAR >= 0 );
00142    assert( logic_op - PIPE_LOGICOP_CLEAR < 0x10 );
00143 
00144    src_pitch *= cpp;
00145    dst_pitch *= cpp;
00146 
00147    switch(cpp) {
00148    case 1:
00149    case 2:
00150    case 3:
00151       BR13 = (translate_raster_op(logic_op) << 16) | (1<<24);
00152       CMD = XY_SRC_COPY_BLT_CMD;
00153       break;
00154    case 4:
00155       BR13 = (translate_raster_op(logic_op) << 16) | (1<<24) |
00156           (1<<25);
00157       CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
00158       break;
00159    default:
00160       return;
00161    }
00162 
00163    if (src_tiled) {
00164       CMD |= XY_SRC_TILED;
00165       src_pitch /= 4;
00166    }
00167 
00168    if (dst_tiled) {
00169       CMD |= XY_DST_TILED;
00170       dst_pitch /= 4;
00171    }
00172 
00173    if (dst_y2 < dst_y ||
00174        dst_x2 < dst_x) {
00175       return;
00176    }
00177 
00178    dst_pitch &= 0xffff;
00179    src_pitch &= 0xffff;
00180 
00181    /* Initial y values don't seem to work with negative pitches.  If
00182     * we adjust the offsets manually (below), it seems to work fine.
00183     *
00184     * On the other hand, if we always adjust, the hardware doesn't
00185     * know which blit directions to use, so overlapping copypixels get
00186     * the wrong result.
00187     */
00188    if (dst_pitch > 0 && src_pitch > 0) {
00189       BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
00190       OUT_BATCH( CMD );
00191       OUT_BATCH( dst_pitch | BR13 );
00192       OUT_BATCH( (dst_y << 16) | dst_x );
00193       OUT_BATCH( (dst_y2 << 16) | dst_x2 );
00194       OUT_RELOC( dst_buffer, BRW_BUFFER_ACCESS_WRITE,
00195                  dst_offset );
00196       OUT_BATCH( (src_y << 16) | src_x );
00197       OUT_BATCH( src_pitch );
00198       OUT_RELOC( src_buffer, BRW_BUFFER_ACCESS_READ,
00199                  src_offset );
00200       ADVANCE_BATCH();
00201    }
00202    else {
00203       BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
00204       OUT_BATCH( CMD );
00205       OUT_BATCH( (dst_pitch & 0xffff) | BR13 );
00206       OUT_BATCH( (0 << 16) | dst_x );
00207       OUT_BATCH( (h << 16) | dst_x2 );
00208       OUT_RELOC( dst_buffer, BRW_BUFFER_ACCESS_WRITE,
00209                  dst_offset + dst_y * dst_pitch );
00210       OUT_BATCH( (src_pitch & 0xffff) );
00211       OUT_RELOC( src_buffer, BRW_BUFFER_ACCESS_READ,
00212                  src_offset + src_y * src_pitch );
00213       ADVANCE_BATCH();
00214    }
00215 }

void brw_fill_blit ( struct brw_context brw,
unsigned  cpp,
short  dst_pitch,
struct pipe_buffer dst_buffer,
unsigned  dst_offset,
boolean  dst_tiled,
short  x,
short  y,
short  w,
short  h,
unsigned  color 
)

Definition at line 42 of file brw_blit.c.

References ADVANCE_BATCH, BATCH_LOCALS, BEGIN_BATCH, BR13(), BRW_BUFFER_ACCESS_WRITE, INTEL_BATCH_NO_CLIPRECTS, OUT_BATCH, OUT_RELOC, XY_BLT_WRITE_ALPHA, XY_BLT_WRITE_RGB, XY_COLOR_BLT_CMD, and XY_DST_TILED.

00051 {
00052    unsigned BR13, CMD;
00053    BATCH_LOCALS;
00054 
00055    dst_pitch *= cpp;
00056 
00057    switch(cpp) {
00058    case 1:
00059    case 2:
00060    case 3:
00061       BR13 = (0xF0 << 16) | (1<<24);
00062       CMD = XY_COLOR_BLT_CMD;
00063       break;
00064    case 4:
00065       BR13 = (0xF0 << 16) | (1<<24) | (1<<25);
00066       CMD = XY_COLOR_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
00067       break;
00068    default:
00069       return;
00070    }
00071 
00072    if (dst_tiled) {
00073       CMD |= XY_DST_TILED;
00074       dst_pitch /= 4;
00075    }
00076 
00077    BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS);
00078    OUT_BATCH( CMD );
00079    OUT_BATCH( dst_pitch | BR13 );
00080    OUT_BATCH( (y << 16) | x );
00081    OUT_BATCH( ((y+h) << 16) | (x+w) );
00082    OUT_RELOC( dst_buffer, BRW_BUFFER_ACCESS_WRITE, dst_offset );
00083    OUT_BATCH( color );
00084    ADVANCE_BATCH();
00085 }

static unsigned translate_raster_op ( unsigned  logicop  )  [static]

Definition at line 87 of file brw_blit.c.

References PIPE_LOGICOP_AND, PIPE_LOGICOP_AND_INVERTED, PIPE_LOGICOP_AND_REVERSE, PIPE_LOGICOP_CLEAR, PIPE_LOGICOP_COPY, PIPE_LOGICOP_COPY_INVERTED, PIPE_LOGICOP_EQUIV, PIPE_LOGICOP_INVERT, PIPE_LOGICOP_NAND, PIPE_LOGICOP_NOOP, PIPE_LOGICOP_NOR, PIPE_LOGICOP_OR, PIPE_LOGICOP_OR_INVERTED, PIPE_LOGICOP_OR_REVERSE, PIPE_LOGICOP_SET, and PIPE_LOGICOP_XOR.

00088 {
00089    switch(logicop) {
00090    case PIPE_LOGICOP_CLEAR: return 0x00;
00091    case PIPE_LOGICOP_AND: return 0x88;
00092    case PIPE_LOGICOP_AND_REVERSE: return 0x44;
00093    case PIPE_LOGICOP_COPY: return 0xCC;
00094    case PIPE_LOGICOP_AND_INVERTED: return 0x22;
00095    case PIPE_LOGICOP_NOOP: return 0xAA;
00096    case PIPE_LOGICOP_XOR: return 0x66;
00097    case PIPE_LOGICOP_OR: return 0xEE;
00098    case PIPE_LOGICOP_NOR: return 0x11;
00099    case PIPE_LOGICOP_EQUIV: return 0x99;
00100    case PIPE_LOGICOP_INVERT: return 0x55;
00101    case PIPE_LOGICOP_OR_REVERSE: return 0xDD;
00102    case PIPE_LOGICOP_COPY_INVERTED: return 0x33;
00103    case PIPE_LOGICOP_OR_INVERTED: return 0xBB;
00104    case PIPE_LOGICOP_NAND: return 0x77;
00105    case PIPE_LOGICOP_SET: return 0xFF;
00106    default: return 0;
00107    }
00108 }


Generated on Tue Sep 29 06:25:35 2009 for Gallium3D by  doxygen 1.5.4