Browse Source

st/mesa: Add support for multiple APIs.

Add st_gl_api_create_es1 and st_gl_api_create_es2 to create OpeGL ES 1.1
and OpenGL ES 2.0 contexts respectively.
tags/mesa-7.9-rc1
Chia-I Wu 15 years ago
parent
commit
57c654324f

+ 2
- 11
src/mesa/state_tracker/st_context.c View File

@@ -153,7 +153,7 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
}


struct st_context *st_create_context(struct pipe_context *pipe,
struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
const __GLcontextModes *visual,
struct st_context *share)
{
@@ -164,16 +164,7 @@ struct st_context *st_create_context(struct pipe_context *pipe,
memset(&funcs, 0, sizeof(funcs));
st_init_driver_functions(&funcs);

#if FEATURE_GL
ctx = _mesa_create_context_for_api(API_OPENGL,
visual, shareCtx, &funcs, NULL);
#elif FEATURE_ES1
ctx = _mesa_create_context_for_api(API_OPENGLES,
visual, shareCtx, &funcs, NULL);
#elif FEATURE_ES2
ctx = _mesa_create_context_for_api(API_OPENGLES2,
visual, shareCtx, &funcs, NULL);
#endif
ctx = _mesa_create_context_for_api(api, visual, shareCtx, &funcs, NULL);

/* XXX: need a capability bit in gallium to query if the pipe
* driver prefers DP4 or MUL/MAD for vertex transformation.

+ 2
- 1
src/mesa/state_tracker/st_context.h View File

@@ -261,7 +261,8 @@ extern int
st_get_msaa(void);

extern struct st_context *
st_create_context(struct pipe_context *pipe, const __GLcontextModes *visual,
st_create_context(gl_api api, struct pipe_context *pipe,
const __GLcontextModes *visual,
struct st_context *share);

extern void

+ 3
- 1
src/mesa/state_tracker/st_gl_api.h View File

@@ -4,6 +4,8 @@

#include "state_tracker/st_api.h"

struct st_api * st_gl_api_create(void);
struct st_api *st_gl_api_create(void);
struct st_api *st_gl_api_create_es1(void);
struct st_api *st_gl_api_create_es2(void);

#endif

+ 75
- 20
src/mesa/state_tracker/st_manager.c View File

@@ -48,17 +48,9 @@
#include "st_context.h"
#include "st_format.h"
#include "st_cb_fbo.h"
#include "st_cb_flush.h"
#include "st_manager.h"

/* these functions are defined in st_context.c */
struct st_context *
st_create_context(struct pipe_context *pipe,
const __GLcontextModes *visual,
struct st_context *share);
void st_destroy_context(struct st_context *st);
void st_flush(struct st_context *st, uint pipeFlushFlags,
struct pipe_fence_handle **fence);

/**
* Cast wrapper to convert a GLframebuffer to an st_framebuffer.
* Return NULL if the GLframebuffer is a user-created framebuffer.
@@ -603,9 +595,9 @@ st_context_destroy(struct st_context_iface *stctxi)
}

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)
create_context(gl_api api, struct st_manager *smapi,
const struct st_visual *visual,
struct st_context_iface *shared_stctxi)
{
struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
struct st_context *st;
@@ -617,7 +609,7 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
return NULL;

st_visual_to_context_mode(visual, &mode);
st = st_create_context(pipe, &mode, shared_ctx);
st = st_create_context(api, pipe, &mode, shared_ctx);
if (!st) {
pipe->destroy(pipe);
return NULL;
@@ -637,6 +629,30 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
return &st->iface;
}

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,
struct st_context_iface *shared_stctxi)
{
return create_context(API_OPENGLES, smapi, visual, 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,
struct st_context_iface *shared_stctxi)
{
return create_context(API_OPENGLES2, smapi, visual, shared_stctxi);
}

static boolean
st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
struct st_framebuffer_iface *stdrawi,
@@ -812,7 +828,7 @@ st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb,
return TRUE;
}

struct st_api st_gl_api = {
static const struct st_api st_gl_api = {
st_api_destroy,
st_api_get_proc_address,
st_api_create_context,
@@ -820,13 +836,52 @@ struct st_api st_gl_api = {
st_api_get_current,
};

/**
* 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.
*/
static const struct st_api st_gl_api_es1 = {
st_api_destroy,
st_api_get_proc_address,
st_api_create_context_es1,
st_api_make_current,
st_api_get_current,
};

static const struct st_api st_gl_api_es2 = {
st_api_destroy,
st_api_get_proc_address,
st_api_create_context_es2,
st_api_make_current,
st_api_get_current,
};

struct st_api *
st_gl_api_create(void)
{
return &st_gl_api;
(void) st_gl_api;
(void) st_gl_api_es1;
(void) st_gl_api_es2;

#if FEATURE_GL
return (struct st_api *) &st_gl_api;
#else
return NULL;
#endif
}

struct st_api *
st_gl_api_create_es1(void)
{
#if FEATURE_ES1
return (struct st_api *) &st_gl_api_es1;
#else
return NULL;
#endif
}

struct st_api *
st_gl_api_create_es2(void)
{
#if FEATURE_ES2
return (struct st_api *) &st_gl_api_es2;
#else
return NULL;
#endif
}

+ 0
- 3
src/mesa/state_tracker/st_manager.h View File

@@ -46,7 +46,4 @@ boolean
st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb,
gl_buffer_index idx);

struct st_api *
st_manager_create_api(void);

#endif /* ST_MANAGER_H */

Loading…
Cancel
Save