X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fstate_tracker%2Fst_context.c;h=8514b6b3756bfd0ca5372594f2915741149216c9;hb=79892e7976fbb91ae426f5868d5f453e977c1f17;hp=cca808d3288e6b35274578a743466d2010ed7857;hpb=ef2bf418b45c7966e9fe78359058b8d44f570be1;p=mesa.git diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index cca808d3288..8514b6b3756 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -31,6 +31,7 @@ #include "main/matrix.h" #include "main/buffers.h" #include "main/scissor.h" +#include "main/viewport.h" #include "vbo/vbo.h" #include "shader/shader_api.h" #include "glapi/glapi.h" @@ -59,13 +60,13 @@ #include "st_cb_texture.h" #include "st_cb_flush.h" #include "st_cb_strings.h" +#include "st_cb_viewport.h" #include "st_atom.h" #include "st_draw.h" #include "st_extensions.h" #include "st_gen_mipmap.h" #include "st_program.h" #include "pipe/p_context.h" -#include "pipe/p_inlines.h" #include "draw/draw_context.h" #include "cso_cache/cso_cache.h" #include "cso_cache/cso_context.h" @@ -105,7 +106,7 @@ static struct st_context * st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) { uint i; - struct st_context *st = CALLOC_STRUCT( st_context ); + struct st_context *st = ST_CALLOC_STRUCT( st_context ); ctx->st = st; @@ -148,7 +149,6 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) /* Need these flags: */ st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; - st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE; st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; @@ -177,6 +177,12 @@ struct st_context *st_create_context(struct pipe_context *pipe, ctx = _mesa_create_context(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. + */ + if (debug_get_bool_option("MESA_MVP_DP4", FALSE)) + _mesa_set_mvp_with_dp4( ctx, GL_TRUE ); + return st_create_context_priv(ctx, pipe); } @@ -209,7 +215,7 @@ static void st_destroy_context_priv( struct st_context *st ) for (i = 0; i < Elements(st->state.constants); i++) { if (st->state.constants[i].buffer) { - pipe_buffer_reference(st->pipe->screen, &st->state.constants[i].buffer, NULL); + pipe_buffer_reference(&st->state.constants[i].buffer, NULL); } } @@ -218,7 +224,7 @@ static void st_destroy_context_priv( struct st_context *st ) st->default_texture = NULL; } - free( st ); + _mesa_free( st ); } @@ -227,6 +233,7 @@ void st_destroy_context( struct st_context *st ) struct pipe_context *pipe = st->pipe; struct cso_context *cso = st->cso_context; GLcontext *ctx = st->ctx; + GLuint i; /* need to unbind and destroy CSO objects before anything else */ cso_release_all(st->cso_context); @@ -234,6 +241,12 @@ void st_destroy_context( struct st_context *st ) st_reference_fragprog(st, &st->fp, NULL); st_reference_vertprog(st, &st->vp, NULL); + /* release framebuffer surfaces */ + for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + pipe_surface_reference(&st->state.framebuffer.cbufs[i], NULL); + } + pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL); + _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache); _vbo_DestroyContext(st->ctx); @@ -246,34 +259,39 @@ void st_destroy_context( struct st_context *st ) pipe->destroy( pipe ); - free(ctx); + _mesa_free(ctx); } -void st_make_current(struct st_context *st, - struct st_framebuffer *draw, - struct st_framebuffer *read) +GLboolean +st_make_current(struct st_context *st, + struct st_framebuffer *draw, + struct st_framebuffer *read) { + /* Call this periodically to detect when the user has begun using + * GL rendering from multiple threads. + */ + _glapi_check_multithread(); + if (st) { - GLboolean firstTime = st->ctx->FirstTimeCurrent; - _mesa_make_current(st->ctx, &draw->Base, &read->Base); - /* Need to initialize viewport here since draw->Base->Width/Height - * will still be zero at this point. - * This could be improved, but would require rather extensive work - * elsewhere (allocate rb surface storage sooner) - */ - if (firstTime) { - GLuint w = draw->InitWidth, h = draw->InitHeight; - _mesa_set_viewport(st->ctx, 0, 0, w, h); - _mesa_set_scissor(st->ctx, 0, 0, w, h); + if (!_mesa_make_current(st->ctx, &draw->Base, &read->Base)) + return GL_FALSE; - } + _mesa_check_init_viewport(st->ctx, draw->InitWidth, draw->InitHeight); + + return GL_TRUE; } else { - _mesa_make_current(NULL, NULL, NULL); + return _mesa_make_current(NULL, NULL, NULL); } } +struct st_context *st_get_current(void) +{ + GET_CURRENT_CONTEXT(ctx); + + return (ctx == NULL) ? NULL : ctx->st; +} void st_copy_context_state(struct st_context *dst, struct st_context *src, @@ -321,6 +339,7 @@ void st_init_driver_functions(struct dd_function_table *functions) st_init_texture_functions(functions); st_init_flush_functions(functions); st_init_string_functions(functions); + st_init_viewport_functions(functions); functions->UpdateState = st_invalidate_state; }