a6bf3c1e10fbafe927fc0fba5bc66a01117274d5
[mesa.git] / src / gallium / state_trackers / dri / drm / dri2.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.9
4 *
5 * Copyright 2009, VMware, Inc.
6 * All Rights Reserved.
7 * Copyright (C) 2010 LunarG Inc.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 * Authors:
27 * Keith Whitwell <keithw@vmware.com>
28 * Jakob Bornecrantz <wallbraker@gmail.com>
29 * Chia-I Wu <olv@lunarg.com>
30 */
31
32 #include "util/u_memory.h"
33 #include "util/u_inlines.h"
34 #include "util/u_format.h"
35 #include "util/u_debug.h"
36 #include "state_tracker/drm_driver.h"
37
38 #include "dri_screen.h"
39 #include "dri_context.h"
40 #include "dri_drawable.h"
41 #include "dri2_buffer.h"
42
43 /**
44 * DRI2 flush extension.
45 */
46 static void
47 dri2_flush_drawable(__DRIdrawable *dPriv)
48 {
49 struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv);
50 struct dri_drawable *drawable = dri_drawable(dPriv);
51
52 struct pipe_resource *ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
53
54 if (ctx) {
55 if (ptex && ctx->pp && drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
56 pp_run(ctx->pp, ptex, ptex, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
57
58 ctx->st->flush(ctx->st, 0, NULL);
59 }
60 }
61
62 static void
63 dri2_invalidate_drawable(__DRIdrawable *dPriv)
64 {
65 struct dri_drawable *drawable = dri_drawable(dPriv);
66
67 dri2InvalidateDrawable(dPriv);
68 drawable->dPriv->lastStamp = drawable->dPriv->dri2.stamp;
69
70 p_atomic_inc(&drawable->base.stamp);
71 }
72
73 static const __DRI2flushExtension dri2FlushExtension = {
74 { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
75 dri2_flush_drawable,
76 dri2_invalidate_drawable,
77 };
78
79 /**
80 * Retrieve __DRIbuffer from the DRI loader.
81 */
82 static __DRIbuffer *
83 dri2_drawable_get_buffers(struct dri_drawable *drawable,
84 const enum st_attachment_type *statts,
85 unsigned *count)
86 {
87 __DRIdrawable *dri_drawable = drawable->dPriv;
88 struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader;
89 boolean with_format;
90 __DRIbuffer *buffers;
91 int num_buffers;
92 unsigned attachments[10];
93 unsigned num_attachments, i;
94
95 assert(loader);
96 with_format = dri_with_format(drawable->sPriv);
97
98 num_attachments = 0;
99
100 /* for Xserver 1.6.0 (DRI2 version 1) we always need to ask for the front */
101 if (!with_format)
102 attachments[num_attachments++] = __DRI_BUFFER_FRONT_LEFT;
103
104 for (i = 0; i < *count; i++) {
105 enum pipe_format format;
106 unsigned bind;
107 int att, bpp;
108
109 dri_drawable_get_format(drawable, statts[i], &format, &bind);
110 if (format == PIPE_FORMAT_NONE)
111 continue;
112
113 switch (statts[i]) {
114 case ST_ATTACHMENT_FRONT_LEFT:
115 /* already added */
116 if (!with_format)
117 continue;
118 att = __DRI_BUFFER_FRONT_LEFT;
119 break;
120 case ST_ATTACHMENT_BACK_LEFT:
121 att = __DRI_BUFFER_BACK_LEFT;
122 break;
123 case ST_ATTACHMENT_FRONT_RIGHT:
124 att = __DRI_BUFFER_FRONT_RIGHT;
125 break;
126 case ST_ATTACHMENT_BACK_RIGHT:
127 att = __DRI_BUFFER_BACK_RIGHT;
128 break;
129 case ST_ATTACHMENT_DEPTH_STENCIL:
130 att = __DRI_BUFFER_DEPTH_STENCIL;
131 break;
132 default:
133 att = -1;
134 break;
135 }
136
137 bpp = util_format_get_blocksizebits(format);
138
139 if (att >= 0) {
140 attachments[num_attachments++] = att;
141 if (with_format) {
142 attachments[num_attachments++] = bpp;
143 }
144 }
145 }
146
147 if (with_format) {
148 num_attachments /= 2;
149 buffers = loader->getBuffersWithFormat(dri_drawable,
150 &dri_drawable->w, &dri_drawable->h,
151 attachments, num_attachments,
152 &num_buffers, dri_drawable->loaderPrivate);
153 }
154 else {
155 buffers = loader->getBuffers(dri_drawable,
156 &dri_drawable->w, &dri_drawable->h,
157 attachments, num_attachments,
158 &num_buffers, dri_drawable->loaderPrivate);
159 }
160
161 if (buffers)
162 *count = num_buffers;
163
164 return buffers;
165 }
166
167 /**
168 * Process __DRIbuffer and convert them into pipe_resources.
169 */
170 static void
171 dri2_drawable_process_buffers(struct dri_drawable *drawable,
172 __DRIbuffer *buffers, unsigned count)
173 {
174 struct dri_screen *screen = dri_screen(drawable->sPriv);
175 __DRIdrawable *dri_drawable = drawable->dPriv;
176 struct pipe_resource templ;
177 struct winsys_handle whandle;
178 boolean have_depth = FALSE;
179 unsigned i, bind;
180
181 if (drawable->old_num == count &&
182 drawable->old_w == dri_drawable->w &&
183 drawable->old_h == dri_drawable->h &&
184 memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0)
185 return;
186
187 for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
188 pipe_resource_reference(&drawable->textures[i], NULL);
189
190 memset(&templ, 0, sizeof(templ));
191 templ.target = screen->target;
192 templ.last_level = 0;
193 templ.width0 = dri_drawable->w;
194 templ.height0 = dri_drawable->h;
195 templ.depth0 = 1;
196 templ.array_size = 1;
197
198 memset(&whandle, 0, sizeof(whandle));
199
200 for (i = 0; i < count; i++) {
201 __DRIbuffer *buf = &buffers[i];
202 enum st_attachment_type statt;
203 enum pipe_format format;
204
205 switch (buf->attachment) {
206 case __DRI_BUFFER_FRONT_LEFT:
207 if (!screen->auto_fake_front) {
208 statt = ST_ATTACHMENT_INVALID;
209 break;
210 }
211 /* fallthrough */
212 case __DRI_BUFFER_FAKE_FRONT_LEFT:
213 statt = ST_ATTACHMENT_FRONT_LEFT;
214 break;
215 case __DRI_BUFFER_BACK_LEFT:
216 statt = ST_ATTACHMENT_BACK_LEFT;
217 break;
218 case __DRI_BUFFER_DEPTH:
219 case __DRI_BUFFER_DEPTH_STENCIL:
220 case __DRI_BUFFER_STENCIL:
221 /* use only the first depth/stencil buffer */
222 if (!have_depth) {
223 have_depth = TRUE;
224 statt = ST_ATTACHMENT_DEPTH_STENCIL;
225 }
226 else {
227 statt = ST_ATTACHMENT_INVALID;
228 }
229 break;
230 default:
231 statt = ST_ATTACHMENT_INVALID;
232 break;
233 }
234
235 dri_drawable_get_format(drawable, statt, &format, &bind);
236 if (statt == ST_ATTACHMENT_INVALID || format == PIPE_FORMAT_NONE)
237 continue;
238
239 templ.format = format;
240 templ.bind = bind;
241 whandle.handle = buf->name;
242 whandle.stride = buf->pitch;
243
244 drawable->textures[statt] =
245 screen->base.screen->resource_from_handle(screen->base.screen,
246 &templ, &whandle);
247 }
248
249 drawable->old_num = count;
250 drawable->old_w = dri_drawable->w;
251 drawable->old_h = dri_drawable->h;
252 memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count);
253 }
254
255 static __DRIbuffer *
256 dri2_allocate_buffer(__DRIscreen *sPriv,
257 unsigned attachment, unsigned format,
258 int width, int height)
259 {
260 struct dri_screen *screen = dri_screen(sPriv);
261 struct dri2_buffer *buffer;
262 struct pipe_resource templ;
263 enum pipe_format pf;
264 unsigned bind = 0;
265 struct winsys_handle whandle;
266
267 switch (attachment) {
268 case __DRI_BUFFER_FRONT_LEFT:
269 case __DRI_BUFFER_FAKE_FRONT_LEFT:
270 bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
271 break;
272 case __DRI_BUFFER_BACK_LEFT:
273 bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
274 break;
275 case __DRI_BUFFER_DEPTH:
276 case __DRI_BUFFER_DEPTH_STENCIL:
277 case __DRI_BUFFER_STENCIL:
278 bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
279 break;
280 }
281
282 switch (format) {
283 case 32:
284 pf = PIPE_FORMAT_B8G8R8X8_UNORM;
285 break;
286 case 16:
287 pf = PIPE_FORMAT_Z16_UNORM;
288 break;
289 default:
290 return NULL;
291 }
292
293 buffer = CALLOC_STRUCT(dri2_buffer);
294 if (!buffer)
295 return NULL;
296
297 memset(&templ, 0, sizeof(templ));
298 templ.bind = bind;
299 templ.format = pf;
300 templ.target = PIPE_TEXTURE_2D;
301 templ.last_level = 0;
302 templ.width0 = width;
303 templ.height0 = height;
304 templ.depth0 = 1;
305 templ.array_size = 1;
306
307 buffer->resource =
308 screen->base.screen->resource_create(screen->base.screen, &templ);
309 if (!buffer->resource)
310 return NULL;
311
312 memset(&whandle, 0, sizeof(whandle));
313 whandle.type = DRM_API_HANDLE_TYPE_SHARED;
314 screen->base.screen->resource_get_handle(screen->base.screen,
315 buffer->resource, &whandle);
316
317 buffer->base.attachment = attachment;
318 buffer->base.name = whandle.handle;
319 buffer->base.cpp = util_format_get_blocksize(pf);
320 buffer->base.pitch = whandle.stride;
321
322 return &buffer->base;
323 }
324
325 static void
326 dri2_release_buffer(__DRIscreen *sPriv, __DRIbuffer *bPriv)
327 {
328 struct dri2_buffer *buffer = dri2_buffer(bPriv);
329
330 pipe_resource_reference(&buffer->resource, NULL);
331 FREE(buffer);
332 }
333
334 /*
335 * Backend functions for st_framebuffer interface.
336 */
337
338 static void
339 dri2_allocate_textures(struct dri_drawable *drawable,
340 const enum st_attachment_type *statts,
341 unsigned count)
342 {
343 __DRIbuffer *buffers;
344 unsigned num_buffers = count;
345
346 buffers = dri2_drawable_get_buffers(drawable, statts, &num_buffers);
347 if (buffers)
348 dri2_drawable_process_buffers(drawable, buffers, num_buffers);
349 }
350
351 static void
352 dri2_flush_frontbuffer(struct dri_drawable *drawable,
353 enum st_attachment_type statt)
354 {
355 __DRIdrawable *dri_drawable = drawable->dPriv;
356 struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader;
357
358 if (loader->flushFrontBuffer == NULL)
359 return;
360
361 if (statt == ST_ATTACHMENT_FRONT_LEFT) {
362 loader->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate);
363 }
364 }
365
366 static void
367 dri2_update_tex_buffer(struct dri_drawable *drawable,
368 struct dri_context *ctx,
369 struct pipe_resource *res)
370 {
371 /* no-op */
372 }
373
374 static __DRIimage *
375 dri2_lookup_egl_image(struct dri_screen *screen, void *handle)
376 {
377 __DRIimageLookupExtension *loader = screen->sPriv->dri2.image;
378 __DRIimage *img;
379
380 if (!loader->lookupEGLImage)
381 return NULL;
382
383 img = loader->lookupEGLImage(screen->sPriv,
384 handle, screen->sPriv->loaderPrivate);
385
386 return img;
387 }
388
389 static __DRIimage *
390 dri2_create_image_from_name(__DRIscreen *_screen,
391 int width, int height, int format,
392 int name, int pitch, void *loaderPrivate)
393 {
394 struct dri_screen *screen = dri_screen(_screen);
395 __DRIimage *img;
396 struct pipe_resource templ;
397 struct winsys_handle whandle;
398 unsigned tex_usage;
399 enum pipe_format pf;
400
401 tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
402
403 switch (format) {
404 case __DRI_IMAGE_FORMAT_RGB565:
405 pf = PIPE_FORMAT_B5G6R5_UNORM;
406 break;
407 case __DRI_IMAGE_FORMAT_XRGB8888:
408 pf = PIPE_FORMAT_B8G8R8X8_UNORM;
409 break;
410 case __DRI_IMAGE_FORMAT_ARGB8888:
411 pf = PIPE_FORMAT_B8G8R8A8_UNORM;
412 break;
413 case __DRI_IMAGE_FORMAT_ABGR8888:
414 pf = PIPE_FORMAT_R8G8B8A8_UNORM;
415 break;
416 default:
417 pf = PIPE_FORMAT_NONE;
418 break;
419 }
420 if (pf == PIPE_FORMAT_NONE)
421 return NULL;
422
423 img = CALLOC_STRUCT(__DRIimageRec);
424 if (!img)
425 return NULL;
426
427 memset(&templ, 0, sizeof(templ));
428 templ.bind = tex_usage;
429 templ.format = pf;
430 templ.target = screen->target;
431 templ.last_level = 0;
432 templ.width0 = width;
433 templ.height0 = height;
434 templ.depth0 = 1;
435 templ.array_size = 1;
436
437 memset(&whandle, 0, sizeof(whandle));
438 whandle.handle = name;
439 whandle.stride = pitch * util_format_get_blocksize(pf);
440
441 img->texture = screen->base.screen->resource_from_handle(screen->base.screen,
442 &templ, &whandle);
443 if (!img->texture) {
444 FREE(img);
445 return NULL;
446 }
447
448 img->level = 0;
449 img->layer = 0;
450 img->loader_private = loaderPrivate;
451
452 return img;
453 }
454
455 static __DRIimage *
456 dri2_create_image_from_renderbuffer(__DRIcontext *context,
457 int renderbuffer, void *loaderPrivate)
458 {
459 struct dri_context *ctx = dri_context(context);
460
461 if (!ctx->st->get_resource_for_egl_image)
462 return NULL;
463
464 /* TODO */
465 return NULL;
466 }
467
468 static __DRIimage *
469 dri2_create_image(__DRIscreen *_screen,
470 int width, int height, int format,
471 unsigned int use, void *loaderPrivate)
472 {
473 struct dri_screen *screen = dri_screen(_screen);
474 __DRIimage *img;
475 struct pipe_resource templ;
476 unsigned tex_usage;
477 enum pipe_format pf;
478
479 tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
480 if (use & __DRI_IMAGE_USE_SCANOUT)
481 tex_usage |= PIPE_BIND_SCANOUT;
482 if (use & __DRI_IMAGE_USE_SHARE)
483 tex_usage |= PIPE_BIND_SHARED;
484 if (use & __DRI_IMAGE_USE_CURSOR) {
485 if (width != 64 || height != 64)
486 return NULL;
487 tex_usage |= PIPE_BIND_CURSOR;
488 }
489
490 switch (format) {
491 case __DRI_IMAGE_FORMAT_RGB565:
492 pf = PIPE_FORMAT_B5G6R5_UNORM;
493 break;
494 case __DRI_IMAGE_FORMAT_XRGB8888:
495 pf = PIPE_FORMAT_B8G8R8X8_UNORM;
496 break;
497 case __DRI_IMAGE_FORMAT_ARGB8888:
498 pf = PIPE_FORMAT_B8G8R8A8_UNORM;
499 break;
500 case __DRI_IMAGE_FORMAT_ABGR8888:
501 pf = PIPE_FORMAT_R8G8B8A8_UNORM;
502 break;
503 default:
504 pf = PIPE_FORMAT_NONE;
505 break;
506 }
507 if (pf == PIPE_FORMAT_NONE)
508 return NULL;
509
510 img = CALLOC_STRUCT(__DRIimageRec);
511 if (!img)
512 return NULL;
513
514 memset(&templ, 0, sizeof(templ));
515 templ.bind = tex_usage;
516 templ.format = pf;
517 templ.target = PIPE_TEXTURE_2D;
518 templ.last_level = 0;
519 templ.width0 = width;
520 templ.height0 = height;
521 templ.depth0 = 1;
522 templ.array_size = 1;
523
524 img->texture = screen->base.screen->resource_create(screen->base.screen, &templ);
525 if (!img->texture) {
526 FREE(img);
527 return NULL;
528 }
529
530 img->level = 0;
531 img->layer = 0;
532
533 img->loader_private = loaderPrivate;
534 return img;
535 }
536
537 static GLboolean
538 dri2_query_image(__DRIimage *image, int attrib, int *value)
539 {
540 struct winsys_handle whandle;
541 memset(&whandle, 0, sizeof(whandle));
542
543 switch (attrib) {
544 case __DRI_IMAGE_ATTRIB_STRIDE:
545 image->texture->screen->resource_get_handle(image->texture->screen,
546 image->texture, &whandle);
547 *value = whandle.stride;
548 return GL_TRUE;
549 case __DRI_IMAGE_ATTRIB_HANDLE:
550 whandle.type = DRM_API_HANDLE_TYPE_KMS;
551 image->texture->screen->resource_get_handle(image->texture->screen,
552 image->texture, &whandle);
553 *value = whandle.handle;
554 return GL_TRUE;
555 case __DRI_IMAGE_ATTRIB_NAME:
556 whandle.type = DRM_API_HANDLE_TYPE_SHARED;
557 image->texture->screen->resource_get_handle(image->texture->screen,
558 image->texture, &whandle);
559 *value = whandle.handle;
560 return GL_TRUE;
561 default:
562 return GL_FALSE;
563 }
564 }
565
566 static __DRIimage *
567 dri2_dup_image(__DRIimage *image, void *loaderPrivate)
568 {
569 __DRIimage *img;
570
571 img = CALLOC_STRUCT(__DRIimageRec);
572 if (!img)
573 return NULL;
574
575 img->texture = NULL;
576 pipe_resource_reference(&img->texture, image->texture);
577 img->level = image->level;
578 img->layer = image->layer;
579 img->loader_private = loaderPrivate;
580
581 return img;
582 }
583
584 static void
585 dri2_destroy_image(__DRIimage *img)
586 {
587 pipe_resource_reference(&img->texture, NULL);
588 FREE(img);
589 }
590
591 static struct __DRIimageExtensionRec dri2ImageExtension = {
592 { __DRI_IMAGE, __DRI_IMAGE_VERSION },
593 dri2_create_image_from_name,
594 dri2_create_image_from_renderbuffer,
595 dri2_destroy_image,
596 dri2_create_image,
597 dri2_query_image,
598 dri2_dup_image,
599 };
600
601 /*
602 * Backend function init_screen.
603 */
604
605 static const __DRIextension *dri_screen_extensions[] = {
606 &driTexBufferExtension.base,
607 &dri2FlushExtension.base,
608 &dri2ImageExtension.base,
609 &dri2ConfigQueryExtension.base,
610 NULL
611 };
612
613 static const __DRIextension *dri_screen_extensions_throttle[] = {
614 &driTexBufferExtension.base,
615 &dri2FlushExtension.base,
616 &dri2ImageExtension.base,
617 &dri2ConfigQueryExtension.base,
618 &dri2ThrottleExtension.base,
619 NULL
620 };
621
622 /**
623 * This is the driver specific part of the createNewScreen entry point.
624 *
625 * Returns the struct gl_config supported by this driver.
626 */
627 static const __DRIconfig **
628 dri2_init_screen(__DRIscreen * sPriv)
629 {
630 const __DRIconfig **configs;
631 struct dri_screen *screen;
632 struct pipe_screen *pscreen;
633 const struct drm_conf_ret *throttle_ret = NULL;
634
635 screen = CALLOC_STRUCT(dri_screen);
636 if (!screen)
637 return NULL;
638
639 screen->sPriv = sPriv;
640 screen->fd = sPriv->fd;
641
642 sPriv->driverPrivate = (void *)screen;
643
644 pscreen = driver_descriptor.create_screen(screen->fd);
645 if (driver_descriptor.configuration)
646 throttle_ret = driver_descriptor.configuration(DRM_CONF_THROTTLE);
647
648 if (throttle_ret && throttle_ret->val.val_int != -1) {
649 sPriv->extensions = dri_screen_extensions_throttle;
650 screen->default_throttle_frames = throttle_ret->val.val_int;
651 } else
652 sPriv->extensions = dri_screen_extensions;
653
654 /* dri_init_screen_helper checks pscreen for us */
655
656 configs = dri_init_screen_helper(screen, pscreen, 32);
657 if (!configs)
658 goto fail;
659
660 sPriv->api_mask = 0;
661 if (screen->st_api->profile_mask & ST_PROFILE_DEFAULT_MASK)
662 sPriv->api_mask |= 1 << __DRI_API_OPENGL;
663 if (screen->st_api->profile_mask & ST_PROFILE_OPENGL_ES1_MASK)
664 sPriv->api_mask |= 1 << __DRI_API_GLES;
665 if (screen->st_api->profile_mask & ST_PROFILE_OPENGL_ES2_MASK)
666 sPriv->api_mask |= 1 << __DRI_API_GLES2;
667
668 screen->auto_fake_front = dri_with_format(sPriv);
669 screen->broken_invalidate = !sPriv->dri2.useInvalidate;
670 screen->lookup_egl_image = dri2_lookup_egl_image;
671
672 return configs;
673 fail:
674 dri_destroy_screen_helper(screen);
675 FREE(screen);
676 return NULL;
677 }
678
679 static boolean
680 dri2_create_buffer(__DRIscreen * sPriv,
681 __DRIdrawable * dPriv,
682 const struct gl_config * visual, boolean isPixmap)
683 {
684 struct dri_drawable *drawable = NULL;
685
686 if (!dri_create_buffer(sPriv, dPriv, visual, isPixmap))
687 return FALSE;
688
689 drawable = dPriv->driverPrivate;
690
691 drawable->allocate_textures = dri2_allocate_textures;
692 drawable->flush_frontbuffer = dri2_flush_frontbuffer;
693 drawable->update_tex_buffer = dri2_update_tex_buffer;
694
695 return TRUE;
696 }
697
698 /**
699 * DRI driver virtual function table.
700 *
701 * DRI versions differ in their implementation of init_screen and swap_buffers.
702 */
703 const struct __DriverAPIRec driDriverAPI = {
704 .InitScreen = dri2_init_screen,
705 .DestroyScreen = dri_destroy_screen,
706 .CreateContext = dri_create_context,
707 .DestroyContext = dri_destroy_context,
708 .CreateBuffer = dri2_create_buffer,
709 .DestroyBuffer = dri_destroy_buffer,
710 .MakeCurrent = dri_make_current,
711 .UnbindContext = dri_unbind_context,
712
713 .AllocateBuffer = dri2_allocate_buffer,
714 .ReleaseBuffer = dri2_release_buffer,
715 };
716
717 /* This is the table of extensions that the loader will dlsym() for. */
718 PUBLIC const __DRIextension *__driDriverExtensions[] = {
719 &driCoreExtension.base,
720 &driDRI2Extension.base,
721 NULL
722 };
723
724 /* vim: set sw=3 ts=8 sts=3 expandtab: */