diff options
-rw-r--r-- | src/gallium/include/state_tracker/st_api.h | 35 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/common/dri_st_api.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/common/egl_g3d_st.c | 29 | ||||
-rw-r--r-- | src/gallium/state_trackers/es/st_es1.c | 13 | ||||
-rw-r--r-- | src/gallium/state_trackers/es/st_es2.c | 14 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/vg_manager.c | 33 | ||||
-rw-r--r-- | src/gallium/targets/libgl-xlib/xlib.c | 16 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_gl_api.h | 9 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_manager.c | 33 |
9 files changed, 86 insertions, 100 deletions
diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 8897ff7c25..002d1c6b84 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -43,14 +43,6 @@ */ /** - * 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. */ enum st_api_type { @@ -379,17 +371,6 @@ struct st_api }; /** - * 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. */ static INLINE boolean @@ -399,9 +380,17 @@ st_visual_have_buffers(const struct st_visual *visual, unsigned mask) } /* 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_ */ diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c index 261bae75a2..f9295cb4ca 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.c +++ b/src/gallium/state_trackers/dri/common/dri_st_api.c @@ -30,7 +30,7 @@ #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" @@ -208,7 +208,7 @@ _dri_get_st_api(void) { 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(); } /** diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c index 57a479f6bc..47ecc503eb 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c @@ -49,41 +49,42 @@ egl_g3d_st_manager(struct st_manager *smapi) 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 diff --git a/src/gallium/state_trackers/es/st_es1.c b/src/gallium/state_trackers/es/st_es1.c index 4e89e06b34..825fdac215 100644 --- a/src/gallium/state_trackers/es/st_es1.c +++ b/src/gallium/state_trackers/es/st_es1.c @@ -1,8 +1,7 @@ -#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(); +} diff --git a/src/gallium/state_trackers/es/st_es2.c b/src/gallium/state_trackers/es/st_es2.c index 82e88b176a..5c773aaf93 100644 --- a/src/gallium/state_trackers/es/st_es2.c +++ b/src/gallium/state_trackers/es/st_es2.c @@ -1,8 +1,8 @@ -#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(); +} diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c index e4226754d1..aecac28e7e 100644 --- a/src/gallium/state_trackers/vega/vg_manager.c +++ b/src/gallium/state_trackers/vega/vg_manager.c @@ -546,26 +546,17 @@ vg_api_destroy(struct st_api *stapi) 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, -}; diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 48e5bdff42..69b4ddd33f 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -36,15 +36,15 @@ #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. @@ -151,7 +151,7 @@ fail: 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, }; diff --git a/src/mesa/state_tracker/st_gl_api.h b/src/mesa/state_tracker/st_gl_api.h new file mode 100644 index 0000000000..52c3fa0b41 --- /dev/null +++ b/src/mesa/state_tracker/st_gl_api.h @@ -0,0 +1,9 @@ + +#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 diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 5cf17fe530..44d59d4476 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -26,7 +26,7 @@ * 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" @@ -692,7 +692,6 @@ st_api_get_proc_address(struct st_api *stapi, const char *procname) static void st_api_destroy(struct st_api *stapi) { - FREE(stapi); } /** @@ -791,24 +790,22 @@ st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb, 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; } |