Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 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" |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 31 | #include "st_cb_bufferobjects.h" |
Brian | 51b300c | 2007-08-02 10:29:50 -0600 | [diff] [blame] | 32 | #include "st_cb_clear.h" |
Brian | 184b6a1 | 2007-08-02 14:21:16 -0600 | [diff] [blame] | 33 | #include "st_cb_drawpixels.h" |
Brian | 64da751 | 2007-08-09 12:27:44 -0600 | [diff] [blame^] | 34 | #include "st_cb_fbo.h" |
Brian | 4435bae | 2007-08-06 15:49:11 -0600 | [diff] [blame] | 35 | #include "st_cb_texture.h" |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 36 | #include "st_atom.h" |
| 37 | #include "st_draw.h" |
| 38 | #include "st_program.h" |
Keith Whitwell | 943964a | 2007-06-14 18:23:43 +0100 | [diff] [blame] | 39 | #include "pipe/p_context.h" |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 40 | |
| 41 | void 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 | |
| 50 | struct st_context *st_create_context( GLcontext *ctx, |
Keith Whitwell | 943964a | 2007-06-14 18:23:43 +0100 | [diff] [blame] | 51 | struct pipe_context *pipe ) |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 52 | { |
| 53 | struct st_context *st = CALLOC_STRUCT( st_context ); |
| 54 | |
| 55 | ctx->st = st; |
| 56 | |
| 57 | st->ctx = ctx; |
Keith Whitwell | 943964a | 2007-06-14 18:23:43 +0100 | [diff] [blame] | 58 | st->pipe = pipe; |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 59 | |
| 60 | st->dirty.mesa = ~0; |
| 61 | st->dirty.st = ~0; |
| 62 | |
| 63 | st_init_atoms( st ); |
| 64 | st_init_draw( st ); |
Brian | 61d0215 | 2007-08-02 20:40:19 -0600 | [diff] [blame] | 65 | |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 66 | /* Need these flags: |
| 67 | */ |
| 68 | st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; |
| 69 | st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE; |
| 70 | |
| 71 | #if 0 |
Keith Whitwell | 4f442d9 | 2007-08-02 13:59:31 +0100 | [diff] [blame] | 72 | st_init_cb_clear( st ); |
Brian | 61d0215 | 2007-08-02 20:40:19 -0600 | [diff] [blame] | 73 | st_init_cb_program( st ); |
Brian | 184b6a1 | 2007-08-02 14:21:16 -0600 | [diff] [blame] | 74 | st_init_cb_drawpixels( st ); |
Brian | 4435bae | 2007-08-06 15:49:11 -0600 | [diff] [blame] | 75 | st_init_cb_texture( st ); |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 76 | #endif |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 77 | |
| 78 | return st; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | void st_destroy_context( struct st_context *st ) |
| 83 | { |
| 84 | st_destroy_atoms( st ); |
| 85 | st_destroy_draw( st ); |
Brian | 61d0215 | 2007-08-02 20:40:19 -0600 | [diff] [blame] | 86 | |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 87 | #if 0 |
Brian | 61d0215 | 2007-08-02 20:40:19 -0600 | [diff] [blame] | 88 | st_destroy_cb_clear( st ); |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 89 | st_destroy_cb_program( st ); |
Brian | 61d0215 | 2007-08-02 20:40:19 -0600 | [diff] [blame] | 90 | st_destroy_cb_drawpixels( st ); |
Brian | 4435bae | 2007-08-06 15:49:11 -0600 | [diff] [blame] | 91 | /*st_destroy_cb_teximage( st );*/ |
| 92 | st_destroy_cb_texture( st ); |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 93 | #endif |
Brian | 61d0215 | 2007-08-02 20:40:19 -0600 | [diff] [blame] | 94 | |
Keith Whitwell | 943964a | 2007-06-14 18:23:43 +0100 | [diff] [blame] | 95 | st->pipe->destroy( st->pipe ); |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 96 | FREE( st ); |
| 97 | } |
| 98 | |
| 99 | |
| 100 | |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 101 | void 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); |
Brian | 64da751 | 2007-08-09 12:27:44 -0600 | [diff] [blame^] | 106 | st_init_fbo_functions(functions); |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 107 | st_init_program_functions(functions); |
| 108 | st_init_texture_functions(functions); |
| 109 | } |