swrast.c revision 8d789be03430b80e0ba2fef19d56dd0b8e699ea2
1/*
2 * Copyright 2008, 2010 George Sapountzis <gsapountzis@gmail.com>
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/formats.h"
37#include "main/framebuffer.h"
38#include "main/imports.h"
39#include "main/renderbuffer.h"
40#include "swrast/swrast.h"
41#include "swrast_setup/swrast_setup.h"
42#include "tnl/tnl.h"
43#include "tnl/t_context.h"
44#include "tnl/t_pipeline.h"
45#include "vbo/vbo.h"
46#include "drivers/common/driverfuncs.h"
47#include "drivers/common/meta.h"
48#include "utils.h"
49
50#include "main/teximage.h"
51#include "main/texfetch.h"
52#include "main/texformat.h"
53#include "main/texstate.h"
54#include "main/texobj.h"
55
56#include "swrast_priv.h"
57
58
59/**
60 * Screen and config-related functions
61 */
62
63static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
64				GLint texture_format, __DRIdrawable *dPriv)
65{
66    struct dri_context *dri_ctx;
67    int x, y, w, h;
68    __DRIscreen *sPriv = dPriv->driScreenPriv;
69    struct gl_texture_unit *texUnit;
70    struct gl_texture_object *texObj;
71    struct gl_texture_image *texImage;
72    uint32_t internalFormat;
73
74    dri_ctx = pDRICtx->driverPrivate;
75
76    internalFormat = (texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4);
77
78    texUnit = _mesa_get_current_tex_unit(&dri_ctx->Base);
79    texObj = _mesa_select_tex_object(&dri_ctx->Base, texUnit, target);
80    texImage = _mesa_get_tex_image(&dri_ctx->Base, texObj, target, 0);
81
82    _mesa_lock_texture(&dri_ctx->Base, texObj);
83
84    sPriv->swrast_loader->getDrawableInfo(dPriv, &x, &y, &w, &h, dPriv->loaderPrivate);
85
86    _mesa_init_teximage_fields(&dri_ctx->Base, target, texImage,
87			       w, h, 1, 0, internalFormat);
88
89    if (texture_format == __DRI_TEXTURE_FORMAT_RGB)
90	texImage->TexFormat = MESA_FORMAT_XRGB8888;
91    else
92	texImage->TexFormat = MESA_FORMAT_ARGB8888;
93
94    _mesa_set_fetch_functions(texImage, 2);
95
96    sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)texImage->Data,
97				   dPriv->loaderPrivate);
98
99    _mesa_unlock_texture(&dri_ctx->Base, texObj);
100}
101
102static void swrastSetTexBuffer(__DRIcontext *pDRICtx, GLint target,
103			       __DRIdrawable *dPriv)
104{
105    swrastSetTexBuffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
106}
107
108static const __DRItexBufferExtension swrastTexBufferExtension = {
109    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
110    swrastSetTexBuffer,
111    swrastSetTexBuffer2,
112};
113
114static const __DRIextension *dri_screen_extensions[] = {
115    &swrastTexBufferExtension.base,
116    NULL
117};
118
119static __DRIconfig **
120swrastFillInModes(__DRIscreen *psp,
121		  unsigned pixel_bits, unsigned depth_bits,
122		  unsigned stencil_bits, GLboolean have_back_buffer)
123{
124    __DRIconfig **configs;
125    unsigned depth_buffer_factor;
126    unsigned back_buffer_factor;
127    GLenum fb_format;
128    GLenum fb_type;
129
130    /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
131     * support pageflipping at all.
132     */
133    static const GLenum back_buffer_modes[] = {
134	GLX_NONE, GLX_SWAP_UNDEFINED_OML
135    };
136
137    uint8_t depth_bits_array[4];
138    uint8_t stencil_bits_array[4];
139    uint8_t msaa_samples_array[1];
140
141    depth_bits_array[0] = 0;
142    depth_bits_array[1] = 0;
143    depth_bits_array[2] = depth_bits;
144    depth_bits_array[3] = depth_bits;
145
146    /* Just like with the accumulation buffer, always provide some modes
147     * with a stencil buffer.
148     */
149    stencil_bits_array[0] = 0;
150    stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
151    stencil_bits_array[2] = 0;
152    stencil_bits_array[3] = (stencil_bits == 0) ? 8 : stencil_bits;
153
154    msaa_samples_array[0] = 0;
155
156    depth_buffer_factor = 4;
157    back_buffer_factor = 2;
158
159    switch (pixel_bits) {
160    case 8:
161	fb_format = GL_RGB;
162	fb_type = GL_UNSIGNED_BYTE_2_3_3_REV;
163	break;
164    case 16:
165	fb_format = GL_RGB;
166	fb_type = GL_UNSIGNED_SHORT_5_6_5;
167	break;
168    case 24:
169	fb_format = GL_BGR;
170	fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
171	break;
172    case 32:
173	fb_format = GL_BGRA;
174	fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
175	break;
176    default:
177	fprintf(stderr, "[%s:%u] bad depth %d\n", __func__, __LINE__,
178		pixel_bits);
179	return NULL;
180    }
181
182    configs = driCreateConfigs(fb_format, fb_type,
183			       depth_bits_array, stencil_bits_array,
184			       depth_buffer_factor, back_buffer_modes,
185			       back_buffer_factor, msaa_samples_array, 1,
186			       GL_TRUE);
187    if (configs == NULL) {
188	fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
189		__LINE__);
190	return NULL;
191    }
192
193    return configs;
194}
195
196static const __DRIconfig **
197dri_init_screen(__DRIscreen * psp)
198{
199    __DRIconfig **configs8, **configs16, **configs24, **configs32;
200
201    TRACE;
202
203    psp->extensions = dri_screen_extensions;
204
205    configs8  = swrastFillInModes(psp,  8,  8, 0, 1);
206    configs16 = swrastFillInModes(psp, 16, 16, 0, 1);
207    configs24 = swrastFillInModes(psp, 24, 24, 8, 1);
208    configs32 = swrastFillInModes(psp, 32, 24, 8, 1);
209
210    configs16 = driConcatConfigs(configs8, configs16);
211    configs24 = driConcatConfigs(configs16, configs24);
212    configs32 = driConcatConfigs(configs24, configs32);
213
214    return (const __DRIconfig **)configs32;
215}
216
217static void
218dri_destroy_screen(__DRIscreen * sPriv)
219{
220    TRACE;
221}
222
223
224/**
225 * Framebuffer and renderbuffer-related functions.
226 */
227
228static GLuint
229choose_pixel_format(const GLvisual *v)
230{
231    int depth = v->rgbBits;
232
233    if (depth == 32
234	&& v->redMask   == 0xff0000
235	&& v->greenMask == 0x00ff00
236	&& v->blueMask  == 0x0000ff)
237	return PF_A8R8G8B8;
238    else if (depth == 24
239	     && v->redMask   == 0xff0000
240	     && v->greenMask == 0x00ff00
241	     && v->blueMask  == 0x0000ff)
242	return PF_X8R8G8B8;
243    else if (depth == 16
244	     && v->redMask   == 0xf800
245	     && v->greenMask == 0x07e0
246	     && v->blueMask  == 0x001f)
247	return PF_R5G6B5;
248    else if (depth == 8
249	     && v->redMask   == 0x07
250	     && v->greenMask == 0x38
251	     && v->blueMask  == 0xc0)
252	return PF_R3G3B2;
253
254    _mesa_problem( NULL, "unexpected format in %s", __FUNCTION__ );
255    return 0;
256}
257
258static void
259swrast_delete_renderbuffer(struct gl_renderbuffer *rb)
260{
261    TRACE;
262
263    free(rb->Data);
264    free(rb);
265}
266
267/* see bytes_per_line in libGL */
268static INLINE int
269bytes_per_line(unsigned pitch_bits, unsigned mul)
270{
271   unsigned mask = mul - 1;
272
273   return ((pitch_bits + mask) & ~mask) / 8;
274}
275
276static GLboolean
277swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
278			   GLenum internalFormat, GLuint width, GLuint height)
279{
280    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
281
282    TRACE;
283
284    rb->Data = NULL;
285    rb->Width = width;
286    rb->Height = height;
287
288    xrb->pitch = bytes_per_line(width * xrb->bpp, 32);
289
290    return GL_TRUE;
291}
292
293static GLboolean
294swrast_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
295			  GLenum internalFormat, GLuint width, GLuint height)
296{
297    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
298
299    TRACE;
300
301    free(rb->Data);
302
303    swrast_alloc_front_storage(ctx, rb, internalFormat, width, height);
304
305    rb->Data = malloc(height * xrb->pitch);
306
307    return GL_TRUE;
308}
309
310static struct swrast_renderbuffer *
311swrast_new_renderbuffer(const GLvisual *visual, GLboolean front)
312{
313    struct swrast_renderbuffer *xrb = calloc(1, sizeof *xrb);
314    GLuint pixel_format;
315
316    TRACE;
317
318    if (!xrb)
319	return NULL;
320
321    _mesa_init_renderbuffer(&xrb->Base, 0);
322
323    pixel_format = choose_pixel_format(visual);
324
325    xrb->Base.Delete = swrast_delete_renderbuffer;
326    if (front) {
327	xrb->Base.AllocStorage = swrast_alloc_front_storage;
328	swrast_set_span_funcs_front(xrb, pixel_format);
329    }
330    else {
331	xrb->Base.AllocStorage = swrast_alloc_back_storage;
332	swrast_set_span_funcs_back(xrb, pixel_format);
333    }
334
335    switch (pixel_format) {
336    case PF_A8R8G8B8:
337	xrb->Base.Format = MESA_FORMAT_ARGB8888;
338	xrb->Base.InternalFormat = GL_RGBA;
339	xrb->Base._BaseFormat = GL_RGBA;
340	xrb->Base.DataType = GL_UNSIGNED_BYTE;
341	xrb->bpp = 32;
342	break;
343    case PF_X8R8G8B8:
344	xrb->Base.Format = MESA_FORMAT_ARGB8888; /* XXX */
345	xrb->Base.InternalFormat = GL_RGB;
346	xrb->Base._BaseFormat = GL_RGB;
347	xrb->Base.DataType = GL_UNSIGNED_BYTE;
348	xrb->bpp = 32;
349	break;
350    case PF_R5G6B5:
351	xrb->Base.Format = MESA_FORMAT_RGB565;
352	xrb->Base.InternalFormat = GL_RGB;
353	xrb->Base._BaseFormat = GL_RGB;
354	xrb->Base.DataType = GL_UNSIGNED_BYTE;
355	xrb->bpp = 16;
356	break;
357    case PF_R3G3B2:
358	xrb->Base.Format = MESA_FORMAT_RGB332;
359	xrb->Base.InternalFormat = GL_RGB;
360	xrb->Base._BaseFormat = GL_RGB;
361	xrb->Base.DataType = GL_UNSIGNED_BYTE;
362	xrb->bpp = 8;
363	break;
364    default:
365	return NULL;
366    }
367
368    return xrb;
369}
370
371static GLboolean
372dri_create_buffer(__DRIscreen * sPriv,
373		  __DRIdrawable * dPriv,
374		  const __GLcontextModes * visual, GLboolean isPixmap)
375{
376    struct dri_drawable *drawable = NULL;
377    GLframebuffer *fb;
378    struct swrast_renderbuffer *frontrb, *backrb;
379
380    TRACE;
381
382    drawable = CALLOC_STRUCT(dri_drawable);
383    if (drawable == NULL)
384	goto drawable_fail;
385
386    dPriv->driverPrivate = drawable;
387    drawable->dPriv = dPriv;
388
389    drawable->row = malloc(MAX_WIDTH * 4);
390    if (drawable->row == NULL)
391	goto drawable_fail;
392
393    fb = &drawable->Base;
394
395    /* basic framebuffer setup */
396    _mesa_initialize_window_framebuffer(fb, visual);
397
398    /* add front renderbuffer */
399    frontrb = swrast_new_renderbuffer(visual, GL_TRUE);
400    _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontrb->Base);
401
402    /* add back renderbuffer */
403    if (visual->doubleBufferMode) {
404	backrb = swrast_new_renderbuffer(visual, GL_FALSE);
405	_mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backrb->Base);
406    }
407
408    /* add software renderbuffers */
409    _mesa_add_soft_renderbuffers(fb,
410				 GL_FALSE, /* color */
411				 visual->haveDepthBuffer,
412				 visual->haveStencilBuffer,
413				 visual->haveAccumBuffer,
414				 GL_FALSE, /* alpha */
415				 GL_FALSE /* aux bufs */);
416
417    return GL_TRUE;
418
419drawable_fail:
420
421    if (drawable)
422	free(drawable->row);
423
424    FREE(drawable);
425
426    return GL_FALSE;
427}
428
429static void
430dri_destroy_buffer(__DRIdrawable * dPriv)
431{
432    TRACE;
433
434    if (dPriv) {
435	struct dri_drawable *drawable = dri_drawable(dPriv);
436	GLframebuffer *fb;
437
438	free(drawable->row);
439
440	fb = &drawable->Base;
441
442	fb->DeletePending = GL_TRUE;
443	_mesa_reference_framebuffer(&fb, NULL);
444    }
445}
446
447static void
448dri_swap_buffers(__DRIdrawable * dPriv)
449{
450    __DRIscreen *sPriv = dPriv->driScreenPriv;
451
452    GET_CURRENT_CONTEXT(ctx);
453
454    struct dri_drawable *drawable = dri_drawable(dPriv);
455    GLframebuffer *fb;
456    struct swrast_renderbuffer *frontrb, *backrb;
457
458    TRACE;
459
460    fb = &drawable->Base;
461
462    frontrb =
463	swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
464    backrb =
465	swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
466
467    /* check for signle-buffered */
468    if (backrb == NULL)
469	return;
470
471    /* check if swapping currently bound buffer */
472    if (ctx && ctx->DrawBuffer == fb) {
473	/* flush pending rendering */
474	_mesa_notifySwapBuffers(ctx);
475    }
476
477    sPriv->swrast_loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP,
478				   0, 0,
479				   frontrb->Base.Width,
480				   frontrb->Base.Height,
481				   backrb->Base.Data,
482				   dPriv->loaderPrivate);
483}
484
485
486/**
487 * General device driver functions.
488 */
489
490static void
491get_window_size( GLframebuffer *fb, GLsizei *w, GLsizei *h )
492{
493    __DRIdrawable *dPriv = swrast_drawable(fb)->dPriv;
494    __DRIscreen *sPriv = dPriv->driScreenPriv;
495    int x, y;
496
497    sPriv->swrast_loader->getDrawableInfo(dPriv,
498					  &x, &y, w, h,
499					  dPriv->loaderPrivate);
500}
501
502static void
503swrast_check_and_update_window_size( GLcontext *ctx, GLframebuffer *fb )
504{
505    GLsizei width, height;
506
507    get_window_size(fb, &width, &height);
508    if (fb->Width != width || fb->Height != height) {
509	_mesa_resize_framebuffer(ctx, fb, width, height);
510    }
511}
512
513static const GLubyte *
514get_string(GLcontext *ctx, GLenum pname)
515{
516    (void) ctx;
517    switch (pname) {
518	case GL_VENDOR:
519	    return (const GLubyte *) "Mesa Project";
520	case GL_RENDERER:
521	    return (const GLubyte *) "Software Rasterizer";
522	default:
523	    return NULL;
524    }
525}
526
527static void
528update_state( GLcontext *ctx, GLuint new_state )
529{
530    /* not much to do here - pass it on */
531    _swrast_InvalidateState( ctx, new_state );
532    _swsetup_InvalidateState( ctx, new_state );
533    _vbo_InvalidateState( ctx, new_state );
534    _tnl_InvalidateState( ctx, new_state );
535}
536
537static void
538viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
539{
540    GLframebuffer *draw = ctx->WinSysDrawBuffer;
541    GLframebuffer *read = ctx->WinSysReadBuffer;
542
543    swrast_check_and_update_window_size(ctx, draw);
544    swrast_check_and_update_window_size(ctx, read);
545}
546
547static gl_format swrastChooseTextureFormat(GLcontext * ctx,
548					   GLint internalFormat,
549					   GLenum format,
550					   GLenum type)
551{
552    if (internalFormat == GL_RGB)
553	return MESA_FORMAT_XRGB8888;
554    return _mesa_choose_tex_format(ctx, internalFormat, format, type);
555}
556
557static void
558swrast_init_driver_functions(struct dd_function_table *driver)
559{
560    driver->GetString = get_string;
561    driver->UpdateState = update_state;
562    driver->GetBufferSize = NULL;
563    driver->Viewport = viewport;
564    driver->ChooseTextureFormat = swrastChooseTextureFormat;
565}
566
567
568/**
569 * Context-related functions.
570 */
571
572static GLboolean
573dri_create_context(gl_api api,
574		   const __GLcontextModes * visual,
575		   __DRIcontext * cPriv, void *sharedContextPrivate)
576{
577    struct dri_context *ctx = NULL;
578    struct dri_context *share = (struct dri_context *)sharedContextPrivate;
579    GLcontext *mesaCtx = NULL;
580    GLcontext *sharedCtx = NULL;
581    struct dd_function_table functions;
582
583    TRACE;
584
585    ctx = CALLOC_STRUCT(dri_context);
586    if (ctx == NULL)
587	goto context_fail;
588
589    cPriv->driverPrivate = ctx;
590    ctx->cPriv = cPriv;
591
592    /* build table of device driver functions */
593    _mesa_init_driver_functions(&functions);
594    swrast_init_driver_functions(&functions);
595
596    if (share) {
597	sharedCtx = &share->Base;
598    }
599
600    mesaCtx = &ctx->Base;
601
602    /* basic context setup */
603    if (!_mesa_initialize_context(mesaCtx, visual, sharedCtx, &functions, (void *) cPriv)) {
604	goto context_fail;
605    }
606
607    /* do bounds checking to prevent segfaults and server crashes! */
608    mesaCtx->Const.CheckArrayBounds = GL_TRUE;
609
610    /* create module contexts */
611    _swrast_CreateContext( mesaCtx );
612    _vbo_CreateContext( mesaCtx );
613    _tnl_CreateContext( mesaCtx );
614    _swsetup_CreateContext( mesaCtx );
615    _swsetup_Wakeup( mesaCtx );
616
617    /* use default TCL pipeline */
618    {
619       TNLcontext *tnl = TNL_CONTEXT(mesaCtx);
620       tnl->Driver.RunPipeline = _tnl_run_pipeline;
621    }
622
623    _mesa_enable_sw_extensions(mesaCtx);
624    _mesa_enable_1_3_extensions(mesaCtx);
625    _mesa_enable_1_4_extensions(mesaCtx);
626    _mesa_enable_1_5_extensions(mesaCtx);
627    _mesa_enable_2_0_extensions(mesaCtx);
628    _mesa_enable_2_1_extensions(mesaCtx);
629
630    _mesa_meta_init(mesaCtx);
631
632    driInitExtensions( mesaCtx, NULL, GL_FALSE );
633
634    return GL_TRUE;
635
636context_fail:
637
638    FREE(ctx);
639
640    return GL_FALSE;
641}
642
643static void
644dri_destroy_context(__DRIcontext * cPriv)
645{
646    TRACE;
647
648    if (cPriv) {
649	struct dri_context *ctx = dri_context(cPriv);
650	GLcontext *mesaCtx;
651
652	mesaCtx = &ctx->Base;
653
654        _mesa_meta_free(mesaCtx);
655	_swsetup_DestroyContext( mesaCtx );
656	_swrast_DestroyContext( mesaCtx );
657	_tnl_DestroyContext( mesaCtx );
658	_vbo_DestroyContext( mesaCtx );
659	_mesa_destroy_context( mesaCtx );
660    }
661}
662
663static GLboolean
664dri_make_current(__DRIcontext * cPriv,
665		 __DRIdrawable * driDrawPriv,
666		 __DRIdrawable * driReadPriv)
667{
668    GLcontext *mesaCtx;
669    GLframebuffer *mesaDraw;
670    GLframebuffer *mesaRead;
671    TRACE;
672
673    if (cPriv) {
674	struct dri_context *ctx = dri_context(cPriv);
675	struct dri_drawable *draw;
676	struct dri_drawable *read;
677
678	if (!driDrawPriv || !driReadPriv)
679	    return GL_FALSE;
680
681	draw = dri_drawable(driDrawPriv);
682	read = dri_drawable(driReadPriv);
683	mesaCtx = &ctx->Base;
684	mesaDraw = &draw->Base;
685	mesaRead = &read->Base;
686
687	/* check for same context and buffer */
688	if (mesaCtx == _mesa_get_current_context()
689	    && mesaCtx->DrawBuffer == mesaDraw
690	    && mesaCtx->ReadBuffer == mesaRead) {
691	    return GL_TRUE;
692	}
693
694	_glapi_check_multithread();
695
696	swrast_check_and_update_window_size(mesaCtx, mesaDraw);
697	if (mesaRead != mesaDraw)
698	    swrast_check_and_update_window_size(mesaCtx, mesaRead);
699
700	_mesa_make_current( mesaCtx,
701			    mesaDraw,
702			    mesaRead );
703    }
704    else {
705	/* unbind */
706	_mesa_make_current( NULL, NULL, NULL );
707    }
708
709    return GL_TRUE;
710}
711
712static GLboolean
713dri_unbind_context(__DRIcontext * cPriv)
714{
715    TRACE;
716    (void) cPriv;
717    return GL_TRUE;
718}
719
720
721const struct __DriverAPIRec driDriverAPI = {
722    .InitScreen = dri_init_screen,
723    .DestroyScreen = dri_destroy_screen,
724    .CreateContext = dri_create_context,
725    .DestroyContext = dri_destroy_context,
726    .CreateBuffer = dri_create_buffer,
727    .DestroyBuffer = dri_destroy_buffer,
728    .SwapBuffers = dri_swap_buffers,
729    .MakeCurrent = dri_make_current,
730    .UnbindContext = dri_unbind_context,
731};
732
733/* This is the table of extensions that the loader will dlsym() for. */
734PUBLIC const __DRIextension *__driDriverExtensions[] = {
735    &driCoreExtension.base,
736    &driSWRastExtension.base,
737    NULL
738};
739