2010-07-28 21:40:43 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Intel Corporation
|
2011-06-06 02:19:40 +01:00
|
|
|
* Copyright © 2011 Apple Inc.
|
2010-07-28 21:40:43 +01:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Soft-
|
|
|
|
* ware"), to deal in the Software without restriction, including without
|
|
|
|
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, provided that the above copyright
|
|
|
|
* notice(s) and this permission notice appear in all copies of the Soft-
|
|
|
|
* ware and that both the above copyright notice(s) and this permission
|
|
|
|
* notice appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
|
|
|
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
|
|
|
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
|
|
|
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
|
|
|
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
|
|
|
|
* MANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name of a copyright holder shall
|
|
|
|
* not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
* other dealings in this Software without prior written authorization of
|
|
|
|
* the copyright holder.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Kristian Høgsberg (krh@bitplanet.net)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(GLX_USE_APPLEGL)
|
|
|
|
|
2011-06-06 02:19:40 +01:00
|
|
|
#include <stdbool.h>
|
2011-06-15 08:27:55 +01:00
|
|
|
#include <dlfcn.h>
|
2011-06-06 02:19:40 +01:00
|
|
|
|
|
|
|
#include "glxclient.h"
|
Fix build of appleglx
Define GLX_USE_APPLEGL, as config/darwin used to, to turn on specific code to
use the applegl direct renderer
Convert src/glx/apple/Makefile to automake
Since the applegl libGL is now built by linking libappleglx into libGL, rather
than by linking selected files into a special libGL:
- Remove duplicate code in apple/glxreply.c and apple/apple_glx.c. This makes
apple/glxreply.c empty, so remove it
- Some indirect rendering code is already guarded by !GLX_USE_APPLEGL, but we
need to add those guards to indirect_glx.c, indirect_init.c (via it's
generator), render2.c and vertarr.c so they don't generate anything
Fix and update various includes
glapi_gentable.c (which is only used on darwin), should be included in shared
glapi as well, to provide _glapi_create_table_from_handle()
Note that neither swrast nor indirect is supported in the APPLEGL path at the
moment, which makes things more complex than they need to be. More untangling
is needed to allow that
v2: Correct apple/Makefile.am for srcdir != builddir
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-05-12 10:47:07 +01:00
|
|
|
#include "apple/apple_glx_context.h"
|
|
|
|
#include "apple/apple_glx.h"
|
|
|
|
#include "apple/apple_cgl.h"
|
2011-06-06 02:19:40 +01:00
|
|
|
#include "glx_error.h"
|
|
|
|
|
2010-07-28 21:40:43 +01:00
|
|
|
static void
|
|
|
|
applegl_destroy_context(struct glx_context *gc)
|
|
|
|
{
|
2011-06-13 20:00:55 +01:00
|
|
|
apple_glx_destroy_context(&gc->driContext, gc->psc->dpy);
|
2010-07-28 21:40:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
applegl_bind_context(struct glx_context *gc, struct glx_context *old,
|
|
|
|
GLXDrawable draw, GLXDrawable read)
|
|
|
|
{
|
2011-06-06 02:19:40 +01:00
|
|
|
Display *dpy = gc->psc->dpy;
|
2010-07-28 21:40:43 +01:00
|
|
|
bool error = apple_glx_make_current_context(dpy,
|
2011-06-06 16:15:32 +01:00
|
|
|
(old && old != &dummyContext) ? old->driContext : NULL,
|
2010-07-28 21:40:43 +01:00
|
|
|
gc ? gc->driContext : NULL, draw);
|
|
|
|
|
|
|
|
apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
|
|
|
|
if (error)
|
2011-06-06 02:19:40 +01:00
|
|
|
return 1; /* GLXBadContext is the same as Success (0) */
|
2010-07-28 21:40:43 +01:00
|
|
|
|
2011-06-14 08:45:12 +01:00
|
|
|
apple_glapi_set_dispatch();
|
|
|
|
|
2010-07-28 21:40:43 +01:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
applegl_unbind_context(struct glx_context *gc, struct glx_context *new)
|
|
|
|
{
|
2011-10-25 00:21:28 +01:00
|
|
|
Display *dpy;
|
|
|
|
bool error;
|
|
|
|
|
|
|
|
/* If we don't have a context, then we have nothing to unbind */
|
|
|
|
if (!gc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* If we have a new context, keep this one around and remove it during bind. */
|
|
|
|
if (new)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dpy = gc->psc->dpy;
|
|
|
|
|
|
|
|
error = apple_glx_make_current_context(dpy,
|
|
|
|
(gc != &dummyContext) ? gc->driContext : NULL,
|
|
|
|
NULL, None);
|
|
|
|
|
|
|
|
apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
|
2010-07-28 21:40:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
applegl_wait_gl(struct glx_context *gc)
|
|
|
|
{
|
|
|
|
glFinish();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
applegl_wait_x(struct glx_context *gc)
|
|
|
|
{
|
2011-06-06 02:19:40 +01:00
|
|
|
Display *dpy = gc->psc->dpy;
|
|
|
|
apple_glx_waitx(dpy, gc->driContext);
|
2010-07-28 21:40:43 +01:00
|
|
|
}
|
|
|
|
|
2021-03-18 15:36:12 +00:00
|
|
|
void *
|
2011-06-15 08:27:55 +01:00
|
|
|
applegl_get_proc_address(const char *symbol)
|
|
|
|
{
|
|
|
|
return dlsym(apple_cgl_get_dl_handle(), symbol);
|
|
|
|
}
|
|
|
|
|
2010-07-28 21:40:43 +01:00
|
|
|
static const struct glx_context_vtable applegl_context_vtable = {
|
2014-02-18 15:46:10 +00:00
|
|
|
.destroy = applegl_destroy_context,
|
|
|
|
.bind = applegl_bind_context,
|
|
|
|
.unbind = applegl_unbind_context,
|
|
|
|
.wait_gl = applegl_wait_gl,
|
|
|
|
.wait_x = applegl_wait_x,
|
2010-07-28 21:40:43 +01:00
|
|
|
};
|
|
|
|
|
2011-06-06 02:19:40 +01:00
|
|
|
struct glx_context *
|
2010-07-28 21:40:43 +01:00
|
|
|
applegl_create_context(struct glx_screen *psc,
|
2011-06-06 16:15:32 +01:00
|
|
|
struct glx_config *config,
|
2010-07-28 21:40:43 +01:00
|
|
|
struct glx_context *shareList, int renderType)
|
|
|
|
{
|
|
|
|
struct glx_context *gc;
|
|
|
|
int errorcode;
|
|
|
|
bool x11error;
|
2011-06-06 16:27:19 +01:00
|
|
|
Display *dpy = psc->dpy;
|
|
|
|
int screen = psc->scr;
|
2010-07-28 21:40:43 +01:00
|
|
|
|
|
|
|
/* TODO: Integrate this with apple_glx_create_context and make
|
|
|
|
* struct apple_glx_context inherit from struct glx_context. */
|
|
|
|
|
2017-11-14 20:13:06 +00:00
|
|
|
if (!config)
|
|
|
|
return NULL;
|
|
|
|
|
2012-09-05 06:52:36 +01:00
|
|
|
gc = calloc(1, sizeof(*gc));
|
2011-06-06 02:19:40 +01:00
|
|
|
if (gc == NULL)
|
2010-07-28 21:40:43 +01:00
|
|
|
return NULL;
|
|
|
|
|
2011-06-06 16:15:32 +01:00
|
|
|
if (!glx_context_init(gc, psc, config)) {
|
2012-09-05 06:52:36 +01:00
|
|
|
free(gc);
|
2010-07-28 21:40:43 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gc->vtable = &applegl_context_vtable;
|
|
|
|
gc->driContext = NULL;
|
|
|
|
|
|
|
|
/* TODO: darwin: Integrate with above to do indirect */
|
2011-06-06 16:15:32 +01:00
|
|
|
if(apple_glx_create_context(&gc->driContext, dpy, screen, config,
|
2010-07-28 21:40:43 +01:00
|
|
|
shareList ? shareList->driContext : NULL,
|
|
|
|
&errorcode, &x11error)) {
|
|
|
|
__glXSendError(dpy, errorcode, 0, X_GLXCreateContext, x11error);
|
|
|
|
gc->vtable->destroy(gc);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gc->currentContextTag = -1;
|
2011-06-06 16:15:32 +01:00
|
|
|
gc->config = config;
|
|
|
|
gc->isDirect = GL_TRUE;
|
2010-07-28 21:40:43 +01:00
|
|
|
gc->xid = 1; /* Just something not None, so we know when to destroy
|
|
|
|
* it in MakeContextCurrent. */
|
|
|
|
|
|
|
|
return gc;
|
|
|
|
}
|
|
|
|
|
2014-02-18 15:46:10 +00:00
|
|
|
static const struct glx_screen_vtable applegl_screen_vtable = {
|
|
|
|
.create_context = applegl_create_context,
|
|
|
|
.create_context_attribs = NULL,
|
|
|
|
.query_renderer_integer = NULL,
|
|
|
|
.query_renderer_string = NULL,
|
2010-07-28 21:40:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
_X_HIDDEN struct glx_screen *
|
|
|
|
applegl_create_screen(int screen, struct glx_display * priv)
|
|
|
|
{
|
|
|
|
struct glx_screen *psc;
|
|
|
|
|
2012-09-05 07:09:22 +01:00
|
|
|
psc = calloc(1, sizeof *psc);
|
2010-07-28 21:40:43 +01:00
|
|
|
if (psc == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
glx_screen_init(psc, screen, priv);
|
|
|
|
psc->vtable = &applegl_screen_vtable;
|
|
|
|
|
|
|
|
return psc;
|
|
|
|
}
|
|
|
|
|
|
|
|
_X_HIDDEN int
|
2011-06-06 02:19:40 +01:00
|
|
|
applegl_create_display(struct glx_display *glx_dpy)
|
2010-07-28 21:40:43 +01:00
|
|
|
{
|
2011-06-06 02:19:40 +01:00
|
|
|
if(!apple_init_glx(glx_dpy->dpy))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return GLXBadContext;
|
2010-07-28 21:40:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|