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