1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include "i915_winsys.h"
30 #include "i915_blit.h"
32 #include "i915_batch.h"
33 #include "i915_debug.h"
35 #define FILE_DEBUG_FLAG DEBUG_BLIT
38 i915_fill_blit(struct i915_context
*i915
,
40 unsigned short dst_pitch
,
41 struct pipe_buffer
*dst_buffer
,
51 "%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
53 dst_buffer
, dst_pitch
, dst_offset
, x
, y
, w
, h
);
59 BR13
= (((int) dst_pitch
) & 0xffff) |
60 (0xF0 << 16) | (1 << 24);
61 CMD
= XY_COLOR_BLT_CMD
;
64 BR13
= (((int) dst_pitch
) & 0xffff) |
65 (0xF0 << 16) | (1 << 24) | (1 << 25);
66 CMD
= (XY_COLOR_BLT_CMD
| XY_COLOR_BLT_WRITE_ALPHA
|
67 XY_COLOR_BLT_WRITE_RGB
);
73 if (!BEGIN_BATCH(6, 1)) {
75 assert(BEGIN_BATCH(6, 1));
79 OUT_BATCH((y
<< 16) | x
);
80 OUT_BATCH(((y
+ h
) << 16) | (x
+ w
));
81 OUT_RELOC(dst_buffer
, I915_BUFFER_ACCESS_WRITE
, dst_offset
);
87 i915_copy_blit(struct i915_context
*i915
,
90 unsigned short src_pitch
,
91 struct pipe_buffer
*src_buffer
,
93 unsigned short dst_pitch
,
94 struct pipe_buffer
*dst_buffer
,
96 short src_x
, short src_y
,
97 short dst_x
, short dst_y
,
101 int dst_y2
= dst_y
+ h
;
102 int dst_x2
= dst_x
+ w
;
106 "%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
108 src_buffer
, src_pitch
, src_offset
, src_x
, src_y
,
109 dst_buffer
, dst_pitch
, dst_offset
, dst_x
, dst_y
, w
, h
);
115 BR13
= (((int) dst_pitch
) & 0xffff) |
116 (0xCC << 16) | (1 << 24);
117 CMD
= XY_SRC_COPY_BLT_CMD
;
120 BR13
= (((int) dst_pitch
) & 0xffff) |
121 (0xCC << 16) | (1 << 24) | (1 << 25);
122 CMD
= (XY_SRC_COPY_BLT_CMD
| XY_SRC_COPY_BLT_WRITE_ALPHA
|
123 XY_SRC_COPY_BLT_WRITE_RGB
);
129 if (dst_y2
< dst_y
|| dst_x2
< dst_x
) {
133 /* Hardware can handle negative pitches but loses the ability to do
134 * proper overlapping blits in that case. We don't really have a
135 * need for either at this stage.
137 assert (dst_pitch
> 0 && src_pitch
> 0);
139 if (!BEGIN_BATCH(8, 2)) {
141 assert(BEGIN_BATCH(8, 2));
145 OUT_BATCH((dst_y
<< 16) | dst_x
);
146 OUT_BATCH((dst_y2
<< 16) | dst_x2
);
147 OUT_RELOC(dst_buffer
, I915_BUFFER_ACCESS_WRITE
, dst_offset
);
148 OUT_BATCH((src_y
<< 16) | src_x
);
149 OUT_BATCH(((int) src_pitch
& 0xffff));
150 OUT_RELOC(src_buffer
, I915_BUFFER_ACCESS_READ
, src_offset
);