* tracker managers.
*/
-/**
- * The entry points of the state trackers.
- */
-#define ST_MODULE_OPENGL_SYMBOL "st_module_OpenGL"
-#define ST_MODULE_OPENGL_ES1_SYMBOL "st_module_OpenGL_ES1"
-#define ST_MODULE_OPENGL_ES2_SYMBOL "st_module_OpenGL_ES2"
-#define ST_MODULE_OPENVG_SYMBOL "st_module_OpenVG"
-
/**
* The supported rendering API of a state tracker.
*/
struct st_context_iface *(*get_current)(struct st_api *stapi);
};
-/**
- * Represent a state tracker.
- *
- * This is the entry point of a state tracker.
- */
-struct st_module
-{
- enum st_api_type api;
- struct st_api *(*create_api)(void);
-};
-
/**
* Return true if the visual has the specified buffers.
*/
}
/* these symbols may need to be dynamically lookup up */
-extern PUBLIC const struct st_module st_module_OpenGL;
-extern PUBLIC const struct st_module st_module_OpenGL_ES1;
-extern PUBLIC const struct st_module st_module_OpenGL_ES2;
-extern PUBLIC const struct st_module st_module_OpenVG;
+extern PUBLIC struct st_api * st_api_create_OpenGL(void);
+extern PUBLIC struct st_api * st_api_create_OpenGL_ES1(void);
+extern PUBLIC struct st_api * st_api_create_OpenGL_ES2(void);
+extern PUBLIC struct st_api * st_api_create_OpenVG(void);
+
+/**
+ * The entry points of the state trackers.
+ */
+#define ST_CREATE_OPENGL_SYMBOL "st_api_create_OpenGL"
+#define ST_CREATE_OPENGL_ES1_SYMBOL "st_api_create_OpenGL_ES1"
+#define ST_CREATE_OPENGL_ES2_SYMBOL "st_api_create_OpenGL_ES2"
+#define ST_CREATE_OPENVG_SYMBOL "st_api_create_OpenVG"
#endif /* _ST_API_H_ */
#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_debug.h"
-#include "state_tracker/st_manager.h" /* for st_manager_create_api */
+#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */
#include "dri_screen.h"
#include "dri_context.h"
{
p_atomic_inc(&dri_st_api.refcnt);
if (p_atomic_read(&dri_st_api.refcnt) == 1)
- dri_st_api.stapi = st_manager_create_api();
+ dri_st_api.stapi = st_gl_api_create();
}
/**
struct st_api *
egl_g3d_create_st_api(enum st_api_type api)
{
- const char *stmod_name;
struct util_dl_library *lib;
- const struct st_module *mod;
+ const char *proc_name;
+ struct st_api * (*proc)(void) = NULL;
switch (api) {
case ST_API_OPENGL:
- stmod_name = ST_MODULE_OPENGL_SYMBOL;
+ proc_name = ST_CREATE_OPENGL_SYMBOL;
break;
case ST_API_OPENGL_ES1:
- stmod_name = ST_MODULE_OPENGL_ES1_SYMBOL;
+ proc_name = ST_CREATE_OPENGL_ES1_SYMBOL;
break;
case ST_API_OPENGL_ES2:
- stmod_name = ST_MODULE_OPENGL_ES2_SYMBOL;
+ proc_name = ST_CREATE_OPENGL_ES2_SYMBOL;
break;
case ST_API_OPENVG:
- stmod_name = ST_MODULE_OPENVG_SYMBOL;
+ proc_name = ST_CREATE_OPENVG_SYMBOL;
break;
default:
- stmod_name = NULL;
- break;
+ assert(!"Unknown API Type\n");
+ return NULL;
}
- if (!stmod_name)
+
+ if (!proc_name)
return NULL;
- mod = NULL;
lib = util_dl_open(NULL);
if (lib) {
- mod = (const struct st_module *)
- util_dl_get_proc_address(lib, stmod_name);
+ proc = util_dl_get_proc_address(lib, proc_name);
+ debug_printf("%s: %s %p\n", __func__, proc_name, proc);
util_dl_close(lib);
}
- if (!mod || mod->api != api)
+
+ if (!proc)
return NULL;
- return mod->create_api();
+ return proc();
}
static boolean
-#include "state_tracker/st_manager.h"
+#include "state_tracker/st_gl_api.h"
-PUBLIC const int st_api_OpenGL_ES1 = 1;
-
-PUBLIC const struct st_module st_module_OpenGL_ES1 = {
- .api = ST_API_OPENGL_ES1,
- .create_api = st_manager_create_api
-};
+PUBLIC struct st_api *
+st_api_create_OpenGL_ES1()
+{
+ return st_gl_api_create();
+}
-#include "state_tracker/st_manager.h"
+#include "state_tracker/st_gl_api.h"
-PUBLIC const int st_api_OpenGL_ES2 = 1;
-
-PUBLIC const struct st_module st_module_OpenGL_ES2 = {
- .api = ST_API_OPENGL_ES2,
- .create_api = st_manager_create_api
-};
+PUBLIC struct st_api *
+st_api_create_OpenGL_ES2()
+{
+ /* linker magic creates different versions */
+ return st_gl_api_create();
+}
free(stapi);
}
-static struct st_api *
-vg_module_create_api(void)
-{
- struct st_api *stapi;
-
- stapi = CALLOC_STRUCT(st_api);
- if (stapi) {
- stapi->destroy = vg_api_destroy;
- stapi->get_proc_address = vg_api_get_proc_address;
- stapi->is_visual_supported = vg_api_is_visual_supported;
-
- stapi->create_context = vg_api_create_context;
- stapi->make_current = vg_api_make_current;
- stapi->get_current = vg_api_get_current;
- }
+struct st_api st_vg_api = {
+ vg_api_destroy,
+ vg_api_get_proc_address,
+ vg_api_is_visual_supported,
+ vg_api_create_context,
+ vg_api_make_current,
+ vg_api_get_current,
+};
- return stapi;
+struct st_api *
+st_api_create_OpenVG(void)
+{
+ return &st_vg_api;
}
-
-PUBLIC const struct st_module st_module_OpenVG = {
- .api = ST_API_OPENVG,
- .create_api = vg_module_create_api,
-};
#include "state_tracker/xlib_sw_winsys.h"
#include "xm_public.h"
-#include "state_tracker/st_manager.h"
+#include "state_tracker/st_gl_api.h"
-/* advertise OpenGL support */
-PUBLIC const int st_api_OpenGL = 1;
+/* piggy back on this libGL for OpenGL support in EGL */
+struct st_api *
+st_api_create_OpenGL()
+{
+ return st_gl_api_create();
+}
-PUBLIC const struct st_module st_module_OpenGL = {
- .api = ST_API_OPENGL,
- .create_api = st_manager_create_api
-};
/* Helper function to choose and instantiate one of the software rasterizers:
* cell, llvmpipe, softpipe.
static struct xm_driver xlib_driver =
{
.create_pipe_screen = swrast_xlib_create_screen,
- .create_st_api = st_manager_create_api,
+ .create_st_api = st_gl_api_create,
};
--- /dev/null
+
+#ifndef ST_GL_API_H
+#define ST_GL_API_H
+
+#include "state_tracker/st_api.h"
+
+struct st_api * st_gl_api_create(void);
+
+#endif
* Chia-I Wu <olv@lunarg.com>
*/
-#include "state_tracker/st_api.h"
+#include "state_tracker/st_gl_api.h"
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
static void
st_api_destroy(struct st_api *stapi)
{
- FREE(stapi);
}
/**
return TRUE;
}
+struct st_api st_gl_api = {
+ st_api_destroy,
+ st_api_get_proc_address,
+ st_api_is_visual_supported,
+ st_api_create_context,
+ st_api_make_current,
+ st_api_get_current,
+};
+
/**
- * Create an st_api to manage the state tracker.
+ * Return the st_api for this state tracker. This might either be GL, GLES1,
+ * GLES2 that mostly depends on the build and link options. But these
+ * functions remain the same either way.
*/
struct st_api *
-st_manager_create_api(void)
+st_gl_api_create(void)
{
- struct st_api *stapi;
-
- stapi = CALLOC_STRUCT(st_api);
- if (stapi) {
- stapi->destroy = st_api_destroy;
- stapi->get_proc_address = st_api_get_proc_address;
- stapi->is_visual_supported = st_api_is_visual_supported;
-
- stapi->create_context = st_api_create_context;
- stapi->make_current = st_api_make_current;
- stapi->get_current = st_api_get_current;
- }
-
- return stapi;
+ return &st_gl_api;
}