st_context.c File Reference

Include dependency graph for st_context.c:

Go to the source code of this file.

Functions

void st_invalidate_state (GLcontext *ctx, GLuint new_state)
 Called via ctx->Driver.UpdateState().
int st_get_msaa (void)
 Check for multisample env var override.
static struct st_contextst_create_context_priv (GLcontext *ctx, struct pipe_context *pipe)
struct st_contextst_create_context (struct pipe_context *pipe, const __GLcontextModes *visual, struct st_context *share)
static void st_destroy_context_priv (struct st_context *st)
void st_destroy_context (struct st_context *st)
void st_make_current (struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read)
void st_copy_context_state (struct st_context *dst, struct st_context *src, uint mask)
st_proc st_get_proc_address (const char *procname)
void st_init_driver_functions (struct dd_function_table *functions)


Function Documentation

void st_copy_context_state ( struct st_context dst,
struct st_context src,
uint  mask 
)

Definition at line 278 of file st_context.c.

References st_context::ctx.

00281 {
00282    _mesa_copy_context(dst->ctx, src->ctx, mask);
00283 }

struct st_context* st_create_context ( struct pipe_context pipe,
const __GLcontextModes *  visual,
struct st_context share 
) [read]

Definition at line 167 of file st_context.c.

References st_context::ctx, st_create_context_priv(), and st_init_driver_functions().

00170 {
00171    GLcontext *ctx;
00172    GLcontext *shareCtx = share ? share->ctx : NULL;
00173    struct dd_function_table funcs;
00174 
00175    memset(&funcs, 0, sizeof(funcs));
00176    st_init_driver_functions(&funcs);
00177 
00178    ctx = _mesa_create_context(visual, shareCtx, &funcs, NULL);
00179 
00180    return st_create_context_priv(ctx, pipe);
00181 }

static struct st_context* st_create_context_priv ( GLcontext *  ctx,
struct pipe_context pipe 
) [static, read]

Definition at line 105 of file st_context.c.

References st_context::cache, CALLOC_STRUCT, st_context::cso_context, cso_create_context(), st_context::ctx, st_context::dirty, st_context::draw, draw_create(), draw_enable_line_stipple(), draw_enable_point_sprites(), draw_wide_line_threshold(), draw_wide_point_threshold(), FALSE, st_context::force_msaa, st_state_flags::mesa, st_context::pipe, PIPE_MAX_SAMPLERS, st_context::pixel_xfer, st_context::sampler_list, st_context::samplers, st_state_flags::st, st_get_msaa(), st_init_atoms(), st_init_bitmap(), st_init_blit(), st_init_clear(), st_init_draw(), st_init_extensions(), st_init_generate_mipmap(), st_init_limits(), and st_context::state.

00106 {
00107    uint i;
00108    struct st_context *st = CALLOC_STRUCT( st_context );
00109    
00110    ctx->st = st;
00111 
00112    st->ctx = ctx;
00113    st->pipe = pipe;
00114 
00115    /* state tracker needs the VBO module */
00116    _vbo_CreateContext(ctx);
00117 
00118 #if FEATURE_feedback || FEATURE_drawpix
00119    st->draw = draw_create(); /* for selection/feedback */
00120 
00121    /* Disable draw options that might convert points/lines to tris, etc.
00122     * as that would foul-up feedback/selection mode.
00123     */
00124    draw_wide_line_threshold(st->draw, 1000.0f);
00125    draw_wide_point_threshold(st->draw, 1000.0f);
00126    draw_enable_line_stipple(st->draw, FALSE);
00127    draw_enable_point_sprites(st->draw, FALSE);
00128 #endif
00129 
00130    st->dirty.mesa = ~0;
00131    st->dirty.st = ~0;
00132 
00133    st->cso_context = cso_create_context(pipe);
00134 
00135    st_init_atoms( st );
00136    st_init_bitmap(st);
00137    st_init_clear(st);
00138    st_init_draw( st );
00139    st_init_generate_mipmap(st);
00140    st_init_blit(st);
00141 
00142    for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
00143       st->state.sampler_list[i] = &st->state.samplers[i];
00144 
00145    /* we want all vertex data to be placed in buffer objects */
00146    vbo_use_buffer_objects(ctx);
00147 
00148    /* Need these flags:
00149     */
00150    st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
00151    st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
00152 
00153    st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
00154 
00155    st->pixel_xfer.cache = _mesa_new_program_cache();
00156 
00157    st->force_msaa = st_get_msaa();
00158 
00159    /* GL limits and extensions */
00160    st_init_limits(st);
00161    st_init_extensions(st);
00162 
00163    return st;
00164 }

