6 #include "i810screen.h"
10 #include "i810ioctl.h"
11 #include "swrast/swrast.h"
17 i810ContextPtr imesa = I810_CONTEXT(ctx); \
18 __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
19 i810ScreenPrivate *i810Screen = imesa->i810Screen; \
20 GLuint pitch = i810Screen->backPitch; \
21 GLuint height = dPriv->h; \
23 char *buf = (char *)(imesa->drawMap + \
26 char *read_buf = (char *)(imesa->readMap + \
29 (void) read_buf; (void) buf; (void) p
31 #define LOCAL_DEPTH_VARS \
32 i810ContextPtr imesa = I810_CONTEXT(ctx); \
33 __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
34 i810ScreenPrivate *i810Screen = imesa->i810Screen; \
35 GLuint pitch = i810Screen->backPitch; \
36 GLuint height = dPriv->h; \
37 char *buf = (char *)(i810Screen->depth.map + \
41 #define INIT_MONO_PIXEL(p, color) \
42 p = PACK_COLOR_565( color[0], color[1], color[2] )
44 #define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
45 _y >= miny && _y < maxy)
48 #define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
49 if ( _y < miny || _y >= maxy ) { \
54 if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
55 if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
58 #define Y_FLIP(_y) (height - _y - 1)
62 #define HW_CLIPLOOP() \
64 __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
65 int _nc = dPriv->numClipRects; \
67 int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
68 int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
69 int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
70 int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
73 #define HW_ENDCLIPLOOP() \
79 /* 16 bit, 565 rgb color spanline and pixel functions
81 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
82 *(GLushort *)(buf + _x*2 + _y*pitch) = ( (((int)r & 0xf8) << 8) | \
83 (((int)g & 0xfc) << 3) | \
84 (((int)b & 0xf8) >> 3))
85 #define WRITE_PIXEL( _x, _y, p ) \
86 *(GLushort *)(buf + _x*2 + _y*pitch) = p
88 #define READ_RGBA( rgba, _x, _y ) \
90 GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
91 rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
92 rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
93 rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
97 #define TAG(x) i810##x##_565
102 /* 16 bit depthbuffer functions.
104 #define WRITE_DEPTH( _x, _y, d ) \
105 *(GLushort *)(buf + _x*2 + _y*pitch) = d;
107 #define READ_DEPTH( d, _x, _y ) \
108 d = *(GLushort *)(buf + _x*2 + _y*pitch);
110 #define TAG(x) i810##x##_16
111 #include "depthtmp.h"
115 * This function is called to specify which buffer to read and write
116 * for software rasterization (swrast) fallbacks. This doesn't necessarily
117 * correspond to glDrawBuffer() or glReadBuffer() calls.
119 static void i810SetBuffer(GLcontext
*ctx
, GLframebuffer
*buffer
,
122 i810ContextPtr imesa
= I810_CONTEXT(ctx
);
127 if ( imesa
->sarea
->pf_current_page
== 1)
128 imesa
->readMap
= imesa
->i810Screen
->back
.map
;
130 imesa
->readMap
= (char*)imesa
->driScreen
->pFB
;
133 if ( imesa
->sarea
->pf_current_page
== 1)
134 imesa
->readMap
= (char*)imesa
->driScreen
->pFB
;
136 imesa
->readMap
= imesa
->i810Screen
->back
.map
;
142 imesa
->drawMap
= imesa
->readMap
;
145 /* Move locking out to get reasonable span performance.
147 void i810SpanRenderStart( GLcontext
*ctx
)
149 i810ContextPtr imesa
= I810_CONTEXT(ctx
);
150 I810_FIREVERTICES(imesa
);
151 LOCK_HARDWARE(imesa
);
152 i810RegetLockQuiescent( imesa
);
155 void i810SpanRenderFinish( GLcontext
*ctx
)
157 i810ContextPtr imesa
= I810_CONTEXT( ctx
);
158 _swrast_flush( ctx
);
159 UNLOCK_HARDWARE( imesa
);
162 void i810InitSpanFuncs( GLcontext
*ctx
)
164 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference(ctx
);
166 swdd
->SetBuffer
= i810SetBuffer
;
168 swdd
->WriteRGBASpan
= i810WriteRGBASpan_565
;
169 swdd
->WriteRGBSpan
= i810WriteRGBSpan_565
;
170 swdd
->WriteMonoRGBASpan
= i810WriteMonoRGBASpan_565
;
171 swdd
->WriteRGBAPixels
= i810WriteRGBAPixels_565
;
172 swdd
->WriteMonoRGBAPixels
= i810WriteMonoRGBAPixels_565
;
173 swdd
->ReadRGBASpan
= i810ReadRGBASpan_565
;
174 swdd
->ReadRGBAPixels
= i810ReadRGBAPixels_565
;
176 swdd
->ReadDepthSpan
= i810ReadDepthSpan_16
;
177 swdd
->WriteDepthSpan
= i810WriteDepthSpan_16
;
178 swdd
->ReadDepthPixels
= i810ReadDepthPixels_16
;
179 swdd
->WriteDepthPixels
= i810WriteDepthPixels_16
;
181 swdd
->SpanRenderStart
= i810SpanRenderStart
;
182 swdd
->SpanRenderFinish
= i810SpanRenderFinish
;