diff options
author | Jakob Bornecrantz <[email protected]> | 2010-04-24 01:05:49 +0100 |
---|---|---|
committer | Jakob Bornecrantz <[email protected]> | 2010-04-26 00:40:17 +0100 |
commit | 0c572c6828b6a338b07a6860280b3a314a81662e (patch) | |
tree | 749dc6f81128f7a1b16953fad240f53108b4f8a4 /src/gallium | |
parent | 81ab19de04e623d24cb65ad1ed3b240bce78235b (diff) |
st_api: Remove st_module
The struct st_module isn't needed as it is the same thing as the st_api
struct. That is they both represent the API. Instead just use a single
function entry point to the the API.
Diffstat (limited to 'src/gallium')
-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 |
7 files changed, 62 insertions, 82 deletions
diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 8897ff7c259..002d1c6b840 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 261bae75a28..f9295cb4ca8 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 57a479f6bca..47ecc503eb7 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 4e89e06b34c..825fdac2150 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 82e88b176ac..5c773aaf93b 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 e4226754d13..aecac28e7ee 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 48e5bdff429..69b4ddd33f7 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, }; |