void st_destroy_context ( struct st_context st  ) 

Definition at line 225 of file st_context.c.

References st_context::cache, st_context::cso_context, cso_destroy_context(), cso_release_all(), st_context::ctx, pipe_context::destroy, st_context::fp, st_context::pipe, st_context::pixel_xfer, st_destroy_context_priv(), st_reference_fragprog(), st_reference_vertprog(), and st_context::vp.

00226 {
00227    struct pipe_context *pipe = st->pipe;
00228    struct cso_context *cso = st->cso_context;
00229    GLcontext *ctx = st->ctx;
00230 
00231    /* need to unbind and destroy CSO objects before anything else */
00232    cso_release_all(st->cso_context);
00233 
00234    st_reference_fragprog(st, &st->fp, NULL);
00235    st_reference_vertprog(st, &st->vp, NULL);
00236 
00237    _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache);
00238 
00239    _vbo_DestroyContext(st->ctx);
00240 
00241    _mesa_free_context_data(ctx);
00242 
00243    st_destroy_context_priv(st);
00244 
00245    cso_destroy_context(cso);
00246 
00247    pipe->destroy( pipe );
00248 
00249    free(ctx);
00250 }

static void st_destroy_context_priv ( struct st_context st  )  [static]

Definition at line 184 of file st_context.c.

References pipe_constant_buffer::buffer, st_context::constants, st_context::ctx, st_context::default_texture, st_context::draw, draw_destroy(), Elements, st_context::pipe, pipe_buffer_reference(), pipe_texture_reference(), st_context::sampler_texture, pipe_context::screen, st_destroy_atoms(), st_destroy_bitmap(), st_destroy_blit(), st_destroy_clear(), st_destroy_draw(), st_destroy_drawpix(), st_destroy_generate_mipmap(), and st_context::state.

00185 {
00186    uint i;
00187 
00188 #if FEATURE_feedback || FEATURE_drawpix
00189    draw_destroy(st->draw);
00190 #endif
00191    st_destroy_atoms( st );
00192    st_destroy_draw( st );
00193    st_destroy_generate_mipmap(st);
00194 #if FEATURE_EXT_framebuffer_blit
00195    st_destroy_blit(st);
00196 #endif
00197    st_destroy_clear(st);
00198 #if FEATURE_drawpix
00199    st_destroy_bitmap(st);
00200    st_destroy_drawpix(st);
00201 #endif
00202 #ifdef FEATURE_OES_draw_texture
00203    st_destroy_drawtex(st);
00204 #endif
00205 
00206    for (i = 0; i < Elements(st->state.sampler_texture); i++) {
00207       pipe_texture_reference(&st->state.sampler_texture[i], NULL);
00208    }
00209 
00210    for (i = 0; i < Elements(st->state.constants); i++) {
00211       if (st->state.constants[i].buffer) {
00212          pipe_buffer_reference(st->pipe->screen, &st->state.constants[i].buffer, NULL);
00213       }
00214    }
00215 
00216    if (st->default_texture) {
00217       st->ctx->Driver.DeleteTexture(st->ctx, st->default_texture);
00218       st->default_texture = NULL;
00219    }
00220 
00221    free( st );
00222 }

int st_get_msaa ( void   ) 

Check for multisample env var override.

Definition at line 95 of file st_context.c.

