diff options
author | Chia-I Wu <[email protected]> | 2010-09-10 10:31:06 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2010-09-10 15:37:43 +0800 |
commit | 4531356817ec8383ac35932903773de67af92e37 (patch) | |
tree | bb9c6262af2ca8261db6b0d325622d122ef04c70 /src/mesa/state_tracker/st_manager.c | |
parent | fcae8ca57512f84c51b7445456aab7ec92a21254 (diff) |
gallium: Add context profile support to st_api.
Add struct st_context_attribs to describe context profiles and
attributes. Modify st_api::create_context to take the new struct
instead of an st_visual.
st_context_attribs can be used to support GLX_ARB_create_context_profile
and GLX_EXT_create_context_es2_profile in the future. But the
motivation for doing it now is to be able to replace ST_API_OPENGL_ES1
and ST_API_OPENGL_ES2 by profiles.
Having 3 st_api's to provide OpenGL, OpenGL ES 1.1, and OpenGL ES 2.0 is
not a sane abstraction, since all of them share glapi for current
context/dispatch management.
Diffstat (limited to 'src/mesa/state_tracker/st_manager.c')
-rw-r--r-- | src/mesa/state_tracker/st_manager.c | 75 |
1 files changed, 55 insertions, 20 deletions
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index ccce574c364..8acd0938bb8 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -44,6 +44,7 @@ #include "main/framebuffer.h" #include "main/fbobject.h" #include "main/renderbuffer.h" +#include "main/version.h" #include "st_texture.h" #include "st_context.h" @@ -303,10 +304,6 @@ st_visual_to_context_mode(const struct st_visual *visual, { memset(mode, 0, sizeof(*mode)); - /* FBO-only context */ - if (!visual) - return; - if (st_visual_have_buffers(visual, ST_ATTACHMENT_BACK_LEFT_MASK)) mode->doubleBufferMode = GL_TRUE; if (st_visual_have_buffers(visual, @@ -612,26 +609,57 @@ st_context_destroy(struct st_context_iface *stctxi) } static struct st_context_iface * -create_context(gl_api api, struct st_manager *smapi, - const struct st_visual *visual, - struct st_context_iface *shared_stctxi) +st_api_create_context(struct st_api *stapi, struct st_manager *smapi, + const struct st_context_attribs *attribs, + struct st_context_iface *shared_stctxi) { struct st_context *shared_ctx = (struct st_context *) shared_stctxi; struct st_context *st; struct pipe_context *pipe; __GLcontextModes mode; + gl_api api; + + if (!(stapi->profile_mask & (1 << attribs->profile))) + return NULL; + + switch (attribs->profile) { + case ST_PROFILE_DEFAULT: + api = API_OPENGL; + break; + case ST_PROFILE_OPENGL_ES1: + api = API_OPENGLES; + break; + case ST_PROFILE_OPENGL_ES2: + api = API_OPENGLES2; + break; + case ST_PROFILE_OPENGL_CORE: + default: + return NULL; + break; + } pipe = smapi->screen->context_create(smapi->screen, NULL); if (!pipe) return NULL; - st_visual_to_context_mode(visual, &mode); + st_visual_to_context_mode(&attribs->visual, &mode); st = st_create_context(api, pipe, &mode, shared_ctx); if (!st) { pipe->destroy(pipe); return NULL; } + /* need to perform version check */ + if (attribs->major > 1 || attribs->minor > 0) { + _mesa_compute_version(st->ctx); + + if (st->ctx->VersionMajor < attribs->major || + st->ctx->VersionMajor < attribs->minor) { + st_destroy_context(st); + return NULL; + } + } + st->invalidate_on_gl_viewport = smapi->get_param(smapi, ST_MANAGER_BROKEN_INVALIDATE); @@ -647,27 +675,19 @@ create_context(gl_api api, struct st_manager *smapi, } static struct st_context_iface * -st_api_create_context(struct st_api *stapi, struct st_manager *smapi, - const struct st_visual *visual, - struct st_context_iface *shared_stctxi) -{ - return create_context(API_OPENGL, smapi, visual, shared_stctxi); -} - -static struct st_context_iface * st_api_create_context_es1(struct st_api *stapi, struct st_manager *smapi, - const struct st_visual *visual, + const struct st_context_attribs *attribs, struct st_context_iface *shared_stctxi) { - return create_context(API_OPENGLES, smapi, visual, shared_stctxi); + return st_api_create_context(stapi, smapi, attribs, shared_stctxi); } static struct st_context_iface * st_api_create_context_es2(struct st_api *stapi, struct st_manager *smapi, - const struct st_visual *visual, + const struct st_context_attribs *attribs, struct st_context_iface *shared_stctxi) { - return create_context(API_OPENGLES2, smapi, visual, shared_stctxi); + return st_api_create_context(stapi, smapi, attribs, shared_stctxi); } static boolean @@ -852,6 +872,17 @@ st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb, } static const struct st_api st_gl_api = { + ST_API_OPENGL, +#if FEATURE_GL + ST_PROFILE_DEFAULT_MASK | +#endif +#if FEATURE_ES1 + ST_PROFILE_OPENGL_ES1_MASK | +#endif +#if FEATURE_ES2 + ST_PROFILE_OPENGL_ES2_MASK | +#endif + 0, st_api_destroy, st_api_get_proc_address, st_api_create_context, @@ -860,6 +891,8 @@ static const struct st_api st_gl_api = { }; static const struct st_api st_gl_api_es1 = { + ST_API_OPENGL_ES1, + ST_PROFILE_OPENGL_ES1_MASK, st_api_destroy, st_api_get_proc_address, st_api_create_context_es1, @@ -868,6 +901,8 @@ static const struct st_api st_gl_api_es1 = { }; static const struct st_api st_gl_api_es2 = { + ST_API_OPENGL_ES2, + ST_PROFILE_OPENGL_ES2_MASK, st_api_destroy, st_api_get_proc_address, st_api_create_context_es2, |