diff options
author | George Staplin <gstaplin@apple.com> | 2009-01-12 14:14:44 -0700 |
---|---|---|
committer | George Staplin <gstaplin@apple.com> | 2009-01-12 14:14:44 -0700 |
commit | d514152195452ae11ec7769c76489651620ad380 (patch) | |
tree | 1da2931414c4e3c6203fca8f351ddf7ab8028758 | |
parent | e929a7990713eb5c1f1b60ac3c33892984500f7d (diff) |
XQuartz: GL: Make indirect.c build and work in the 1.6 branch.
Reorder some header files and provide some types earlier on.
Remove the static __GLXextensionInfo __glDDXExtensionInfo; that isn't
used in 1.4 or 1.5, and seems to have been removed from 1.6. Remove
the data structures associated with that too.
Remove __glXAquaDrawableResize. The GLX structure doesn't use
it anymore, and the Apple version did nothing useful before.
__glXAquaDrawableSwapBuffers(): base no longer contains a drawGlxc
member. Now provide the the Apple/Aqua context in the __GLXAquaDrawable
struct. Add the context member to the __GLXAquaDrawable struct.
Remove the fallback configs. They aren't used in 1.4 or 1.5 either.
Remove init_visuals(). It's not used in 1.4 or 1.5 either.
In the drawable constructor initialize the state properly, including
the new context member.
Remove glAquaResetExtension() -- it's not used anymore.
This has been tested remotely and proven to work with glxgears,
fire, various texture programs I wrote, and various Mesa demos.
-rw-r--r-- | hw/xquartz/GL/indirect.c | 672 |
1 files changed, 84 insertions, 588 deletions
diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c index afaa957d9..9ddc0e7f1 100644 --- a/hw/xquartz/GL/indirect.c +++ b/hw/xquartz/GL/indirect.c | |||
@@ -57,7 +57,6 @@ | |||
57 | #include <OpenGL/OpenGL.h> | 57 | #include <OpenGL/OpenGL.h> |
58 | #include <OpenGL/CGLContext.h> | 58 | #include <OpenGL/CGLContext.h> |
59 | 59 | ||
60 | // X11 and X11's glx | ||
61 | #include <GL/gl.h> | 60 | #include <GL/gl.h> |
62 | #include <GL/glxproto.h> | 61 | #include <GL/glxproto.h> |
63 | #include <windowstr.h> | 62 | #include <windowstr.h> |
@@ -78,16 +77,13 @@ | |||
78 | 77 | ||
79 | #include "capabilities.h" | 78 | #include "capabilities.h" |
80 | 79 | ||
81 | #include <dispatch.h> | ||
82 | #define GLAPIENTRYP * | ||
83 | typedef unsigned long long GLuint64EXT; | 80 | typedef unsigned long long GLuint64EXT; |
84 | typedef long long GLint64EXT; | 81 | typedef long long GLint64EXT; |
82 | #include <dispatch.h> | ||
85 | #include <Xplugin.h> | 83 | #include <Xplugin.h> |
86 | #include <glapi.h> | 84 | #include <glapi.h> |
87 | #include <glapitable.h> | 85 | #include <glapitable.h> |
88 | 86 | ||
89 | // ggs: needed to call back to glx with visual configs | ||
90 | extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs); | ||
91 | __GLXprovider * GlxGetDRISWrastProvider (void); | 87 | __GLXprovider * GlxGetDRISWrastProvider (void); |
92 | 88 | ||
93 | // Write debugging output, or not | 89 | // Write debugging output, or not |
@@ -105,15 +101,6 @@ void warn_func(void * p1, char *format, ...); | |||
105 | static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen); | 101 | static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen); |
106 | static __GLXdrawable * __glXAquaScreenCreateDrawable(__GLXscreen *screen, DrawablePtr pDraw, int type, XID drawId, __GLXconfig *conf); | 102 | static __GLXdrawable * __glXAquaScreenCreateDrawable(__GLXscreen *screen, DrawablePtr pDraw, int type, XID drawId, __GLXconfig *conf); |
107 | 103 | ||
108 | static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp, | ||
109 | int *nvisualp, int *ndepthp, | ||
110 | int *rootDepthp, VisualID *defaultVisp, | ||
111 | unsigned long sizes, int bitsPerRGB); | ||
112 | |||
113 | static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, | ||
114 | void **privates); | ||
115 | |||
116 | static void glAquaResetExtension(void); | ||
117 | static void __glXAquaContextDestroy(__GLXcontext *baseContext); | 104 | static void __glXAquaContextDestroy(__GLXcontext *baseContext); |
118 | static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext); | 105 | static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext); |
119 | static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext); | 106 | static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext); |
@@ -123,16 +110,16 @@ static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, un | |||
123 | static CGLPixelFormatObj makeFormat(__GLXconfig *conf); | 110 | static CGLPixelFormatObj makeFormat(__GLXconfig *conf); |
124 | 111 | ||
125 | __GLXprovider __glXDRISWRastProvider = { | 112 | __GLXprovider __glXDRISWRastProvider = { |
126 | __glXAquaScreenProbe, | 113 | __glXAquaScreenProbe, |
127 | "Core OpenGL", | 114 | "Core OpenGL", |
128 | NULL | 115 | NULL |
129 | }; | 116 | }; |
130 | 117 | ||
131 | __GLXprovider * | 118 | __GLXprovider * |
132 | GlxGetDRISWRastProvider (void) | 119 | GlxGetDRISWRastProvider (void) |
133 | { | 120 | { |
134 | GLAQUA_DEBUG_MSG("GlxGetDRISWRastProvider\n"); | 121 | GLAQUA_DEBUG_MSG("GlxGetDRISWRastProvider\n"); |
135 | return &__glXDRISWRastProvider; | 122 | return &__glXDRISWRastProvider; |
136 | } | 123 | } |
137 | 124 | ||
138 | typedef struct __GLXAquaScreen __GLXAquaScreen; | 125 | typedef struct __GLXAquaScreen __GLXAquaScreen; |
@@ -143,11 +130,8 @@ struct __GLXAquaScreen { | |||
143 | __GLXscreen base; | 130 | __GLXscreen base; |
144 | int index; | 131 | int index; |
145 | int num_vis; | 132 | int num_vis; |
146 | //__GLcontextModes *modes; | ||
147 | }; | 133 | }; |
148 | 134 | ||
149 | static __GLXAquaScreen glAquaScreens[MAXSCREENS]; | ||
150 | |||
151 | struct __GLXAquaContext { | 135 | struct __GLXAquaContext { |
152 | __GLXcontext base; | 136 | __GLXcontext base; |
153 | CGLContextObj ctx; | 137 | CGLContextObj ctx; |
@@ -160,71 +144,60 @@ struct __GLXAquaDrawable { | |||
160 | __GLXdrawable base; | 144 | __GLXdrawable base; |
161 | DrawablePtr pDraw; | 145 | DrawablePtr pDraw; |
162 | xp_surface_id sid; | 146 | xp_surface_id sid; |
147 | __GLXAquaContext *context; | ||
163 | }; | 148 | }; |
164 | 149 | ||
150 | |||
165 | static __GLXcontext * | 151 | static __GLXcontext * |
166 | __glXAquaScreenCreateContext(__GLXscreen *screen, | 152 | __glXAquaScreenCreateContext(__GLXscreen *screen, |
167 | __GLXconfig *conf, | 153 | __GLXconfig *conf, |
168 | __GLXcontext *baseShareContext) | 154 | __GLXcontext *baseShareContext) |
169 | { | 155 | { |
170 | __GLXAquaContext *context; | 156 | __GLXAquaContext *context; |
171 | __GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext; | 157 | __GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext; |
172 | CGLError gl_err; | 158 | CGLError gl_err; |
173 | 159 | ||
174 | GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n"); | 160 | GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n"); |
175 | 161 | ||
176 | context = xalloc (sizeof (__GLXAquaContext)); | 162 | context = xalloc (sizeof (__GLXAquaContext)); |
177 | 163 | ||
178 | if (context == NULL) | 164 | if (context == NULL) |
179 | return NULL; | 165 | return NULL; |
180 | |||
181 | memset(context, 0, sizeof *context); | ||
182 | |||
183 | context->base.pGlxScreen = screen; | ||
184 | |||
185 | context->base.destroy = __glXAquaContextDestroy; | ||
186 | context->base.makeCurrent = __glXAquaContextMakeCurrent; | ||
187 | context->base.loseCurrent = __glXAquaContextLoseCurrent; | ||
188 | context->base.copy = __glXAquaContextCopy; | ||
189 | context->base.forceCurrent = __glXAquaContextForceCurrent; | ||
190 | /*FIXME verify that the context->base is fully initialized. */ | ||
191 | |||
192 | context->pixelFormat = makeFormat(conf); | ||
193 | 166 | ||
194 | if (!context->pixelFormat) { | 167 | memset(context, 0, sizeof *context); |
168 | |||
169 | context->base.pGlxScreen = screen; | ||
170 | |||
171 | context->base.destroy = __glXAquaContextDestroy; | ||
172 | context->base.makeCurrent = __glXAquaContextMakeCurrent; | ||
173 | context->base.loseCurrent = __glXAquaContextLoseCurrent; | ||
174 | context->base.copy = __glXAquaContextCopy; | ||
175 | context->base.forceCurrent = __glXAquaContextForceCurrent; | ||
176 | /*FIXME verify that the context->base is fully initialized. */ | ||
177 | |||
178 | context->pixelFormat = makeFormat(conf); | ||
179 | |||
180 | if (!context->pixelFormat) { | ||
195 | xfree(context); | 181 | xfree(context); |
196 | return NULL; | 182 | return NULL; |
197 | } | 183 | } |
198 | |||
199 | context->ctx = NULL; | ||
200 | gl_err = CGLCreateContext(context->pixelFormat, | ||
201 | shareContext ? shareContext->ctx : NULL, | ||
202 | &context->ctx); | ||
203 | |||
204 | if (gl_err != 0) { | ||
205 | ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err)); | ||
206 | CGLDestroyPixelFormat(context->pixelFormat); | ||
207 | xfree(context); | ||
208 | return NULL; | ||
209 | } | ||
210 | 184 | ||
211 | setup_dispatch_table(); | 185 | context->ctx = NULL; |
212 | GLAQUA_DEBUG_MSG("glAquaCreateContext done\n"); | 186 | gl_err = CGLCreateContext(context->pixelFormat, |
187 | shareContext ? shareContext->ctx : NULL, | ||
188 | &context->ctx); | ||
213 | 189 | ||
214 | return &context->base; | 190 | if (gl_err != 0) { |
215 | } | 191 | ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err)); |
216 | 192 | CGLDestroyPixelFormat(context->pixelFormat); | |
217 | /* Nothing seems to use these anymore... */ | 193 | xfree(context); |
218 | static __GLXextensionInfo __glDDXExtensionInfo = { | 194 | return NULL; |
219 | GL_CORE_APPLE, | 195 | } |
220 | glAquaResetExtension, | 196 | |
221 | glAquaInitVisuals, | 197 | setup_dispatch_table(); |
222 | glAquaSetVisualConfigs | 198 | GLAQUA_DEBUG_MSG("glAquaCreateContext done\n"); |
223 | }; | 199 | |
224 | 200 | return &context->base; | |
225 | void *__glXglDDXExtensionInfo(void) { | ||
226 | GLAQUA_DEBUG_MSG("glXAglDDXExtensionInfo\n"); | ||
227 | return &__glDDXExtensionInfo; | ||
228 | } | 201 | } |
229 | 202 | ||
230 | /* maps from surface id -> list of __GLcontext */ | 203 | /* maps from surface id -> list of __GLcontext */ |
@@ -234,7 +207,7 @@ static void __glXAquaContextDestroy(__GLXcontext *baseContext) { | |||
234 | x_list *lst; | 207 | x_list *lst; |
235 | 208 | ||
236 | __GLXAquaContext *context = (__GLXAquaContext *) baseContext; | 209 | __GLXAquaContext *context = (__GLXAquaContext *) baseContext; |
237 | 210 | ||
238 | GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx 0x%x)\n", | 211 | GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx 0x%x)\n", |
239 | (unsigned int) baseContext); | 212 | (unsigned int) baseContext); |
240 | if (context != NULL) { | 213 | if (context != NULL) { |
@@ -275,33 +248,33 @@ static void surface_notify(void *_arg, void *data) { | |||
275 | __GLXAquaDrawable *draw = (__GLXAquaDrawable *)data; | 248 | __GLXAquaDrawable *draw = (__GLXAquaDrawable *)data; |
276 | __GLXAquaContext *context; | 249 | __GLXAquaContext *context; |
277 | x_list *lst; | 250 | x_list *lst; |
278 | if(_arg == NULL || data == NULL) { | 251 | if(_arg == NULL || data == NULL) { |
279 | ErrorF("surface_notify called with bad params"); | 252 | ErrorF("surface_notify called with bad params"); |
280 | return; | 253 | return; |
281 | } | 254 | } |
282 | 255 | ||
283 | GLAQUA_DEBUG_MSG("surface_notify(%p, %p)\n", _arg, data); | 256 | GLAQUA_DEBUG_MSG("surface_notify(%p, %p)\n", _arg, data); |
284 | switch (arg->kind) { | 257 | switch (arg->kind) { |
285 | case AppleDRISurfaceNotifyDestroyed: | 258 | case AppleDRISurfaceNotifyDestroyed: |
286 | if (surface_hash != NULL) | 259 | if (surface_hash != NULL) |
287 | x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id)); | 260 | x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id)); |
288 | draw->base.pDraw = NULL; | 261 | draw->base.pDraw = NULL; |
289 | draw->sid = 0; | 262 | draw->sid = 0; |
290 | break; | 263 | break; |
291 | 264 | ||
292 | case AppleDRISurfaceNotifyChanged: | 265 | case AppleDRISurfaceNotifyChanged: |
293 | if (surface_hash != NULL) { | 266 | if (surface_hash != NULL) { |
294 | lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL); | 267 | lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL); |
295 | for (; lst != NULL; lst = lst->next) | 268 | for (; lst != NULL; lst = lst->next) |
296 | { | 269 | { |
297 | context = lst->data; | 270 | context = lst->data; |
298 | xp_update_gl_context(context->ctx); | 271 | xp_update_gl_context(context->ctx); |
299 | } | 272 | } |
300 | } | 273 | } |
301 | break; | 274 | break; |
302 | default: | 275 | default: |
303 | ErrorF("surface_notify: unknown kind %d\n", arg->kind); | 276 | ErrorF("surface_notify: unknown kind %d\n", arg->kind); |
304 | break; | 277 | break; |
305 | } | 278 | } |
306 | } | 279 | } |
307 | 280 | ||
@@ -316,7 +289,7 @@ static BOOL attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) { | |||
316 | pDraw = draw->base.pDraw; | 289 | pDraw = draw->base.pDraw; |
317 | 290 | ||
318 | if(NULL == pDraw) { | 291 | if(NULL == pDraw) { |
319 | ErrorF("%s:attach() pDraw is NULL!\n", __FILE__); | 292 | ErrorF("%s:%s() pDraw is NULL!\n", __FILE__, __func__); |
320 | return TRUE; | 293 | return TRUE; |
321 | } | 294 | } |
322 | 295 | ||
@@ -355,10 +328,14 @@ static BOOL attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) { | |||
355 | x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst); | 328 | x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst); |
356 | } | 329 | } |
357 | 330 | ||
331 | |||
332 | |||
358 | GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id, | 333 | GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id, |
359 | (unsigned int) draw->sid); | 334 | (unsigned int) draw->sid); |
360 | } | 335 | } |
361 | 336 | ||
337 | draw->context = context; | ||
338 | |||
362 | return FALSE; | 339 | return FALSE; |
363 | } | 340 | } |
364 | 341 | ||
@@ -434,27 +411,31 @@ static int __glXAquaContextForceCurrent(__GLXcontext *baseContext) | |||
434 | 411 | ||
435 | /* Drawing surface notification callbacks */ | 412 | /* Drawing surface notification callbacks */ |
436 | 413 | ||
437 | static GLboolean __glXAquaDrawableResize(__GLXdrawable *base) { | ||
438 | GLAQUA_DEBUG_MSG("unimplemented glAquaDrawableResize\n"); | ||
439 | return GL_TRUE; | ||
440 | } | ||
441 | |||
442 | static GLboolean __glXAquaDrawableSwapBuffers(__GLXdrawable *base) { | 414 | static GLboolean __glXAquaDrawableSwapBuffers(__GLXdrawable *base) { |
443 | CGLError gl_err; | 415 | CGLError err; |
444 | __GLXAquaContext * drawableCtx; | 416 | __GLXAquaDrawable *drawable; |
417 | |||
445 | // GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base); | 418 | // GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base); |
446 | 419 | ||
447 | if(!base) { | 420 | if(!base) { |
448 | ErrorF("glXAquaDrawbleSwapBuffers passed NULL\n"); | 421 | ErrorF("%s passed NULL\n", __func__); |
449 | return GL_FALSE; | 422 | return GL_FALSE; |
450 | } | 423 | } |
451 | 424 | ||
452 | drawableCtx = (__GLXAquaContext *)base->drawGlxc; | 425 | drawable = (__GLXAquaDrawable *)base; |
453 | 426 | ||
454 | if (drawableCtx != NULL && drawableCtx->ctx != NULL) { | 427 | if(NULL == drawable->context) { |
455 | gl_err = CGLFlushDrawable(drawableCtx->ctx); | 428 | ErrorF("%s called with a NULL->context for drawable %p!\n", |
456 | if (gl_err != 0) | 429 | __func__, (void *)drawable); |
457 | ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err)); | 430 | return GL_FALSE; |
431 | } | ||
432 | |||
433 | err = CGLFlushDrawable(drawable->context->ctx); | ||
434 | |||
435 | if(kCGLNoError != err) { | ||
436 | ErrorF("CGLFlushDrawable error: %s in %s\n", CGLErrorString(err), | ||
437 | __func__); | ||
438 | return GL_FALSE; | ||
458 | } | 439 | } |
459 | 440 | ||
460 | return GL_TRUE; | 441 | return GL_TRUE; |
@@ -518,482 +499,6 @@ static CGLPixelFormatObj makeFormat(__GLXconfig *conf) { | |||
518 | return fobj; | 499 | return fobj; |
519 | } | 500 | } |
520 | 501 | ||
521 | // Originally copied from Mesa | ||
522 | |||
523 | static int numConfigs = 0; | ||
524 | static __GLXvisualConfig *visualConfigs = NULL; | ||
525 | static void **visualPrivates = NULL; | ||
526 | |||
527 | /* | ||
528 | * In the case the driver defines no GLX visuals we'll use these. | ||
529 | * Note that for TrueColor and DirectColor visuals, bufferSize is the | ||
530 | * sum of redSize, greenSize, blueSize and alphaSize, which may be larger | ||
531 | * than the nplanes/rootDepth of the server's X11 visuals | ||
532 | */ | ||
533 | #define NUM_FALLBACK_CONFIGS 5 | ||
534 | static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { | ||
535 | /* [0] = RGB, double buffered, Z */ | ||
536 | { | ||
537 | -1, /* vid */ | ||
538 | -1, /* class */ | ||
539 | True, /* rgba */ | ||
540 | -1, -1, -1, 0, /* rgba sizes */ | ||
541 | -1, -1, -1, 0, /* rgba masks */ | ||
542 | 0, 0, 0, 0, /* rgba accum sizes */ | ||
543 | True, /* doubleBuffer */ | ||
544 | False, /* stereo */ | ||
545 | -1, /* bufferSize */ | ||
546 | 16, /* depthSize */ | ||
547 | 0, /* stencilSize */ | ||
548 | 0, /* auxBuffers */ | ||
549 | 0, /* level */ | ||
550 | GLX_NONE, /* visualRating */ | ||
551 | GLX_NONE, /* transparentPixel */ | ||
552 | 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ | ||
553 | 0 /* transparentIndex */ | ||
554 | }, | ||
555 | /* [1] = RGB, double buffered, Z, stencil, accum */ | ||
556 | { | ||
557 | -1, /* vid */ | ||
558 | -1, /* class */ | ||
559 | True, /* rgba */ | ||
560 | -1, -1, -1, 0, /* rgba sizes */ | ||
561 | -1, -1, -1, 0, /* rgba masks */ | ||
562 | 16, 16, 16, 0, /* rgba accum sizes */ | ||
563 | True, /* doubleBuffer */ | ||
564 | False, /* stereo */ | ||
565 | -1, /* bufferSize */ | ||
566 | 16, /* depthSize */ | ||
567 | 8, /* stencilSize */ | ||
568 | 0, /* auxBuffers */ | ||
569 | 0, /* level */ | ||
570 | GLX_NONE, /* visualRating */ | ||
571 | GLX_NONE, /* transparentPixel */ | ||
572 | 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ | ||
573 | 0 /* transparentIndex */ | ||
574 | }, | ||
575 | /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */ | ||
576 | { | ||
577 | -1, /* vid */ | ||
578 | -1, /* class */ | ||
579 | True, /* rgba */ | ||
580 | -1, -1, -1, 8, /* rgba sizes */ | ||
581 | -1, -1, -1, -1, /* rgba masks */ | ||
582 | 16, 16, 16, 16, /* rgba accum sizes */ | ||
583 | True, /* doubleBuffer */ | ||
584 | False, /* stereo */ | ||
585 | -1, /* bufferSize */ | ||
586 | 16, /* depthSize */ | ||
587 | 8, /* stencilSize */ | ||
588 | 0, /* auxBuffers */ | ||
589 | 0, /* level */ | ||
590 | GLX_NONE, /* visualRating */ | ||
591 | GLX_NONE, /* transparentPixel */ | ||
592 | 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ | ||
593 | 0 /* transparentIndex */ | ||
594 | }, | ||
595 | /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */ | ||
596 | { | ||
597 | -1, /* vid */ | ||
598 | -1, /* class */ | ||
599 | True, /* rgba */ | ||
600 | -1, -1, -1, 8, /* rgba sizes */ | ||
601 | -1, -1, -1, -1, /* rgba masks */ | ||
602 | 16, 16, 16, 16, /* rgba accum sizes */ | ||
603 | False, /* doubleBuffer */ | ||
604 | False, /* stereo */ | ||
605 | -1, /* bufferSize */ | ||
606 | 16, /* depthSize */ | ||
607 | 8, /* stencilSize */ | ||
608 | 0, /* auxBuffers */ | ||
609 | 0, /* level */ | ||
610 | GLX_NONE, /* visualRating */ | ||
611 | GLX_NONE, /* transparentPixel */ | ||
612 | 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ | ||
613 | 0 /* transparentIndex */ | ||
614 | }, | ||
615 | /* [4] = CI, double buffered, Z */ | ||
616 | { | ||
617 | -1, /* vid */ | ||
618 | -1, /* class */ | ||
619 | False, /* rgba? (false = color index) */ | ||
620 | -1, -1, -1, 0, /* rgba sizes */ | ||
621 | -1, -1, -1, 0, /* rgba masks */ | ||
622 | 0, 0, 0, 0, /* rgba accum sizes */ | ||
623 | True, /* doubleBuffer */ | ||
624 | False, /* stereo */ | ||
625 | -1, /* bufferSize */ | ||
626 | 16, /* depthSize */ | ||
627 | 0, /* stencilSize */ | ||
628 | 0, /* auxBuffers */ | ||
629 | 0, /* level */ | ||
630 | GLX_NONE, /* visualRating */ | ||
631 | GLX_NONE, /* transparentPixel */ | ||
632 | 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ | ||
633 | 0 /* transparentIndex */ | ||
634 | }, | ||
635 | }; | ||
636 | |||
637 | static __GLXvisualConfig NullConfig = { | ||
638 | -1, /* vid */ | ||
639 | -1, /* class */ | ||
640 | False, /* rgba */ | ||
641 | -1, -1, -1, 0, /* rgba sizes */ | ||
642 | -1, -1, -1, 0, /* rgba masks */ | ||
643 | 0, 0, 0, 0, /* rgba accum sizes */ | ||
644 | False, /* doubleBuffer */ | ||
645 | False, /* stereo */ | ||
646 | -1, /* bufferSize */ | ||
647 | 16, /* depthSize */ | ||
648 | 0, /* stencilSize */ | ||
649 | 0, /* auxBuffers */ | ||
650 | 0, /* level */ | ||
651 | GLX_NONE_EXT, /* visualRating */ | ||
652 | 0, /* transparentPixel */ | ||
653 | 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ | ||
654 | 0 /* transparentIndex */ | ||
655 | }; | ||
656 | |||
657 | |||
658 | static inline int count_bits(uint32_t x) | ||
659 | { | ||
660 | x = x - ((x >> 1) & 0x55555555); | ||
661 | x = (x & 0x33333333) + ((x >> 2) & 0x33333333); | ||
662 | x = (x + (x >> 4)) & 0x0f0f0f0f; | ||
663 | x = x + (x >> 8); | ||
664 | x = x + (x >> 16); | ||
665 | return x & 63; | ||
666 | } | ||
667 | |||
668 | |||
669 | static Bool init_visuals(int *nvisualp, VisualPtr *visualp, | ||
670 | VisualID *defaultVisp, | ||
671 | int ndepth, DepthPtr pdepth, | ||
672 | int rootDepth) | ||
673 | { | ||
674 | #if 0 | ||
675 | int numRGBconfigs; | ||
676 | int numCIconfigs; | ||
677 | int numVisuals = *nvisualp; | ||
678 | int numNewVisuals; | ||
679 | int numNewConfigs; | ||
680 | VisualPtr pVisual = *visualp; | ||
681 | VisualPtr pVisualNew = NULL; | ||
682 | VisualID *orig_vid = NULL; | ||
683 | __GLcontextModes *modes; | ||
684 | __GLXvisualConfig *pNewVisualConfigs = NULL; | ||
685 | void **glXVisualPriv; | ||
686 | void **pNewVisualPriv; | ||
687 | int found_default; | ||
688 | int i, j, k; | ||
689 | |||
690 | GLAQUA_DEBUG_MSG("init_visuals\n"); | ||
691 | |||
692 | if (numConfigs > 0) | ||
693 | numNewConfigs = numConfigs; | ||
694 | else | ||
695 | numNewConfigs = NUM_FALLBACK_CONFIGS; | ||
696 | |||
697 | /* Alloc space for the list of new GLX visuals */ | ||
698 | pNewVisualConfigs = (__GLXvisualConfig *) | ||
699 | malloc(numNewConfigs * sizeof(__GLXvisualConfig)); | ||
700 | if (!pNewVisualConfigs) { | ||
701 | return FALSE; | ||
702 | } | ||
703 | |||
704 | /* Alloc space for the list of new GLX visual privates */ | ||
705 | pNewVisualPriv = (void **) malloc(numNewConfigs * sizeof(void *)); | ||
706 | if (!pNewVisualPriv) { | ||
707 | free(pNewVisualConfigs); | ||
708 | return FALSE; | ||
709 | } | ||
710 | |||
711 | /* | ||
712 | ** If SetVisualConfigs was not called, then use default GLX | ||
713 | ** visual configs. | ||
714 | */ | ||
715 | if (numConfigs == 0) { | ||
716 | memcpy(pNewVisualConfigs, FallbackConfigs, | ||
717 | NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig)); | ||
718 | memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *)); | ||
719 | } | ||
720 | else { | ||
721 | /* copy driver's visual config info */ | ||
722 | for (i = 0; i < numConfigs; i++) { | ||
723 | pNewVisualConfigs[i] = visualConfigs[i]; | ||
724 | pNewVisualPriv[i] = visualPrivates[i]; | ||
725 | } | ||
726 | } | ||
727 | |||
728 | /* Count the number of RGB and CI visual configs */ | ||
729 | numRGBconfigs = 0; | ||
730 | numCIconfigs = 0; | ||
731 | for (i = 0; i < numNewConfigs; i++) { | ||
732 | if (pNewVisualConfigs[i].rgba) | ||
733 | numRGBconfigs++; | ||
734 | else | ||
735 | numCIconfigs++; | ||
736 | } | ||
737 | |||
738 | /* Count the total number of visuals to compute */ | ||
739 | numNewVisuals = 0; | ||
740 | for (i = 0; i < numVisuals; i++) { | ||
741 | int count; | ||
742 | |||
743 | count = ((pVisual[i].class == TrueColor || | ||
744 | pVisual[i].class == DirectColor) | ||
745 | ? numRGBconfigs : numCIconfigs); | ||
746 | if (count == 0) | ||
747 | count = 1; /* preserve the existing visual */ | ||
748 | |||
749 | numNewVisuals += count; | ||
750 | } | ||
751 | |||
752 | /* Reset variables for use with the next screen/driver's visual configs */ | ||
753 | visualConfigs = NULL; | ||
754 | numConfigs = 0; | ||
755 | |||
756 | /* Alloc temp space for the list of orig VisualIDs for each new visual */ | ||
757 | orig_vid = (VisualID *)malloc(numNewVisuals * sizeof(VisualID)); | ||
758 | if (!orig_vid) { | ||
759 | free(pNewVisualPriv); | ||
760 | free(pNewVisualConfigs); | ||
761 | return FALSE; | ||
762 | } | ||
763 | |||
764 | /* Alloc space for the list of glXVisuals */ | ||
765 | modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes)); | ||
766 | if (modes == NULL) { | ||
767 | free(orig_vid); | ||
768 | free(pNewVisualPriv); | ||
769 | free(pNewVisualConfigs); | ||
770 | return FALSE; | ||
771 | } | ||
772 | |||
773 | /* Alloc space for the list of glXVisualPrivates */ | ||
774 | glXVisualPriv = (void **)malloc(numNewVisuals * sizeof(void *)); | ||
775 | if (!glXVisualPriv) { | ||
776 | _gl_context_modes_destroy( modes ); | ||
777 | free(orig_vid); | ||
778 | free(pNewVisualPriv); | ||
779 | free(pNewVisualConfigs); | ||
780 | return FALSE; | ||
781 | } | ||
782 | |||
783 | /* Alloc space for the new list of the X server's visuals */ | ||
784 | pVisualNew = (VisualPtr)malloc(numNewVisuals * sizeof(VisualRec)); | ||
785 | if (!pVisualNew) { | ||
786 | free(glXVisualPriv); | ||
787 | _gl_context_modes_destroy( modes ); | ||
788 | free(orig_vid); | ||
789 | free(pNewVisualPriv); | ||
790 | free(pNewVisualConfigs); | ||
791 | return FALSE; | ||
792 | } | ||
793 | |||
794 | /* Initialize the new visuals */ | ||
795 | found_default = FALSE; | ||
796 | glAquaScreens[screenInfo.numScreens-1].modes = modes; | ||
797 | for (i = j = 0; i < numVisuals; i++) { | ||
798 | int is_rgb = (pVisual[i].class == TrueColor || | ||
799 | pVisual[i].class == DirectColor); | ||
800 | |||
801 | if (!is_rgb) | ||
802 | { | ||
803 | /* We don't support non-rgb visuals for GL. But we don't | ||
804 | want to remove them either, so just pass them through | ||
805 | with null glX configs */ | ||
806 | |||
807 | pVisualNew[j] = pVisual[i]; | ||
808 | pVisualNew[j].vid = FakeClientID(0); | ||
809 | |||
810 | /* Check for the default visual */ | ||
811 | if (!found_default && pVisual[i].vid == *defaultVisp) { | ||
812 | *defaultVisp = pVisualNew[j].vid; | ||
813 | found_default = TRUE; | ||
814 | } | ||
815 | |||
816 | /* Save the old VisualID */ | ||
817 | orig_vid[j] = pVisual[i].vid; | ||
818 | |||
819 | /* Initialize the glXVisual */ | ||
820 | _gl_copy_visual_to_context_mode( modes, & NullConfig ); | ||
821 | modes->visualID = pVisualNew[j].vid; | ||
822 | |||
823 | j++; | ||
824 | |||
825 | continue; | ||
826 | } | ||
827 | |||
828 | for (k = 0; k < numNewConfigs; k++) { | ||
829 | if (pNewVisualConfigs[k].rgba != is_rgb) | ||
830 | continue; | ||
831 | |||
832 | assert( modes != NULL ); | ||
833 | |||
834 | /* Initialize the new visual */ | ||
835 | pVisualNew[j] = pVisual[i]; | ||
836 | pVisualNew[j].vid = FakeClientID(0); | ||
837 | |||
838 | /* Check for the default visual */ | ||
839 | if (!found_default && pVisual[i].vid == *defaultVisp) { | ||
840 | *defaultVisp = pVisualNew[j].vid; | ||
841 | found_default = TRUE; | ||
842 | } | ||
843 | |||
844 | /* Save the old VisualID */ | ||
845 | orig_vid[j] = pVisual[i].vid; | ||
846 | |||
847 | /* Initialize the glXVisual */ | ||
848 | _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] ); | ||
849 | modes->visualID = pVisualNew[j].vid; | ||
850 | |||
851 | /* | ||
852 | * If the class is -1, then assume the X visual information | ||
853 | * is identical to what GLX needs, and take them from the X | ||
854 | * visual. NOTE: if class != -1, then all other fields MUST | ||
855 | * be initialized. | ||
856 | */ | ||
857 | if (modes->visualType == GLX_NONE) { | ||
858 | modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class ); | ||
859 | modes->redBits = count_bits(pVisual[i].redMask); | ||
860 | modes->greenBits = count_bits(pVisual[i].greenMask); | ||
861 | modes->blueBits = count_bits(pVisual[i].blueMask); | ||
862 | modes->alphaBits = modes->alphaBits; | ||
863 | modes->redMask = pVisual[i].redMask; | ||
864 | modes->greenMask = pVisual[i].greenMask; | ||
865 | modes->blueMask = pVisual[i].blueMask; | ||
866 | modes->alphaMask = modes->alphaMask; | ||
867 | modes->rgbBits = (is_rgb) | ||
868 | ? (modes->redBits + modes->greenBits + | ||
869 | modes->blueBits + modes->alphaBits) | ||
870 | : rootDepth; | ||
871 | } | ||
872 | |||
873 | /* Save the device-dependent private for this visual */ | ||
874 | glXVisualPriv[j] = pNewVisualPriv[k]; | ||
875 | |||
876 | j++; | ||
877 | modes = modes->next; | ||
878 | } | ||
879 | } | ||
880 | |||
881 | assert(j <= numNewVisuals); | ||
882 | |||
883 | /* Save the GLX visuals in the screen structure */ | ||
884 | glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals; | ||
885 | // glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv; | ||
886 | |||
887 | /* set up depth's VisualIDs */ | ||
888 | for (i = 0; i < ndepth; i++) { | ||
889 | int numVids = 0; | ||
890 | VisualID *pVids = NULL; | ||
891 | int k, n = 0; | ||
892 | |||
893 | /* Count the new number of VisualIDs at this depth */ | ||
894 | for (j = 0; j < pdepth[i].numVids; j++) | ||
895 | for (k = 0; k < numNewVisuals; k++) | ||
896 | if (pdepth[i].vids[j] == orig_vid[k]) | ||
897 | numVids++; | ||
898 | |||
899 | /* Allocate a new list of VisualIDs for this depth */ | ||
900 | pVids = (VisualID *)malloc(numVids * sizeof(VisualID)); | ||
901 | |||
902 | /* Initialize the new list of VisualIDs for this depth */ | ||
903 | for (j = 0; j < pdepth[i].numVids; j++) | ||
904 | for (k = 0; k < numNewVisuals; k++) | ||
905 | if (pdepth[i].vids[j] == orig_vid[k]) | ||
906 | pVids[n++] = pVisualNew[k].vid; | ||
907 | |||
908 | /* Update this depth's list of VisualIDs */ | ||
909 | free(pdepth[i].vids); | ||
910 | pdepth[i].vids = pVids; | ||
911 | pdepth[i].numVids = numVids; | ||
912 | } | ||
913 | |||
914 | /* Update the X server's visuals */ | ||
915 | *nvisualp = numNewVisuals; | ||
916 | *visualp = pVisualNew; | ||
917 | |||
918 | /* Free the old list of the X server's visuals */ | ||
919 | free(pVisual); | ||
920 | |||
921 | /* Clean up temporary allocations */ | ||
922 | free(orig_vid); | ||
923 | free(pNewVisualPriv); | ||
924 | free(pNewVisualConfigs); | ||
925 | |||
926 | /* Free the private list created by DDX HW driver */ | ||
927 | if (visualPrivates) | ||
928 | free(visualPrivates); | ||
929 | visualPrivates = NULL; | ||
930 | |||
931 | return TRUE; | ||
932 | #endif | ||
933 | return FALSE; | ||
934 | } | ||
935 | |||
936 | static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, | ||
937 | void **privates) | ||
938 | { | ||
939 | #if 0 | ||
940 | GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n"); | ||
941 | |||
942 | numConfigs = nconfigs; | ||
943 | visualConfigs = configs; | ||
944 | visualPrivates = privates; | ||
945 | #endif | ||
946 | } | ||
947 | |||
948 | |||
949 | static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp, | ||
950 | int *nvisualp, int *ndepthp, | ||
951 | int *rootDepthp, VisualID *defaultVisp, | ||
952 | unsigned long sizes, int bitsPerRGB) | ||
953 | { | ||
954 | GLAQUA_DEBUG_MSG("glAquaInitVisuals\n"); | ||
955 | |||
956 | /* | ||
957 | * setup the visuals supported by this particular screen. | ||
958 | */ | ||
959 | return init_visuals(nvisualp, visualp, defaultVisp, | ||
960 | *ndepthp, *depthp, *rootDepthp); | ||
961 | } | ||
962 | |||
963 | #if 0 | ||
964 | static void fixup_visuals(int screen) | ||
965 | { | ||
966 | ScreenPtr pScreen = screenInfo.screens[screen]; | ||
967 | glAquaScreenRec *pScr = &glAquaScreens[screen]; | ||
968 | int j; | ||
969 | __GLcontextModes *modes; | ||
970 | |||
971 | GLAQUA_DEBUG_MSG("fixup_visuals\n"); | ||
972 | |||
973 | for ( modes = pScr->modes ; modes != NULL ; modes = modes->next ) { | ||
974 | const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); | ||
975 | const int nplanes = (modes->rgbBits - modes->alphaBits); | ||
976 | const VisualPtr pVis = pScreen->visuals; | ||
977 | |||
978 | /* Find a visual that matches the GLX visual's class and size */ | ||
979 | for (j = 0; j < pScreen->numVisuals; j++) { | ||
980 | if (pVis[j].class == vis_class && | ||
981 | pVis[j].nplanes == nplanes) { | ||
982 | |||
983 | /* Fixup the masks */ | ||
984 | modes->redMask = pVis[j].redMask; | ||
985 | modes->greenMask = pVis[j].greenMask; | ||
986 | modes->blueMask = pVis[j].blueMask; | ||
987 | |||
988 | /* Recalc the sizes */ | ||
989 | modes->redBits = count_bits(modes->redMask); | ||
990 | modes->greenBits = count_bits(modes->greenMask); | ||
991 | modes->blueBits = count_bits(modes->blueMask); | ||
992 | } | ||
993 | } | ||
994 | } | ||
995 | } | ||
996 | #endif | ||
997 | static void __glXAquaScreenDestroy(__GLXscreen *screen) { | 502 | static void __glXAquaScreenDestroy(__GLXscreen *screen) { |
998 | 503 | ||
999 | GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen); | 504 | GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen); |
@@ -1210,10 +715,6 @@ static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) { | |||
1210 | screen->base.fbconfigs = CreateConfigs(&screen->base.numFBConfigs, | 715 | screen->base.fbconfigs = CreateConfigs(&screen->base.numFBConfigs, |
1211 | pScreen->myNum); | 716 | pScreen->myNum); |
1212 | 717 | ||
1213 | /* This seems odd, but visuals is a __GLXconfig too. */ | ||
1214 | screen->base.visuals = screen->base.fbconfigs; | ||
1215 | screen->base.numVisuals = screen->base.numFBConfigs; | ||
1216 | |||
1217 | GlxSetVisualConfig(GLX_ALL_VISUALS); | 718 | GlxSetVisualConfig(GLX_ALL_VISUALS); |
1218 | 719 | ||
1219 | __glXScreenInit(&screen->base, pScreen); | 720 | __glXScreenInit(&screen->base, pScreen); |
@@ -1271,8 +772,6 @@ __glXAquaScreenCreateDrawable(__GLXscreen *screen, | |||
1271 | __GLXconfig *conf) { | 772 | __GLXconfig *conf) { |
1272 | __GLXAquaDrawable *glxPriv; | 773 | __GLXAquaDrawable *glxPriv; |
1273 | 774 | ||
1274 | GLAQUA_DEBUG_MSG("glAquaScreenCreateDrawable(%p,%p,%d,%p)\n", context, pDraw, drawId, modes); | ||
1275 | |||
1276 | glxPriv = xalloc(sizeof *glxPriv); | 775 | glxPriv = xalloc(sizeof *glxPriv); |
1277 | 776 | ||
1278 | if(glxPriv == NULL) | 777 | if(glxPriv == NULL) |
@@ -1286,19 +785,16 @@ __glXAquaScreenCreateDrawable(__GLXscreen *screen, | |||
1286 | } | 785 | } |
1287 | 786 | ||
1288 | glxPriv->base.destroy = __glXAquaDrawableDestroy; | 787 | glxPriv->base.destroy = __glXAquaDrawableDestroy; |
1289 | glxPriv->base.resize = __glXAquaDrawableResize; | ||
1290 | glxPriv->base.swapBuffers = __glXAquaDrawableSwapBuffers; | 788 | glxPriv->base.swapBuffers = __glXAquaDrawableSwapBuffers; |
1291 | glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */ | 789 | glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */ |
1292 | 790 | ||
791 | glxPriv->pDraw = pDraw; | ||
792 | glxPriv->sid = 0; | ||
793 | glxPriv->context = NULL; | ||
794 | |||
1293 | return &glxPriv->base; | 795 | return &glxPriv->base; |
1294 | } | 796 | } |
1295 | 797 | ||
1296 | static void glAquaResetExtension(void) | ||
1297 | { | ||
1298 | GLAQUA_DEBUG_MSG("glAquaResetExtension\n"); | ||
1299 | CGLSetOption(kCGLGOResetLibrary, GL_TRUE); | ||
1300 | } | ||
1301 | |||
1302 | // Extra goodies for glx | 798 | // Extra goodies for glx |
1303 | 799 | ||
1304 | GLuint __glFloorLog2(GLuint val) | 800 | GLuint __glFloorLog2(GLuint val) |