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.
This commit is contained in:
@@ -42,14 +42,6 @@
|
||||
* 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.
|
||||
*/
|
||||
@@ -378,17 +370,6 @@ struct st_api
|
||||
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.
|
||||
*/
|
||||
@@ -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_ */
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
return stapi;
|
||||
}
|
||||
|
||||
PUBLIC const struct st_module st_module_OpenVG = {
|
||||
.api = ST_API_OPENVG,
|
||||
.create_api = vg_module_create_api,
|
||||
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,
|
||||
};
|
||||
|
||||
struct st_api *
|
||||
st_api_create_OpenVG(void)
|
||||
{
|
||||
return &st_vg_api;
|
||||
}
|
||||
|
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
|
9
src/mesa/state_tracker/st_gl_api.h
Normal file
9
src/mesa/state_tracker/st_gl_api.h
Normal file
@@ -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
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user