apple: Extended Apple feature support using GLX_USE_APPLE.

On MacOS/Apple/Dawin you can only get MESA to forward the GL funtions to
the systems OpenGL.framework or run SWRast directly. There is no way to use a gallium driver, even if they have been compiled.
The two gallium drivers of interest are SWRast and Zink, as the rest are hardware drivers and not relavent on MacOS.

The code changes add a new define GLX_USE_APPLE. This is used in combination with the existing GLX_USE_APPLEGL.
GLX_USE_APPLEGL calls the systems OpenGL.framework, Apple's OpenGL.
GLX_USE_APPLE calls the non-system OpenGL code, i.e. Gallium, hence the subtle naming difference. Apple systems are still used, just not the GL ones.
When GLX_USE_APPLE is defined the code will use the DRI/gallium driver sub-system so SWRast and Zink can selected at runtime on MacOS.

This also allows Zink to be run on MacOS, once it is fixed up.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28205>
This commit is contained in:
duncan.hopkins
2023-10-27 16:13:40 +01:00
committed by Marge Bot
parent b0bdd0cae3
commit 97b6851815
17 changed files with 36 additions and 27 deletions

View File

@@ -141,7 +141,7 @@ DEFINE_LOADER_DRM_ENTRYPOINT(zynqmp_dpsub)
DEFINE_LOADER_DRM_ENTRYPOINT(lima)
#endif
#if defined(GALLIUM_ZINK) && !defined(__APPLE__)
#if defined(GALLIUM_ZINK)
#if DETECT_OS_ANDROID
DEFINE_LOADER_DRM_ENTRYPOINT(zink);
#else

View File

@@ -12,7 +12,7 @@
/*****************************************************************************/
#ifndef GLX_USE_APPLEGL
#if !defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE)
static void
do_enable_disable(GLenum array, GLboolean val)
{

View File

@@ -31,7 +31,7 @@
*/
#ifdef GLX_DIRECT_RENDERING
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
#include <stdio.h>
#include <X11/Xlibint.h>
@@ -96,6 +96,7 @@ static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay,
static Bool
DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
{
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
struct glx_drawable *glxDraw;
@@ -162,6 +163,7 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
/* client doesn't support server event */
break;
}
#endif
return False;
}

View File

@@ -30,7 +30,7 @@
* Kristian Høgsberg (krh@redhat.com)
*/
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>

View File

@@ -33,7 +33,7 @@
* Kristian Høgsberg (krh@redhat.com)
*/
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
#include <unistd.h>
#include <dlfcn.h>

View File

@@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
#include "glxclient.h"
#include "glx_error.h"

View File

@@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
#include "glxclient.h"
#include "glx_error.h"

View File

@@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
#include <xcb/xcb.h>
#include <xcb/xproto.h>

View File

