blob: 2b962867704380800470b56d69f0f53cfa7d4f5a [file] [log] [blame]
Keith Whitwell8e4a95a2007-05-24 10:41:34 +01001/**************************************************************************
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"
Brian51b300c2007-08-02 10:29:50 -060031#include "st_cb_clear.h"
Brian184b6a12007-08-02 14:21:16 -060032#include "st_cb_drawpixels.h"
Brian4435bae2007-08-06 15:49:11 -060033#include "st_cb_texture.h"
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010034#include "st_atom.h"
35#include "st_draw.h"
36#include "st_program.h"
Keith Whitwell943964a2007-06-14 18:23:43 +010037#include "pipe/p_context.h"
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010038
39void st_invalidate_state(GLcontext * ctx, GLuint new_state)
40{
41 struct st_context *st = st_context(ctx);
42
43 st->dirty.mesa |= new_state;
44 st->dirty.st |= ST_NEW_MESA;
45}
46
47
48struct st_context *st_create_context( GLcontext *ctx,
Keith Whitwell943964a2007-06-14 18:23:43 +010049 struct pipe_context *pipe )
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010050{
51 struct st_context *st = CALLOC_STRUCT( st_context );
52
53 ctx->st = st;
54
55 st->ctx = ctx;
Keith Whitwell943964a2007-06-14 18:23:43 +010056 st->pipe = pipe;
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010057
58 st->dirty.mesa = ~0;
59 st->dirty.st = ~0;
60
61 st_init_atoms( st );
62 st_init_draw( st );
Brian61d02152007-08-02 20:40:19 -060063
Keith Whitwell4f442d92007-08-02 13:59:31 +010064 st_init_cb_clear( st );
Brian61d02152007-08-02 20:40:19 -060065 st_init_cb_program( st );
Brian184b6a12007-08-02 14:21:16 -060066 st_init_cb_drawpixels( st );
Brian4435bae2007-08-06 15:49:11 -060067 st_init_cb_texture( st );
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010068
69 return st;
70}
71
72
73void st_destroy_context( struct st_context *st )
74{
75 st_destroy_atoms( st );
76 st_destroy_draw( st );
Brian61d02152007-08-02 20:40:19 -060077
78 st_destroy_cb_clear( st );
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010079 st_destroy_cb_program( st );
Brian61d02152007-08-02 20:40:19 -060080 st_destroy_cb_drawpixels( st );
Brian4435bae2007-08-06 15:49:11 -060081 /*st_destroy_cb_teximage( st );*/
82 st_destroy_cb_texture( st );
Brian61d02152007-08-02 20:40:19 -060083
Keith Whitwell943964a2007-06-14 18:23:43 +010084 st->pipe->destroy( st->pipe );
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010085 FREE( st );
86}
87
88
89