glx: move the glFlush call one layer down
[mesa.git] / src / glx / drisw_glx.c
1 /*
2 * Copyright 2008 George Sapountzis
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, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
25
26 #include <X11/Xlib.h>
27 #include "glxclient.h"
28 #include <dlfcn.h>
29 #include "dri_common.h"
30
31 struct drisw_display
32 {
33 __GLXDRIdisplay base;
34 };
35
36 struct drisw_context
37 {
38 struct glx_context base;
39 __DRIcontext *driContext;
40
41 };
42
43 struct drisw_screen
44 {
45 struct glx_screen base;
46
47 __DRIscreen *driScreen;
48 __GLXDRIscreen vtable;
49 const __DRIcoreExtension *core;
50 const __DRIswrastExtension *swrast;
51 const __DRItexBufferExtension *texBuffer;
52
53 const __DRIconfig **driver_configs;
54
55 void *driver;
56 };
57
58 struct drisw_drawable
59 {
60 __GLXDRIdrawable base;
61
62 GC gc;
63 GC swapgc;
64
65 __DRIdrawable *driDrawable;
66 XVisualInfo *visinfo;
67 XImage *ximage;
68 };
69
70 static Bool
71 XCreateDrawable(struct drisw_drawable * pdp,
72 Display * dpy, XID drawable, int visualid)
73 {
74 XGCValues gcvalues;
75 long visMask;
76 XVisualInfo visTemp;
77 int num_visuals;
78
79 /* create GC's */
80 pdp->gc = XCreateGC(dpy, drawable, 0, NULL);
81 pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL);
82
83 gcvalues.function = GXcopy;
84 gcvalues.graphics_exposures = False;
85 XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues);
86 XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues);
87 XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues);
88
89 /* visual */
90 visTemp.visualid = visualid;
91 visMask = VisualIDMask;
92 pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals);
93
94 if (!pdp->visinfo || num_visuals == 0)
95 return False;
96
97 /* create XImage */
98 pdp->ximage = XCreateImage(dpy,
99 pdp->visinfo->visual,
100 pdp->visinfo->depth,
101 ZPixmap, 0, /* format, offset */
102 NULL, /* data */
103 0, 0, /* width, height */
104 32, /* bitmap_pad */
105 0); /* bytes_per_line */
106
107 /**
108 * swrast does not handle 24-bit depth with 24 bpp, so let X do the
109 * the conversion for us.
110 */
111 if (pdp->ximage->bits_per_pixel == 24)
112 pdp->ximage->bits_per_pixel = 32;
113
114 return True;
115 }
116
117 static void
118 XDestroyDrawable(struct drisw_drawable * pdp, Display * dpy, XID drawable)
119 {
120 XDestroyImage(pdp->ximage);
121 free(pdp->visinfo);
122
123 XFreeGC(dpy, pdp->gc);
124 XFreeGC(dpy, pdp->swapgc);
125 }
126
127 /**
128 * swrast loader functions
129 */
130
131 static void
132 swrastGetDrawableInfo(__DRIdrawable * draw,
133 int *x, int *y, int *w, int *h,
134 void *loaderPrivate)
135 {
136 struct drisw_drawable *pdp = loaderPrivate;
137 __GLXDRIdrawable *pdraw = &(pdp->base);
138 Display *dpy = pdraw->psc->dpy;
139 Drawable drawable;
140
141 Window root;
142 unsigned uw, uh, bw, depth;
143
144 drawable = pdraw->xDrawable;
145
146 XGetGeometry(dpy, drawable, &root, x, y, &uw, &uh, &bw, &depth);
147 *w = uw;
148 *h = uh;
149 }
150
151 /**
152 * Align renderbuffer pitch.
153 *
154 * This should be chosen by the driver and the loader (libGL, xserver/glx)
155 * should use the driver provided pitch.
156 *
157 * It seems that the xorg loader (that is the xserver loading swrast_dri for
158 * indirect rendering, not client-side libGL) requires that the pitch is
159 * exactly the image width padded to 32 bits. XXX
160 *
161 * The above restriction can probably be overcome by using ScratchPixmap and
162 * CopyArea in the xserver, similar to ShmPutImage, and setting the width of
163 * the scratch pixmap to 'pitch / cpp'.
164 */
165 static inline int
166 bytes_per_line(unsigned pitch_bits, unsigned mul)
167 {
168 unsigned mask = mul - 1;
169
170 return ((pitch_bits + mask) & ~mask) / 8;
171 }
172
173 static void
174 swrastPutImage(__DRIdrawable * draw, int op,
175 int x, int y, int w, int h,
176 char *data, void *loaderPrivate)
177 {
178 struct drisw_drawable *pdp = loaderPrivate;
179 __GLXDRIdrawable *pdraw = &(pdp->base);
180 Display *dpy = pdraw->psc->dpy;
181 Drawable drawable;
182 XImage *ximage;
183 GC gc;
184
185 switch (op) {
186 case __DRI_SWRAST_IMAGE_OP_DRAW:
187 gc = pdp->gc;
188 break;
189 case __DRI_SWRAST_IMAGE_OP_SWAP:
190 gc = pdp->swapgc;
191 break;
192 default:
193 return;
194 }
195
196 drawable = pdraw->xDrawable;
197
198 ximage = pdp->ximage;
199 ximage->data = data;
200 ximage->width = w;
201 ximage->height = h;
202 ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
203
204 XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
205
206 ximage->data = NULL;
207 }
208
209 static void
210 swrastGetImage(__DRIdrawable * read,
211 int x, int y, int w, int h,
212 char *data, void *loaderPrivate)
213 {
214 struct drisw_drawable *prp = loaderPrivate;
215 __GLXDRIdrawable *pread = &(prp->base);
216 Display *dpy = pread->psc->dpy;
217 Drawable readable;
218 XImage *ximage;
219
220 readable = pread->xDrawable;
221
222 ximage = prp->ximage;
223 ximage->data = data;
224 ximage->width = w;
225 ximage->height = h;
226 ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
227
228 XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
229
230 ximage->data = NULL;
231 }
232
233 static const __DRIswrastLoaderExtension swrastLoaderExtension = {
234 {__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION},
235 swrastGetDrawableInfo,
236 swrastPutImage,
237 swrastGetImage
238 };
239
240 static const __DRIextension *loader_extensions[] = {
241 &systemTimeExtension.base,
242 &swrastLoaderExtension.base,
243 NULL
244 };
245
246 /**
247 * GLXDRI functions
248 */
249
250 static void
251 drisw_destroy_context(struct glx_context *context)
252 {
253 struct drisw_context *pcp = (struct drisw_context *) context;
254 struct drisw_screen *psc = (struct drisw_screen *) context->psc;
255
256 driReleaseDrawables(&pcp->base);
257
258 free((char *) context->extensions);
259
260 (*psc->core->destroyContext) (pcp->driContext);
261
262 free(pcp);
263 }
264
265 static int
266 drisw_bind_context(struct glx_context *context, struct glx_context *old,
267 GLXDrawable draw, GLXDrawable read)
268 {
269 struct drisw_context *pcp = (struct drisw_context *) context;
270 struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
271 struct drisw_drawable *pdraw, *pread;
272
273 pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw);
274 pread = (struct drisw_drawable *) driFetchDrawable(context, read);
275
276 driReleaseDrawables(&pcp->base);
277
278 if (pdraw == NULL || pread == NULL)
279 return GLXBadDrawable;
280
281 if ((*psc->core->bindContext) (pcp->driContext,
282 pdraw->driDrawable, pread->driDrawable))
283 return Success;
284
285 return GLXBadContext;
286 }
287
288 static void
289 drisw_unbind_context(struct glx_context *context, struct glx_context *new)
290 {
291 struct drisw_context *pcp = (struct drisw_context *) context;
292 struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
293
294 (*psc->core->unbindContext) (pcp->driContext);
295 }
296
297 static void
298 drisw_bind_tex_image(Display * dpy,
299 GLXDrawable drawable,
300 int buffer, const int *attrib_list)
301 {
302 struct glx_context *gc = __glXGetCurrentContext();
303 struct drisw_context *pcp = (struct drisw_context *) gc;
304 __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
305 struct drisw_drawable *pdraw = (struct drisw_drawable *) base;
306 struct drisw_screen *psc;
307
308 __glXInitialize(dpy);
309
310 if (pdraw != NULL) {
311 psc = (struct drisw_screen *) base->psc;
312
313 if (!psc->texBuffer)
314 return;
315
316 if (psc->texBuffer->base.version >= 2 &&
317 psc->texBuffer->setTexBuffer2 != NULL) {
318 (*psc->texBuffer->setTexBuffer2) (pcp->driContext,
319 pdraw->base.textureTarget,
320 pdraw->base.textureFormat,
321 pdraw->driDrawable);
322 }
323 else {
324 (*psc->texBuffer->setTexBuffer) (pcp->driContext,
325 pdraw->base.textureTarget,
326 pdraw->driDrawable);
327 }
328 }
329 }
330
331 static void
332 drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
333 {
334 #if __DRI_TEX_BUFFER_VERSION >= 3
335 struct glx_context *gc = __glXGetCurrentContext();
336 struct dri2_context *pcp = (struct dri2_context *) gc;
337 __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
338 struct glx_display *dpyPriv = __glXInitialize(dpy);
339 struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
340 struct dri2_screen *psc;
341
342 if (pdraw != NULL) {
343 psc = (struct dri2_screen *) base->psc;
344
345 if (!psc->texBuffer)
346 return;
347
348 if (psc->texBuffer->base.version >= 3 &&
349 psc->texBuffer->releaseTexBuffer != NULL) {
350 (*psc->texBuffer->releaseTexBuffer) (pcp->driContext,
351 pdraw->base.textureTarget,
352 pdraw->driDrawable);
353 }
354 }
355 #endif
356 }
357
358 static const struct glx_context_vtable drisw_context_vtable = {
359 drisw_destroy_context,
360 drisw_bind_context,
361 drisw_unbind_context,
362 NULL,
363 NULL,
364 DRI_glXUseXFont,
365 drisw_bind_tex_image,
366 drisw_release_tex_image,
367 NULL, /* get_proc_address */
368 };
369
370 static struct glx_context *
371 drisw_create_context(struct glx_screen *base,
372 struct glx_config *config_base,
373 struct glx_context *shareList, int renderType)
374 {
375 struct drisw_context *pcp, *pcp_shared;
376 __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
377 struct drisw_screen *psc = (struct drisw_screen *) base;
378 __DRIcontext *shared = NULL;
379
380 if (!psc->base.driScreen)
381 return NULL;
382
383 if (shareList) {
384 /* If the shareList context is not a DRISW context, we cannot possibly
385 * create a DRISW context that shares it.
386 */
387 if (shareList->vtable->destroy != drisw_destroy_context) {
388 return NULL;
389 }
390
391 pcp_shared = (struct drisw_context *) shareList;
392 shared = pcp_shared->driContext;
393 }
394
395 pcp = calloc(1, sizeof *pcp);
396 if (pcp == NULL)
397 return NULL;
398
399 if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
400 free(pcp);
401 return NULL;
402 }
403
404 pcp->driContext =
405 (*psc->core->createNewContext) (psc->driScreen,
406 config->driConfig, shared, pcp);
407 if (pcp->driContext == NULL) {
408 free(pcp);
409 return NULL;
410 }
411
412 pcp->base.vtable = &drisw_context_vtable;
413
414 return &pcp->base;
415 }
416
417 static struct glx_context *
418 drisw_create_context_attribs(struct glx_screen *base,
419 struct glx_config *config_base,
420 struct glx_context *shareList,
421 unsigned num_attribs,
422 const uint32_t *attribs,
423 unsigned *error)
424 {
425 struct drisw_context *pcp, *pcp_shared;
426 __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
427 struct drisw_screen *psc = (struct drisw_screen *) base;
428 __DRIcontext *shared = NULL;
429
430 uint32_t minor_ver = 1;
431 uint32_t major_ver = 0;
432 uint32_t flags = 0;
433 unsigned api;
434 int reset = __DRI_CTX_RESET_NO_NOTIFICATION;
435 uint32_t ctx_attribs[2 * 4];
436 unsigned num_ctx_attribs = 0;
437
438 if (!psc->base.driScreen)
439 return NULL;
440
441 if (psc->swrast->base.version < 3)
442 return NULL;
443
444 /* Remap the GLX tokens to DRI2 tokens.
445 */
446 if (!dri2_convert_glx_attribs(num_attribs, attribs,
447 &major_ver, &minor_ver, &flags, &api, &reset,
448 error))
449 return NULL;
450
451 if (reset != __DRI_CTX_RESET_NO_NOTIFICATION)
452 return NULL;
453
454 if (shareList) {
455 pcp_shared = (struct drisw_context *) shareList;
456 shared = pcp_shared->driContext;
457 }
458
459 pcp = calloc(1, sizeof *pcp);
460 if (pcp == NULL)
461 return NULL;
462
463 if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
464 free(pcp);
465 return NULL;
466 }
467
468 ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION;
469 ctx_attribs[num_ctx_attribs++] = major_ver;
470 ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MINOR_VERSION;
471 ctx_attribs[num_ctx_attribs++] = minor_ver;
472
473 if (flags != 0) {
474 ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_FLAGS;
475
476 /* The current __DRI_CTX_FLAG_* values are identical to the
477 * GLX_CONTEXT_*_BIT values.
478 */
479 ctx_attribs[num_ctx_attribs++] = flags;
480 }
481
482 pcp->driContext =
483 (*psc->swrast->createContextAttribs) (psc->driScreen,
484 api,
485 config->driConfig,
486 shared,
487 num_ctx_attribs / 2,
488 ctx_attribs,
489 error,
490 pcp);
491 if (pcp->driContext == NULL) {
492 free(pcp);
493 return NULL;
494 }
495
496 pcp->base.vtable = &drisw_context_vtable;
497
498 return &pcp->base;
499 }
500
501 static void
502 driswDestroyDrawable(__GLXDRIdrawable * pdraw)
503 {
504 struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw;
505 struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc;
506
507 (*psc->core->destroyDrawable) (pdp->driDrawable);
508
509 XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
510 free(pdp);
511 }
512
513 static __GLXDRIdrawable *
514 driswCreateDrawable(struct glx_screen *base, XID xDrawable,
515 GLXDrawable drawable, struct glx_config *modes)
516 {
517 struct drisw_drawable *pdp;
518 __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
519 struct drisw_screen *psc = (struct drisw_screen *) base;
520 Bool ret;
521 const __DRIswrastExtension *swrast = psc->swrast;
522
523 pdp = calloc(1, sizeof(*pdp));
524 if (!pdp)
525 return NULL;
526
527 pdp->base.xDrawable = xDrawable;
528 pdp->base.drawable = drawable;
529 pdp->base.psc = &psc->base;
530
531 ret = XCreateDrawable(pdp, psc->base.dpy, xDrawable, modes->visualID);
532 if (!ret) {
533 free(pdp);
534 return NULL;
535 }
536
537 /* Create a new drawable */
538 pdp->driDrawable =
539 (*swrast->createNewDrawable) (psc->driScreen, config->driConfig, pdp);
540
541 if (!pdp->driDrawable) {
542 XDestroyDrawable(pdp, psc->base.dpy, xDrawable);
543 free(pdp);
544 return NULL;
545 }
546
547 pdp->base.destroyDrawable = driswDestroyDrawable;
548
549 return &pdp->base;
550 }
551
552 static int64_t
553 driswSwapBuffers(__GLXDRIdrawable * pdraw,
554 int64_t target_msc, int64_t divisor, int64_t remainder,
555 Bool flush)
556 {
557 struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw;
558 struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc;
559
560 (void) target_msc;
561 (void) divisor;
562 (void) remainder;
563
564 if (flush) {
565 glFlush();
566 }
567
568 (*psc->core->swapBuffers) (pdp->driDrawable);
569
570 return 0;
571 }
572
573 static void
574 driswDestroyScreen(struct glx_screen *base)
575 {
576 struct drisw_screen *psc = (struct drisw_screen *) base;
577
578 /* Free the direct rendering per screen data */
579 (*psc->core->destroyScreen) (psc->driScreen);
580 driDestroyConfigs(psc->driver_configs);
581 psc->driScreen = NULL;
582 if (psc->driver)
583 dlclose(psc->driver);
584 }
585
586 #define SWRAST_DRIVER_NAME "swrast"
587
588 static void *
589 driOpenSwrast(void)
590 {
591 void *driver = NULL;
592
593 if (driver == NULL)
594 driver = driOpenDriver(SWRAST_DRIVER_NAME);
595
596 return driver;
597 }
598
599 static const struct glx_screen_vtable drisw_screen_vtable = {
600 drisw_create_context,
601 drisw_create_context_attribs
602 };
603
604 static void
605 driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions)
606 {
607 int i;
608
609 __glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read");
610
611 if (psc->swrast->base.version >= 3) {
612 __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
613 __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
614
615 /* DRISW version >= 2 implies support for OpenGL ES 2.0.
616 */
617 __glXEnableDirectExtension(&psc->base,
618 "GLX_EXT_create_context_es2_profile");
619 }
620
621 /* FIXME: Figure out what other extensions can be ported here from dri2. */
622 for (i = 0; extensions[i]; i++) {
623 if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
624 psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
625 __glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap");
626 }
627 }
628 }
629
630 static struct glx_screen *
631 driswCreateScreen(int screen, struct glx_display *priv)
632 {
633 __GLXDRIscreen *psp;
634 const __DRIconfig **driver_configs;
635 const __DRIextension **extensions;
636 struct drisw_screen *psc;
637 struct glx_config *configs = NULL, *visuals = NULL;
638 int i;
639
640 psc = calloc(1, sizeof *psc);
641 if (psc == NULL)
642 return NULL;
643
644 if (!glx_screen_init(&psc->base, screen, priv)) {
645 free(psc);
646 return NULL;
647 }
648
649 psc->driver = driOpenSwrast();
650 if (psc->driver == NULL)
651 goto handle_error;
652
653 extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
654 if (extensions == NULL) {
655 ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
656 goto handle_error;
657 }
658
659 for (i = 0; extensions[i]; i++) {
660 if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
661 psc->core = (__DRIcoreExtension *) extensions[i];
662 if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0)
663 psc->swrast = (__DRIswrastExtension *) extensions[i];
664 }
665
666 if (psc->core == NULL || psc->swrast == NULL) {
667 ErrorMessageF("core dri extension not found\n");
668 goto handle_error;
669 }
670
671 psc->driScreen =
672 psc->swrast->createNewScreen(screen, loader_extensions,
673 &driver_configs, psc);
674 if (psc->driScreen == NULL) {
675 ErrorMessageF("failed to create dri screen\n");
676 goto handle_error;
677 }
678
679 extensions = psc->core->getExtensions(psc->driScreen);
680 driswBindExtensions(psc, extensions);
681
682 configs = driConvertConfigs(psc->core, psc->base.configs, driver_configs);
683 visuals = driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
684
685 if (!configs || !visuals)
686 goto handle_error;
687
688 glx_config_destroy_list(psc->base.configs);
689 psc->base.configs = configs;
690 glx_config_destroy_list(psc->base.visuals);
691 psc->base.visuals = visuals;
692
693 psc->driver_configs = driver_configs;
694
695 psc->base.vtable = &drisw_screen_vtable;
696 psp = &psc->vtable;
697 psc->base.driScreen = psp;
698 psp->destroyScreen = driswDestroyScreen;
699 psp->createDrawable = driswCreateDrawable;
700 psp->swapBuffers = driswSwapBuffers;
701
702 return &psc->base;
703
704 handle_error:
705 if (configs)
706 glx_config_destroy_list(configs);
707 if (visuals)
708 glx_config_destroy_list(visuals);
709 if (psc->driScreen)
710 psc->core->destroyScreen(psc->driScreen);
711 psc->driScreen = NULL;
712
713 if (psc->driver)
714 dlclose(psc->driver);
715 glx_screen_cleanup(&psc->base);
716 free(psc);
717
718 CriticalErrorMessageF("failed to load driver: %s\n", SWRAST_DRIVER_NAME);
719
720 return NULL;
721 }
722
723 /* Called from __glXFreeDisplayPrivate.
724 */
725 static void
726 driswDestroyDisplay(__GLXDRIdisplay * dpy)
727 {
728 free(dpy);
729 }
730
731 /*
732 * Allocate, initialize and return a __DRIdisplayPrivate object.
733 * This is called from __glXInitialize() when we are given a new
734 * display pointer.
735 */
736 _X_HIDDEN __GLXDRIdisplay *
737 driswCreateDisplay(Display * dpy)
738 {
739 struct drisw_display *pdpyp;
740
741 pdpyp = malloc(sizeof *pdpyp);
742 if (pdpyp == NULL)
743 return NULL;
744
745 pdpyp->base.destroyDisplay = driswDestroyDisplay;
746 pdpyp->base.createScreen = driswCreateScreen;
747
748 return &pdpyp->base;
749 }
750
751 #endif /* GLX_DIRECT_RENDERING */