mesa/src/glx/clientattrib.c
duncan.hopkins 97b6851815 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>
2024-03-18 18:06:45 +00:00

108 lines
2.7 KiB
C

/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
*
* SPDX-License-Identifier: SGI-B-2.0
*/
#include <assert.h>
#include "glxclient.h"
#include "indirect.h"
#include "indirect_vertex_array.h"
/*****************************************************************************/
#if !defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE)
static void
do_enable_disable(GLenum array, GLboolean val)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
unsigned index = 0;
if (array == GL_TEXTURE_COORD_ARRAY) {
index = __glXGetActiveTextureUnit(state);
}
if (!__glXSetArrayEnable(state, array, index, val)) {
__glXSetError(gc, GL_INVALID_ENUM);
}
}
void
__indirect_glEnableClientState(GLenum array)
{
do_enable_disable(array, GL_TRUE);
}
void
__indirect_glDisableClientState(GLenum array)
{
do_enable_disable(array, GL_FALSE);
}
/************************************************************************/
void
__indirect_glPushClientAttrib(GLuint mask)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
__GLXattribute **spp = gc->attributes.stackPointer, *sp;
if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) {
if (!(sp = *spp)) {
sp = malloc(sizeof(__GLXattribute));
if (sp == NULL) {
__glXSetError(gc, GL_OUT_OF_MEMORY);
return;
}
*spp = sp;
}
sp->mask = mask;
gc->attributes.stackPointer = spp + 1;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
sp->storePack = state->storePack;
sp->storeUnpack = state->storeUnpack;
}
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
__glXPushArrayState(state);
}
}
else {
__glXSetError(gc, GL_STACK_OVERFLOW);
return;
}
}
void
__indirect_glPopClientAttrib(void)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
__GLXattribute **spp = gc->attributes.stackPointer, *sp;
GLuint mask;
if (spp > &gc->attributes.stack[0]) {
--spp;
sp = *spp;
assert(sp != 0);
mask = sp->mask;
gc->attributes.stackPointer = spp;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
state->storePack = sp->storePack;
state->storeUnpack = sp->storeUnpack;
}
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
__glXPopArrayState(state);
}
sp->mask = 0;
}
else {
__glXSetError(gc, GL_STACK_UNDERFLOW);
return;
}
}
#endif