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