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 Y_FLIP(_y) (height - _y - 1)
50 /* 16 bit, 565 rgb color spanline and pixel functions
52 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
53 *(GLushort *)(buf + _x*2 + _y*pitch) = ( (((int)r & 0xf8) << 8) | \
54 (((int)g & 0xfc) << 3) | \
55 (((int)b & 0xf8) >> 3))
56 #define WRITE_PIXEL( _x, _y, p ) \
57 *(GLushort *)(buf + _x*2 + _y*pitch) = p
59 #define READ_RGBA( rgba, _x, _y ) \
61 GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
62 rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
63 rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
64 rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
68 #define TAG(x) i810##x##_565
71 /* 16 bit depthbuffer functions.
73 #define WRITE_DEPTH( _x, _y, d ) \
74 *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
76 #define READ_DEPTH( d, _x, _y ) \
77 d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
79 #define TAG(x) i810##x##_16
84 * This function is called to specify which buffer to read and write
85 * for software rasterization (swrast) fallbacks. This doesn't necessarily
86 * correspond to glDrawBuffer() or glReadBuffer() calls.
88 static void i810SetBuffer(GLcontext
*ctx
, GLframebuffer
*buffer
,
91 i810ContextPtr imesa
= I810_CONTEXT(ctx
);
95 case BUFFER_BIT_FRONT_LEFT
:
96 if ( imesa
->sarea
->pf_current_page
== 1)
97 imesa
->readMap
= imesa
->i810Screen
->back
.map
;
99 imesa
->readMap
= (char*)imesa
->driScreen
->pFB
;
101 case BUFFER_BIT_BACK_LEFT
:
102 if ( imesa
->sarea
->pf_current_page
== 1)
103 imesa
->readMap
= (char*)imesa
->driScreen
->pFB
;
105 imesa
->readMap
= imesa
->i810Screen
->back
.map
;
111 imesa
->drawMap
= imesa
->readMap
;
114 /* Move locking out to get reasonable span performance.
116 void i810SpanRenderStart( GLcontext
*ctx
)
118 i810ContextPtr imesa
= I810_CONTEXT(ctx
);
119 I810_FIREVERTICES(imesa
);
120 LOCK_HARDWARE(imesa
);
121 i810RegetLockQuiescent( imesa
);
124 void i810SpanRenderFinish( GLcontext
*ctx
)
126 i810ContextPtr imesa
= I810_CONTEXT( ctx
);
127 _swrast_flush( ctx
);
128 UNLOCK_HARDWARE( imesa
);
131 void i810InitSpanFuncs( GLcontext
*ctx
)
133 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference(ctx
);
135 swdd
->SetBuffer
= i810SetBuffer
;
138 swdd
->WriteRGBASpan
= i810WriteRGBASpan_565
;
139 swdd
->WriteRGBSpan
= i810WriteRGBSpan_565
;
140 swdd
->WriteMonoRGBASpan
= i810WriteMonoRGBASpan_565
;
141 swdd
->WriteRGBAPixels
= i810WriteRGBAPixels_565
;
142 swdd
->WriteMonoRGBAPixels
= i810WriteMonoRGBAPixels_565
;
143 swdd
->ReadRGBASpan
= i810ReadRGBASpan_565
;
144 swdd
->ReadRGBAPixels
= i810ReadRGBAPixels_565
;
148 swdd
->ReadDepthSpan
= i810ReadDepthSpan_16
;
149 swdd
->WriteDepthSpan
= i810WriteDepthSpan_16
;
150 swdd
->ReadDepthPixels
= i810ReadDepthPixels_16
;
151 swdd
->WriteDepthPixels
= i810WriteDepthPixels_16
;
154 swdd
->SpanRenderStart
= i810SpanRenderStart
;
155 swdd
->SpanRenderFinish
= i810SpanRenderFinish
;
161 * Plug in the Get/Put routines for the given driRenderbuffer.
164 i810SetSpanFunctions(driRenderbuffer
*drb
, const GLvisual
*vis
)
166 if (drb
->Base
.InternalFormat
== GL_RGBA
) {
168 drb
->Base
.GetRow
= i810ReadRGBASpan_565
;
169 drb
->Base
.GetValues
= i810ReadRGBAPixels_565
;
170 drb
->Base
.PutRow
= i810WriteRGBASpan_565
;
171 drb
->Base
.PutRowRGB
= i810WriteRGBSpan_565
;
172 drb
->Base
.PutMonoRow
= i810WriteMonoRGBASpan_565
;
173 drb
->Base
.PutValues
= i810WriteRGBAPixels_565
;
174 drb
->Base
.PutMonoValues
= i810WriteMonoRGBAPixels_565
;
176 else if (drb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT16
) {
177 drb
->Base
.GetRow
= i810ReadDepthSpan_16
;
178 drb
->Base
.GetValues
= i810ReadDepthPixels_16
;
179 drb
->Base
.PutRow
= i810WriteDepthSpan_16
;
180 drb
->Base
.PutMonoRow
= i810WriteMonoDepthSpan_16
;
181 drb
->Base
.PutValues
= i810WriteDepthPixels_16
;
182 drb
->Base
.PutMonoValues
= NULL
;
184 else if (drb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT24
) {
185 /* should never get here */
186 drb
->Base
.GetRow
= NULL
;
187 drb
->Base
.GetValues
= NULL
;
188 drb
->Base
.PutRow
= NULL
;
189 drb
->Base
.PutMonoRow
= NULL
;
190 drb
->Base
.PutValues
= NULL
;
191 drb
->Base
.PutMonoValues
= NULL
;
193 else if (drb
->Base
.InternalFormat
== GL_STENCIL_INDEX8_EXT
) {
194 drb
->Base
.GetRow
= NULL
;
195 drb
->Base
.GetValues
= NULL
;
196 drb
->Base
.PutRow
= NULL
;
197 drb
->Base
.PutMonoRow
= NULL
;
198 drb
->Base
.PutValues
= NULL
;
199 drb
->Base
.PutMonoValues
= NULL
;