00096 {
00097    const char *msaa = _mesa_getenv("__GL_FSAA_MODE");
00098    if (msaa)
00099       return atoi(msaa);
00100    return 0;
00101 }

st_proc st_get_proc_address ( const char *  procname  ) 

Definition at line 287 of file st_context.c.

00288 {
00289    return (st_proc) _glapi_get_proc_address(procname);
00290 }

void st_init_driver_functions ( struct dd_function_table *  functions  ) 

Definition at line 294 of file st_context.c.

References st_init_accum_functions(), st_init_bitmap_functions(), st_init_blit_functions(), st_init_bufferobject_functions(), st_init_clear_functions(), st_init_drawpixels_functions(), st_init_fbo_functions(), st_init_feedback_functions(), st_init_flush_functions(), st_init_get_functions(), st_init_program_functions(), st_init_query_functions(), st_init_rasterpos_functions(), st_init_readpixels_functions(), st_init_string_functions(), st_init_texture_functions(), and st_invalidate_state().

00295 {
00296    _mesa_init_glsl_driver_functions(functions);
00297 
00298 #if FEATURE_accum
00299    st_init_accum_functions(functions);
00300 #endif
00301 #if FEATURE_EXT_framebuffer_blit
00302    st_init_blit_functions(functions);
00303 #endif
00304    st_init_bufferobject_functions(functions);
00305    st_init_clear_functions(functions);
00306 #if FEATURE_drawpix
00307    st_init_bitmap_functions(functions);
00308    st_init_drawpixels_functions(functions);
00309    st_init_rasterpos_functions(functions);
00310 #endif
00311    st_init_fbo_functions(functions);
00312    st_init_get_functions(functions);
00313 #if FEATURE_feedback
00314    st_init_feedback_functions(functions);
00315 #endif
00316    st_init_program_functions(functions);
00317 #if FEATURE_ARB_occlusion_query
00318    st_init_query_functions(functions);
00319 #endif
00320    st_init_readpixels_functions(functions);
00321    st_init_texture_functions(functions);
00322    st_init_flush_functions(functions);
00323    st_init_string_functions(functions);
00324 
00325    functions->UpdateState = st_invalidate_state;
00326 }

void st_invalidate_state ( GLcontext *  ctx,
GLuint  new_state 
)

Called via ctx->Driver.UpdateState().

Definition at line 77 of file st_context.c.

References st_context::dirty, st_state_flags::mesa, st_state_flags::st, st_context(), and ST_NEW_MESA.

00078 {
00079    struct st_context *st = st_context(ctx);
00080 
00081    st->dirty.mesa |= new_state;
00082    st->dirty.st |= ST_NEW_MESA;
00083 
00084    /* This is the only core Mesa module we depend upon.
00085     * No longer use swrast, swsetup, tnl.
00086     */
00087    _vbo_InvalidateState(ctx, new_state);
00088 }

void st_make_current ( struct st_context st,
struct st_framebuffer draw,
struct st_framebuffer read 
)

Definition at line 253 of file st_context.c.

References st_framebuffer::Base, st_context::ctx, st_framebuffer::InitHeight, and st_framebuffer::InitWidth.

00256 {
00257    if (st) {
00258       GLboolean firstTime = st->ctx->FirstTimeCurrent;
00259       _mesa_make_current(st->ctx, &draw->Base, &read->Base);
00260       /* Need to initialize viewport here since draw->Base->Width/Height
00261        * will still be zero at this point.
00262        * This could be improved, but would require rather extensive work
00263        * elsewhere (allocate rb surface storage sooner)
00264        */
00265       if (firstTime) {
00266          GLuint w = draw->InitWidth, h = draw->InitHeight;
00267          _mesa_set_viewport(st->ctx, 0, 0, w, h);
00268          _mesa_set_scissor(st->ctx, 0, 0, w, h);
00269 
00270       }
00271    }
00272    else {
00273       _mesa_make_current(NULL, NULL, NULL);
00274    }
00275 }


Generated on Tue Sep 29 06:25:54 2009 for Gallium3D by  doxygen 1.5.4