Merge branch 'r500-support'
[mesa.git] / src / mesa / drivers / dri / swrast / swrast.c
1 /*
2 * Copyright (C) 2008 George Sapountzis <gsap7@yahoo.gr>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 */
21
22 /*
23 * DRI software rasterizer
24 *
25 * This is the mesa swrast module packaged into a DRI driver structure.
26 *
27 * The front-buffer is allocated by the loader. The loader provides read/write
28 * callbacks for access to the front-buffer. The driver uses a scratch row for
29 * front-buffer rendering to avoid repeated calls to the loader.
30 *
31 * The back-buffer is allocated by the driver and is private.
32 */
33
34 #include "context.h"
35 #include "extensions.h"
36 #include "framebuffer.h"
37 #include "imports.h"
38 #include "renderbuffer.h"
39 #include "swrast/swrast.h"
40 #include "swrast_setup/swrast_setup.h"
41 #include "tnl/tnl.h"
42 #include "tnl/t_context.h"
43 #include "tnl/t_pipeline.h"
44 #include "vbo/vbo.h"
45 #include "drivers/common/driverfuncs.h"
46
47 #include "swrast_priv.h"
48
49
50 #define need_GL_VERSION_1_3
51 #define need_GL_VERSION_1_4
52 #define need_GL_VERSION_1_5
53 #define need_GL_VERSION_2_0
54
55 /* sw extensions for imaging */
56 #define need_GL_EXT_blend_color
57 #define need_GL_EXT_blend_minmax
58 #define need_GL_EXT_convolution
59 #define need_GL_EXT_histogram
60 #define need_GL_SGI_color_table
61
62 /* sw extensions not associated with some GL version */
63 #define need_GL_ARB_shader_objects
64 #define need_GL_ARB_vertex_program
65 #define need_GL_APPLE_vertex_array_object
66 #define need_GL_ATI_fragment_shader
67 #define need_GL_EXT_depth_bounds_test
68 #define need_GL_EXT_framebuffer_object
69 #define need_GL_EXT_framebuffer_blit
70 #define need_GL_EXT_gpu_program_parameters
71 #define need_GL_EXT_paletted_texture
72 #define need_GL_IBM_multimode_draw_arrays
73 #define need_GL_MESA_resize_buffers
74 #define need_GL_NV_vertex_program
75 #define need_GL_NV_fragment_program
76
77 #include "extension_helper.h"
78 #include "utils.h"
79
80 const struct dri_extension card_extensions[] =
81 {
82 { "GL_VERSION_1_3", GL_VERSION_1_3_functions },
83 { "GL_VERSION_1_4", GL_VERSION_1_4_functions },
84 { "GL_VERSION_1_5", GL_VERSION_1_5_functions },
85 { "GL_VERSION_2_0", GL_VERSION_2_0_functions },
86
87 { "GL_EXT_blend_color", GL_EXT_blend_color_functions },
88 { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions },
89 { "GL_EXT_convolution", GL_EXT_convolution_functions },
90 { "GL_EXT_histogram", GL_EXT_histogram_functions },
91 { "GL_SGI_color_table", GL_SGI_color_table_functions },
92
93 { "GL_ARB_shader_objects", GL_ARB_shader_objects_functions },
94 { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions },
95 { "GL_APPLE_vertex_array_object", GL_APPLE_vertex_array_object_functions },
96 { "GL_ATI_fragment_shader", GL_ATI_fragment_shader_functions },
97 { "GL_EXT_depth_bounds_test", GL_EXT_depth_bounds_test_functions },
98 { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
99 { "GL_EXT_framebuffer_blit", GL_EXT_framebuffer_blit_functions },
100 { "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions },
101 { "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions },
102 { "GL_IBM_multimode_draw_arrays", GL_IBM_multimode_draw_arrays_functions },
103 { "GL_MESA_resize_buffers", GL_MESA_resize_buffers_functions },
104 { "GL_NV_vertex_program", GL_NV_vertex_program_functions },
105 { "GL_NV_fragment_program", GL_NV_fragment_program_functions },
106 { NULL, NULL }
107 };
108
109
110 /**
111 * Screen and config-related functions
112 */
113
114 static void
115 setupLoaderExtensions(__DRIscreen *psp,
116 const __DRIextension **extensions)
117 {
118 int i;
119
120 for (i = 0; extensions[i]; i++) {
121 if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0)
122 psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i];
123 }
124 }
125
126 static __DRIconfig **
127 swrastFillInModes(__DRIscreen *psp,
128 unsigned pixel_bits, unsigned depth_bits,
129 unsigned stencil_bits, GLboolean have_back_buffer)
130 {
131 __DRIconfig **configs;
132 unsigned depth_buffer_factor;
133 unsigned back_buffer_factor;
134 GLenum fb_format;
135 GLenum fb_type;
136
137 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
138 * support pageflipping at all.
139 */
140 static const GLenum back_buffer_modes[] = {
141 GLX_NONE, GLX_SWAP_UNDEFINED_OML
142 };
143
144 u_int8_t depth_bits_array[4];
145 u_int8_t stencil_bits_array[4];
146
147 depth_bits_array[0] = 0;
148 depth_bits_array[1] = 0;
149 depth_bits_array[2] = depth_bits;
150 depth_bits_array[3] = depth_bits;
151
152 /* Just like with the accumulation buffer, always provide some modes
153 * with a stencil buffer.
154 */
155 stencil_bits_array[0] = 0;
156 stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
157 stencil_bits_array[2] = 0;
158 stencil_bits_array[3] = (stencil_bits == 0) ? 8 : stencil_bits;
159
160 depth_buffer_factor = 4;
161 back_buffer_factor = 2;
162
163 if (pixel_bits == 8) {
164 fb_format = GL_RGB;
165 fb_type = GL_UNSIGNED_BYTE_2_3_3_REV;
166 }
167 else if (pixel_bits == 16) {
168 fb_format = GL_RGB;
169 fb_type = GL_UNSIGNED_SHORT_5_6_5;
170 }
171 else {
172 fb_format = GL_BGRA;
173 fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
174 }
175
176 configs = driCreateConfigs(fb_format, fb_type,
177 depth_bits_array, stencil_bits_array,
178 depth_buffer_factor, back_buffer_modes,
179 back_buffer_factor);
180 if (configs == NULL) {
181 fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
182 __LINE__);
183 return NULL;
184 }
185
186 return configs;
187 }
188
189 static __DRIscreen *
190 driCreateNewScreen(int scrn, const __DRIextension **extensions,
191 const __DRIconfig ***driver_configs, void *data)
192 {
193 static const __DRIextension *emptyExtensionList[] = { NULL };
194 __DRIscreen *psp;
195 __DRIconfig **configs8, **configs16, **configs32;
196
197 (void) data;
198
199 TRACE;
200
201 psp = _mesa_calloc(sizeof(*psp));
202 if (!psp)
203 return NULL;
204
205 setupLoaderExtensions(psp, extensions);
206
207 psp->num = scrn;
208 psp->extensions = emptyExtensionList;
209
210 configs8 = swrastFillInModes(psp, 8, 8, 0, 1);
211 configs16 = swrastFillInModes(psp, 16, 16, 0, 1);
212 configs32 = swrastFillInModes(psp, 32, 24, 8, 1);
213
214 configs16 = (__DRIconfig **)driConcatConfigs(configs8, configs16);
215
216 *driver_configs = driConcatConfigs(configs16, configs32);
217
218 driInitExtensions( NULL, card_extensions, GL_FALSE );
219
220 return psp;
221 }
222
223 static void driDestroyScreen(__DRIscreen *psp)
224 {
225 TRACE;
226
227 if (psp) {
228 _mesa_free(psp);
229 }
230 }
231
232 static const __DRIextension **driGetExtensions(__DRIscreen *psp)
233 {
234 TRACE;
235
236 return psp->extensions;
237 }
238
239
240 /**
241 * Framebuffer and renderbuffer-related functions.
242 */
243
244 static GLuint
245 choose_pixel_format(const GLvisual *v)
246 {
247 if (v->rgbMode) {
248 int bpp = v->rgbBits;
249
250 if (bpp == 32
251 && v->redMask == 0xff0000
252 && v->greenMask == 0x00ff00
253 && v->blueMask == 0x0000ff)
254 return PF_A8R8G8B8;
255 else if (bpp == 16
256 && v->redMask == 0xf800
257 && v->greenMask == 0x07e0
258 && v->blueMask == 0x001f)
259 return PF_R5G6B5;
260 else if (bpp == 8
261 && v->redMask == 0x07
262 && v->greenMask == 0x38
263 && v->blueMask == 0xc0)
264 return PF_R3G3B2;
265 }
266 else {
267 if (v->indexBits == 8)
268 return PF_CI8;
269 }
270
271 _mesa_problem( NULL, "unexpected format in %s", __FUNCTION__ );
272 return 0;
273 }
274
275 static void
276 swrast_delete_renderbuffer(struct gl_renderbuffer *rb)
277 {
278 TRACE;
279
280 _mesa_free(rb->Data);
281 _mesa_free(rb);
282 }
283
284 static GLboolean
285 swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
286 GLenum internalFormat, GLuint width, GLuint height)
287 {
288 struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
289 int bpp;
290 unsigned mask = PITCH_ALIGN_BITS - 1;
291
292 TRACE;
293
294 rb->Data = NULL;
295 rb->Width = width;
296 rb->Height = height;
297
298 switch (internalFormat) {
299 case GL_RGB:
300 bpp = rb->RedBits + rb->GreenBits + rb->BlueBits;
301 break;
302 case GL_RGBA:
303 bpp = rb->RedBits + rb->GreenBits + rb->BlueBits + rb->AlphaBits;
304 break;
305 case GL_COLOR_INDEX8_EXT:
306 bpp = rb->IndexBits;
307 break;
308 default:
309 _mesa_problem( NULL, "unexpected format in %s", __FUNCTION__ );
310 return GL_FALSE;
311 }
312
313 /* always pad to PITCH_ALIGN_BITS */
314 xrb->pitch = ((width * bpp + mask) & ~mask) / 8;
315
316 return GL_TRUE;
317 }
318
319 static GLboolean
320 swrast_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
321 GLenum internalFormat, GLuint width, GLuint height)
322 {
323 struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
324
325 TRACE;
326
327 _mesa_free(rb->Data);
328
329 (void) swrast_alloc_front_storage(ctx, rb, internalFormat, width, height);
330
331 rb->Data = _mesa_malloc(height * xrb->pitch);
332
333 return GL_TRUE;
334 }
335
336 static struct swrast_renderbuffer *
337 swrast_new_renderbuffer(const GLvisual *visual, GLboolean front)
338 {
339 struct swrast_renderbuffer *xrb = _mesa_calloc(sizeof *xrb);
340 GLuint pixel_format;
341
342 TRACE;
343
344 if (xrb) {
345 _mesa_init_renderbuffer(&xrb->Base, 0);
346
347 pixel_format = choose_pixel_format(visual);
348
349 xrb->Base.Delete = swrast_delete_renderbuffer;
350 if (front) {
351 xrb->Base.AllocStorage = swrast_alloc_front_storage;
352 swrast_set_span_funcs_front(xrb, pixel_format);
353 }
354 else {
355 xrb->Base.AllocStorage = swrast_alloc_back_storage;
356 swrast_set_span_funcs_back(xrb, pixel_format);
357 }
358
359 switch (pixel_format) {
360 case PF_A8R8G8B8:
361 xrb->Base.InternalFormat = GL_RGBA;
362 xrb->Base._BaseFormat = GL_RGBA;
363 xrb->Base.DataType = GL_UNSIGNED_BYTE;
364 xrb->Base.RedBits = 8 * sizeof(GLubyte);
365 xrb->Base.GreenBits = 8 * sizeof(GLubyte);
366 xrb->Base.BlueBits = 8 * sizeof(GLubyte);
367 xrb->Base.AlphaBits = 8 * sizeof(GLubyte);
368 break;
369 case PF_R5G6B5:
370 xrb->Base.InternalFormat = GL_RGB;
371 xrb->Base._BaseFormat = GL_RGB;
372 xrb->Base.DataType = GL_UNSIGNED_BYTE;
373 xrb->Base.RedBits = 5 * sizeof(GLubyte);
374 xrb->Base.GreenBits = 6 * sizeof(GLubyte);
375 xrb->Base.BlueBits = 5 * sizeof(GLubyte);
376 xrb->Base.AlphaBits = 0;
377 break;
378 case PF_R3G3B2:
379 xrb->Base.InternalFormat = GL_RGB;
380 xrb->Base._BaseFormat = GL_RGB;
381 xrb->Base.DataType = GL_UNSIGNED_BYTE;
382 xrb->Base.RedBits = 3 * sizeof(GLubyte);
383 xrb->Base.GreenBits = 3 * sizeof(GLubyte);
384 xrb->Base.BlueBits = 2 * sizeof(GLubyte);
385 xrb->Base.AlphaBits = 0;
386 break;
387 case PF_CI8:
388 xrb->Base.InternalFormat = GL_COLOR_INDEX8_EXT;
389 xrb->Base._BaseFormat = GL_COLOR_INDEX;
390 xrb->Base.DataType = GL_UNSIGNED_BYTE;
391 xrb->Base.IndexBits = 8 * sizeof(GLubyte);
392 break;
393 default:
394 return NULL;
395 }
396 }
397 return xrb;
398 }
399
400 static __DRIdrawable *
401 driCreateNewDrawable(__DRIscreen *screen,
402 const __DRIconfig *config, void *data)
403 {
404 __DRIdrawable *buf;
405 struct swrast_renderbuffer *frontrb, *backrb;
406
407 TRACE;
408
409 buf = _mesa_calloc(sizeof *buf);
410 if (!buf)
411 return NULL;
412
413 buf->loaderPrivate = data;
414
415 buf->driScreenPriv = screen;
416
417 buf->row = _mesa_malloc(MAX_WIDTH * 4);
418
419 /* basic framebuffer setup */
420 _mesa_initialize_framebuffer(&buf->Base, &config->modes);
421
422 /* add front renderbuffer */
423 frontrb = swrast_new_renderbuffer(&config->modes, GL_TRUE);
424 _mesa_add_renderbuffer(&buf->Base, BUFFER_FRONT_LEFT, &frontrb->Base);
425
426 /* add back renderbuffer */
427 if (config->modes.doubleBufferMode) {
428 backrb = swrast_new_renderbuffer(&config->modes, GL_FALSE);
429 _mesa_add_renderbuffer(&buf->Base, BUFFER_BACK_LEFT, &backrb->Base);
430 }
431
432 /* add software renderbuffers */
433 _mesa_add_soft_renderbuffers(&buf->Base,
434 GL_FALSE, /* color */
435 config->modes.haveDepthBuffer,
436 config->modes.haveStencilBuffer,
437 config->modes.haveAccumBuffer,
438 GL_FALSE, /* alpha */
439 GL_FALSE /* aux bufs */);
440
441 return buf;
442 }
443
444 static void
445 driDestroyDrawable(__DRIdrawable *buf)
446 {
447 TRACE;
448
449 if (buf) {
450 struct gl_framebuffer *fb = &buf->Base;
451
452 _mesa_free(buf->row);
453
454 fb->DeletePending = GL_TRUE;
455 _mesa_unreference_framebuffer(&fb);
456 }
457 }
458
459 static void driSwapBuffers(__DRIdrawable *buf)
460 {
461 GET_CURRENT_CONTEXT(ctx);
462
463 struct swrast_renderbuffer *frontrb =
464 swrast_renderbuffer(buf->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
465 struct swrast_renderbuffer *backrb =
466 swrast_renderbuffer(buf->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
467
468 __DRIscreen *screen = buf->driScreenPriv;
469
470 TRACE;
471
472 /* check for signle-buffered */
473 if (backrb == NULL)
474 return;
475
476 /* check if swapping currently bound buffer */
477 if (ctx && ctx->DrawBuffer == &(buf->Base)) {
478 /* flush pending rendering */
479 _mesa_notifySwapBuffers(ctx);
480 }
481
482 screen->swrast_loader->putImage(buf, __DRI_SWRAST_IMAGE_OP_SWAP,
483 0, 0,
484 frontrb->Base.Width,
485 frontrb->Base.Height,
486 backrb->Base.Data,
487 buf->loaderPrivate);
488 }
489
490
491 /**
492 * General device driver functions.
493 */
494
495 static void
496 get_window_size( GLframebuffer *fb, GLsizei *w, GLsizei *h )
497 {
498 __DRIdrawable *buf = swrast_drawable(fb);
499 __DRIscreen *screen = buf->driScreenPriv;
500 int x, y;
501
502 screen->swrast_loader->getDrawableInfo(buf,
503 &x, &y, w, h,
504 buf->loaderPrivate);
505 }
506
507 static void
508 swrast_check_and_update_window_size( GLcontext *ctx, GLframebuffer *fb )
509 {
510 GLsizei width, height;
511
512 get_window_size(fb, &width, &height);
513 if (fb->Width != width || fb->Height != height) {
514 _mesa_resize_framebuffer(ctx, fb, width, height);
515 }
516 }
517
518 static const GLubyte *
519 get_string(GLcontext *ctx, GLenum pname)
520 {
521 (void) ctx;
522 switch (pname) {
523 case GL_VENDOR:
524 return (const GLubyte *) "Mesa Project";
525 case GL_RENDERER:
526 return (const GLubyte *) "Software Rasterizer";
527 default:
528 return NULL;
529 }
530 }
531
532 static void
533 update_state( GLcontext *ctx, GLuint new_state )
534 {
535 /* not much to do here - pass it on */
536 _swrast_InvalidateState( ctx, new_state );
537 _swsetup_InvalidateState( ctx, new_state );
538 _vbo_InvalidateState( ctx, new_state );
539 _tnl_InvalidateState( ctx, new_state );
540 }
541
542 static void
543 viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
544 {
545 GLframebuffer *draw = ctx->WinSysDrawBuffer;
546 GLframebuffer *read = ctx->WinSysReadBuffer;
547
548 swrast_check_and_update_window_size(ctx, draw);
549 swrast_check_and_update_window_size(ctx, read);
550 }
551
552 static void
553 swrast_init_driver_functions(struct dd_function_table *driver)
554 {
555 driver->GetString = get_string;
556 driver->UpdateState = update_state;
557 driver->GetBufferSize = NULL;
558 driver->Viewport = viewport;
559 }
560
561
562 /**
563 * Context-related functions.
564 */
565
566 static __DRIcontext *
567 driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
568 __DRIcontext *shared, void *data)
569 {
570 __DRIcontext *ctx;
571 GLcontext *mesaCtx;
572 struct dd_function_table functions;
573
574 TRACE;
575
576 ctx = _mesa_calloc(sizeof *ctx);
577 if (!ctx)
578 return NULL;
579
580 ctx->loaderPrivate = data;
581
582 ctx->driScreenPriv = screen;
583
584 /* build table of device driver functions */
585 _mesa_init_driver_functions(&functions);
586 swrast_init_driver_functions(&functions);
587
588 if (!_mesa_initialize_context(&ctx->Base, &config->modes,
589 shared ? &shared->Base : NULL,
590 &functions, (void *) ctx)) {
591 _mesa_free(ctx);
592 return NULL;
593 }
594
595 mesaCtx = &ctx->Base;
596
597 /* do bounds checking to prevent segfaults and server crashes! */
598 mesaCtx->Const.CheckArrayBounds = GL_TRUE;
599
600 /* create module contexts */
601 _swrast_CreateContext( mesaCtx );
602 _vbo_CreateContext( mesaCtx );
603 _tnl_CreateContext( mesaCtx );
604 _swsetup_CreateContext( mesaCtx );
605 _swsetup_Wakeup( mesaCtx );
606
607 /* use default TCL pipeline */
608 {
609 TNLcontext *tnl = TNL_CONTEXT(mesaCtx);
610 tnl->Driver.RunPipeline = _tnl_run_pipeline;
611 }
612
613 _mesa_enable_sw_extensions(mesaCtx);
614 _mesa_enable_1_3_extensions(mesaCtx);
615 _mesa_enable_1_4_extensions(mesaCtx);
616 _mesa_enable_1_5_extensions(mesaCtx);
617 _mesa_enable_2_0_extensions(mesaCtx);
618 _mesa_enable_2_1_extensions(mesaCtx);
619
620 return ctx;
621 }
622
623 static void
624 driDestroyContext(__DRIcontext *ctx)
625 {
626 GLcontext *mesaCtx;
627 TRACE;
628
629 if (ctx) {
630 mesaCtx = &ctx->Base;
631 _swsetup_DestroyContext( mesaCtx );
632 _swrast_DestroyContext( mesaCtx );
633 _tnl_DestroyContext( mesaCtx );
634 _vbo_DestroyContext( mesaCtx );
635 _mesa_destroy_context( mesaCtx );
636 }
637 }
638
639 static int
640 driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask)
641 {
642 TRACE;
643
644 _mesa_copy_context(&src->Base, &dst->Base, mask);
645 return GL_TRUE;
646 }
647
648 static int driBindContext(__DRIcontext *ctx,
649 __DRIdrawable *draw,
650 __DRIdrawable *read)
651 {
652 GLcontext *mesaCtx;
653 GLframebuffer *mesaDraw;
654 GLframebuffer *mesaRead;
655 TRACE;
656
657 if (ctx) {
658 if (!draw || !read)
659 return GL_FALSE;
660
661 mesaCtx = &ctx->Base;
662 mesaDraw = &draw->Base;
663 mesaRead = &read->Base;
664
665 /* check for same context and buffer */
666 if (mesaCtx == _mesa_get_current_context()
667 && mesaCtx->DrawBuffer == mesaDraw
668 && mesaCtx->ReadBuffer == mesaRead) {
669 return GL_TRUE;
670 }
671
672 _glapi_check_multithread();
673
674 swrast_check_and_update_window_size(mesaCtx, mesaDraw);
675 if (read != draw)
676 swrast_check_and_update_window_size(mesaCtx, mesaRead);
677
678 _mesa_make_current( mesaCtx,
679 mesaDraw,
680 mesaRead );
681 }
682 else {
683 /* unbind */
684 _mesa_make_current( NULL, NULL, NULL );
685 }
686
687 return GL_TRUE;
688 }
689
690 static int driUnbindContext(__DRIcontext *ctx)
691 {
692 TRACE;
693 (void) ctx;
694 _mesa_make_current(NULL, NULL, NULL);
695 return GL_TRUE;
696 }
697
698
699 static const __DRIcoreExtension driCoreExtension = {
700 { __DRI_CORE, __DRI_CORE_VERSION },
701 NULL, /* driCreateNewScreen */
702 driDestroyScreen,
703 driGetExtensions,
704 driGetConfigAttrib,
705 driIndexConfigAttrib,
706 NULL, /* driCreateNewDrawable */
707 driDestroyDrawable,
708 driSwapBuffers,
709 driCreateNewContext,
710 driCopyContext,
711 driDestroyContext,
712 driBindContext,
713 driUnbindContext
714 };
715
716 static const __DRIswrastExtension driSWRastExtension = {
717 { __DRI_SWRAST, __DRI_SWRAST_VERSION },
718 driCreateNewScreen,
719 driCreateNewDrawable
720 };
721
722 /* This is the table of extensions that the loader will dlsym() for. */
723 PUBLIC const __DRIextension *__driDriverExtensions[] = {
724 &driCoreExtension.base,
725 &driSWRastExtension.base,
726 NULL
727 };