dri/swrast: minor cosmetic
[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 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 return NULL;
346
347 _mesa_init_renderbuffer(&xrb->Base, 0);
348
349 pixel_format = choose_pixel_format(visual);
350
351 xrb->Base.Delete = swrast_delete_renderbuffer;
352 if (front) {
353 xrb->Base.AllocStorage = swrast_alloc_front_storage;
354 swrast_set_span_funcs_front(xrb, pixel_format);
355 }
356 else {
357 xrb->Base.AllocStorage = swrast_alloc_back_storage;
358 swrast_set_span_funcs_back(xrb, pixel_format);
359 }
360
361 switch (pixel_format) {
362 case PF_A8R8G8B8:
363 xrb->Base.InternalFormat = GL_RGBA;
364 xrb->Base._BaseFormat = GL_RGBA;
365 xrb->Base.DataType = GL_UNSIGNED_BYTE;
366 xrb->Base.RedBits = 8 * sizeof(GLubyte);
367 xrb->Base.GreenBits = 8 * sizeof(GLubyte);
368 xrb->Base.BlueBits = 8 * sizeof(GLubyte);
369 xrb->Base.AlphaBits = 8 * sizeof(GLubyte);
370 break;
371 case PF_R5G6B5:
372 xrb->Base.InternalFormat = GL_RGB;
373 xrb->Base._BaseFormat = GL_RGB;
374 xrb->Base.DataType = GL_UNSIGNED_BYTE;
375 xrb->Base.RedBits = 5 * sizeof(GLubyte);
376 xrb->Base.GreenBits = 6 * sizeof(GLubyte);
377 xrb->Base.BlueBits = 5 * sizeof(GLubyte);
378 xrb->Base.AlphaBits = 0;
379 break;
380 case PF_R3G3B2:
381 xrb->Base.InternalFormat = GL_RGB;
382 xrb->Base._BaseFormat = GL_RGB;
383 xrb->Base.DataType = GL_UNSIGNED_BYTE;
384 xrb->Base.RedBits = 3 * sizeof(GLubyte);
385 xrb->Base.GreenBits = 3 * sizeof(GLubyte);
386 xrb->Base.BlueBits = 2 * sizeof(GLubyte);
387 xrb->Base.AlphaBits = 0;
388 break;
389 case PF_CI8:
390 xrb->Base.InternalFormat = GL_COLOR_INDEX8_EXT;
391 xrb->Base._BaseFormat = GL_COLOR_INDEX;
392 xrb->Base.DataType = GL_UNSIGNED_BYTE;
393 xrb->Base.IndexBits = 8 * sizeof(GLubyte);
394 break;
395 default:
396 return NULL;
397 }
398
399 return xrb;
400 }
401
402 static __DRIdrawable *
403 driCreateNewDrawable(__DRIscreen *screen,
404 const __DRIconfig *config, void *data)
405 {
406 __DRIdrawable *buf;
407 struct swrast_renderbuffer *frontrb, *backrb;
408
409 TRACE;
410
411 buf = _mesa_calloc(sizeof *buf);
412 if (!buf)
413 return NULL;
414
415 buf->loaderPrivate = data;
416
417 buf->driScreenPriv = screen;
418
419 buf->row = _mesa_malloc(MAX_WIDTH * 4);
420
421 /* basic framebuffer setup */
422 _mesa_initialize_framebuffer(&buf->Base, &config->modes);
423
424 /* add front renderbuffer */
425 frontrb = swrast_new_renderbuffer(&config->modes, GL_TRUE);
426 _mesa_add_renderbuffer(&buf->Base, BUFFER_FRONT_LEFT, &frontrb->Base);
427
428 /* add back renderbuffer */
429 if (config->modes.doubleBufferMode) {
430 backrb = swrast_new_renderbuffer(&config->modes, GL_FALSE);
431 _mesa_add_renderbuffer(&buf->Base, BUFFER_BACK_LEFT, &backrb->Base);
432 }
433
434 /* add software renderbuffers */
435 _mesa_add_soft_renderbuffers(&buf->Base,
436 GL_FALSE, /* color */
437 config->modes.haveDepthBuffer,
438 config->modes.haveStencilBuffer,
439 config->modes.haveAccumBuffer,
440 GL_FALSE, /* alpha */
441 GL_FALSE /* aux bufs */);
442
443 return buf;
444 }
445
446 static void
447 driDestroyDrawable(__DRIdrawable *buf)
448 {
449 TRACE;
450
451 if (buf) {
452 struct gl_framebuffer *fb = &buf->Base;
453
454 _mesa_free(buf->row);
455
456 fb->DeletePending = GL_TRUE;
457 _mesa_unreference_framebuffer(&fb);
458 }
459 }
460
461 static void driSwapBuffers(__DRIdrawable *buf)
462 {
463 GET_CURRENT_CONTEXT(ctx);
464
465 struct swrast_renderbuffer *frontrb =
466 swrast_renderbuffer(buf->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
467 struct swrast_renderbuffer *backrb =
468 swrast_renderbuffer(buf->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
469
470 __DRIscreen *screen = buf->driScreenPriv;
471
472 TRACE;
473
474 /* check for signle-buffered */
475 if (backrb == NULL)
476 return;
477
478 /* check if swapping currently bound buffer */
479 if (ctx && ctx->DrawBuffer == &(buf->Base)) {
480 /* flush pending rendering */
481 _mesa_notifySwapBuffers(ctx);
482 }
483
484 screen->swrast_loader->putImage(buf, __DRI_SWRAST_IMAGE_OP_SWAP,
485 0, 0,
486 frontrb->Base.Width,
487 frontrb->Base.Height,
488 backrb->Base.Data,
489 buf->loaderPrivate);
490 }
491
492
493 /**
494 * General device driver functions.
495 */
496
497 static void
498 get_window_size( GLframebuffer *fb, GLsizei *w, GLsizei *h )
499 {
500 __DRIdrawable *buf = swrast_drawable(fb);
501 __DRIscreen *screen = buf->driScreenPriv;
502 int x, y;
503
504 screen->swrast_loader->getDrawableInfo(buf,
505 &x, &y, w, h,
506 buf->loaderPrivate);
507 }
508
509 static void
510 swrast_check_and_update_window_size( GLcontext *ctx, GLframebuffer *fb )
511 {
512 GLsizei width, height;
513
514 get_window_size(fb, &width, &height);
515 if (fb->Width != width || fb->Height != height) {
516 _mesa_resize_framebuffer(ctx, fb, width, height);
517 }
518 }
519
520 static const GLubyte *
521 get_string(GLcontext *ctx, GLenum pname)
522 {
523 (void) ctx;
524 switch (pname) {
525 case GL_VENDOR:
526 return (const GLubyte *) "Mesa Project";
527 case GL_RENDERER:
528 return (const GLubyte *) "Software Rasterizer";
529 default:
530 return NULL;
531 }
532 }
533
534 static void
535 update_state( GLcontext *ctx, GLuint new_state )
536 {
537 /* not much to do here - pass it on */
538 _swrast_InvalidateState( ctx, new_state );
539 _swsetup_InvalidateState( ctx, new_state );
540 _vbo_InvalidateState( ctx, new_state );
541 _tnl_InvalidateState( ctx, new_state );
542 }
543
544 static void
545 viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
546 {
547 GLframebuffer *draw = ctx->WinSysDrawBuffer;
548 GLframebuffer *read = ctx->WinSysReadBuffer;
549
550 swrast_check_and_update_window_size(ctx, draw);
551 swrast_check_and_update_window_size(ctx, read);
552 }
553
554 static void
555 swrast_init_driver_functions(struct dd_function_table *driver)
556 {
557 driver->GetString = get_string;
558 driver->UpdateState = update_state;
559 driver->GetBufferSize = NULL;
560 driver->Viewport = viewport;
561 }
562
563
564 /**
565 * Context-related functions.
566 */
567
568 static __DRIcontext *
569 driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
570 __DRIcontext *shared, void *data)
571 {
572 __DRIcontext *ctx;
573 GLcontext *mesaCtx;
574 struct dd_function_table functions;
575
576 TRACE;
577
578 ctx = _mesa_calloc(sizeof *ctx);
579 if (!ctx)
580 return NULL;
581
582 ctx->loaderPrivate = data;
583
584 ctx->driScreenPriv = screen;
585
586 /* build table of device driver functions */
587 _mesa_init_driver_functions(&functions);
588 swrast_init_driver_functions(&functions);
589
590 if (!_mesa_initialize_context(&ctx->Base, &config->modes,
591 shared ? &shared->Base : NULL,
592 &functions, (void *) ctx)) {
593 _mesa_free(ctx);
594 return NULL;
595 }
596
597 mesaCtx = &ctx->Base;
598
599 /* do bounds checking to prevent segfaults and server crashes! */
600 mesaCtx->Const.CheckArrayBounds = GL_TRUE;
601
602 /* create module contexts */
603 _swrast_CreateContext( mesaCtx );
604 _vbo_CreateContext( mesaCtx );
605 _tnl_CreateContext( mesaCtx );
606 _swsetup_CreateContext( mesaCtx );
607 _swsetup_Wakeup( mesaCtx );
608
609 /* use default TCL pipeline */
610 {
611 TNLcontext *tnl = TNL_CONTEXT(mesaCtx);
612 tnl->Driver.RunPipeline = _tnl_run_pipeline;
613 }
614
615 _mesa_enable_sw_extensions(mesaCtx);
616 _mesa_enable_1_3_extensions(mesaCtx);
617 _mesa_enable_1_4_extensions(mesaCtx);
618 _mesa_enable_1_5_extensions(mesaCtx);
619 _mesa_enable_2_0_extensions(mesaCtx);
620 _mesa_enable_2_1_extensions(mesaCtx);
621
622 return ctx;
623 }
624
625 static void
626 driDestroyContext(__DRIcontext *ctx)
627 {
628 GLcontext *mesaCtx;
629 TRACE;
630
631 if (ctx) {
632 mesaCtx = &ctx->Base;
633 _swsetup_DestroyContext( mesaCtx );
634 _swrast_DestroyContext( mesaCtx );
635 _tnl_DestroyContext( mesaCtx );
636 _vbo_DestroyContext( mesaCtx );
637 _mesa_destroy_context( mesaCtx );
638 }
639 }
640
641 static int
642 driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask)
643 {
644 TRACE;
645
646 _mesa_copy_context(&src->Base, &dst->Base, mask);
647 return GL_TRUE;
648 }
649
650 static int driBindContext(__DRIcontext *ctx,
651 __DRIdrawable *draw,
652 __DRIdrawable *read)
653 {
654 GLcontext *mesaCtx;
655 GLframebuffer *mesaDraw;
656 GLframebuffer *mesaRead;
657 TRACE;
658
659 if (ctx) {
660 if (!draw || !read)
661 return GL_FALSE;
662
663 mesaCtx = &ctx->Base;
664 mesaDraw = &draw->Base;
665 mesaRead = &read->Base;
666
667 /* check for same context and buffer */
668 if (mesaCtx == _mesa_get_current_context()
669 && mesaCtx->DrawBuffer == mesaDraw
670 && mesaCtx->ReadBuffer == mesaRead) {
671 return GL_TRUE;
672 }
673
674 _glapi_check_multithread();
675
676 swrast_check_and_update_window_size(mesaCtx, mesaDraw);
677 if (read != draw)
678 swrast_check_and_update_window_size(mesaCtx, mesaRead);
679
680 _mesa_make_current( mesaCtx,
681 mesaDraw,
682 mesaRead );
683 }
684 else {
685 /* unbind */
686 _mesa_make_current( NULL, NULL, NULL );
687 }
688
689 return GL_TRUE;
690 }
691
692 static int driUnbindContext(__DRIcontext *ctx)
693 {
694 TRACE;
695 (void) ctx;
696 _mesa_make_current(NULL, NULL, NULL);
697 return GL_TRUE;
698 }
699
700
701 static const __DRIcoreExtension driCoreExtension = {
702 { __DRI_CORE, __DRI_CORE_VERSION },
703 NULL, /* driCreateNewScreen */
704 driDestroyScreen,
705 driGetExtensions,
706 driGetConfigAttrib,
707 driIndexConfigAttrib,
708 NULL, /* driCreateNewDrawable */
709 driDestroyDrawable,
710 driSwapBuffers,
711 driCreateNewContext,
712 driCopyContext,
713 driDestroyContext,
714 driBindContext,
715 driUnbindContext
716 };
717
718 static const __DRIswrastExtension driSWRastExtension = {
719 { __DRI_SWRAST, __DRI_SWRAST_VERSION },
720 driCreateNewScreen,
721 driCreateNewDrawable
722 };
723
724 /* This is the table of extensions that the loader will dlsym() for. */
725 PUBLIC const __DRIextension *__driDriverExtensions[] = {
726 &driCoreExtension.base,
727 &driSWRastExtension.base,
728 NULL
729 };