2 * Copyright © 2008 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Soft-
6 * ware"), to deal in the Software without restriction, including without
7 * limitation the rights to use, copy, modify, merge, publish, distribute,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, provided that the above copyright
10 * notice(s) and this permission notice appear in all copies of the Soft-
11 * ware and that both the above copyright notice(s) and this permission
12 * notice appear in supporting documentation.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
17 * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
18 * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
19 * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
22 * MANCE OF THIS SOFTWARE.
24 * Except as contained in this notice, the name of a copyright holder shall
25 * not be used in advertising or otherwise to promote the sale, use or
26 * other dealings in this Software without prior written authorization of
27 * the copyright holder.
30 * Kristian Høgsberg (krh@redhat.com)
33 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
36 #include <X11/extensions/Xfixes.h>
37 #include <X11/Xlib-xcb.h>
41 #include "glxclient.h"
42 #include <X11/extensions/dri2proto.h>
47 #include <sys/types.h>
52 #include "dri_common.h"
53 #include "dri2_priv.h"
56 /* From xmlpool/options.h, user exposed so should be stable */
57 #define DRI_CONF_VBLANK_NEVER 0
58 #define DRI_CONF_VBLANK_DEF_INTERVAL_0 1
59 #define DRI_CONF_VBLANK_DEF_INTERVAL_1 2
60 #define DRI_CONF_VBLANK_ALWAYS_SYNC 3
70 ** XFree86-DRI version information
76 int invalidateAvailable
;
78 __glxHashTable
*dri2Hash
;
80 const __DRIextension
*loader_extensions
[4];
85 struct glx_context base
;
86 __DRIcontext
*driContext
;
91 __GLXDRIdrawable base
;
92 __DRIdrawable
*driDrawable
;
93 __DRIbuffer buffers
[5];
100 uint64_t previous_time
;
104 static const struct glx_context_vtable dri2_context_vtable
;
106 /* For XCB's handling of ust/msc/sbc counters, we have to hand it the high and
107 * low halves separately. This helps you split them.
110 split_counter(uint64_t counter
, uint32_t *hi
, uint32_t *lo
)
112 *hi
= (counter
>> 32);
113 *lo
= counter
& 0xffffffff;
117 merge_counter(uint32_t hi
, uint32_t lo
)
119 return ((uint64_t)hi
<< 32) | lo
;
123 dri2_destroy_context(struct glx_context
*context
)
125 struct dri2_context
*pcp
= (struct dri2_context
*) context
;
126 struct dri2_screen
*psc
= (struct dri2_screen
*) context
->psc
;
128 driReleaseDrawables(&pcp
->base
);
130 free((char *) context
->extensions
);
132 (*psc
->core
->destroyContext
) (pcp
->driContext
);
138 dri2_bind_context(struct glx_context
*context
, struct glx_context
*old
,
139 GLXDrawable draw
, GLXDrawable read
)
141 struct dri2_context
*pcp
= (struct dri2_context
*) context
;
142 struct dri2_screen
*psc
= (struct dri2_screen
*) pcp
->base
.psc
;
143 struct dri2_drawable
*pdraw
, *pread
;
144 __DRIdrawable
*dri_draw
= NULL
, *dri_read
= NULL
;
145 struct dri2_display
*pdp
;
147 pdraw
= (struct dri2_drawable
*) driFetchDrawable(context
, draw
);
148 pread
= (struct dri2_drawable
*) driFetchDrawable(context
, read
);
150 driReleaseDrawables(&pcp
->base
);
153 dri_draw
= pdraw
->driDrawable
;
154 else if (draw
!= None
)
155 return GLXBadDrawable
;
158 dri_read
= pread
->driDrawable
;
159 else if (read
!= None
)
160 return GLXBadDrawable
;
162 if (!(*psc
->core
->bindContext
) (pcp
->driContext
, dri_draw
, dri_read
))
163 return GLXBadContext
;
165 /* If the server doesn't send invalidate events, we may miss a
166 * resize before the rendering starts. Invalidate the buffers now
167 * so the driver will recheck before rendering starts. */
168 pdp
= (struct dri2_display
*) psc
->base
.display
;
169 if (!pdp
->invalidateAvailable
&& pdraw
) {
170 dri2InvalidateBuffers(psc
->base
.dpy
, pdraw
->base
.xDrawable
);
171 if (pread
!= pdraw
&& pread
)
172 dri2InvalidateBuffers(psc
->base
.dpy
, pread
->base
.xDrawable
);
179 dri2_unbind_context(struct glx_context
*context
, struct glx_context
*new)
181 struct dri2_context
*pcp
= (struct dri2_context
*) context
;
182 struct dri2_screen
*psc
= (struct dri2_screen
*) pcp
->base
.psc
;
184 (*psc
->core
->unbindContext
) (pcp
->driContext
);
187 static struct glx_context
*
188 dri2_create_context(struct glx_screen
*base
,
189 struct glx_config
*config_base
,
190 struct glx_context
*shareList
, int renderType
)
192 struct dri2_context
*pcp
, *pcp_shared
;
193 struct dri2_screen
*psc
= (struct dri2_screen
*) base
;
194 __GLXDRIconfigPrivate
*config
= (__GLXDRIconfigPrivate
*) config_base
;
195 __DRIcontext
*shared
= NULL
;
197 /* Check the renderType value */
198 if (!validate_renderType_against_config(config_base
, renderType
))
202 /* If the shareList context is not a DRI2 context, we cannot possibly
203 * create a DRI2 context that shares it.
205 if (shareList
->vtable
->destroy
!= dri2_destroy_context
) {
209 pcp_shared
= (struct dri2_context
*) shareList
;
210 shared
= pcp_shared
->driContext
;
213 pcp
= calloc(1, sizeof *pcp
);
217 if (!glx_context_init(&pcp
->base
, &psc
->base
, &config
->base
)) {
222 pcp
->base
.renderType
= renderType
;
225 (*psc
->dri2
->createNewContext
) (psc
->driScreen
,
226 config
->driConfig
, shared
, pcp
);
228 if (pcp
->driContext
== NULL
) {
233 pcp
->base
.vtable
= &dri2_context_vtable
;
238 static struct glx_context
*
239 dri2_create_context_attribs(struct glx_screen
*base
,
240 struct glx_config
*config_base
,
241 struct glx_context
*shareList
,
242 unsigned num_attribs
,
243 const uint32_t *attribs
,
246 struct dri2_context
*pcp
= NULL
;
247 struct dri2_context
*pcp_shared
= NULL
;
248 struct dri2_screen
*psc
= (struct dri2_screen
*) base
;
249 __GLXDRIconfigPrivate
*config
= (__GLXDRIconfigPrivate
*) config_base
;
250 __DRIcontext
*shared
= NULL
;
258 uint32_t ctx_attribs
[2 * 5];
259 unsigned num_ctx_attribs
= 0;
261 if (psc
->dri2
->base
.version
< 3) {
262 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
266 /* Remap the GLX tokens to DRI2 tokens.
268 if (!dri2_convert_glx_attribs(num_attribs
, attribs
,
269 &major_ver
, &minor_ver
, &renderType
, &flags
,
270 &api
, &reset
, error
))
273 /* Check the renderType value */
274 if (!validate_renderType_against_config(config_base
, renderType
))
278 pcp_shared
= (struct dri2_context
*) shareList
;
279 shared
= pcp_shared
->driContext
;
282 pcp
= calloc(1, sizeof *pcp
);
284 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
288 if (!glx_context_init(&pcp
->base
, &psc
->base
, &config
->base
))
291 ctx_attribs
[num_ctx_attribs
++] = __DRI_CTX_ATTRIB_MAJOR_VERSION
;
292 ctx_attribs
[num_ctx_attribs
++] = major_ver
;
293 ctx_attribs
[num_ctx_attribs
++] = __DRI_CTX_ATTRIB_MINOR_VERSION
;
294 ctx_attribs
[num_ctx_attribs
++] = minor_ver
;
296 /* Only send a value when the non-default value is requested. By doing
297 * this we don't have to check the driver's DRI2 version before sending the
300 if (reset
!= __DRI_CTX_RESET_NO_NOTIFICATION
) {
301 ctx_attribs
[num_ctx_attribs
++] = __DRI_CTX_ATTRIB_RESET_STRATEGY
;
302 ctx_attribs
[num_ctx_attribs
++] = reset
;
306 ctx_attribs
[num_ctx_attribs
++] = __DRI_CTX_ATTRIB_FLAGS
;
308 /* The current __DRI_CTX_FLAG_* values are identical to the
309 * GLX_CONTEXT_*_BIT values.
311 ctx_attribs
[num_ctx_attribs
++] = flags
;
314 /* The renderType is retrieved from attribs, or set to default
317 pcp
->base
.renderType
= renderType
;
320 (*psc
->dri2
->createContextAttribs
) (psc
->driScreen
,
329 if (pcp
->driContext
== NULL
)
332 pcp
->base
.vtable
= &dri2_context_vtable
;
343 dri2DestroyDrawable(__GLXDRIdrawable
*base
)
345 struct dri2_screen
*psc
= (struct dri2_screen
*) base
->psc
;
346 struct dri2_drawable
*pdraw
= (struct dri2_drawable
*) base
;
347 struct glx_display
*dpyPriv
= psc
->base
.display
;
348 struct dri2_display
*pdp
= (struct dri2_display
*)dpyPriv
->dri2Display
;
350 __glxHashDelete(pdp
->dri2Hash
, pdraw
->base
.xDrawable
);
351 (*psc
->core
->destroyDrawable
) (pdraw
->driDrawable
);
353 /* If it's a GLX 1.3 drawables, we can destroy the DRI2 drawable
354 * now, as the application explicitly asked to destroy the GLX
355 * drawable. Otherwise, for legacy drawables, we let the DRI2
356 * drawable linger on the server, since there's no good way of
357 * knowing when the application is done with it. The server will
358 * destroy the DRI2 drawable when it destroys the X drawable or the
359 * client exits anyway. */
360 if (pdraw
->base
.xDrawable
!= pdraw
->base
.drawable
)
361 DRI2DestroyDrawable(psc
->base
.dpy
, pdraw
->base
.xDrawable
);
366 static __GLXDRIdrawable
*
367 dri2CreateDrawable(struct glx_screen
*base
, XID xDrawable
,
368 GLXDrawable drawable
, struct glx_config
*config_base
)
370 struct dri2_drawable
*pdraw
;
371 struct dri2_screen
*psc
= (struct dri2_screen
*) base
;
372 __GLXDRIconfigPrivate
*config
= (__GLXDRIconfigPrivate
*) config_base
;
373 struct glx_display
*dpyPriv
;
374 struct dri2_display
*pdp
;
375 GLint vblank_mode
= DRI_CONF_VBLANK_DEF_INTERVAL_1
;
377 dpyPriv
= __glXInitialize(psc
->base
.dpy
);
381 pdraw
= calloc(1, sizeof(*pdraw
));
385 pdraw
->base
.destroyDrawable
= dri2DestroyDrawable
;
386 pdraw
->base
.xDrawable
= xDrawable
;
387 pdraw
->base
.drawable
= drawable
;
388 pdraw
->base
.psc
= &psc
->base
;
389 pdraw
->bufferCount
= 0;
390 pdraw
->swap_interval
= 1; /* default may be overridden below */
391 pdraw
->have_back
= 0;
394 psc
->config
->configQueryi(psc
->driScreen
,
395 "vblank_mode", &vblank_mode
);
397 switch (vblank_mode
) {
398 case DRI_CONF_VBLANK_NEVER
:
399 case DRI_CONF_VBLANK_DEF_INTERVAL_0
:
400 pdraw
->swap_interval
= 0;
402 case DRI_CONF_VBLANK_DEF_INTERVAL_1
:
403 case DRI_CONF_VBLANK_ALWAYS_SYNC
:
405 pdraw
->swap_interval
= 1;
409 DRI2CreateDrawable(psc
->base
.dpy
, xDrawable
);
410 pdp
= (struct dri2_display
*)dpyPriv
->dri2Display
;;
411 /* Create a new drawable */
413 (*psc
->dri2
->createNewDrawable
) (psc
->driScreen
,
414 config
->driConfig
, pdraw
);
416 if (!pdraw
->driDrawable
) {
417 DRI2DestroyDrawable(psc
->base
.dpy
, xDrawable
);
422 if (__glxHashInsert(pdp
->dri2Hash
, xDrawable
, pdraw
)) {
423 (*psc
->core
->destroyDrawable
) (pdraw
->driDrawable
);
424 DRI2DestroyDrawable(psc
->base
.dpy
, xDrawable
);
430 * Make sure server has the same swap interval we do for the new
433 if (psc
->vtable
.setSwapInterval
)
434 psc
->vtable
.setSwapInterval(&pdraw
->base
, pdraw
->swap_interval
);
440 dri2DrawableGetMSC(struct glx_screen
*psc
, __GLXDRIdrawable
*pdraw
,
441 int64_t *ust
, int64_t *msc
, int64_t *sbc
)
443 xcb_connection_t
*c
= XGetXCBConnection(pdraw
->psc
->dpy
);
444 xcb_dri2_get_msc_cookie_t get_msc_cookie
;
445 xcb_dri2_get_msc_reply_t
*get_msc_reply
;
447 get_msc_cookie
= xcb_dri2_get_msc_unchecked(c
, pdraw
->xDrawable
);
448 get_msc_reply
= xcb_dri2_get_msc_reply(c
, get_msc_cookie
, NULL
);
453 *ust
= merge_counter(get_msc_reply
->ust_hi
, get_msc_reply
->ust_lo
);
454 *msc
= merge_counter(get_msc_reply
->msc_hi
, get_msc_reply
->msc_lo
);
455 *sbc
= merge_counter(get_msc_reply
->sbc_hi
, get_msc_reply
->sbc_lo
);
462 dri2WaitForMSC(__GLXDRIdrawable
*pdraw
, int64_t target_msc
, int64_t divisor
,
463 int64_t remainder
, int64_t *ust
, int64_t *msc
, int64_t *sbc
)
465 xcb_connection_t
*c
= XGetXCBConnection(pdraw
->psc
->dpy
);
466 xcb_dri2_wait_msc_cookie_t wait_msc_cookie
;
467 xcb_dri2_wait_msc_reply_t
*wait_msc_reply
;
468 uint32_t target_msc_hi
, target_msc_lo
;
469 uint32_t divisor_hi
, divisor_lo
;
470 uint32_t remainder_hi
, remainder_lo
;
472 split_counter(target_msc
, &target_msc_hi
, &target_msc_lo
);
473 split_counter(divisor
, &divisor_hi
, &divisor_lo
);
474 split_counter(remainder
, &remainder_hi
, &remainder_lo
);
476 wait_msc_cookie
= xcb_dri2_wait_msc_unchecked(c
, pdraw
->xDrawable
,
477 target_msc_hi
, target_msc_lo
,
478 divisor_hi
, divisor_lo
,
479 remainder_hi
, remainder_lo
);
480 wait_msc_reply
= xcb_dri2_wait_msc_reply(c
, wait_msc_cookie
, NULL
);
485 *ust
= merge_counter(wait_msc_reply
->ust_hi
, wait_msc_reply
->ust_lo
);
486 *msc
= merge_counter(wait_msc_reply
->msc_hi
, wait_msc_reply
->msc_lo
);
487 *sbc
= merge_counter(wait_msc_reply
->sbc_hi
, wait_msc_reply
->sbc_lo
);
488 free(wait_msc_reply
);
494 dri2WaitForSBC(__GLXDRIdrawable
*pdraw
, int64_t target_sbc
, int64_t *ust
,
495 int64_t *msc
, int64_t *sbc
)
497 xcb_connection_t
*c
= XGetXCBConnection(pdraw
->psc
->dpy
);
498 xcb_dri2_wait_sbc_cookie_t wait_sbc_cookie
;
499 xcb_dri2_wait_sbc_reply_t
*wait_sbc_reply
;
500 uint32_t target_sbc_hi
, target_sbc_lo
;
502 split_counter(target_sbc
, &target_sbc_hi
, &target_sbc_lo
);
504 wait_sbc_cookie
= xcb_dri2_wait_sbc_unchecked(c
, pdraw
->xDrawable
,
505 target_sbc_hi
, target_sbc_lo
);
506 wait_sbc_reply
= xcb_dri2_wait_sbc_reply(c
, wait_sbc_cookie
, NULL
);
511 *ust
= merge_counter(wait_sbc_reply
->ust_hi
, wait_sbc_reply
->ust_lo
);
512 *msc
= merge_counter(wait_sbc_reply
->msc_hi
, wait_sbc_reply
->msc_lo
);
513 *sbc
= merge_counter(wait_sbc_reply
->sbc_hi
, wait_sbc_reply
->sbc_lo
);
514 free(wait_sbc_reply
);
519 static __DRIcontext
*
520 dri2GetCurrentContext()
522 struct glx_context
*gc
= __glXGetCurrentContext();
523 struct dri2_context
*dri2Ctx
= (struct dri2_context
*)gc
;
525 return dri2Ctx
? dri2Ctx
->driContext
: NULL
;
529 * dri2Throttle - Request driver throttling
531 * This function uses the DRI2 throttle extension to give the
532 * driver the opportunity to throttle on flush front, copysubbuffer
536 dri2Throttle(struct dri2_screen
*psc
,
537 struct dri2_drawable
*draw
,
538 enum __DRI2throttleReason reason
)
541 __DRIcontext
*ctx
= dri2GetCurrentContext();
543 psc
->throttle
->throttle(ctx
, draw
->driDrawable
, reason
);
548 * Asks the driver to flush any queued work necessary for serializing with the
549 * X command stream, and optionally the slightly more strict requirement of
550 * glFlush() equivalence (which would require flushing even if nothing had
551 * been drawn to a window system framebuffer, for example).
554 dri2Flush(struct dri2_screen
*psc
,
556 struct dri2_drawable
*draw
,
558 enum __DRI2throttleReason throttle_reason
)
560 if (ctx
&& psc
->f
&& psc
->f
->base
.version
>= 4) {
561 psc
->f
->flush_with_flags(ctx
, draw
->driDrawable
, flags
, throttle_reason
);
563 if (flags
& __DRI2_FLUSH_CONTEXT
)
567 psc
->f
->flush(draw
->driDrawable
);
569 dri2Throttle(psc
, draw
, throttle_reason
);
574 __dri2CopySubBuffer(__GLXDRIdrawable
*pdraw
, int x
, int y
,
575 int width
, int height
,
576 enum __DRI2throttleReason reason
, Bool flush
)
578 struct dri2_drawable
*priv
= (struct dri2_drawable
*) pdraw
;
579 struct dri2_screen
*psc
= (struct dri2_screen
*) pdraw
->psc
;
581 XserverRegion region
;
582 __DRIcontext
*ctx
= dri2GetCurrentContext();
585 /* Check we have the right attachments */
586 if (!priv
->have_back
)
590 xrect
.y
= priv
->height
- y
- height
;
592 xrect
.height
= height
;
594 flags
= __DRI2_FLUSH_DRAWABLE
;
596 flags
|= __DRI2_FLUSH_CONTEXT
;
597 dri2Flush(psc
, ctx
, priv
, flags
, __DRI2_THROTTLE_SWAPBUFFER
);
599 region
= XFixesCreateRegion(psc
->base
.dpy
, &xrect
, 1);
600 DRI2CopyRegion(psc
->base
.dpy
, pdraw
->xDrawable
, region
,
601 DRI2BufferFrontLeft
, DRI2BufferBackLeft
);
603 /* Refresh the fake front (if present) after we just damaged the real
606 if (priv
->have_fake_front
)
607 DRI2CopyRegion(psc
->base
.dpy
, pdraw
->xDrawable
, region
,
608 DRI2BufferFakeFrontLeft
, DRI2BufferFrontLeft
);
610 XFixesDestroyRegion(psc
->base
.dpy
, region
);
614 dri2CopySubBuffer(__GLXDRIdrawable
*pdraw
, int x
, int y
,
615 int width
, int height
, Bool flush
)
617 __dri2CopySubBuffer(pdraw
, x
, y
, width
, height
,
618 __DRI2_THROTTLE_COPYSUBBUFFER
, flush
);
623 dri2_copy_drawable(struct dri2_drawable
*priv
, int dest
, int src
)
626 XserverRegion region
;
627 struct dri2_screen
*psc
= (struct dri2_screen
*) priv
->base
.psc
;
631 xrect
.width
= priv
->width
;
632 xrect
.height
= priv
->height
;
635 (*psc
->f
->flush
) (priv
->driDrawable
);
637 region
= XFixesCreateRegion(psc
->base
.dpy
, &xrect
, 1);
638 DRI2CopyRegion(psc
->base
.dpy
, priv
->base
.xDrawable
, region
, dest
, src
);
639 XFixesDestroyRegion(psc
->base
.dpy
, region
);
644 dri2_wait_x(struct glx_context
*gc
)
646 struct dri2_drawable
*priv
= (struct dri2_drawable
*)
647 GetGLXDRIDrawable(gc
->currentDpy
, gc
->currentDrawable
);
649 if (priv
== NULL
|| !priv
->have_fake_front
)
652 dri2_copy_drawable(priv
, DRI2BufferFakeFrontLeft
, DRI2BufferFrontLeft
);
656 dri2_wait_gl(struct glx_context
*gc
)
658 struct dri2_drawable
*priv
= (struct dri2_drawable
*)
659 GetGLXDRIDrawable(gc
->currentDpy
, gc
->currentDrawable
);
661 if (priv
== NULL
|| !priv
->have_fake_front
)
664 dri2_copy_drawable(priv
, DRI2BufferFrontLeft
, DRI2BufferFakeFrontLeft
);
668 * Called by the driver when it needs to update the real front buffer with the
669 * contents of its fake front buffer.
672 dri2FlushFrontBuffer(__DRIdrawable
*driDrawable
, void *loaderPrivate
)
674 struct glx_display
*priv
;
675 struct dri2_display
*pdp
;
676 struct glx_context
*gc
;
677 struct dri2_drawable
*pdraw
= loaderPrivate
;
678 struct dri2_screen
*psc
;
683 if (!pdraw
->base
.psc
)
686 psc
= (struct dri2_screen
*) pdraw
->base
.psc
;
688 priv
= __glXInitialize(psc
->base
.dpy
);
693 pdp
= (struct dri2_display
*) priv
->dri2Display
;
694 gc
= __glXGetCurrentContext();
696 dri2Throttle(psc
, pdraw
, __DRI2_THROTTLE_FLUSHFRONT
);
698 /* Old servers don't send invalidate events */
699 if (!pdp
->invalidateAvailable
)
700 dri2InvalidateBuffers(priv
->dpy
, pdraw
->base
.xDrawable
);
707 dri2DestroyScreen(struct glx_screen
*base
)
709 struct dri2_screen
*psc
= (struct dri2_screen
*) base
;
711 /* Free the direct rendering per screen data */
712 (*psc
->core
->destroyScreen
) (psc
->driScreen
);
713 driDestroyConfigs(psc
->driver_configs
);
719 * Process list of buffer received from the server
721 * Processes the list of buffers received in a reply from the server to either
722 * \c DRI2GetBuffers or \c DRI2GetBuffersWithFormat.
725 process_buffers(struct dri2_drawable
* pdraw
, DRI2Buffer
* buffers
,
730 pdraw
->bufferCount
= count
;
731 pdraw
->have_fake_front
= 0;
732 pdraw
->have_back
= 0;
734 /* This assumes the DRI2 buffer attachment tokens matches the
735 * __DRIbuffer tokens. */
736 for (i
= 0; i
< count
; i
++) {
737 pdraw
->buffers
[i
].attachment
= buffers
[i
].attachment
;
738 pdraw
->buffers
[i
].name
= buffers
[i
].name
;
739 pdraw
->buffers
[i
].pitch
= buffers
[i
].pitch
;
740 pdraw
->buffers
[i
].cpp
= buffers
[i
].cpp
;
741 pdraw
->buffers
[i
].flags
= buffers
[i
].flags
;
742 if (pdraw
->buffers
[i
].attachment
== __DRI_BUFFER_FAKE_FRONT_LEFT
)
743 pdraw
->have_fake_front
= 1;
744 if (pdraw
->buffers
[i
].attachment
== __DRI_BUFFER_BACK_LEFT
)
745 pdraw
->have_back
= 1;
750 unsigned dri2GetSwapEventType(Display
* dpy
, XID drawable
)
752 struct glx_display
*glx_dpy
= __glXInitialize(dpy
);
753 __GLXDRIdrawable
*pdraw
;
754 pdraw
= dri2GetGlxDrawableFromXDrawableId(dpy
, drawable
);
755 if (!pdraw
|| !(pdraw
->eventMask
& GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK
))
757 return glx_dpy
->codes
->first_event
+ GLX_BufferSwapComplete
;
760 static void show_fps(struct dri2_drawable
*draw
)
763 ((struct dri2_screen
*) draw
->base
.psc
)->show_fps_interval
;
765 uint64_t current_time
;
767 gettimeofday(&tv
, 0);
768 current_time
= (uint64_t)tv
.tv_sec
*1000000 + (uint64_t)tv
.tv_usec
;
772 if (draw
->previous_time
+ interval
* 1000000 <= current_time
) {
773 if (draw
->previous_time
) {
774 fprintf(stderr
, "libGL: FPS = %.1f\n",
775 ((uint64_t)draw
->frames
* 1000000) /
776 (double)(current_time
- draw
->previous_time
));
779 draw
->previous_time
= current_time
;
784 dri2XcbSwapBuffers(Display
*dpy
,
785 __GLXDRIdrawable
*pdraw
,
790 xcb_dri2_swap_buffers_cookie_t swap_buffers_cookie
;
791 xcb_dri2_swap_buffers_reply_t
*swap_buffers_reply
;
792 uint32_t target_msc_hi
, target_msc_lo
;
793 uint32_t divisor_hi
, divisor_lo
;
794 uint32_t remainder_hi
, remainder_lo
;
796 xcb_connection_t
*c
= XGetXCBConnection(dpy
);
798 split_counter(target_msc
, &target_msc_hi
, &target_msc_lo
);
799 split_counter(divisor
, &divisor_hi
, &divisor_lo
);
800 split_counter(remainder
, &remainder_hi
, &remainder_lo
);
802 swap_buffers_cookie
=
803 xcb_dri2_swap_buffers_unchecked(c
, pdraw
->xDrawable
,
804 target_msc_hi
, target_msc_lo
,
805 divisor_hi
, divisor_lo
,
806 remainder_hi
, remainder_lo
);
808 /* Immediately wait on the swapbuffers reply. If we didn't, we'd have
809 * to do so some time before reusing a (non-pageflipped) backbuffer.
810 * Otherwise, the new rendering could get ahead of the X Server's
811 * dispatch of the swapbuffer and you'd display garbage.
813 * We use XSync() first to reap the invalidate events through the event
814 * filter, to ensure that the next drawing doesn't use an invalidated
820 xcb_dri2_swap_buffers_reply(c
, swap_buffers_cookie
, NULL
);
821 if (swap_buffers_reply
) {
822 ret
= merge_counter(swap_buffers_reply
->swap_hi
,
823 swap_buffers_reply
->swap_lo
);
824 free(swap_buffers_reply
);
830 dri2SwapBuffers(__GLXDRIdrawable
*pdraw
, int64_t target_msc
, int64_t divisor
,
831 int64_t remainder
, Bool flush
)
833 struct dri2_drawable
*priv
= (struct dri2_drawable
*) pdraw
;
834 struct glx_display
*dpyPriv
= __glXInitialize(priv
->base
.psc
->dpy
);
835 struct dri2_screen
*psc
= (struct dri2_screen
*) priv
->base
.psc
;
836 struct dri2_display
*pdp
=
837 (struct dri2_display
*)dpyPriv
->dri2Display
;
840 /* Check we have the right attachments */
841 if (!priv
->have_back
)
844 /* Old servers can't handle swapbuffers */
845 if (!pdp
->swapAvailable
) {
846 __dri2CopySubBuffer(pdraw
, 0, 0, priv
->width
, priv
->height
,
847 __DRI2_THROTTLE_SWAPBUFFER
, flush
);
849 __DRIcontext
*ctx
= dri2GetCurrentContext();
850 unsigned flags
= __DRI2_FLUSH_DRAWABLE
;
852 flags
|= __DRI2_FLUSH_CONTEXT
;
853 dri2Flush(psc
, ctx
, priv
, flags
, __DRI2_THROTTLE_SWAPBUFFER
);
855 ret
= dri2XcbSwapBuffers(pdraw
->psc
->dpy
, pdraw
,
856 target_msc
, divisor
, remainder
);
859 if (psc
->show_fps_interval
) {
863 /* Old servers don't send invalidate events */
864 if (!pdp
->invalidateAvailable
)
865 dri2InvalidateBuffers(dpyPriv
->dpy
, pdraw
->xDrawable
);
871 dri2GetBuffers(__DRIdrawable
* driDrawable
,
872 int *width
, int *height
,
873 unsigned int *attachments
, int count
,
874 int *out_count
, void *loaderPrivate
)
876 struct dri2_drawable
*pdraw
= loaderPrivate
;
879 buffers
= DRI2GetBuffers(pdraw
->base
.psc
->dpy
, pdraw
->base
.xDrawable
,
880 width
, height
, attachments
, count
, out_count
);
884 pdraw
->width
= *width
;
885 pdraw
->height
= *height
;
886 process_buffers(pdraw
, buffers
, *out_count
);
890 return pdraw
->buffers
;
894 dri2GetBuffersWithFormat(__DRIdrawable
* driDrawable
,
895 int *width
, int *height
,
896 unsigned int *attachments
, int count
,
897 int *out_count
, void *loaderPrivate
)
899 struct dri2_drawable
*pdraw
= loaderPrivate
;
902 buffers
= DRI2GetBuffersWithFormat(pdraw
->base
.psc
->dpy
,
903 pdraw
->base
.xDrawable
,
904 width
, height
, attachments
,
909 pdraw
->width
= *width
;
910 pdraw
->height
= *height
;
911 process_buffers(pdraw
, buffers
, *out_count
);
915 return pdraw
->buffers
;
919 dri2SetSwapInterval(__GLXDRIdrawable
*pdraw
, int interval
)
921 xcb_connection_t
*c
= XGetXCBConnection(pdraw
->psc
->dpy
);
922 struct dri2_drawable
*priv
= (struct dri2_drawable
*) pdraw
;
923 GLint vblank_mode
= DRI_CONF_VBLANK_DEF_INTERVAL_1
;
924 struct dri2_screen
*psc
= (struct dri2_screen
*) priv
->base
.psc
;
927 psc
->config
->configQueryi(psc
->driScreen
,
928 "vblank_mode", &vblank_mode
);
930 switch (vblank_mode
) {
931 case DRI_CONF_VBLANK_NEVER
:
933 return GLX_BAD_VALUE
;
935 case DRI_CONF_VBLANK_ALWAYS_SYNC
:
937 return GLX_BAD_VALUE
;
943 xcb_dri2_swap_interval(c
, priv
->base
.xDrawable
, interval
);
944 priv
->swap_interval
= interval
;
950 dri2GetSwapInterval(__GLXDRIdrawable
*pdraw
)
952 struct dri2_drawable
*priv
= (struct dri2_drawable
*) pdraw
;
954 return priv
->swap_interval
;
957 static const __DRIdri2LoaderExtension dri2LoaderExtension
= {
958 .base
= { __DRI_DRI2_LOADER
, 3 },
960 .getBuffers
= dri2GetBuffers
,
961 .flushFrontBuffer
= dri2FlushFrontBuffer
,
962 .getBuffersWithFormat
= dri2GetBuffersWithFormat
,
965 static const __DRIdri2LoaderExtension dri2LoaderExtension_old
= {
966 .base
= { __DRI_DRI2_LOADER
, 3 },
968 .getBuffers
= dri2GetBuffers
,
969 .flushFrontBuffer
= dri2FlushFrontBuffer
,
970 .getBuffersWithFormat
= NULL
,
973 static const __DRIuseInvalidateExtension dri2UseInvalidate
= {
974 { __DRI_USE_INVALIDATE
, __DRI_USE_INVALIDATE_VERSION
}
978 dri2InvalidateBuffers(Display
*dpy
, XID drawable
)
980 __GLXDRIdrawable
*pdraw
=
981 dri2GetGlxDrawableFromXDrawableId(dpy
, drawable
);
982 struct dri2_screen
*psc
;
983 struct dri2_drawable
*pdp
= (struct dri2_drawable
*) pdraw
;
988 psc
= (struct dri2_screen
*) pdraw
->psc
;
990 if (pdraw
&& psc
->f
&& psc
->f
->base
.version
>= 3 && psc
->f
->invalidate
)
991 psc
->f
->invalidate(pdp
->driDrawable
);
995 dri2_bind_tex_image(Display
* dpy
,
996 GLXDrawable drawable
,
997 int buffer
, const int *attrib_list
)
999 struct glx_context
*gc
= __glXGetCurrentContext();
1000 struct dri2_context
*pcp
= (struct dri2_context
*) gc
;
1001 __GLXDRIdrawable
*base
= GetGLXDRIDrawable(dpy
, drawable
);
1002 struct glx_display
*dpyPriv
= __glXInitialize(dpy
);
1003 struct dri2_drawable
*pdraw
= (struct dri2_drawable
*) base
;
1004 struct dri2_display
*pdp
;
1005 struct dri2_screen
*psc
;
1007 if (dpyPriv
== NULL
)
1010 pdp
= (struct dri2_display
*) dpyPriv
->dri2Display
;
1012 if (pdraw
!= NULL
) {
1013 psc
= (struct dri2_screen
*) base
->psc
;
1015 if (!pdp
->invalidateAvailable
&& psc
->f
&&
1016 psc
->f
->base
.version
>= 3 && psc
->f
->invalidate
)
1017 psc
->f
->invalidate(pdraw
->driDrawable
);
1019 if (psc
->texBuffer
->base
.version
>= 2 &&
1020 psc
->texBuffer
->setTexBuffer2
!= NULL
) {
1021 (*psc
->texBuffer
->setTexBuffer2
) (pcp
->driContext
,
1022 pdraw
->base
.textureTarget
,
1023 pdraw
->base
.textureFormat
,
1024 pdraw
->driDrawable
);
1027 (*psc
->texBuffer
->setTexBuffer
) (pcp
->driContext
,
1028 pdraw
->base
.textureTarget
,
1029 pdraw
->driDrawable
);
1035 dri2_release_tex_image(Display
* dpy
, GLXDrawable drawable
, int buffer
)
1037 #if __DRI_TEX_BUFFER_VERSION >= 3
1038 struct glx_context
*gc
= __glXGetCurrentContext();
1039 struct dri2_context
*pcp
= (struct dri2_context
*) gc
;
1040 __GLXDRIdrawable
*base
= GetGLXDRIDrawable(dpy
, drawable
);
1041 struct glx_display
*dpyPriv
= __glXInitialize(dpy
);
1042 struct dri2_drawable
*pdraw
= (struct dri2_drawable
*) base
;
1043 struct dri2_display
*pdp
=
1044 (struct dri2_display
*) dpyPriv
->dri2Display
;
1045 struct dri2_screen
*psc
;
1047 if (pdraw
!= NULL
) {
1048 psc
= (struct dri2_screen
*) base
->psc
;
1050 if (psc
->texBuffer
->base
.version
>= 3 &&
1051 psc
->texBuffer
->releaseTexBuffer
!= NULL
) {
1052 (*psc
->texBuffer
->releaseTexBuffer
) (pcp
->driContext
,
1053 pdraw
->base
.textureTarget
,
1054 pdraw
->driDrawable
);
1060 static const struct glx_context_vtable dri2_context_vtable
= {
1061 dri2_destroy_context
,
1063 dri2_unbind_context
,
1067 dri2_bind_tex_image
,
1068 dri2_release_tex_image
,
1069 NULL
, /* get_proc_address */
1073 dri2BindExtensions(struct dri2_screen
*psc
, struct glx_display
* priv
,
1074 const char *driverName
)
1076 const struct dri2_display
*const pdp
= (struct dri2_display
*)
1078 const __DRIextension
**extensions
;
1081 extensions
= psc
->core
->getExtensions(psc
->driScreen
);
1083 __glXEnableDirectExtension(&psc
->base
, "GLX_SGI_video_sync");
1084 __glXEnableDirectExtension(&psc
->base
, "GLX_SGI_swap_control");
1085 __glXEnableDirectExtension(&psc
->base
, "GLX_MESA_swap_control");
1086 __glXEnableDirectExtension(&psc
->base
, "GLX_SGI_make_current_read");
1089 * GLX_INTEL_swap_event is broken on the server side, where it's
1090 * currently unconditionally enabled. This completely breaks
1091 * systems running on drivers which don't support that extension.
1092 * There's no way to test for its presence on this side, so instead
1093 * of disabling it unconditionally, just disable it for drivers
1094 * which are known to not support it, or for DDX drivers supporting
1095 * only an older (pre-ScheduleSwap) version of DRI2.
1097 * This is a hack which is required until:
1098 * http://lists.x.org/archives/xorg-devel/2013-February/035449.html
1099 * is merged and updated xserver makes it's way into distros:
1101 if (pdp
->swapAvailable
&& strcmp(driverName
, "vmwgfx") != 0) {
1102 __glXEnableDirectExtension(&psc
->base
, "GLX_INTEL_swap_event");
1105 if (psc
->dri2
->base
.version
>= 3) {
1106 const unsigned mask
= psc
->dri2
->getAPIMask(psc
->driScreen
);
1108 __glXEnableDirectExtension(&psc
->base
, "GLX_ARB_create_context");
1109 __glXEnableDirectExtension(&psc
->base
, "GLX_ARB_create_context_profile");
1111 if ((mask
& (1 << __DRI_API_GLES2
)) != 0)
1112 __glXEnableDirectExtension(&psc
->base
,
1113 "GLX_EXT_create_context_es2_profile");
1116 for (i
= 0; extensions
[i
]; i
++) {
1117 if ((strcmp(extensions
[i
]->name
, __DRI_TEX_BUFFER
) == 0)) {
1118 psc
->texBuffer
= (__DRItexBufferExtension
*) extensions
[i
];
1119 __glXEnableDirectExtension(&psc
->base
, "GLX_EXT_texture_from_pixmap");
1122 if ((strcmp(extensions
[i
]->name
, __DRI2_FLUSH
) == 0)) {
1123 psc
->f
= (__DRI2flushExtension
*) extensions
[i
];
1124 /* internal driver extension, no GL extension exposed */
1127 if ((strcmp(extensions
[i
]->name
, __DRI2_CONFIG_QUERY
) == 0))
1128 psc
->config
= (__DRI2configQueryExtension
*) extensions
[i
];
1130 if (((strcmp(extensions
[i
]->name
, __DRI2_THROTTLE
) == 0)))
1131 psc
->throttle
= (__DRI2throttleExtension
*) extensions
[i
];
1133 /* DRI2 version 3 is also required because
1134 * GLX_ARB_create_context_robustness requires GLX_ARB_create_context.
1136 if (psc
->dri2
->base
.version
>= 3
1137 && strcmp(extensions
[i
]->name
, __DRI2_ROBUSTNESS
) == 0)
1138 __glXEnableDirectExtension(&psc
->base
,
1139 "GLX_ARB_create_context_robustness");
1141 /* DRI2 version 3 is also required because GLX_MESA_query_renderer
1142 * requires GLX_ARB_create_context_profile.
1144 if (psc
->dri2
->base
.version
>= 3
1145 && strcmp(extensions
[i
]->name
, __DRI2_RENDERER_QUERY
) == 0) {
1146 psc
->rendererQuery
= (__DRI2rendererQueryExtension
*) extensions
[i
];
1147 __glXEnableDirectExtension(&psc
->base
, "GLX_MESA_query_renderer");
1152 static const struct glx_screen_vtable dri2_screen_vtable
= {
1153 dri2_create_context
,
1154 dri2_create_context_attribs
,
1155 dri2_query_renderer_integer
,
1156 dri2_query_renderer_string
,
1159 static struct glx_screen
*
1160 dri2CreateScreen(int screen
, struct glx_display
* priv
)
1162 const __DRIconfig
**driver_configs
;
1163 const __DRIextension
**extensions
;
1164 const struct dri2_display
*const pdp
= (struct dri2_display
*)
1166 struct dri2_screen
*psc
;
1167 __GLXDRIscreen
*psp
;
1168 struct glx_config
*configs
= NULL
, *visuals
= NULL
;
1169 char *driverName
= NULL
, *loader_driverName
, *deviceName
, *tmp
;
1173 psc
= calloc(1, sizeof *psc
);
1179 if (!glx_screen_init(&psc
->base
, screen
, priv
)) {
1184 if (!DRI2Connect(priv
->dpy
, RootWindow(priv
->dpy
, screen
),
1185 &driverName
, &deviceName
)) {
1186 glx_screen_cleanup(&psc
->base
);
1188 InfoMessageF("screen %d does not appear to be DRI2 capable\n", screen
);
1193 psc
->fd
= open(deviceName
, O_RDWR
| O_CLOEXEC
);
1194 if (psc
->fd
== -1 && errno
== EINVAL
)
1197 psc
->fd
= open(deviceName
, O_RDWR
);
1199 fcntl(psc
->fd
, F_SETFD
, fcntl(psc
->fd
, F_GETFD
) | FD_CLOEXEC
);
1202 ErrorMessageF("failed to open drm device: %s\n", strerror(errno
));
1206 /* If Mesa knows about the appropriate driver for this fd, then trust it.
1207 * Otherwise, default to the server's value.
1209 loader_driverName
= loader_get_driver_for_fd(psc
->fd
, 0);
1210 if (loader_driverName
) {
1212 driverName
= loader_driverName
;
1215 psc
->driver
= driOpenDriver(driverName
);
1216 if (psc
->driver
== NULL
) {
1217 ErrorMessageF("driver pointer missing\n");
1221 extensions
= driGetDriverExtensions(psc
->driver
, driverName
);
1222 if (extensions
== NULL
)
1225 for (i
= 0; extensions
[i
]; i
++) {
1226 if (strcmp(extensions
[i
]->name
, __DRI_CORE
) == 0)
1227 psc
->core
= (__DRIcoreExtension
*) extensions
[i
];
1228 if (strcmp(extensions
[i
]->name
, __DRI_DRI2
) == 0)
1229 psc
->dri2
= (__DRIdri2Extension
*) extensions
[i
];
1232 if (psc
->core
== NULL
|| psc
->dri2
== NULL
) {
1233 ErrorMessageF("core dri or dri2 extension not found\n");
1237 if (drmGetMagic(psc
->fd
, &magic
)) {
1238 ErrorMessageF("failed to get magic\n");
1242 if (!DRI2Authenticate(priv
->dpy
, RootWindow(priv
->dpy
, screen
), magic
)) {
1243 ErrorMessageF("failed to authenticate magic %d\n", magic
);
1247 if (psc
->dri2
->base
.version
>= 4) {
1249 psc
->dri2
->createNewScreen2(screen
, psc
->fd
,
1250 (const __DRIextension
**)
1251 &pdp
->loader_extensions
[0],
1253 &driver_configs
, psc
);
1256 psc
->dri2
->createNewScreen(screen
, psc
->fd
,
1257 (const __DRIextension
**)
1258 &pdp
->loader_extensions
[0],
1259 &driver_configs
, psc
);
1262 if (psc
->driScreen
== NULL
) {
1263 ErrorMessageF("failed to create dri screen\n");
1267 dri2BindExtensions(psc
, priv
, driverName
);
1269 configs
= driConvertConfigs(psc
->core
, psc
->base
.configs
, driver_configs
);
1270 visuals
= driConvertConfigs(psc
->core
, psc
->base
.visuals
, driver_configs
);
1272 if (!configs
|| !visuals
)
1275 glx_config_destroy_list(psc
->base
.configs
);
1276 psc
->base
.configs
= configs
;
1277 glx_config_destroy_list(psc
->base
.visuals
);
1278 psc
->base
.visuals
= visuals
;
1280 psc
->driver_configs
= driver_configs
;
1282 psc
->base
.vtable
= &dri2_screen_vtable
;
1284 psc
->base
.driScreen
= psp
;
1285 psp
->destroyScreen
= dri2DestroyScreen
;
1286 psp
->createDrawable
= dri2CreateDrawable
;
1287 psp
->swapBuffers
= dri2SwapBuffers
;
1288 psp
->getDrawableMSC
= NULL
;
1289 psp
->waitForMSC
= NULL
;
1290 psp
->waitForSBC
= NULL
;
1291 psp
->setSwapInterval
= NULL
;
1292 psp
->getSwapInterval
= NULL
;
1294 if (pdp
->driMinor
>= 2) {
1295 psp
->getDrawableMSC
= dri2DrawableGetMSC
;
1296 psp
->waitForMSC
= dri2WaitForMSC
;
1297 psp
->waitForSBC
= dri2WaitForSBC
;
1298 psp
->setSwapInterval
= dri2SetSwapInterval
;
1299 psp
->getSwapInterval
= dri2GetSwapInterval
;
1300 __glXEnableDirectExtension(&psc
->base
, "GLX_OML_sync_control");
1303 /* DRI2 suports SubBuffer through DRI2CopyRegion, so it's always
1305 psp
->copySubBuffer
= dri2CopySubBuffer
;
1306 __glXEnableDirectExtension(&psc
->base
, "GLX_MESA_copy_sub_buffer");
1311 tmp
= getenv("LIBGL_SHOW_FPS");
1312 psc
->show_fps_interval
= (tmp
) ? atoi(tmp
) : 0;
1313 if (psc
->show_fps_interval
< 0)
1314 psc
->show_fps_interval
= 0;
1319 CriticalErrorMessageF("failed to load driver: %s\n", driverName
);
1322 glx_config_destroy_list(configs
);
1324 glx_config_destroy_list(visuals
);
1326 psc
->core
->destroyScreen(psc
->driScreen
);
1327 psc
->driScreen
= NULL
;
1331 dlclose(psc
->driver
);
1335 glx_screen_cleanup(&psc
->base
);
1341 /* Called from __glXFreeDisplayPrivate.
1344 dri2DestroyDisplay(__GLXDRIdisplay
* dpy
)
1346 struct dri2_display
*pdp
= (struct dri2_display
*) dpy
;
1348 __glxHashDestroy(pdp
->dri2Hash
);
1352 _X_HIDDEN __GLXDRIdrawable
*
1353 dri2GetGlxDrawableFromXDrawableId(Display
*dpy
, XID id
)
1355 struct glx_display
*d
= __glXInitialize(dpy
);
1356 struct dri2_display
*pdp
= (struct dri2_display
*) d
->dri2Display
;
1357 __GLXDRIdrawable
*pdraw
;
1359 if (__glxHashLookup(pdp
->dri2Hash
, id
, (void *) &pdraw
) == 0)
1366 * Allocate, initialize and return a __DRIdisplayPrivate object.
1367 * This is called from __glXInitialize() when we are given a new
1370 _X_HIDDEN __GLXDRIdisplay
*
1371 dri2CreateDisplay(Display
* dpy
)
1373 struct dri2_display
*pdp
;
1374 int eventBase
, errorBase
, i
;
1376 if (!DRI2QueryExtension(dpy
, &eventBase
, &errorBase
))
1379 pdp
= malloc(sizeof *pdp
);
1383 if (!DRI2QueryVersion(dpy
, &pdp
->driMajor
, &pdp
->driMinor
)) {
1389 pdp
->swapAvailable
= (pdp
->driMinor
>= 2);
1390 pdp
->invalidateAvailable
= (pdp
->driMinor
>= 3);
1392 pdp
->base
.destroyDisplay
= dri2DestroyDisplay
;
1393 pdp
->base
.createScreen
= dri2CreateScreen
;
1396 if (pdp
->driMinor
< 1)
1397 pdp
->loader_extensions
[i
++] = &dri2LoaderExtension_old
.base
;
1399 pdp
->loader_extensions
[i
++] = &dri2LoaderExtension
.base
;
1401 pdp
->loader_extensions
[i
++] = &systemTimeExtension
.base
;
1403 pdp
->loader_extensions
[i
++] = &dri2UseInvalidate
.base
;
1405 pdp
->loader_extensions
[i
++] = NULL
;
1407 pdp
->dri2Hash
= __glxHashCreate();
1408 if (pdp
->dri2Hash
== NULL
) {
1416 #endif /* GLX_DIRECT_RENDERING */