st_context.c revision 39407fd85467141fceafbedf52d9e55e008eb011
1/************************************************************************** 2 * 3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28#include "imports.h" 29#include "st_public.h" 30#include "st_context.h" 31#include "st_cb_bufferobjects.h" 32#include "st_cb_clear.h" 33#include "st_cb_drawpixels.h" 34#include "st_cb_fbo.h" 35#include "st_cb_readpixels.h" 36#include "st_cb_texture.h" 37#include "st_cb_flush.h" 38#include "st_cb_strings.h" 39#include "st_atom.h" 40#include "st_draw.h" 41#include "st_program.h" 42#include "pipe/p_context.h" 43 44 45void st_invalidate_state(GLcontext * ctx, GLuint new_state) 46{ 47 struct st_context *st = st_context(ctx); 48 49 st->dirty.mesa |= new_state; 50 st->dirty.st |= ST_NEW_MESA; 51} 52 53 54struct st_context *st_create_context( GLcontext *ctx, 55 struct pipe_context *pipe ) 56{ 57 struct st_context *st = CALLOC_STRUCT( st_context ); 58 59 ctx->st = st; 60 61 st->ctx = ctx; 62 st->pipe = pipe; 63 64 st->dirty.mesa = ~0; 65 st->dirty.st = ~0; 66 67 st_init_atoms( st ); 68 st_init_draw( st ); 69 70 /* Need these flags: 71 */ 72 st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; 73 st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE; 74 75#if 0 76 st_init_cb_clear( st ); 77 st_init_cb_program( st ); 78 st_init_cb_drawpixels( st ); 79 st_init_cb_texture( st ); 80#endif 81 82 return st; 83} 84 85 86void st_destroy_context( struct st_context *st ) 87{ 88 st_destroy_atoms( st ); 89 st_destroy_draw( st ); 90 91#if 0 92 st_destroy_cb_clear( st ); 93 st_destroy_cb_program( st ); 94 st_destroy_cb_drawpixels( st ); 95 /*st_destroy_cb_teximage( st );*/ 96 st_destroy_cb_texture( st ); 97#endif 98 99 st->pipe->destroy( st->pipe ); 100 FREE( st ); 101} 102 103 104 105void st_init_driver_functions(struct dd_function_table *functions) 106{ 107 st_init_bufferobject_functions(functions); 108 st_init_clear_functions(functions); 109 st_init_drawpixels_functions(functions); 110 st_init_fbo_functions(functions); 111 st_init_program_functions(functions); 112 st_init_readpixels_functions(functions); 113 st_init_texture_functions(functions); 114 st_init_flush_functions(functions); 115 st_init_string_functions(functions); 116} 117