db44eede651168185ee04a53f4557631aa508c37
[mesa.git] / src / mesa / drivers / dri / common / dri_util.c
1 /*
2 * (C) Copyright IBM Corporation 2002, 2004
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /**
26 * \file dri_util.c
27 * DRI utility functions.
28 *
29 * This module acts as glue between GLX and the actual hardware driver. A DRI
30 * driver doesn't really \e have to use any of this - it's optional. But, some
31 * useful stuff is done here that otherwise would have to be duplicated in most
32 * drivers.
33 *
34 * Basically, these utility functions take care of some of the dirty details of
35 * screen initialization, context creation, context binding, DRM setup, etc.
36 *
37 * These functions are compiled into each DRI driver so libGL.so knows nothing
38 * about them.
39 */
40
41
42 #include <stdbool.h>
43 #ifndef __NOT_HAVE_DRM_H
44 #include <xf86drm.h>
45 #endif
46 #include "dri_util.h"
47 #include "utils.h"
48 #include "xmlpool.h"
49 #include "../glsl/glsl_parser_extras.h"
50 #include "main/mtypes.h"
51 #include "main/version.h"
52 #include "main/macros.h"
53
54 PUBLIC const char __dri2ConfigOptions[] =
55 DRI_CONF_BEGIN
56 DRI_CONF_SECTION_PERFORMANCE
57 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
58 DRI_CONF_SECTION_END
59 DRI_CONF_END;
60
61 /*****************************************************************/
62 /** \name Screen handling functions */
63 /*****************************************************************/
64 /*@{*/
65
66 static void
67 setupLoaderExtensions(__DRIscreen *psp,
68 const __DRIextension **extensions)
69 {
70 int i;
71
72 for (i = 0; extensions[i]; i++) {
73 if (strcmp(extensions[i]->name, __DRI_DRI2_LOADER) == 0)
74 psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i];
75 if (strcmp(extensions[i]->name, __DRI_IMAGE_LOOKUP) == 0)
76 psp->dri2.image = (__DRIimageLookupExtension *) extensions[i];
77 if (strcmp(extensions[i]->name, __DRI_USE_INVALIDATE) == 0)
78 psp->dri2.useInvalidate = (__DRIuseInvalidateExtension *) extensions[i];
79 if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0)
80 psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i];
81 }
82 }
83
84 /**
85 * This is the first entrypoint in the driver called by the DRI driver loader
86 * after dlopen()ing it.
87 *
88 * It's used to create global state for the driver across contexts on the same
89 * Display.
90 */
91 static __DRIscreen *
92 dri2CreateNewScreen(int scrn, int fd,
93 const __DRIextension **extensions,
94 const __DRIconfig ***driver_configs, void *data)
95 {
96 static const __DRIextension *emptyExtensionList[] = { NULL };
97 __DRIscreen *psp;
98
99 psp = calloc(1, sizeof(*psp));
100 if (!psp)
101 return NULL;
102
103 psp->driver = &driDriverAPI;
104
105 setupLoaderExtensions(psp, extensions);
106
107 #ifndef __NOT_HAVE_DRM_H
108 if (fd != -1) {
109 drmVersionPtr version = drmGetVersion(fd);
110 if (version) {
111 psp->drm_version.major = version->version_major;
112 psp->drm_version.minor = version->version_minor;
113 psp->drm_version.patch = version->version_patchlevel;
114 drmFreeVersion(version);
115 }
116 }
117 #endif
118
119 psp->loaderPrivate = data;
120
121 psp->extensions = emptyExtensionList;
122 psp->fd = fd;
123 psp->myNum = scrn;
124
125 *driver_configs = psp->driver->InitScreen(psp);
126 if (*driver_configs == NULL) {
127 free(psp);
128 return NULL;
129 }
130
131 int gl_version_override = _mesa_get_gl_version_override();
132 if (gl_version_override >= 31) {
133 psp->max_gl_core_version = MAX2(psp->max_gl_core_version,
134 gl_version_override);
135 } else {
136 psp->max_gl_compat_version = MAX2(psp->max_gl_compat_version,
137 gl_version_override);
138 }
139
140 psp->api_mask = (1 << __DRI_API_OPENGL);
141 if (psp->max_gl_core_version > 0)
142 psp->api_mask |= (1 << __DRI_API_OPENGL_CORE);
143 if (psp->max_gl_es1_version > 0)
144 psp->api_mask |= (1 << __DRI_API_GLES);
145 if (psp->max_gl_es2_version > 0)
146 psp->api_mask |= (1 << __DRI_API_GLES2);
147 if (psp->max_gl_es2_version >= 30)
148 psp->api_mask |= (1 << __DRI_API_GLES3);
149
150 driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions);
151 driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, "dri2");
152
153
154 return psp;
155 }
156
157 /** swrast driver createNewScreen entrypoint. */
158 static __DRIscreen *
159 driCreateNewScreen(int scrn, const __DRIextension **extensions,
160 const __DRIconfig ***driver_configs, void *data)
161 {
162 return dri2CreateNewScreen(scrn, -1, extensions, driver_configs, data);
163 }
164
165 /**
166 * Destroy the per-screen private information.
167 *
168 * \internal
169 * This function calls __DriverAPIRec::DestroyScreen on \p screenPrivate, calls
170 * drmClose(), and finally frees \p screenPrivate.
171 */
172 static void driDestroyScreen(__DRIscreen *psp)
173 {
174 if (psp) {
175 /* No interaction with the X-server is possible at this point. This
176 * routine is called after XCloseDisplay, so there is no protocol
177 * stream open to the X-server anymore.
178 */
179
180 _mesa_destroy_shader_compiler();
181
182 psp->driver->DestroyScreen(psp);
183
184 driDestroyOptionCache(&psp->optionCache);
185 driDestroyOptionInfo(&psp->optionInfo);
186
187 free(psp);
188 }
189 }
190
191 static const __DRIextension **driGetExtensions(__DRIscreen *psp)
192 {
193 return psp->extensions;
194 }
195
196 /*@}*/
197
198
199 static bool
200 validate_context_version(__DRIscreen *screen,
201 int mesa_api,
202 unsigned major_version,
203 unsigned minor_version,
204 unsigned *dri_ctx_error)
205 {
206 unsigned req_version = 10 * major_version + minor_version;
207 unsigned max_version = 0;
208
209 switch (mesa_api) {
210 case API_OPENGL_COMPAT:
211 max_version = screen->max_gl_compat_version;
212 break;
213 case API_OPENGL_CORE:
214 max_version = screen->max_gl_core_version;
215 break;
216 case API_OPENGLES:
217 max_version = screen->max_gl_es1_version;
218 break;
219 case API_OPENGLES2:
220 max_version = screen->max_gl_es2_version;
221 break;
222 default:
223 max_version = 0;
224 break;
225 }
226
227 if (max_version == 0) {
228 *dri_ctx_error = __DRI_CTX_ERROR_BAD_API;
229 return false;
230 } else if (req_version > max_version) {
231 *dri_ctx_error = __DRI_CTX_ERROR_BAD_VERSION;
232 return false;
233 }
234
235 return true;
236 }
237
238 /*****************************************************************/
239 /** \name Context handling functions */
240 /*****************************************************************/
241 /*@{*/
242
243 static __DRIcontext *
244 dri2CreateContextAttribs(__DRIscreen *screen, int api,
245 const __DRIconfig *config,
246 __DRIcontext *shared,
247 unsigned num_attribs,
248 const uint32_t *attribs,
249 unsigned *error,
250 void *data)
251 {
252 __DRIcontext *context;
253 const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
254 void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
255 gl_api mesa_api;
256 unsigned major_version = 1;
257 unsigned minor_version = 0;
258 uint32_t flags = 0;
259
260 assert((num_attribs == 0) || (attribs != NULL));
261
262 if (!(screen->api_mask & (1 << api))) {
263 *error = __DRI_CTX_ERROR_BAD_API;
264 return NULL;
265 }
266
267 switch (api) {
268 case __DRI_API_OPENGL:
269 mesa_api = API_OPENGL_COMPAT;
270 break;
271 case __DRI_API_GLES:
272 mesa_api = API_OPENGLES;
273 break;
274 case __DRI_API_GLES2:
275 case __DRI_API_GLES3:
276 mesa_api = API_OPENGLES2;
277 break;
278 case __DRI_API_OPENGL_CORE:
279 mesa_api = API_OPENGL_CORE;
280 break;
281 default:
282 *error = __DRI_CTX_ERROR_BAD_API;
283 return NULL;
284 }
285
286 for (unsigned i = 0; i < num_attribs; i++) {
287 switch (attribs[i * 2]) {
288 case __DRI_CTX_ATTRIB_MAJOR_VERSION:
289 major_version = attribs[i * 2 + 1];
290 break;
291 case __DRI_CTX_ATTRIB_MINOR_VERSION:
292 minor_version = attribs[i * 2 + 1];
293 break;
294 case __DRI_CTX_ATTRIB_FLAGS:
295 flags = attribs[i * 2 + 1];
296 break;
297 default:
298 /* We can't create a context that satisfies the requirements of an
299 * attribute that we don't understand. Return failure.
300 */
301 assert(!"Should not get here.");
302 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
303 return NULL;
304 }
305 }
306
307 /* Mesa does not support the GL_ARB_compatibilty extension or the
308 * compatibility profile. This means that we treat a API_OPENGL_COMPAT 3.1 as
309 * API_OPENGL_CORE and reject API_OPENGL_COMPAT 3.2+.
310 */
311 if (mesa_api == API_OPENGL_COMPAT && major_version == 3 && minor_version == 1)
312 mesa_api = API_OPENGL_CORE;
313
314 if (mesa_api == API_OPENGL_COMPAT
315 && ((major_version > 3)
316 || (major_version == 3 && minor_version >= 2))) {
317 *error = __DRI_CTX_ERROR_BAD_API;
318 return NULL;
319 }
320
321 /* The EGL_KHR_create_context spec says:
322 *
323 * "Flags are only defined for OpenGL context creation, and specifying
324 * a flags value other than zero for other types of contexts,
325 * including OpenGL ES contexts, will generate an error."
326 *
327 * The GLX_EXT_create_context_es2_profile specification doesn't say
328 * anything specific about this case. However, none of the known flags
329 * have any meaning in an ES context, so this seems safe.
330 */
331 if (mesa_api != API_OPENGL_COMPAT
332 && mesa_api != API_OPENGL_CORE
333 && flags != 0) {
334 *error = __DRI_CTX_ERROR_BAD_FLAG;
335 return NULL;
336 }
337
338 /* There are no forward-compatible contexts before OpenGL 3.0. The
339 * GLX_ARB_create_context spec says:
340 *
341 * "Forward-compatible contexts are defined only for OpenGL versions
342 * 3.0 and later."
343 *
344 * Forward-looking contexts are supported by silently converting the
345 * requested API to API_OPENGL_CORE.
346 *
347 * In Mesa, a debug context is the same as a regular context.
348 */
349 if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
350 mesa_api = API_OPENGL_CORE;
351 }
352
353 if ((flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE))
354 != 0) {
355 *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
356 return NULL;
357 }
358
359 if (!validate_context_version(screen, mesa_api,
360 major_version, minor_version, error))
361 return NULL;
362
363 context = calloc(1, sizeof *context);
364 if (!context) {
365 *error = __DRI_CTX_ERROR_NO_MEMORY;
366 return NULL;
367 }
368
369 context->loaderPrivate = data;
370
371 context->driScreenPriv = screen;
372 context->driDrawablePriv = NULL;
373 context->driReadablePriv = NULL;
374
375 if (!screen->driver->CreateContext(mesa_api, modes, context,
376 major_version, minor_version,
377 flags, error, shareCtx) ) {
378 free(context);
379 return NULL;
380 }
381
382 struct gl_context *ctx = context->driverPrivate;
383 if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
384 ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
385 if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
386 ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
387 ctx->Debug.DebugOutput = GL_TRUE;
388 }
389
390 *error = __DRI_CTX_ERROR_SUCCESS;
391 return context;
392 }
393
394 static __DRIcontext *
395 dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
396 const __DRIconfig *config,
397 __DRIcontext *shared, void *data)
398 {
399 unsigned error;
400
401 return dri2CreateContextAttribs(screen, api, config, shared, 0, NULL,
402 &error, data);
403 }
404
405 static __DRIcontext *
406 dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
407 __DRIcontext *shared, void *data)
408 {
409 return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL,
410 config, shared, data);
411 }
412
413 /**
414 * Destroy the per-context private information.
415 *
416 * \internal
417 * This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls
418 * drmDestroyContext(), and finally frees \p contextPrivate.
419 */
420 static void
421 driDestroyContext(__DRIcontext *pcp)
422 {
423 if (pcp) {
424 pcp->driScreenPriv->driver->DestroyContext(pcp);
425 free(pcp);
426 }
427 }
428
429 static int
430 driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask)
431 {
432 (void) dest;
433 (void) src;
434 (void) mask;
435 return GL_FALSE;
436 }
437
438 /*@}*/
439
440
441 /*****************************************************************/
442 /** \name Context (un)binding functions */
443 /*****************************************************************/
444 /*@{*/
445
446 static void dri_get_drawable(__DRIdrawable *pdp);
447 static void dri_put_drawable(__DRIdrawable *pdp);
448
449 /**
450 * This function takes both a read buffer and a draw buffer. This is needed
451 * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent
452 * function.
453 */
454 static int driBindContext(__DRIcontext *pcp,
455 __DRIdrawable *pdp,
456 __DRIdrawable *prp)
457 {
458 /*
459 ** Assume error checking is done properly in glXMakeCurrent before
460 ** calling driUnbindContext.
461 */
462
463 if (!pcp)
464 return GL_FALSE;
465
466 /* Bind the drawable to the context */
467 pcp->driDrawablePriv = pdp;
468 pcp->driReadablePriv = prp;
469 if (pdp) {
470 pdp->driContextPriv = pcp;
471 dri_get_drawable(pdp);
472 }
473 if (prp && pdp != prp) {
474 dri_get_drawable(prp);
475 }
476
477 return pcp->driScreenPriv->driver->MakeCurrent(pcp, pdp, prp);
478 }
479
480 /**
481 * Unbind context.
482 *
483 * \param scrn the screen.
484 * \param gc context.
485 *
486 * \return \c GL_TRUE on success, or \c GL_FALSE on failure.
487 *
488 * \internal
489 * This function calls __DriverAPIRec::UnbindContext, and then decrements
490 * __DRIdrawableRec::refcount which must be non-zero for a successful
491 * return.
492 *
493 * While casting the opaque private pointers associated with the parameters
494 * into their respective real types it also assures they are not \c NULL.
495 */
496 static int driUnbindContext(__DRIcontext *pcp)
497 {
498 __DRIdrawable *pdp;
499 __DRIdrawable *prp;
500
501 /*
502 ** Assume error checking is done properly in glXMakeCurrent before
503 ** calling driUnbindContext.
504 */
505
506 if (pcp == NULL)
507 return GL_FALSE;
508
509 pdp = pcp->driDrawablePriv;
510 prp = pcp->driReadablePriv;
511
512 /* already unbound */
513 if (!pdp && !prp)
514 return GL_TRUE;
515
516 pcp->driScreenPriv->driver->UnbindContext(pcp);
517
518 assert(pdp);
519 if (pdp->refcount == 0) {
520 /* ERROR!!! */
521 return GL_FALSE;
522 }
523
524 dri_put_drawable(pdp);
525
526 if (prp != pdp) {
527 if (prp->refcount == 0) {
528 /* ERROR!!! */
529 return GL_FALSE;
530 }
531
532 dri_put_drawable(prp);
533 }
534
535 pcp->driDrawablePriv = NULL;
536 pcp->driReadablePriv = NULL;
537
538 return GL_TRUE;
539 }
540
541 /*@}*/
542
543
544 static void dri_get_drawable(__DRIdrawable *pdp)
545 {
546 pdp->refcount++;
547 }
548
549 static void dri_put_drawable(__DRIdrawable *pdp)
550 {
551 if (pdp) {
552 pdp->refcount--;
553 if (pdp->refcount)
554 return;
555
556 pdp->driScreenPriv->driver->DestroyBuffer(pdp);
557 free(pdp);
558 }
559 }
560
561 static __DRIdrawable *
562 dri2CreateNewDrawable(__DRIscreen *screen,
563 const __DRIconfig *config,
564 void *data)
565 {
566 __DRIdrawable *pdraw;
567
568 pdraw = malloc(sizeof *pdraw);
569 if (!pdraw)
570 return NULL;
571
572 pdraw->loaderPrivate = data;
573
574 pdraw->driScreenPriv = screen;
575 pdraw->driContextPriv = NULL;
576 pdraw->refcount = 0;
577 pdraw->lastStamp = 0;
578 pdraw->w = 0;
579 pdraw->h = 0;
580
581 dri_get_drawable(pdraw);
582
583 if (!screen->driver->CreateBuffer(screen, pdraw, &config->modes,
584 GL_FALSE)) {
585 free(pdraw);
586 return NULL;
587 }
588
589 pdraw->dri2.stamp = pdraw->lastStamp + 1;
590
591 return pdraw;
592 }
593
594 static void
595 driDestroyDrawable(__DRIdrawable *pdp)
596 {
597 dri_put_drawable(pdp);
598 }
599
600 static __DRIbuffer *
601 dri2AllocateBuffer(__DRIscreen *screen,
602 unsigned int attachment, unsigned int format,
603 int width, int height)
604 {
605 return screen->driver->AllocateBuffer(screen, attachment, format,
606 width, height);
607 }
608
609 static void
610 dri2ReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
611 {
612 screen->driver->ReleaseBuffer(screen, buffer);
613 }
614
615
616 static int
617 dri2ConfigQueryb(__DRIscreen *screen, const char *var, GLboolean *val)
618 {
619 if (!driCheckOption(&screen->optionCache, var, DRI_BOOL))
620 return -1;
621
622 *val = driQueryOptionb(&screen->optionCache, var);
623
624 return 0;
625 }
626
627 static int
628 dri2ConfigQueryi(__DRIscreen *screen, const char *var, GLint *val)
629 {
630 if (!driCheckOption(&screen->optionCache, var, DRI_INT) &&
631 !driCheckOption(&screen->optionCache, var, DRI_ENUM))
632 return -1;
633
634 *val = driQueryOptioni(&screen->optionCache, var);
635
636 return 0;
637 }
638
639 static int
640 dri2ConfigQueryf(__DRIscreen *screen, const char *var, GLfloat *val)
641 {
642 if (!driCheckOption(&screen->optionCache, var, DRI_FLOAT))
643 return -1;
644
645 *val = driQueryOptionf(&screen->optionCache, var);
646
647 return 0;
648 }
649
650 static unsigned int
651 dri2GetAPIMask(__DRIscreen *screen)
652 {
653 return screen->api_mask;
654 }
655
656 /**
657 * swrast swapbuffers entrypoint.
658 *
659 * DRI2 implements this inside the loader with only flushes handled by the
660 * driver.
661 */
662 static void
663 driSwapBuffers(__DRIdrawable *pdp)
664 {
665 assert(pdp->driScreenPriv->swrast_loader);
666
667 pdp->driScreenPriv->driver->SwapBuffers(pdp);
668 }
669
670 /** Core interface */
671 const __DRIcoreExtension driCoreExtension = {
672 .base = { __DRI_CORE, __DRI_CORE_VERSION },
673
674 .createNewScreen = NULL,
675 .destroyScreen = driDestroyScreen,
676 .getExtensions = driGetExtensions,
677 .getConfigAttrib = driGetConfigAttrib,
678 .indexConfigAttrib = driIndexConfigAttrib,
679 .createNewDrawable = NULL,
680 .destroyDrawable = driDestroyDrawable,
681 .swapBuffers = driSwapBuffers, /* swrast */
682 .createNewContext = dri2CreateNewContext, /* swrast */
683 .copyContext = driCopyContext,
684 .destroyContext = driDestroyContext,
685 .bindContext = driBindContext,
686 .unbindContext = driUnbindContext
687 };
688
689 /** DRI2 interface */
690 const __DRIdri2Extension driDRI2Extension = {
691 .base = { __DRI_DRI2, 3 },
692
693 .createNewScreen = dri2CreateNewScreen,
694 .createNewDrawable = dri2CreateNewDrawable,
695 .createNewContext = dri2CreateNewContext,
696 .getAPIMask = dri2GetAPIMask,
697 .createNewContextForAPI = dri2CreateNewContextForAPI,
698 .allocateBuffer = dri2AllocateBuffer,
699 .releaseBuffer = dri2ReleaseBuffer,
700 .createContextAttribs = dri2CreateContextAttribs
701 };
702
703 const __DRIswrastExtension driSWRastExtension = {
704 { __DRI_SWRAST, __DRI_SWRAST_VERSION },
705 driCreateNewScreen,
706 dri2CreateNewDrawable,
707 dri2CreateNewContextForAPI,
708 dri2CreateContextAttribs
709 };
710
711 const __DRI2configQueryExtension dri2ConfigQueryExtension = {
712 .base = { __DRI2_CONFIG_QUERY, __DRI2_CONFIG_QUERY_VERSION },
713
714 .configQueryb = dri2ConfigQueryb,
715 .configQueryi = dri2ConfigQueryi,
716 .configQueryf = dri2ConfigQueryf,
717 };
718
719 void
720 dri2InvalidateDrawable(__DRIdrawable *drawable)
721 {
722 drawable->dri2.stamp++;
723 }
724
725 /**
726 * Check that the gl_framebuffer associated with dPriv is the right size.
727 * Resize the gl_framebuffer if needed.
728 * It's expected that the dPriv->driverPrivate member points to a
729 * gl_framebuffer object.
730 */
731 void
732 driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv)
733 {
734 struct gl_framebuffer *fb = (struct gl_framebuffer *) dPriv->driverPrivate;
735 if (fb && (dPriv->w != fb->Width || dPriv->h != fb->Height)) {
736 ctx->Driver.ResizeBuffers(ctx, fb, dPriv->w, dPriv->h);
737 /* if the driver needs the hw lock for ResizeBuffers, the drawable
738 might have changed again by now */
739 assert(fb->Width == dPriv->w);
740 assert(fb->Height == dPriv->h);
741 }
742 }