Alpha test fix
[mesa.git] / src / mesa / drivers / directfb / idirectfbgl_mesa.c
1 /*
2 * Copyright (C) 2004 Claudio Ciccani <klan@users.sf.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 *
18 * Based on glfbdev.c, written by Brian Paul.
19 *
20 */
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <unistd.h>
25
26 #include <directfb.h>
27
28 #include <direct/messages.h>
29 #include <direct/interface.h>
30 #include <direct/mem.h>
31
32 #ifdef CLAMP
33 # undef CLAMP
34 #endif
35
36 #include "GL/directfbgl.h"
37 #include "glheader.h"
38 #include "buffers.h"
39 #include "context.h"
40 #include "extensions.h"
41 #include "imports.h"
42 #include "texformat.h"
43 #include "teximage.h"
44 #include "texstore.h"
45 #include "array_cache/acache.h"
46 #include "swrast/swrast.h"
47 #include "swrast_setup/swrast_setup.h"
48 #include "tnl/tnl.h"
49 #include "tnl/t_context.h"
50 #include "tnl/t_pipeline.h"
51 #include "drivers/common/driverfuncs.h"
52
53
54 static DFBResult
55 Probe( void *data );
56
57 static DFBResult
58 Construct( IDirectFBGL *thiz,
59 IDirectFBSurface *surface );
60
61 #include <direct/interface_implementation.h>
62
63 DIRECT_INTERFACE_IMPLEMENTATION( IDirectFBGL, Mesa )
64
65 /*
66 * private data struct of IDirectFBGL
67 */
68 typedef struct {
69 int ref; /* reference counter */
70
71 bool locked;
72
73 IDirectFBSurface *surface;
74 DFBSurfacePixelFormat format;
75 int width;
76 int height;
77
78 struct {
79 __u8 *start;
80 __u8 *end;
81 int pitch;
82 } video;
83
84 GLvisual visual;
85 GLframebuffer framebuffer;
86 GLcontext context;
87 } IDirectFBGL_data;
88
89
90 static bool dfb_mesa_setup_visual ( GLvisual *visual,
91 DFBSurfacePixelFormat format );
92 static bool dfb_mesa_create_context ( GLcontext *context,
93 GLframebuffer *framebuffer,
94 GLvisual *visual,
95 DFBSurfacePixelFormat format,
96 void *data );
97 static void dfb_mesa_destroy_context( GLcontext *context,
98 GLframebuffer *framebuffer );
99
100
101 static void
102 IDirectFBGL_Destruct( IDirectFBGL *thiz )
103 {
104 IDirectFBGL_data *data = (IDirectFBGL_data*) thiz->priv;
105
106 dfb_mesa_destroy_context( &data->context, &data->framebuffer );
107
108 data->surface->Release( data->surface );
109
110 DIRECT_DEALLOCATE_INTERFACE( thiz );
111 }
112
113 static DFBResult
114 IDirectFBGL_AddRef( IDirectFBGL *thiz )
115 {
116 DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
117
118 data->ref++;
119
120 return DFB_OK;
121 }
122
123 static DFBResult
124 IDirectFBGL_Release( IDirectFBGL *thiz )
125 {
126 DIRECT_INTERFACE_GET_DATA( IDirectFBGL )
127
128 if (--data->ref == 0) {
129 IDirectFBGL_Destruct( thiz );
130 }
131
132 return DFB_OK;
133 }
134
135 static DFBResult
136 IDirectFBGL_Lock( IDirectFBGL *thiz )
137 {
138 IDirectFBSurface *surface;
139 int width = 0;
140 int height = 0;
141 DFBResult err;
142
143 DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
144
145 if (data->locked)
146 return DFB_LOCKED;
147
148 surface = data->surface;
149 surface->GetSize( surface, &width, &height );
150
151 err = surface->Lock( surface, DSLF_READ | DSLF_WRITE,
152 (void**) &data->video.start, &data->video.pitch );
153 if (err != DFB_OK) {
154 D_ERROR( "DirectFBGL/Mesa: couldn't lock surface.\n" );
155 return err;
156 }
157 data->video.end = data->video.start + (height-1) * data->video.pitch;
158
159 if (data->width != width || data->height != height) {
160 data->width = width;
161 data->height = height;
162 _mesa_ResizeBuffersMESA();
163 }
164
165 data->locked = true;
166
167 return DFB_OK;
168 }
169
170 static DFBResult
171 IDirectFBGL_Unlock( IDirectFBGL *thiz )
172 {
173 DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
174
175 if (!data->locked)
176 return DFB_OK;
177
178 data->surface->Unlock( data->surface );
179 data->video.start = NULL;
180 data->video.end = NULL;
181
182 data->locked = false;
183
184 return DFB_OK;
185 }
186
187 static DFBResult
188 IDirectFBGL_GetAttributes( IDirectFBGL *thiz,
189 DFBGLAttributes *attributes )
190 {
191 GLvisual *visual;
192
193 DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
194
195 if (!attributes)
196 return DFB_INVARG;
197
198 visual = &data->visual;
199
200 attributes->buffer_size = visual->rgbBits ? : visual->indexBits;
201 attributes->depth_size = visual->depthBits;
202 attributes->stencil_size = visual->stencilBits;
203 attributes->aux_buffers = visual->numAuxBuffers;
204 attributes->red_size = visual->redBits;
205 attributes->green_size = visual->greenBits;
206 attributes->blue_size = visual->blueBits;
207 attributes->alpha_size = visual->alphaBits;
208 attributes->accum_red_size = visual->accumRedBits;
209 attributes->accum_green_size = visual->accumGreenBits;
210 attributes->accum_blue_size = visual->accumBlueBits;
211 attributes->accum_alpha_size = visual->accumAlphaBits;
212 attributes->double_buffer = (visual->doubleBufferMode != 0);
213 attributes->stereo = (visual->stereoMode != 0);
214
215 return DFB_OK;
216 }
217
218
219 /* exported symbols */
220
221 static DFBResult
222 Probe( void *data )
223 {
224 return DFB_OK;
225 }
226
227 static DFBResult
228 Construct( IDirectFBGL *thiz,
229 IDirectFBSurface *surface )
230 {
231 /* Allocate interface data. */
232 DIRECT_ALLOCATE_INTERFACE_DATA( thiz, IDirectFBGL );
233
234 /* Initialize interface data. */
235 data->ref = 1;
236 data->surface = surface;
237
238 surface->AddRef( surface );
239 surface->GetPixelFormat( surface, &data->format );
240 surface->GetSize( surface, &data->width, &data->height );
241
242 /* Configure visual. */
243 if (!dfb_mesa_setup_visual( &data->visual, data->format )) {
244 D_ERROR( "DirectFBGL/Mesa: failed to initialize visual.\n" );
245 surface->Release( surface );
246 return DFB_UNSUPPORTED;
247 }
248
249 /* Create context. */
250 if (!dfb_mesa_create_context( &data->context, &data->framebuffer,
251 &data->visual, data->format, (void*) data )) {
252 D_ERROR( "DirectFBGL/Mesa: failed to create context.\n" );
253 surface->Release( surface );
254 return DFB_UNSUPPORTED;
255 }
256
257 /* Assign interface pointers. */
258 thiz->AddRef = IDirectFBGL_AddRef;
259 thiz->Release = IDirectFBGL_Release;
260 thiz->Lock = IDirectFBGL_Lock;
261 thiz->Unlock = IDirectFBGL_Unlock;
262 thiz->GetAttributes = IDirectFBGL_GetAttributes;
263
264 return DFB_OK;
265 }
266
267
268 /* internal functions */
269
270 static const GLubyte*
271 get_string( GLcontext *ctx, GLenum pname )
272 {
273 switch (pname) {
274 case GL_VENDOR:
275 return "Claudio Ciccani";
276 case GL_VERSION:
277 return "1.0";
278 default:
279 return NULL;
280 }
281 }
282
283 static void
284 update_state( GLcontext *ctx, GLuint new_state )
285 {
286 _swrast_InvalidateState( ctx, new_state );
287 _swsetup_InvalidateState( ctx, new_state );
288 _ac_InvalidateState( ctx, new_state );
289 _tnl_InvalidateState( ctx, new_state );
290 }
291
292 static void
293 get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
294 {
295 GLcontext *ctx = _mesa_get_current_context();
296 IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
297
298 *width = (GLuint) data->width;
299 *height = (GLuint) data->height;
300 }
301
302 static void
303 set_viewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h )
304 {
305 _mesa_ResizeBuffersMESA();
306 }
307
308 /* required but not used */
309 static void
310 set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
311 {
312 return;
313 }
314
315
316 /* RGB332 */
317 #define NAME(PREFIX) PREFIX##_RGB332
318 #define SPAN_VARS \
319 IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
320 #define INIT_PIXEL_PTR(P, X, Y) \
321 GLubyte *P = data->video.end - (Y) * data->video.pitch + (X)
322 #define INC_PIXEL_PTR(P) P += 1
323 #define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
324 *P = ( (((R) & 0xe0)) | (((G) & 0xe0) >> 3) | ((B) >> 6) )
325 #define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
326 *P = ( (((R) & 0xe0)) | (((G) & 0xe0) >> 3) | ((B) >> 6) )
327 #define FETCH_RGBA_PIXEL(R, G, B, A, P) \
328 R = ((*P & 0xe0) ); \
329 G = ((*P & 0x1c) << 3); \
330 B = ((*P & 0x03) << 6); \
331 A = CHAN_MAX
332
333 #include "swrast/s_spantemp.h"
334
335 /* ARGB1555 */
336 #define NAME(PREFIX) PREFIX##_ARGB1555
337 #define SPAN_VARS \
338 IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
339 #define INIT_PIXEL_PTR(P, X, Y) \
340 GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2)
341 #define INC_PIXEL_PTR(P) P += 1
342 #define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
343 *P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
344 #define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
345 *P = ( (((A) & 0x80) << 8) | (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
346 #define FETCH_RGBA_PIXEL(R, G, B, A, P) \
347 R = ((*P & 0x7c00) >> 7); \
348 G = ((*P & 0x03e0) >> 2); \
349 B = ((*P & 0x001f) << 3); \
350 A = ((*P & 0x8000) ? 0xff : 0)
351
352 #include "swrast/s_spantemp.h"
353
354 /* RGB16 */
355 #define NAME(PREFIX) PREFIX##_RGB16
356 #define SPAN_VARS \
357 IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
358 #define INIT_PIXEL_PTR(P, X, Y) \
359 GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2)
360 #define INC_PIXEL_PTR(P) P += 1
361 #define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
362 *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
363 #define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
364 *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
365 #define FETCH_RGBA_PIXEL(R, G, B, A, P) \
366 R = ((*P & 0xf800) >> 8); \
367 G = ((*P & 0x07e0) >> 3); \
368 B = ((*P & 0x001f) << 3); \
369 A = CHAN_MAX
370
371 #include "swrast/s_spantemp.h"
372
373 /* RGB24 */
374 #define NAME(PREFIX) PREFIX##_RGB24
375 #define SPAN_VARS \
376 IDirectFBGL_data *data = ctx->DriverCtx;
377 #define INIT_PIXEL_PTR(P, X, Y) \
378 GLubyte *P = data->video.end - (Y) * data->video.pitch + (X) * 3
379 #define INC_PIXEL_PTR(P) P += 3
380 #define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
381 P[0] = B; P[1] = G; P[2] = R
382 #define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
383 P[0] = B; P[1] = G; P[2] = R
384 #define FETCH_RGBA_PIXEL(R, G, B, A, P) \
385 R = P[2]; G = P[1]; B = P[0]; A = CHAN_MAX
386
387 #include "swrast/s_spantemp.h"
388
389 /* RGB32 */
390 #define NAME(PREFIX) PREFIX##_RGB32
391 #define SPAN_VARS \
392 IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
393 #define INIT_PIXEL_PTR(P, X, Y) \
394 GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4)
395 #define INC_PIXEL_PTR(P) P += 1
396 #define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
397 *P = ( ((R) << 16) | ((G) << 8) | (B) )
398 #define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
399 *P = ( ((R) << 16) | ((G) << 8) | (B) )
400 #define FETCH_RGBA_PIXEL(R, G, B, A, P) \
401 R = ((*P & 0x00ff0000) >> 16); \
402 G = ((*P & 0x0000ff00) >> 8); \
403 B = ((*P & 0x000000ff) ); \
404 A = CHAN_MAX
405
406 #include "swrast/s_spantemp.h"
407
408 /* ARGB */
409 #define NAME(PREFIX) PREFIX##_ARGB
410 #define SPAN_VARS \
411 IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
412 #define INIT_PIXEL_PTR(P, X, Y) \
413 GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4)
414 #define INC_PIXEL_PTR(P) P += 1
415 #define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
416 *P = ( 0xff000000 | ((R) << 16) | ((G) << 8) | (B) )
417 #define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
418 *P = ( ((A) << 24) | ((R) << 16) | ((G) << 8) | (B) )
419 #define FETCH_RGBA_PIXEL(R, G, B, A, P) \
420 R = ((*P & 0x00ff0000) >> 16); \
421 G = ((*P & 0x0000ff00) >> 8); \
422 B = ((*P & 0x000000ff) ); \
423 A = ((*P & 0xff000000) >> 24)
424
425 #include "swrast/s_spantemp.h"
426
427 /* AiRGB */
428 #define NAME(PREFIX) PREFIX##_AiRGB
429 #define SPAN_VARS \
430 IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
431 #define INIT_PIXEL_PTR(P, X, Y) \
432 GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4)
433 #define INC_PIXEL_PTR(P) P += 1
434 #define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
435 *P = ( ((R) << 16) | ((G) << 8) | (B) )
436 #define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
437 *P = ( ((0xff - (A)) << 24) | ((R) << 16) | ((G) << 8) | (B) )
438 #define FETCH_RGBA_PIXEL(R, G, B, A, P) \
439 R = ((*P & 0x00ff0000) >> 16); \
440 G = ((*P & 0x0000ff00) >> 8); \
441 B = ((*P & 0x000000ff) ); \
442 A = (0xff - ((*P & 0xff000000) >> 24))
443
444 #include "swrast/s_spantemp.h"
445
446
447 static bool
448 dfb_mesa_setup_visual( GLvisual *visual,
449 DFBSurfacePixelFormat format )
450 {
451 GLboolean rgbFlag = GL_TRUE;
452 GLboolean dbFlag = GL_FALSE;
453 GLboolean stereoFlag = GL_FALSE;
454 GLint redBits = 0;
455 GLint blueBits = 0;
456 GLint greenBits = 0;
457 GLint alphaBits = 0;
458 GLint indexBits = 0;
459 GLint depthBits = 0;
460 GLint stencilBits = 0;
461 GLint accumRedBits = 0;
462 GLint accumGreenBits = 0;
463 GLint accumBlueBits = 0;
464 GLint accumAlphaBits = 0;
465 GLint numSamples = 0;
466
467 /* FIXME: LUT8 support. */
468 switch (format) {
469 case DSPF_RGB332:
470 redBits = 3;
471 greenBits = 3;
472 blueBits = 2;
473 break;
474 case DSPF_ARGB1555:
475 redBits = 5;
476 greenBits = 5;
477 blueBits = 5;
478 alphaBits = 1;
479 break;
480 case DSPF_RGB16:
481 redBits = 5;
482 greenBits = 6;
483 blueBits = 5;
484 break;
485 case DSPF_ARGB:
486 case DSPF_AiRGB:
487 alphaBits = 8;
488 case DSPF_RGB24:
489 case DSPF_RGB32:
490 redBits = 8;
491 greenBits = 8;
492 blueBits = 8;
493 break;
494 default:
495 D_WARN( "unsupported pixelformat" );
496 return false;
497 }
498
499 if (rgbFlag) {
500 accumRedBits = redBits;
501 accumGreenBits = greenBits;
502 accumBlueBits = blueBits;
503 accumAlphaBits = alphaBits;
504 depthBits = redBits + greenBits + blueBits;
505 stencilBits = alphaBits;
506 } else
507 depthBits = 8;
508
509 return _mesa_initialize_visual( visual,
510 rgbFlag, dbFlag, stereoFlag,
511 redBits, greenBits, blueBits, alphaBits,
512 indexBits, depthBits, stencilBits,
513 accumRedBits, accumGreenBits,
514 accumBlueBits, accumAlphaBits,
515 numSamples );
516 }
517
518 static bool
519 dfb_mesa_create_context( GLcontext *context,
520 GLframebuffer *framebuffer,
521 GLvisual *visual,
522 DFBSurfacePixelFormat format,
523 void *data )
524 {
525 struct dd_function_table functions;
526 struct swrast_device_driver *swdd;
527
528 _mesa_initialize_framebuffer( framebuffer, visual,
529 visual->haveDepthBuffer,
530 visual->haveStencilBuffer,
531 visual->haveAccumBuffer,
532 visual->accumAlphaBits > 0 );
533
534 _mesa_init_driver_functions( &functions );
535 functions.GetString = get_string;
536 functions.UpdateState = update_state;
537 functions.GetBufferSize = get_buffer_size;
538 functions.Viewport = set_viewport;
539
540 if (!_mesa_initialize_context( context, visual, NULL,
541 &functions, data )) {
542 D_DEBUG( "DirectFBGL/Mesa: _mesa_initialize_context() failed.\n" );
543 _mesa_free_framebuffer_data( framebuffer );
544 return false;
545 }
546
547 _swrast_CreateContext( context );
548 _ac_CreateContext( context );
549 _tnl_CreateContext( context );
550 _swsetup_CreateContext( context );
551 _swsetup_Wakeup( context );
552
553 swdd = _swrast_GetDeviceDriverReference( context );
554 swdd->SetBuffer = set_buffer;
555 switch (format) {
556 case DSPF_RGB332:
557 swdd->WriteRGBASpan = write_rgba_span_RGB332;
558 swdd->WriteRGBSpan = write_rgb_span_RGB332;
559 swdd->WriteMonoRGBASpan = write_monorgba_span_RGB332;
560 swdd->WriteRGBAPixels = write_rgba_pixels_RGB332;
561 swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB332;
562 swdd->ReadRGBASpan = read_rgba_span_RGB332;
563 swdd->ReadRGBAPixels = read_rgba_pixels_RGB332;
564 break;
565 case DSPF_ARGB1555:
566 swdd->WriteRGBASpan = write_rgba_span_ARGB1555;
567 swdd->WriteRGBSpan = write_rgb_span_ARGB1555;
568 swdd->WriteMonoRGBASpan = write_monorgba_span_ARGB1555;
569 swdd->WriteRGBAPixels = write_rgba_pixels_ARGB1555;
570 swdd->WriteMonoRGBAPixels = write_monorgba_pixels_ARGB1555;
571 swdd->ReadRGBASpan = read_rgba_span_ARGB1555;
572 swdd->ReadRGBAPixels = read_rgba_pixels_ARGB1555;
573 break;
574 case DSPF_RGB16:
575 swdd->WriteRGBASpan = write_rgba_span_RGB16;
576 swdd->WriteRGBSpan = write_rgb_span_RGB16;
577 swdd->WriteMonoRGBASpan = write_monorgba_span_RGB16;
578 swdd->WriteRGBAPixels = write_rgba_pixels_RGB16;
579 swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB16;
580 swdd->ReadRGBASpan = read_rgba_span_RGB16;
581 swdd->ReadRGBAPixels = read_rgba_pixels_RGB16;
582 break;
583 case DSPF_RGB24:
584 swdd->WriteRGBASpan = write_rgba_span_RGB24;
585 swdd->WriteRGBSpan = write_rgb_span_RGB24;
586 swdd->WriteMonoRGBASpan = write_monorgba_span_RGB24;
587 swdd->WriteRGBAPixels = write_rgba_pixels_RGB24;
588 swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB24;
589 swdd->ReadRGBASpan = read_rgba_span_RGB24;
590 swdd->ReadRGBAPixels = read_rgba_pixels_RGB24;
591 break;
592 case DSPF_RGB32:
593 swdd->WriteRGBASpan = write_rgba_span_RGB32;
594 swdd->WriteRGBSpan = write_rgb_span_RGB32;
595 swdd->WriteMonoRGBASpan = write_monorgba_span_RGB32;
596 swdd->WriteRGBAPixels = write_rgba_pixels_RGB32;
597 swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB32;
598 swdd->ReadRGBASpan = read_rgba_span_RGB32;
599 swdd->ReadRGBAPixels = read_rgba_pixels_RGB32;
600 break;
601 case DSPF_ARGB:
602 swdd->WriteRGBASpan = write_rgba_span_ARGB;
603 swdd->WriteRGBSpan = write_rgb_span_ARGB;
604 swdd->WriteMonoRGBASpan = write_monorgba_span_ARGB;
605 swdd->WriteRGBAPixels = write_rgba_pixels_ARGB;
606 swdd->WriteMonoRGBAPixels = write_monorgba_pixels_ARGB;
607 swdd->ReadRGBASpan = read_rgba_span_ARGB;
608 swdd->ReadRGBAPixels = read_rgba_pixels_ARGB;
609 break;
610 case DSPF_AiRGB:
611 swdd->WriteRGBASpan = write_rgba_span_AiRGB;
612 swdd->WriteRGBSpan = write_rgb_span_AiRGB;
613 swdd->WriteMonoRGBASpan = write_monorgba_span_AiRGB;
614 swdd->WriteRGBAPixels = write_rgba_pixels_AiRGB;
615 swdd->WriteMonoRGBAPixels = write_monorgba_pixels_AiRGB;
616 swdd->ReadRGBASpan = read_rgba_span_AiRGB;
617 swdd->ReadRGBAPixels = read_rgba_pixels_AiRGB;
618 break;
619 default:
620 D_BUG( "unexpected pixelformat" );
621 return false;
622 }
623
624 TNL_CONTEXT( context )->Driver.RunPipeline = _tnl_run_pipeline;
625
626 _mesa_enable_sw_extensions( context );
627
628 _mesa_make_current( context, framebuffer );
629
630 return true;
631 }
632
633 static void
634 dfb_mesa_destroy_context( GLcontext *context,
635 GLframebuffer *framebuffer )
636 {
637 _mesa_make_current( NULL, NULL );
638 _mesa_free_framebuffer_data( framebuffer );
639 _mesa_notifyDestroy( context );
640 _mesa_free_context_data( context );
641 }
642