1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #include "main/imports.h"
29 #include "main/context.h"
30 #include "main/extensions.h"
32 #include "st_public.h"
33 #include "st_context.h"
34 #include "st_cb_accum.h"
35 #include "st_cb_bufferobjects.h"
36 #include "st_cb_clear.h"
37 #include "st_cb_drawpixels.h"
38 #include "st_cb_fbo.h"
39 #include "st_cb_feedback.h"
40 #include "st_cb_queryobj.h"
41 #include "st_cb_rasterpos.h"
42 #include "st_cb_readpixels.h"
43 #include "st_cb_texture.h"
44 #include "st_cb_flush.h"
45 #include "st_cb_strings.h"
48 #include "st_program.h"
49 #include "pipe/p_context.h"
50 #include "pipe/draw/draw_context.h"
51 #include "pipe/cso_cache/cso_cache.h"
55 * Called via ctx->Driver.UpdateState()
57 void st_invalidate_state(GLcontext
* ctx
, GLuint new_state
)
59 struct st_context
*st
= st_context(ctx
);
61 st
->dirty
.mesa
|= new_state
;
62 st
->dirty
.st
|= ST_NEW_MESA
;
64 /* This is the only core Mesa module we depend upon.
65 * No longer use swrast, swsetup, tnl.
67 _vbo_InvalidateState(ctx
, new_state
);
71 struct st_context
*st_create_context2(struct pipe_context
*pipe
,
72 const GLvisual
*visual
,
73 struct st_context
*share
)
76 GLcontext
*shareCtx
= share
? share
->ctx
: NULL
;
77 struct dd_function_table funcs
;
79 memset(&funcs
, 0, sizeof(funcs
));
80 st_init_driver_functions(&funcs
);
82 ctx
= _mesa_create_context(visual
, shareCtx
, &funcs
, NULL
);
84 return st_create_context(ctx
, pipe
);
88 struct st_context
*st_create_context( GLcontext
*ctx
,
89 struct pipe_context
*pipe
)
91 struct st_context
*st
= CALLOC_STRUCT( st_context
);
98 /* state tracker needs the VBO module */
99 _vbo_CreateContext(ctx
);
101 st
->draw
= draw_create(); /* for selection/feedback */
106 st
->cache
= cso_cache_create();
111 /* we want all vertex data to be placed in buffer objects */
112 vbo_use_buffer_objects(ctx
);
116 st
->ctx
->FragmentProgram
._MaintainTexEnvProgram
= GL_TRUE
;
117 st
->ctx
->FragmentProgram
._UseTexEnvProgram
= GL_TRUE
;
119 st
->ctx
->VertexProgram
._MaintainTnlProgram
= GL_TRUE
;
121 st
->haveFramebufferRegions
= GL_TRUE
;
123 st
->pixel_xfer
.cache
= _mesa_new_program_cache();
125 /* XXXX This is temporary! */
126 _mesa_enable_sw_extensions(ctx
);
132 void st_destroy_context2( struct st_context
*st
)
134 GLcontext
*ctx
= st
->ctx
;
135 _mesa_free_context_data(ctx
);
136 st_destroy_context(st
);
141 void st_destroy_context( struct st_context
*st
)
143 draw_destroy(st
->draw
);
144 st_destroy_atoms( st
);
145 st_destroy_draw( st
);
147 _vbo_DestroyContext(st
->ctx
);
149 cso_cache_delete( st
->cache
);
151 _mesa_delete_program_cache(st
->ctx
, st
->pixel_xfer
.cache
);
153 st
->pipe
->destroy( st
->pipe
);
158 struct st_framebuffer
*st_create_framebuffer( const __GLcontextModes
*visual
)
160 struct st_framebuffer
*stfb
161 = CALLOC_STRUCT(st_framebuffer
);
168 void st_make_current(struct st_context
*st
,
169 struct st_framebuffer
*draw
,
170 struct st_framebuffer
*read
)
173 _mesa_make_current(st
->ctx
, &draw
->Base
, &read
->Base
);
176 _mesa_make_current(NULL
, NULL
, NULL
);
182 void st_init_driver_functions(struct dd_function_table
*functions
)
184 st_init_accum_functions(functions
);
185 st_init_bufferobject_functions(functions
);
186 st_init_clear_functions(functions
);
187 st_init_drawpixels_functions(functions
);
188 st_init_fbo_functions(functions
);
189 st_init_feedback_functions(functions
);
190 st_init_program_functions(functions
);
191 st_init_query_functions(functions
);
192 st_init_rasterpos_functions(functions
);
193 st_init_readpixels_functions(functions
);
194 st_init_texture_functions(functions
);
195 st_init_flush_functions(functions
);
196 st_init_string_functions(functions
);
198 functions
->UpdateState
= st_invalidate_state
;