@@ -48,7 +48,7 @@
#include "glx_error.h"
#ifndef GLX_USE_APPLEGL
#if !defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE)
/**
* Change a drawable's attribute.
*

View File

@@ -68,7 +68,7 @@ extern void DRI_glXUseXFont(struct glx_context *ctx,
#endif
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
/**
* Display dependent methods. This structure is initialized during the
@@ -512,7 +512,7 @@ struct glx_screen
bool allow_invalid_glx_destroy_window;
bool keep_native_window_glx_drawable;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
/**
* Per screen direct rendering interface functions and data.
*/
@@ -579,7 +579,7 @@ struct glx_display
__glxHashTable *glXDrawHash;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
__glxHashTable *drawHash;
/**
@@ -613,7 +613,7 @@ glx_screen_init(struct glx_screen *psc,
extern void
glx_screen_cleanup(struct glx_screen *psc);
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
extern __GLXDRIdrawable *
dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id);
#endif
@@ -732,7 +732,7 @@ extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
int32_t * numerator,
int32_t * denominator);
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
extern GLboolean
__glxGetMscRate(struct glx_screen *psc,
int32_t * numerator, int32_t * denominator);

View File

@@ -33,7 +33,7 @@
#include <xcb/glx.h>
#include "GL/mesa_glinterop.h"
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
/**
* Get the __DRIdrawable for the drawable associated with a GLXContext
@@ -315,7 +315,7 @@ CreateContext(Display *dpy, int generic_id, struct glx_config *config,
}
gc = NULL;
#ifdef GLX_USE_APPLEGL
#if defined(GLX_USE_APPLEGL) && !defined(GLX_USE_APPLE)
gc = applegl_create_context(psc, config, shareList, renderType);
#else
if (allowDirect && psc->vtable->create_context)
@@ -652,7 +652,7 @@ glXIsDirect(Display * dpy, GLXContext gc_user)
_GLX_PUBLIC void
glXSwapBuffers(Display * dpy, GLXDrawable drawable)
{
#ifdef GLX_USE_APPLEGL
#if defined(GLX_USE_APPLEGL) && !defined(GLX_USE_APPLE)
struct glx_context * gc = __glXGetCurrentContext();
if(gc != &dummyContext && apple_glx_is_current_drawable(dpy, gc->driContext, drawable)) {
apple_glx_swap_buffers(gc->driContext);
@@ -667,7 +667,7 @@ glXSwapBuffers(Display * dpy, GLXDrawable drawable)
gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
{
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);

View File

@@ -798,9 +798,15 @@ AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv, Bool zink)
psc = priv->driswDisplay->createScreen(i, priv);
#endif /* GLX_DIRECT_RENDERING && !GLX_USE_APPLEGL */
#if defined(GLX_USE_APPLE)
if (psc == NULL && priv->driswDisplay) {
psc = priv->driswDisplay->createScreen(i, priv);
}
#endif
bool indirect = false;
#if defined(GLX_USE_APPLEGL)
#if defined(GLX_USE_APPLEGL) && !defined(GLX_USE_APPLE)
if (psc == NULL)
psc = applegl_create_screen(i, priv);
#else
@@ -880,7 +886,7 @@ __glXInitialize(Display * dpy)
Bool zink = False;
Bool try_zink = False;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
Bool glx_direct = !debug_get_bool_option("LIBGL_ALWAYS_INDIRECT", false);
Bool glx_accel = !debug_get_bool_option("LIBGL_ALWAYS_SOFTWARE", false);
const char *env = getenv("MESA_LOADER_DRIVER_OVERRIDE");
@@ -927,7 +933,7 @@ __glXInitialize(Display * dpy)
#endif
#endif /* GLX_DIRECT_RENDERING && !GLX_USE_APPLEGL */
#ifdef GLX_USE_APPLEGL
#if defined(GLX_USE_APPLEGL) && !defined(GLX_USE_APPLE)
if (!applegl_create_display(dpyPriv)) {
free(dpyPriv);
return NULL;
@@ -936,7 +942,7 @@ __glXInitialize(Display * dpy)
if (!AllocAndFetchScreenConfigs(dpy, dpyPriv, zink | try_zink)) {
Bool fail = True;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
if (try_zink) {
free(dpyPriv->screens);
dpyPriv->driswDisplay->destroyDisplay(dpyPriv->driswDisplay);

View File

@@ -37,7 +37,7 @@
#include "indirect.h"
#include "util/u_debug.h"
#ifndef GLX_USE_APPLEGL
#if !defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE)
extern struct _glapi_table *__glXNewIndirectAPI(void);

View File

@@ -5,7 +5,7 @@
* SPDX-License-Identifier: SGI-B-2.0
*/
#ifndef GLX_USE_APPLEGL
#if !defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE)
#include "packrender.h"
#include "indirect.h"

View File

@@ -9,7 +9,7 @@
#include "indirect.h"
#include "indirect_vertex_array.h"
#ifndef GLX_USE_APPLEGL
#if !defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE)
/*****************************************************************************/

View File

@@ -928,7 +928,7 @@ class PrintGlxProtoInit_c(gl_XML.gl_print_base):
#include "glapi.h"
#include <assert.h>
#ifndef GLX_USE_APPLEGL
#if !defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE)
/**
* No-op function used to initialize functions that have no GLX protocol

View File

@@ -83,6 +83,7 @@ __glapi_gentable_set_remaining_noop(struct _glapi_table *disp) {
"""
footer = """
#if defined(GLX_USE_APPLEGL) || defined(GLX_USE_WINDOWSGL)
struct _glapi_table *
_glapi_create_table_from_handle(void *handle, const char *symbol_prefix) {
struct _glapi_table *disp = calloc(_glapi_get_dispatch_table_size(), sizeof(_glapi_proc));
@@ -124,7 +125,7 @@ void
}
fprintf(stderr, "could not patch %s in dispatch table\\n", name);
}
#endif
"""