acf6b246af0b0b3c0d27ddade514dec2144a5ffb
[mesa.git] / src / gbm / backends / dri / gbm_dri.c
1 /*
2 * Copyright © 2011 Intel Corporation
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Benjamin Franzke <benjaminfranzke@googlemail.com>
26 */
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <stddef.h>
31 #include <stdint.h>
32 #include <string.h>
33 #include <limits.h>
34
35 #include <sys/types.h>
36 #include <sys/mman.h>
37 #include <unistd.h>
38 #include <dlfcn.h>
39 #include <xf86drm.h>
40
41 #include <GL/gl.h> /* dri_interface needs GL types */
42 #include <GL/internal/dri_interface.h>
43
44 #include "gbm_driint.h"
45
46 #include "gbmint.h"
47 #include "loader.h"
48
49 /* For importing wl_buffer */
50 #if HAVE_WAYLAND_PLATFORM
51 #include "../../../egl/wayland/wayland-drm/wayland-drm.h"
52 #endif
53
54 static __DRIimage *
55 dri_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
56 {
57 struct gbm_dri_device *dri = data;
58
59 if (dri->lookup_image == NULL)
60 return NULL;
61
62 return dri->lookup_image(screen, image, dri->lookup_user_data);
63 }
64
65 static __DRIbuffer *
66 dri_get_buffers(__DRIdrawable * driDrawable,
67 int *width, int *height,
68 unsigned int *attachments, int count,
69 int *out_count, void *data)
70 {
71 struct gbm_dri_surface *surf = data;
72 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
73
74 if (dri->get_buffers == NULL)
75 return NULL;
76
77 return dri->get_buffers(driDrawable, width, height, attachments,
78 count, out_count, surf->dri_private);
79 }
80
81 static void
82 dri_flush_front_buffer(__DRIdrawable * driDrawable, void *data)
83 {
84 struct gbm_dri_surface *surf = data;
85 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
86
87 if (dri->flush_front_buffer != NULL)
88 dri->flush_front_buffer(driDrawable, surf->dri_private);
89 }
90
91 static __DRIbuffer *
92 dri_get_buffers_with_format(__DRIdrawable * driDrawable,
93 int *width, int *height,
94 unsigned int *attachments, int count,
95 int *out_count, void *data)
96 {
97 struct gbm_dri_surface *surf = data;
98 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
99
100 if (dri->get_buffers_with_format == NULL)
101 return NULL;
102
103 return
104 dri->get_buffers_with_format(driDrawable, width, height, attachments,
105 count, out_count, surf->dri_private);
106 }
107
108 static int
109 image_get_buffers(__DRIdrawable *driDrawable,
110 unsigned int format,
111 uint32_t *stamp,
112 void *loaderPrivate,
113 uint32_t buffer_mask,
114 struct __DRIimageList *buffers)
115 {
116 struct gbm_dri_surface *surf = loaderPrivate;
117 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
118
119 if (dri->image_get_buffers == NULL)
120 return 0;
121
122 return dri->image_get_buffers(driDrawable, format, stamp,
123 surf->dri_private, buffer_mask, buffers);
124 }
125
126 static const __DRIuseInvalidateExtension use_invalidate = {
127 { __DRI_USE_INVALIDATE, 1 }
128 };
129
130 static const __DRIimageLookupExtension image_lookup_extension = {
131 { __DRI_IMAGE_LOOKUP, 1 },
132 dri_lookup_egl_image
133 };
134
135 static const __DRIdri2LoaderExtension dri2_loader_extension = {
136 .base = { __DRI_DRI2_LOADER, 3 },
137
138 .getBuffers = dri_get_buffers,
139 .flushFrontBuffer = dri_flush_front_buffer,
140 .getBuffersWithFormat = dri_get_buffers_with_format,
141 };
142
143 static const __DRIimageLoaderExtension image_loader_extension = {
144 .base = { __DRI_IMAGE_LOADER, 1 },
145
146 .getBuffers = image_get_buffers,
147 .flushFrontBuffer = dri_flush_front_buffer,
148 };
149
150
151 struct dri_extension_match {
152 const char *name;
153 int version;
154 int offset;
155 };
156
157 static struct dri_extension_match dri_core_extensions[] = {
158 { __DRI2_FLUSH, 1, offsetof(struct gbm_dri_device, flush) },
159 { __DRI_IMAGE, 1, offsetof(struct gbm_dri_device, image) },
160 { NULL, 0, 0 }
161 };
162
163 static struct dri_extension_match gbm_dri_device_extensions[] = {
164 { __DRI_CORE, 1, offsetof(struct gbm_dri_device, core) },
165 { __DRI_DRI2, 1, offsetof(struct gbm_dri_device, dri2) },
166 { NULL, 0, 0 }
167 };
168
169 static int
170 dri_bind_extensions(struct gbm_dri_device *dri,
171 struct dri_extension_match *matches,
172 const __DRIextension **extensions)
173 {
174 int i, j, ret = 0;
175 void *field;
176
177 for (i = 0; extensions[i]; i++) {
178 for (j = 0; matches[j].name; j++) {
179 if (strcmp(extensions[i]->name, matches[j].name) == 0 &&
180 extensions[i]->version >= matches[j].version) {
181 field = ((char *) dri + matches[j].offset);
182 *(const __DRIextension **) field = extensions[i];
183 }
184 }
185 }
186
187 for (j = 0; matches[j].name; j++) {
188 field = ((char *) dri + matches[j].offset);
189 if (*(const __DRIextension **) field == NULL) {
190 ret = -1;
191 }
192 }
193
194 return ret;
195 }
196
197 static int
198 dri_load_driver(struct gbm_dri_device *dri)
199 {
200 const __DRIextension **extensions = NULL;
201 char path[PATH_MAX], *search_paths, *p, *next, *end;
202 char *get_extensions_name;
203
204 search_paths = NULL;
205 if (geteuid() == getuid()) {
206 /* don't allow setuid apps to use GBM_DRIVERS_PATH */
207 search_paths = getenv("GBM_DRIVERS_PATH");
208 }
209 if (search_paths == NULL)
210 search_paths = DEFAULT_DRIVER_DIR;
211
212 dri->driver = NULL;
213 end = search_paths + strlen(search_paths);
214 for (p = search_paths; p < end && dri->driver == NULL; p = next + 1) {
215 int len;
216 next = strchr(p, ':');
217 if (next == NULL)
218 next = end;
219
220 len = next - p;
221 #if GLX_USE_TLS
222 snprintf(path, sizeof path,
223 "%.*s/tls/%s_dri.so", len, p, dri->base.driver_name);
224 dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
225 #endif
226 if (dri->driver == NULL) {
227 snprintf(path, sizeof path,
228 "%.*s/%s_dri.so", len, p, dri->base.driver_name);
229 dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
230 }
231 /* not need continue to loop all paths once the driver is found */
232 if (dri->driver != NULL)
233 break;
234 }
235
236 if (dri->driver == NULL) {
237 fprintf(stderr, "gbm: failed to open any driver (search paths %s)",
238 search_paths);
239 return -1;
240 }
241
242 if (asprintf(&get_extensions_name, "%s_%s",
243 __DRI_DRIVER_GET_EXTENSIONS, dri->base.driver_name) != -1) {
244 const __DRIextension **(*get_extensions)(void);
245
246 get_extensions = dlsym(dri->driver, get_extensions_name);
247 free(get_extensions_name);
248
249 if (get_extensions)
250 extensions = get_extensions();
251 }
252
253 if (!extensions)
254 extensions = dlsym(dri->driver, __DRI_DRIVER_EXTENSIONS);
255 if (extensions == NULL) {
256 fprintf(stderr, "gbm: driver exports no extensions (%s)", dlerror());
257 dlclose(dri->driver);
258 return -1;
259 }
260 dri->driver_extensions = extensions;
261
262 if (dri_bind_extensions(dri, gbm_dri_device_extensions, extensions) < 0) {
263 dlclose(dri->driver);
264 fprintf(stderr, "failed to bind extensions\n");
265 return -1;
266 }
267
268 return 0;
269 }
270
271 static int
272 dri_screen_create(struct gbm_dri_device *dri)
273 {
274 const __DRIextension **extensions;
275 int ret = 0;
276
277 dri->base.driver_name = loader_get_driver_for_fd(dri->base.base.fd, 0);
278 if (dri->base.driver_name == NULL)
279 return -1;
280
281 ret = dri_load_driver(dri);
282 if (ret) {
283 fprintf(stderr, "failed to load driver: %s\n", dri->base.driver_name);
284 return ret;
285 };
286
287 dri->extensions[0] = &image_lookup_extension.base;
288 dri->extensions[1] = &use_invalidate.base;
289 dri->extensions[2] = &dri2_loader_extension.base;
290 dri->extensions[3] = &image_loader_extension.base;
291 dri->extensions[4] = NULL;
292
293 if (dri->dri2 == NULL)
294 return -1;
295
296 if (dri->dri2->base.version >= 4) {
297 dri->screen = dri->dri2->createNewScreen2(0, dri->base.base.fd,
298 dri->extensions,
299 dri->driver_extensions,
300 &dri->driver_configs, dri);
301 } else {
302 dri->screen = dri->dri2->createNewScreen(0, dri->base.base.fd,
303 dri->extensions,
304 &dri->driver_configs, dri);
305 }
306 if (dri->screen == NULL)
307 return -1;
308
309 extensions = dri->core->getExtensions(dri->screen);
310 if (dri_bind_extensions(dri, dri_core_extensions, extensions) < 0) {
311 ret = -1;
312 goto free_screen;
313 }
314
315 dri->lookup_image = NULL;
316 dri->lookup_user_data = NULL;
317
318 return 0;
319
320 free_screen:
321 dri->core->destroyScreen(dri->screen);
322
323 return ret;
324 }
325
326 static int
327 gbm_dri_is_format_supported(struct gbm_device *gbm,
328 uint32_t format,
329 uint32_t usage)
330 {
331 switch (format) {
332 case GBM_BO_FORMAT_XRGB8888:
333 case GBM_FORMAT_XRGB8888:
334 break;
335 case GBM_BO_FORMAT_ARGB8888:
336 case GBM_FORMAT_ARGB8888:
337 if (usage & GBM_BO_USE_SCANOUT)
338 return 0;
339 break;
340 default:
341 return 0;
342 }
343
344 if (usage & GBM_BO_USE_CURSOR_64X64 &&
345 usage & GBM_BO_USE_RENDERING)
346 return 0;
347
348 return 1;
349 }
350
351 static int
352 gbm_dri_bo_write(struct gbm_bo *_bo, const void *buf, size_t count)
353 {
354 struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
355
356 if (bo->image != NULL)
357 return -1;
358
359 memcpy(bo->map, buf, count);
360
361 return 0;
362 }
363
364 static void
365 gbm_dri_bo_destroy(struct gbm_bo *_bo)
366 {
367 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
368 struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
369 struct drm_mode_destroy_dumb arg;
370
371 if (bo->image != NULL) {
372 dri->image->destroyImage(bo->image);
373 } else {
374 munmap(bo->map, bo->size);
375 memset(&arg, 0, sizeof(arg));
376 arg.handle = bo->handle;
377 drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
378 }
379
380 free(bo);
381 }
382
383 static uint32_t
384 gbm_dri_to_gbm_format(uint32_t dri_format)
385 {
386 uint32_t ret = 0;
387
388 switch (dri_format) {
389 case __DRI_IMAGE_FORMAT_RGB565:
390 ret = GBM_FORMAT_RGB565;
391 break;
392 case __DRI_IMAGE_FORMAT_XRGB8888:
393 ret = GBM_FORMAT_XRGB8888;
394 break;
395 case __DRI_IMAGE_FORMAT_ARGB8888:
396 ret = GBM_FORMAT_ARGB8888;
397 break;
398 case __DRI_IMAGE_FORMAT_ABGR8888:
399 ret = GBM_FORMAT_ABGR8888;
400 break;
401 default:
402 ret = 0;
403 break;
404 }
405
406 return ret;
407 }
408
409 static struct gbm_bo *
410 gbm_dri_bo_import(struct gbm_device *gbm,
411 uint32_t type, void *buffer, uint32_t usage)
412 {
413 struct gbm_dri_device *dri = gbm_dri_device(gbm);
414 struct gbm_dri_bo *bo;
415 __DRIimage *image;
416 unsigned dri_use = 0;
417 int gbm_format;
418
419 /* Required for query image WIDTH & HEIGHT */
420 if (dri->image->base.version < 4)
421 return NULL;
422
423 switch (type) {
424 #if HAVE_WAYLAND_PLATFORM
425 case GBM_BO_IMPORT_WL_BUFFER:
426 {
427 struct wl_drm_buffer *wb;
428
429 if (!dri->wl_drm)
430 return NULL;
431
432 wb = wayland_drm_buffer_get(dri->wl_drm, (struct wl_resource *) buffer);
433 if (!wb)
434 return NULL;
435
436 image = wb->driver_buffer;
437
438 switch (wb->format) {
439 case WL_DRM_FORMAT_XRGB8888:
440 gbm_format = GBM_FORMAT_XRGB8888;
441 break;
442 case WL_DRM_FORMAT_ARGB8888:
443 gbm_format = GBM_FORMAT_ARGB8888;
444 break;
445 case WL_DRM_FORMAT_RGB565:
446 gbm_format = GBM_FORMAT_RGB565;
447 break;
448 case WL_DRM_FORMAT_YUYV:
449 gbm_format = GBM_FORMAT_YUYV;
450 break;
451 default:
452 return NULL;
453 }
454 break;
455 }
456 #endif
457
458 case GBM_BO_IMPORT_EGL_IMAGE:
459 {
460 int dri_format;
461 if (dri->lookup_image == NULL)
462 return NULL;
463
464 image = dri->lookup_image(dri->screen, buffer, dri->lookup_user_data);
465 dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_FORMAT, &dri_format);
466 gbm_format = gbm_dri_to_gbm_format(dri_format);
467 if (gbm_format == 0)
468 return NULL;
469 break;
470 }
471
472 default:
473 return NULL;
474 }
475
476
477 bo = calloc(1, sizeof *bo);
478 if (bo == NULL)
479 return NULL;
480
481 bo->image = dri->image->dupImage(image, NULL);
482
483 if (usage & GBM_BO_USE_SCANOUT)
484 dri_use |= __DRI_IMAGE_USE_SCANOUT;
485 if (usage & GBM_BO_USE_CURSOR_64X64)
486 dri_use |= __DRI_IMAGE_USE_CURSOR;
487 if (dri->image->base.version >= 2 &&
488 !dri->image->validateUsage(bo->image, dri_use)) {
489 free(bo);
490 return NULL;
491 }
492
493 bo->base.base.gbm = gbm;
494 bo->base.base.format = gbm_format;
495
496 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_WIDTH,
497 (int*)&bo->base.base.width);
498 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HEIGHT,
499 (int*)&bo->base.base.height);
500 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
501 (int*)&bo->base.base.stride);
502 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE,
503 &bo->base.base.handle.s32);
504
505 return &bo->base.base;
506 }
507
508 static struct gbm_bo *
509 create_dumb(struct gbm_device *gbm,
510 uint32_t width, uint32_t height,
511 uint32_t format, uint32_t usage)
512 {
513 struct gbm_dri_device *dri = gbm_dri_device(gbm);
514 struct drm_mode_create_dumb create_arg;
515 struct drm_mode_map_dumb map_arg;
516 struct gbm_dri_bo *bo;
517 struct drm_mode_destroy_dumb destroy_arg;
518 int ret;
519
520 if (!(usage & GBM_BO_USE_CURSOR_64X64))
521 return NULL;
522 if (format != GBM_FORMAT_ARGB8888)
523 return NULL;
524
525 bo = calloc(1, sizeof *bo);
526 if (bo == NULL)
527 return NULL;
528
529 create_arg.bpp = 32;
530 create_arg.width = width;
531 create_arg.height = height;
532
533 ret = drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_arg);
534 if (ret)
535 goto free_bo;
536
537 bo->base.base.gbm = gbm;
538 bo->base.base.width = width;
539 bo->base.base.height = height;
540 bo->base.base.stride = create_arg.pitch;
541 bo->base.base.format = format;
542 bo->base.base.handle.u32 = create_arg.handle;
543 bo->handle = create_arg.handle;
544 bo->size = create_arg.size;
545
546 memset(&map_arg, 0, sizeof(map_arg));
547 map_arg.handle = bo->handle;
548
549 ret = drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_MAP_DUMB, &map_arg);
550 if (ret)
551 goto destroy_dumb;
552
553 bo->map = mmap(0, bo->size, PROT_WRITE,
554 MAP_SHARED, dri->base.base.fd, map_arg.offset);
555 if (bo->map == MAP_FAILED)
556 goto destroy_dumb;
557
558 return &bo->base.base;
559
560 destroy_dumb:
561 memset(&destroy_arg, 0, sizeof destroy_arg);
562 destroy_arg.handle = create_arg.handle;
563 drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg);
564 free_bo:
565 free(bo);
566
567 return NULL;
568 }
569
570 static struct gbm_bo *
571 gbm_dri_bo_create(struct gbm_device *gbm,
572 uint32_t width, uint32_t height,
573 uint32_t format, uint32_t usage)
574 {
575 struct gbm_dri_device *dri = gbm_dri_device(gbm);
576 struct gbm_dri_bo *bo;
577 int dri_format;
578 unsigned dri_use = 0;
579
580 if (usage & GBM_BO_USE_WRITE)
581 return create_dumb(gbm, width, height, format, usage);
582
583 bo = calloc(1, sizeof *bo);
584 if (bo == NULL)
585 return NULL;
586
587 bo->base.base.gbm = gbm;
588 bo->base.base.width = width;
589 bo->base.base.height = height;
590 bo->base.base.format = format;
591
592 switch (format) {
593 case GBM_FORMAT_RGB565:
594 dri_format =__DRI_IMAGE_FORMAT_RGB565;
595 break;
596 case GBM_FORMAT_XRGB8888:
597 case GBM_BO_FORMAT_XRGB8888:
598 dri_format = __DRI_IMAGE_FORMAT_XRGB8888;
599 break;
600 case GBM_FORMAT_ARGB8888:
601 case GBM_BO_FORMAT_ARGB8888:
602 dri_format = __DRI_IMAGE_FORMAT_ARGB8888;
603 break;
604 case GBM_FORMAT_ABGR8888:
605 dri_format = __DRI_IMAGE_FORMAT_ABGR8888;
606 break;
607 case GBM_FORMAT_ARGB2101010:
608 dri_format = __DRI_IMAGE_FORMAT_ARGB2101010;
609 break;
610 case GBM_FORMAT_XRGB2101010:
611 dri_format = __DRI_IMAGE_FORMAT_XRGB2101010;
612 break;
613 default:
614 goto failed;
615 }
616
617 if (usage & GBM_BO_USE_SCANOUT)
618 dri_use |= __DRI_IMAGE_USE_SCANOUT;
619 if (usage & GBM_BO_USE_CURSOR_64X64)
620 dri_use |= __DRI_IMAGE_USE_CURSOR;
621
622 /* Gallium drivers requires shared in order to get the handle/stride */
623 dri_use |= __DRI_IMAGE_USE_SHARE;
624
625 bo->image =
626 dri->image->createImage(dri->screen,
627 width, height,
628 dri_format, dri_use,
629 bo);
630 if (bo->image == NULL)
631 goto failed;
632
633 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE,
634 &bo->base.base.handle.s32);
635 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
636 (int *) &bo->base.base.stride);
637
638 return &bo->base.base;
639
640 failed:
641 free(bo);
642 return NULL;
643 }
644
645 static struct gbm_surface *
646 gbm_dri_surface_create(struct gbm_device *gbm,
647 uint32_t width, uint32_t height,
648 uint32_t format, uint32_t flags)
649 {
650 struct gbm_dri_surface *surf;
651
652 surf = calloc(1, sizeof *surf);
653 if (surf == NULL)
654 return NULL;
655
656 surf->base.gbm = gbm;
657 surf->base.width = width;
658 surf->base.height = height;
659 surf->base.format = format;
660 surf->base.flags = flags;
661
662 return &surf->base;
663 }
664
665 static void
666 gbm_dri_surface_destroy(struct gbm_surface *_surf)
667 {
668 struct gbm_dri_surface *surf = gbm_dri_surface(_surf);
669
670 free(surf);
671 }
672
673 static void
674 dri_destroy(struct gbm_device *gbm)
675 {
676 struct gbm_dri_device *dri = gbm_dri_device(gbm);
677
678 dri->core->destroyScreen(dri->screen);
679 free(dri->driver_configs);
680 dlclose(dri->driver);
681 free(dri->base.driver_name);
682
683 free(dri);
684 }
685
686 static struct gbm_device *
687 dri_device_create(int fd)
688 {
689 struct gbm_dri_device *dri;
690 int ret;
691
692 dri = calloc(1, sizeof *dri);
693
694 dri->base.base.fd = fd;
695 dri->base.base.bo_create = gbm_dri_bo_create;
696 dri->base.base.bo_import = gbm_dri_bo_import;
697 dri->base.base.is_format_supported = gbm_dri_is_format_supported;
698 dri->base.base.bo_write = gbm_dri_bo_write;
699 dri->base.base.bo_destroy = gbm_dri_bo_destroy;
700 dri->base.base.destroy = dri_destroy;
701 dri->base.base.surface_create = gbm_dri_surface_create;
702 dri->base.base.surface_destroy = gbm_dri_surface_destroy;
703
704 dri->base.type = GBM_DRM_DRIVER_TYPE_DRI;
705 dri->base.base.name = "drm";
706
707 ret = dri_screen_create(dri);
708 if (ret)
709 goto err_dri;
710
711 return &dri->base.base;
712
713 err_dri:
714 free(dri);
715
716 return NULL;
717 }
718
719 struct gbm_backend gbm_dri_backend = {
720 .backend_name = "dri",
721 .create_device = dri_device_create,
722 };