apple: Use glapi rather than reinventing the wheel
With this change, Apple's libGL is now using glapi rather than implementing its own dispatch. In this implementation, two dispatch tables are created: __ogl_framework_api always points into OpenGL.framework. __applegl_api is the vtable that is used. It points into OpenGL.framework or to local implementations that override / interpose this in OpenGL.framework The initialization for __ogl_framework_api was copied from XQuartz with some modifications and probably still needs further edits to better deal with aliases. This is a good step towards supporting both indirect and direct rendering on darwin. Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
apple_xgl_api.[hc]
|
||||
exports.list
|
||||
stage.[1234]
|
||||
|
||||
|
||||
+11
-17
@@ -30,8 +30,7 @@ SOURCES = \
|
||||
apple_glx_pixmap.c \
|
||||
apple_glx_surface.c \
|
||||
apple_visual.c \
|
||||
apple_xgl_api.c \
|
||||
apple_xgl_api_additional.c \
|
||||
apple_glapi.c \
|
||||
apple_xgl_api_read.c \
|
||||
apple_xgl_api_stereo.c \
|
||||
apple_xgl_api_viewport.c \
|
||||
@@ -54,18 +53,18 @@ SOURCES = \
|
||||
|
||||
include $(TOP)/src/mesa/sources.mak
|
||||
|
||||
# override GLAPI_LIB
|
||||
GLAPI_LIB = $(TOP)/src/mapi/glapi/libglapi.a
|
||||
|
||||
LDFLAGS += -lXplugin -framework ApplicationServices -framework CoreFoundation
|
||||
|
||||
MESA_GLAPI_ASM_SOURCES = $(addprefix $(TOP)/src/mesa/, $(GLAPI_ASM_SOURCES))
|
||||
MESA_GLAPI_SOURCES = $(addprefix $(TOP)/src/mesa/, $(GLAPI_SOURCES))
|
||||
MESA_GLAPI_OBJECTS = $(addprefix $(TOP)/src/mesa/, $(GLAPI_OBJECTS))
|
||||
|
||||
OBJECTS = $(SOURCES:.c=.o) # $(MESA_GLAPI_OBJECTS)
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
INCLUDES = -I. -Iinclude -I..\
|
||||
-I$(TOP)/include \
|
||||
-I$(TOP)/include/GL/internal \
|
||||
-I$(TOP)/src/mesa \
|
||||
-I$(TOP)/src/mesa/main \
|
||||
-I$(TOP)/src/mapi \
|
||||
-I$(TOP)/src/mapi/glapi \
|
||||
$(LIBDRM_CFLAGS) \
|
||||
@@ -74,13 +73,6 @@ INCLUDES = -I. -Iinclude -I..\
|
||||
|
||||
##### RULES #####
|
||||
|
||||
$(OBJECTS) : apple_xgl_api.h
|
||||
|
||||
apple_xgl_api.c : apple_xgl_api.h
|
||||
|
||||
apple_xgl_api.h : gen_api_header.tcl gen_api_library.tcl gen_code.tcl gen_defs.tcl gen_exports.tcl gen_funcs.tcl gen_types.tcl
|
||||
$(TCLSH) gen_code.tcl
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@
|
||||
|
||||
@@ -92,11 +84,14 @@ apple_xgl_api.h : gen_api_header.tcl gen_api_library.tcl gen_code.tcl gen_def
|
||||
default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
|
||||
|
||||
# Make libGL
|
||||
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
|
||||
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(GLAPI_LIB) Makefile
|
||||
$(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major 1 -minor 2 $(MKLIB_OPTIONS) \
|
||||
-install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/lib$(GL_LIB).1.dylib \
|
||||
$(GL_LIB_DEPS) $(OBJECTS)
|
||||
$(GL_LIB_DEPS) $(OBJECTS) $(GLAPI_LIB)
|
||||
|
||||
$(GLAPI_LIB):
|
||||
@$(MAKE) -C $(TOP)/src/mapi/glapi
|
||||
|
||||
depend: $(SOURCES) $(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES) Makefile
|
||||
rm -f depend
|
||||
@@ -121,7 +116,6 @@ install: install_libraries
|
||||
clean:
|
||||
-rm -f *.o *.a *~
|
||||
-rm -f *.c~ *.h~
|
||||
-rm -f apple_xgl_api.h apple_xgl_api.c
|
||||
-rm -f *.dylib
|
||||
-rm -f include/GL/gl.h
|
||||
-rm -f $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,7 +37,6 @@
|
||||
#include "apple_glx.h"
|
||||
#include "apple_glx_context.h"
|
||||
#include "apple_cgl.h"
|
||||
#include "apple_xgl_api.h"
|
||||
|
||||
static bool initialized = false;
|
||||
static int dri_event_base = 0;
|
||||
|
||||
@@ -46,4 +46,6 @@ void *apple_glx_get_proc_address(const GLubyte * procname);
|
||||
void apple_glx_waitx(Display * dpy, void *ptr);
|
||||
int apple_get_dri_event_base(void);
|
||||
|
||||
void apple_xgl_init_direct(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008, 2009 Apple Inc.
|
||||
Copyright (c) 2011 Apple Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
@@ -27,11 +27,26 @@
|
||||
prior written authorization.
|
||||
*/
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#ifndef APPLE_XGL_API_H
|
||||
|
||||
GLAPI void APIENTRY glTexImage3DEXT(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei
|
||||
depth, GLint border, GLenum format, GLenum type, const void * pixels) {
|
||||
glTexImage3D(target, level, (GLint)internalformat, width, height, depth, border, format, type, pixels);
|
||||
}
|
||||
__private_extern__ void
|
||||
__applegl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, void *pixels);
|
||||
|
||||
__private_extern__ void
|
||||
__applegl_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
|
||||
|
||||
__private_extern__ void
|
||||
__applegl_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
|
||||
GLsizei width);
|
||||
|
||||
__private_extern__ void
|
||||
__applegl_glDrawBuffer(GLenum mode);
|
||||
|
||||
__private_extern__ void
|
||||
__applegl_glDrawBuffersARB(GLsizei n, const GLenum * bufs);
|
||||
|
||||
__private_extern__ void
|
||||
__applegl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008, 2009 Apple Inc.
|
||||
Copyright (c) 2008-2011 Apple Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
@@ -37,8 +37,9 @@
|
||||
#include "glxclient.h"
|
||||
#include "apple_glx_context.h"
|
||||
#include "apple_xgl_api.h"
|
||||
#include "glapitable.h"
|
||||
|
||||
extern struct apple_xgl_api __ogl_framework_api;
|
||||
extern struct _glapi_table * __ogl_framework_api;
|
||||
|
||||
struct apple_xgl_saved_state
|
||||
{
|
||||
@@ -95,39 +96,39 @@ UnsetRead(struct apple_xgl_saved_state *saved)
|
||||
}
|
||||
|
||||
void
|
||||
glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
__applegl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, void *pixels)
|
||||
{
|
||||
struct apple_xgl_saved_state saved;
|
||||
|
||||
SetRead(&saved);
|
||||
|
||||
__ogl_framework_api.ReadPixels(x, y, width, height, format, type, pixels);
|
||||
__ogl_framework_api->ReadPixels(x, y, width, height, format, type, pixels);
|
||||
|
||||
UnsetRead(&saved);
|
||||
}
|
||||
|
||||
void
|
||||
glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
|
||||
__applegl_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
|
||||
{
|
||||
struct apple_xgl_saved_state saved;
|
||||
|
||||
SetRead(&saved);
|
||||
|
||||
__ogl_framework_api.CopyPixels(x, y, width, height, type);
|
||||
__ogl_framework_api->CopyPixels(x, y, width, height, type);
|
||||
|
||||
UnsetRead(&saved);
|
||||
}
|
||||
|
||||
void
|
||||
glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
|
||||
__applegl_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
|
||||
GLsizei width)
|
||||
{
|
||||
struct apple_xgl_saved_state saved;
|
||||
|
||||
SetRead(&saved);
|
||||
|
||||
__ogl_framework_api.CopyColorTable(target, internalformat, x, y, width);
|
||||
__ogl_framework_api->CopyColorTable(target, internalformat, x, y, width);
|
||||
|
||||
UnsetRead(&saved);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2009 Apple Inc.
|
||||
Copyright (c) 2009-2011 Apple Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
@@ -40,14 +40,16 @@
|
||||
#include "glxclient.h"
|
||||
#include "apple_glx_context.h"
|
||||
#include "apple_xgl_api.h"
|
||||
#include "glapitable.h"
|
||||
|
||||
extern struct _glapi_table * __ogl_framework_api;
|
||||
|
||||
extern struct apple_xgl_api __ogl_framework_api;
|
||||
/*
|
||||
* These are special functions for stereoscopic support
|
||||
* differences in MacOS X.
|
||||
*/
|
||||
void
|
||||
glDrawBuffer(GLenum mode)
|
||||
__applegl_glDrawBuffer(GLenum mode)
|
||||
{
|
||||
struct glx_context * gc = __glXGetCurrentContext();
|
||||
|
||||
@@ -73,16 +75,16 @@ glDrawBuffer(GLenum mode)
|
||||
break;
|
||||
}
|
||||
|
||||
__ogl_framework_api.DrawBuffers(n, buf);
|
||||
__ogl_framework_api->DrawBuffersARB(n, buf);
|
||||
}
|
||||
else {
|
||||
__ogl_framework_api.DrawBuffer(mode);
|
||||
__ogl_framework_api->DrawBuffer(mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glDrawBuffers(GLsizei n, const GLenum * bufs)
|
||||
__applegl_glDrawBuffersARB(GLsizei n, const GLenum * bufs)
|
||||
{
|
||||
struct glx_context * gc = __glXGetCurrentContext();
|
||||
|
||||
@@ -114,15 +116,9 @@ glDrawBuffers(GLsizei n, const GLenum * bufs)
|
||||
newbuf[outi++] = GL_FRONT_RIGHT;
|
||||
}
|
||||
|
||||
__ogl_framework_api.DrawBuffers(outi, newbuf);
|
||||
__ogl_framework_api->DrawBuffersARB(outi, newbuf);
|
||||
}
|
||||
else {
|
||||
__ogl_framework_api.DrawBuffers(n, bufs);
|
||||
__ogl_framework_api->DrawBuffersARB(n, bufs);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glDrawBuffersARB(GLsizei n, const GLenum * bufs)
|
||||
{
|
||||
glDrawBuffers(n, bufs);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2009 Apple Inc.
|
||||
Copyright (c) 2009-2011 Apple Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
@@ -30,11 +30,12 @@
|
||||
#include "glxclient.h"
|
||||
#include "apple_glx_context.h"
|
||||
#include "apple_xgl_api.h"
|
||||
#include "glapitable.h"
|
||||
|
||||
extern struct apple_xgl_api __ogl_framework_api;
|
||||
extern struct _glapi_table * __ogl_framework_api;
|
||||
|
||||
void
|
||||
glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
__applegl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
{
|
||||
struct glx_context *gc = __glXGetCurrentContext();
|
||||
Display *dpy = glXGetCurrentDisplay();
|
||||
@@ -42,5 +43,5 @@ glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
if (gc && gc->driContext)
|
||||
apple_glx_context_update(dpy, gc->driContext);
|
||||
|
||||
__ogl_framework_api.Viewport(x, y, width, height);
|
||||
__ogl_framework_api->Viewport(x, y, width, height);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ proc main {argc argv} {
|
||||
set body "[set return]__ogl_framework_api.[set f]([set callvars]);"
|
||||
}
|
||||
|
||||
puts $fd "GLAPI [dict get $attr return] APIENTRY gl[set f]([set pstr]) \{\n\t$body\n\}"
|
||||
puts $fd "GLAPI [dict get $attr return] APIENTRY __apple_gl[set f]([set pstr]) \{\n\t$body\n\}"
|
||||
}
|
||||
|
||||
puts $fd $::init_code
|
||||
|
||||
Reference in New Issue
Block a user