blob: 9f7916e40e80641992ba2be2489bae3d1585839f [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"
Brian6da92342007-08-06 20:53:28 +010031#include "st_cb_bufferobjects.h"
Brian51b300c2007-08-02 10:29:50 -060032#include "st_cb_clear.h"
Brian184b6a12007-08-02 14:21:16 -060033#include "st_cb_drawpixels.h"
Brian64da7512007-08-09 12:27:44 -060034#include "st_cb_fbo.h"
Brian4435bae2007-08-06 15:49:11 -060035#include "st_cb_texture.h"
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010036#include "st_atom.h"
37#include "st_draw.h"
38#include "st_program.h"
Keith Whitwell943964a2007-06-14 18:23:43 +010039#include "pipe/p_context.h"
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010040
41void st_invalidate_state(GLcontext * ctx, GLuint new_state)
42{
43 struct st_context *st = st_context(ctx);
44
45 st->dirty.mesa |= new_state;
46 st->dirty.st |= ST_NEW_MESA;
47}
48
49
50struct st_context *st_create_context( GLcontext *ctx,
Keith Whitwell943964a2007-06-14 18:23:43 +010051 struct pipe_context *pipe )
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010052{
53 struct st_context *st = CALLOC_STRUCT( st_context );
54
55 ctx->st = st;
56
57 st->ctx = ctx;
Keith Whitwell943964a2007-06-14 18:23:43 +010058 st->pipe = pipe;
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010059
60 st->dirty.mesa = ~0;
61 st->dirty.st = ~0;
62
63 st_init_atoms( st );
64 st_init_draw( st );
Brian61d02152007-08-02 20:40:19 -060065
Brian6da92342007-08-06 20:53:28 +010066 /* Need these flags:
67 */
68 st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
69 st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
70
71#if 0
Keith Whitwell4f442d92007-08-02 13:59:31 +010072 st_init_cb_clear( st );
Brian61d02152007-08-02 20:40:19 -060073 st_init_cb_program( st );
Brian184b6a12007-08-02 14:21:16 -060074 st_init_cb_drawpixels( st );
Brian4435bae2007-08-06 15:49:11 -060075 st_init_cb_texture( st );
Brian6da92342007-08-06 20:53:28 +010076#endif
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010077
78 return st;
79}
80
81
82void st_destroy_context( struct st_context *st )
83{
84 st_destroy_atoms( st );
85 st_destroy_draw( st );
Brian61d02152007-08-02 20:40:19 -060086
Brian6da92342007-08-06 20:53:28 +010087#if 0
Brian61d02152007-08-02 20:40:19 -060088 st_destroy_cb_clear( st );
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010089 st_destroy_cb_program( st );
Brian61d02152007-08-02 20:40:19 -060090 st_destroy_cb_drawpixels( st );
Brian4435bae2007-08-06 15:49:11 -060091 /*st_destroy_cb_teximage( st );*/
92 st_destroy_cb_texture( st );
Brian6da92342007-08-06 20:53:28 +010093#endif
Brian61d02152007-08-02 20:40:19 -060094
Keith Whitwell943964a2007-06-14 18:23:43 +010095 st->pipe->destroy( st->pipe );
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010096 FREE( st );
97}
98
99
100
Brian6da92342007-08-06 20:53:28 +0100101void st_init_driver_functions(struct dd_function_table *functions)
102{
103 st_init_bufferobject_functions(functions);
104 st_init_clear_functions(functions);
105 st_init_drawpixels_functions(functions);
Brian64da7512007-08-09 12:27:44 -0600106 st_init_fbo_functions(functions);
Brian6da92342007-08-06 20:53:28 +0100107 st_init_program_functions(functions);
108 st_init_texture_functions(functions);
109}