Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
Brian | c6499a7 | 2007-11-05 18:04:30 -0700 | [diff] [blame] | 3 | * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 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 | |
Brian | 1e6d1ab | 2007-08-17 15:27:18 +0100 | [diff] [blame] | 28 | #include "main/imports.h" |
Brian Paul | 122c676 | 2011-12-03 10:04:18 -0700 | [diff] [blame] | 29 | #include "main/accum.h" |
Brian | 80d2658 | 2007-11-01 17:46:04 -0600 | [diff] [blame] | 30 | #include "main/context.h" |
Brian Paul | 34a5d3b | 2011-04-10 12:48:28 -0600 | [diff] [blame] | 31 | #include "main/samplerobj.h" |
Brian Paul | a37b221 | 2010-06-10 20:23:03 -0600 | [diff] [blame] | 32 | #include "main/shaderobj.h" |
Vinson Lee | 9c98e9e | 2010-08-04 21:17:13 -0700 | [diff] [blame] | 33 | #include "program/prog_cache.h" |
Brian | 1e6d1ab | 2007-08-17 15:27:18 +0100 | [diff] [blame] | 34 | #include "vbo/vbo.h" |
Brian Paul | 5ebd849 | 2008-06-17 14:27:36 -0600 | [diff] [blame] | 35 | #include "glapi/glapi.h" |
Chia-I Wu | de8a879 | 2010-02-07 19:20:52 +0800 | [diff] [blame] | 36 | #include "st_context.h" |
Keith Whitwell | b02ef74 | 2009-10-05 15:50:11 +0100 | [diff] [blame] | 37 | #include "st_debug.h" |
Brian | f6cd377 | 2008-03-20 14:50:17 -0600 | [diff] [blame] | 38 | #include "st_cb_bitmap.h" |
Brian | 0df877a | 2008-03-18 17:16:23 -0600 | [diff] [blame] | 39 | #include "st_cb_blit.h" |
Brian | f6cd377 | 2008-03-20 14:50:17 -0600 | [diff] [blame] | 40 | #include "st_cb_bufferobjects.h" |
Brian | 51b300c | 2007-08-02 10:29:50 -0600 | [diff] [blame] | 41 | #include "st_cb_clear.h" |
Brian Paul | c9b5583 | 2009-12-31 14:47:21 -0700 | [diff] [blame] | 42 | #include "st_cb_condrender.h" |
Brian | 184b6a1 | 2007-08-02 14:21:16 -0600 | [diff] [blame] | 43 | #include "st_cb_drawpixels.h" |
Brian Paul | d7a4d49 | 2008-06-20 08:09:59 -0600 | [diff] [blame] | 44 | #include "st_cb_rasterpos.h" |
Brian Paul | 4424c66 | 2008-08-12 18:02:44 -0600 | [diff] [blame] | 45 | #include "st_cb_drawtex.h" |
Chia-I Wu | a1aa53b | 2010-02-25 23:10:47 +0800 | [diff] [blame] | 46 | #include "st_cb_eglimage.h" |
Brian | 64da751 | 2007-08-09 12:27:44 -0600 | [diff] [blame] | 47 | #include "st_cb_fbo.h" |
Brian | b4bacd1 | 2007-09-17 14:24:11 -0600 | [diff] [blame] | 48 | #include "st_cb_feedback.h" |
Brian Paul | 22a3d02 | 2008-03-24 11:55:29 -0600 | [diff] [blame] | 49 | #include "st_cb_program.h" |
Brian | 2486474 | 2007-08-11 19:57:37 +0100 | [diff] [blame] | 50 | #include "st_cb_queryobj.h" |
Brian | 6f27aab | 2007-08-10 11:37:21 -0600 | [diff] [blame] | 51 | #include "st_cb_readpixels.h" |
Brian | 4435bae | 2007-08-06 15:49:11 -0600 | [diff] [blame] | 52 | #include "st_cb_texture.h" |
Brian Paul | fef6e36 | 2010-05-10 21:11:21 -0600 | [diff] [blame] | 53 | #include "st_cb_xformfb.h" |
Keith Whitwell | 5c2c056 | 2007-08-10 12:57:14 +0100 | [diff] [blame] | 54 | #include "st_cb_flush.h" |
Marek Olšák | 5257a6d | 2011-03-05 20:32:28 +0100 | [diff] [blame] | 55 | #include "st_cb_syncobj.h" |
Keith Whitwell | 39407fd | 2007-08-10 16:42:26 +0100 | [diff] [blame] | 56 | #include "st_cb_strings.h" |
Marek Olšák | aea4ed4 | 2011-03-08 11:32:35 +0100 | [diff] [blame] | 57 | #include "st_cb_texturebarrier.h" |
Jakob Bornecrantz | a93f9f3 | 2010-05-21 20:37:23 +0100 | [diff] [blame] | 58 | #include "st_cb_viewport.h" |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 59 | #include "st_atom.h" |
| 60 | #include "st_draw.h" |
Brian | c6499a7 | 2007-11-05 18:04:30 -0700 | [diff] [blame] | 61 | #include "st_extensions.h" |
Brian | 62abcb9 | 2008-02-08 14:54:18 -0700 | [diff] [blame] | 62 | #include "st_gen_mipmap.h" |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 63 | #include "st_program.h" |
Keith Whitwell | 943964a | 2007-06-14 18:23:43 +0100 | [diff] [blame] | 64 | #include "pipe/p_context.h" |
José Fonseca | 2848688 | 2010-02-02 14:42:17 +0000 | [diff] [blame] | 65 | #include "util/u_inlines.h" |
Brian | 339e7ec | 2008-03-11 18:54:31 -0600 | [diff] [blame] | 66 | #include "cso_cache/cso_context.h" |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 67 | |
Brian | 6f27aab | 2007-08-10 11:37:21 -0600 | [diff] [blame] | 68 | |
Brian Paul | 6b97fe5 | 2010-08-06 15:09:51 -0600 | [diff] [blame] | 69 | DEBUG_GET_ONCE_BOOL_OPTION(mesa_mvp_dp4, "MESA_MVP_DP4", FALSE) |
Jakob Bornecrantz | 99611f0 | 2010-08-05 17:13:41 -0700 | [diff] [blame] | 70 | |
| 71 | |
Brian | d775509 | 2007-10-31 11:08:07 -0600 | [diff] [blame] | 72 | /** |
| 73 | * Called via ctx->Driver.UpdateState() |
| 74 | */ |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 75 | void st_invalidate_state(struct gl_context * ctx, GLuint new_state) |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 76 | { |
| 77 | struct st_context *st = st_context(ctx); |
| 78 | |
| 79 | st->dirty.mesa |= new_state; |
| 80 | st->dirty.st |= ST_NEW_MESA; |
Brian | d775509 | 2007-10-31 11:08:07 -0600 | [diff] [blame] | 81 | |
| 82 | /* This is the only core Mesa module we depend upon. |
| 83 | * No longer use swrast, swsetup, tnl. |
| 84 | */ |
| 85 | _vbo_InvalidateState(ctx, new_state); |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | |
Brian Paul | 1a820f5 | 2008-09-17 14:32:33 -0600 | [diff] [blame] | 89 | /** |
| 90 | * Check for multisample env var override. |
| 91 | */ |
| 92 | int |
| 93 | st_get_msaa(void) |
| 94 | { |
| 95 | const char *msaa = _mesa_getenv("__GL_FSAA_MODE"); |
| 96 | if (msaa) |
| 97 | return atoi(msaa); |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 102 | static struct st_context * |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 103 | st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe ) |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 104 | { |
Brian | 339e7ec | 2008-03-11 18:54:31 -0600 | [diff] [blame] | 105 | uint i; |
Brian Paul | f1a59a6 | 2009-02-12 10:14:36 -0700 | [diff] [blame] | 106 | struct st_context *st = ST_CALLOC_STRUCT( st_context ); |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 107 | |
| 108 | ctx->st = st; |
| 109 | |
| 110 | st->ctx = ctx; |
Keith Whitwell | 943964a | 2007-06-14 18:23:43 +0100 | [diff] [blame] | 111 | st->pipe = pipe; |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 112 | |
Keith Whitwell | b02ef74 | 2009-10-05 15:50:11 +0100 | [diff] [blame] | 113 | /* XXX: this is one-off, per-screen init: */ |
| 114 | st_debug_init(); |
| 115 | |
Brian | 8984a28 | 2007-10-31 11:35:50 -0600 | [diff] [blame] | 116 | /* state tracker needs the VBO module */ |
| 117 | _vbo_CreateContext(ctx); |
Brian | 8984a28 | 2007-10-31 11:35:50 -0600 | [diff] [blame] | 118 | |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 119 | st->dirty.mesa = ~0; |
| 120 | st->dirty.st = ~0; |
| 121 | |
Brian | 339e7ec | 2008-03-11 18:54:31 -0600 | [diff] [blame] | 122 | st->cso_context = cso_create_context(pipe); |
Zack Rusin | 9780327 | 2007-09-14 04:08:58 -0400 | [diff] [blame] | 123 | |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 124 | st_init_atoms( st ); |
Brian | c62b197 | 2008-03-28 14:53:47 -0600 | [diff] [blame] | 125 | st_init_bitmap(st); |
Brian Paul | ce5c867 | 2008-04-03 12:54:32 -0600 | [diff] [blame] | 126 | st_init_clear(st); |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 127 | st_init_draw( st ); |
Brian | 62abcb9 | 2008-02-08 14:54:18 -0700 | [diff] [blame] | 128 | st_init_generate_mipmap(st); |
Brian | 0df877a | 2008-03-18 17:16:23 -0600 | [diff] [blame] | 129 | st_init_blit(st); |
Brian | 61d0215 | 2007-08-02 20:40:19 -0600 | [diff] [blame] | 130 | |
Luca Barbieri | 3070e0e | 2010-08-06 07:39:21 +0200 | [diff] [blame] | 131 | if(pipe->screen->get_param(pipe->screen, PIPE_CAP_NPOT_TEXTURES)) |
| 132 | st->internal_target = PIPE_TEXTURE_2D; |
| 133 | else |
| 134 | st->internal_target = PIPE_TEXTURE_RECT; |
| 135 | |
Roland Scheidegger | ae7b7bf | 2010-03-09 15:09:01 +0100 | [diff] [blame] | 136 | for (i = 0; i < 3; i++) { |
| 137 | memset(&st->velems_util_draw[i], 0, sizeof(struct pipe_vertex_element)); |
| 138 | st->velems_util_draw[i].src_offset = i * 4 * sizeof(float); |
| 139 | st->velems_util_draw[i].instance_divisor = 0; |
| 140 | st->velems_util_draw[i].vertex_buffer_index = 0; |
| 141 | st->velems_util_draw[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; |
| 142 | } |
| 143 | |
Brian | 1e6d1ab | 2007-08-17 15:27:18 +0100 | [diff] [blame] | 144 | /* we want all vertex data to be placed in buffer objects */ |
| 145 | vbo_use_buffer_objects(ctx); |
| 146 | |
Brian Paul | 2997b45 | 2011-10-25 17:41:12 -0600 | [diff] [blame] | 147 | |
| 148 | /* make sure that no VBOs are left mapped when we're drawing. */ |
| 149 | vbo_always_unmap_buffers(ctx); |
| 150 | |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 151 | /* Need these flags: |
| 152 | */ |
| 153 | st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 154 | |
Brian | e3bdd66 | 2007-08-16 17:33:49 -0600 | [diff] [blame] | 155 | st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; |
| 156 | |
Brian | d6a739f | 2007-10-30 16:13:37 -0600 | [diff] [blame] | 157 | st->pixel_xfer.cache = _mesa_new_program_cache(); |
Brian | df174bd | 2007-10-30 12:24:05 -0600 | [diff] [blame] | 158 | |
Brian Paul | 1a820f5 | 2008-09-17 14:32:33 -0600 | [diff] [blame] | 159 | st->force_msaa = st_get_msaa(); |
| 160 | |
Brian | c6499a7 | 2007-11-05 18:04:30 -0700 | [diff] [blame] | 161 | /* GL limits and extensions */ |
| 162 | st_init_limits(st); |
| 163 | st_init_extensions(st); |
Brian | af3d6c8 | 2007-08-21 20:15:00 -0600 | [diff] [blame] | 164 | |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 165 | return st; |
| 166 | } |
| 167 | |
| 168 | |
Chia-I Wu | 57c6543 | 2010-06-23 17:40:49 +0800 | [diff] [blame] | 169 | struct st_context *st_create_context(gl_api api, struct pipe_context *pipe, |
Kristian Høgsberg | d3491e7 | 2010-10-12 11:58:47 -0400 | [diff] [blame] | 170 | const struct gl_config *visual, |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 171 | struct st_context *share) |
Brian | 80d2658 | 2007-11-01 17:46:04 -0600 | [diff] [blame] | 172 | { |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 173 | struct gl_context *ctx; |
| 174 | struct gl_context *shareCtx = share ? share->ctx : NULL; |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 175 | struct dd_function_table funcs; |
| 176 | |
Brian Paul | c628fd7 | 2010-11-23 10:28:43 -0700 | [diff] [blame] | 177 | /* Sanity checks */ |
| 178 | assert(MESA_SHADER_VERTEX == PIPE_SHADER_VERTEX); |
| 179 | assert(MESA_SHADER_FRAGMENT == PIPE_SHADER_FRAGMENT); |
| 180 | assert(MESA_SHADER_GEOMETRY == PIPE_SHADER_GEOMETRY); |
| 181 | |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 182 | memset(&funcs, 0, sizeof(funcs)); |
| 183 | st_init_driver_functions(&funcs); |
| 184 | |
Brian Paul | 6f2f449 | 2011-02-08 19:25:04 -0700 | [diff] [blame] | 185 | ctx = _mesa_create_context(api, visual, shareCtx, &funcs, NULL); |
Emil Velikov | 1ab5e15 | 2011-07-11 15:42:15 +0100 | [diff] [blame] | 186 | if (!ctx) { |
| 187 | return NULL; |
| 188 | } |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 189 | |
Keith Whitwell | b6e8256 | 2009-05-05 12:12:28 +0100 | [diff] [blame] | 190 | /* XXX: need a capability bit in gallium to query if the pipe |
| 191 | * driver prefers DP4 or MUL/MAD for vertex transformation. |
| 192 | */ |
Jakob Bornecrantz | 99611f0 | 2010-08-05 17:13:41 -0700 | [diff] [blame] | 193 | if (debug_get_option_mesa_mvp_dp4()) |
Keith Whitwell | b6e8256 | 2009-05-05 12:12:28 +0100 | [diff] [blame] | 194 | _mesa_set_mvp_with_dp4( ctx, GL_TRUE ); |
| 195 | |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 196 | return st_create_context_priv(ctx, pipe); |
Brian | 80d2658 | 2007-11-01 17:46:04 -0600 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 200 | static void st_destroy_context_priv( struct st_context *st ) |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 201 | { |
Brian | 6128c93 | 2007-12-26 07:16:12 -0700 | [diff] [blame] | 202 | uint i; |
| 203 | |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 204 | st_destroy_atoms( st ); |
| 205 | st_destroy_draw( st ); |
Brian | 0df877a | 2008-03-18 17:16:23 -0600 | [diff] [blame] | 206 | st_destroy_generate_mipmap(st); |
| 207 | st_destroy_blit(st); |
Brian | 85e4ec6 | 2008-03-20 09:13:51 -0600 | [diff] [blame] | 208 | st_destroy_clear(st); |
Brian Paul | 414b535 | 2008-06-17 16:57:02 -0600 | [diff] [blame] | 209 | st_destroy_bitmap(st); |
Brian Paul | 90ce846 | 2008-05-20 13:38:45 -0600 | [diff] [blame] | 210 | st_destroy_drawpix(st); |
Brian Paul | 4424c66 | 2008-08-12 18:02:44 -0600 | [diff] [blame] | 211 | st_destroy_drawtex(st); |
Brian | 61d0215 | 2007-08-02 20:40:19 -0600 | [diff] [blame] | 212 | |
Marek Olšák | 588fa88 | 2011-02-09 01:10:11 +0100 | [diff] [blame] | 213 | /* Unreference any user vertex buffers. */ |
José Fonseca | 0c501ba | 2011-04-07 12:19:14 +0100 | [diff] [blame] | 214 | for (i = 0; i < st->num_user_attribs; i++) { |
| 215 | pipe_resource_reference(&st->user_attrib[i].buffer, NULL); |
Marek Olšák | 588fa88 | 2011-02-09 01:10:11 +0100 | [diff] [blame] | 216 | } |
| 217 | |
Michal Krol | b8030c6 | 2010-03-12 14:37:36 +0100 | [diff] [blame] | 218 | for (i = 0; i < Elements(st->state.sampler_views); i++) { |
| 219 | pipe_sampler_view_reference(&st->state.sampler_views[i], NULL); |
Brian Paul | 87afc9b | 2008-05-16 16:04:30 -0600 | [diff] [blame] | 220 | } |
| 221 | |
Brian Paul | 8f6d9e1 | 2008-08-14 15:38:09 -0600 | [diff] [blame] | 222 | if (st->default_texture) { |
| 223 | st->ctx->Driver.DeleteTexture(st->ctx, st->default_texture); |
| 224 | st->default_texture = NULL; |
| 225 | } |
| 226 | |
Kristian Høgsberg | 32f2fd1 | 2010-02-19 11:58:49 -0500 | [diff] [blame] | 227 | free( st ); |
Keith Whitwell | 8e4a95a | 2007-05-24 10:41:34 +0100 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 231 | void st_destroy_context( struct st_context *st ) |
| 232 | { |
Brian Paul | a770d40 | 2008-04-24 12:11:24 -0600 | [diff] [blame] | 233 | struct pipe_context *pipe = st->pipe; |
| 234 | struct cso_context *cso = st->cso_context; |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 235 | struct gl_context *ctx = st->ctx; |
Brian Paul | f104e4d | 2009-05-11 16:09:39 -0600 | [diff] [blame] | 236 | GLuint i; |
Brian Paul | f2b3f6c | 2008-04-17 11:12:44 -0600 | [diff] [blame] | 237 | |
| 238 | /* need to unbind and destroy CSO objects before anything else */ |
Brian Paul | a770d40 | 2008-04-24 12:11:24 -0600 | [diff] [blame] | 239 | cso_release_all(st->cso_context); |
Brian Paul | f2b3f6c | 2008-04-17 11:12:44 -0600 | [diff] [blame] | 240 | |
Brian Paul | 69fd676 | 2008-05-20 14:38:22 -0600 | [diff] [blame] | 241 | st_reference_fragprog(st, &st->fp, NULL); |
| 242 | st_reference_vertprog(st, &st->vp, NULL); |
| 243 | |
Brian Paul | f104e4d | 2009-05-11 16:09:39 -0600 | [diff] [blame] | 244 | /* release framebuffer surfaces */ |
| 245 | for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { |
| 246 | pipe_surface_reference(&st->state.framebuffer.cbufs[i], NULL); |
| 247 | } |
| 248 | pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL); |
| 249 | |
Tilman Sauerbeck | 965c8a3 | 2010-10-31 15:55:51 +0100 | [diff] [blame] | 250 | pipe->set_index_buffer(pipe, NULL); |
| 251 | |
Tilman Sauerbeck | 646a8b7 | 2010-11-02 22:15:15 +0100 | [diff] [blame] | 252 | for (i = 0; i < PIPE_SHADER_TYPES; i++) { |
Jakob Bornecrantz | d72cb9c | 2010-12-06 20:59:49 +0100 | [diff] [blame] | 253 | pipe->set_constant_buffer(pipe, i, 0, NULL); |
Tilman Sauerbeck | 646a8b7 | 2010-11-02 22:15:15 +0100 | [diff] [blame] | 254 | } |
| 255 | |
Brian Paul | f2b3f6c | 2008-04-17 11:12:44 -0600 | [diff] [blame] | 256 | _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache); |
| 257 | |
Brian Paul | 753635f | 2008-09-16 08:51:28 -0600 | [diff] [blame] | 258 | _vbo_DestroyContext(st->ctx); |
| 259 | |
Brian Paul | 3d203b6 | 2010-12-13 17:20:12 -0700 | [diff] [blame] | 260 | st_destroy_program_variants(st); |
| 261 | |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 262 | _mesa_free_context_data(ctx); |
Brian Paul | a770d40 | 2008-04-24 12:11:24 -0600 | [diff] [blame] | 263 | |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 264 | st_destroy_context_priv(st); |
Brian Paul | a770d40 | 2008-04-24 12:11:24 -0600 | [diff] [blame] | 265 | |
| 266 | cso_destroy_context(cso); |
| 267 | |
| 268 | pipe->destroy( pipe ); |
| 269 | |
Kristian Høgsberg | 32f2fd1 | 2010-02-19 11:58:49 -0500 | [diff] [blame] | 270 | free(ctx); |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 274 | void st_init_driver_functions(struct dd_function_table *functions) |
| 275 | { |
Brian Paul | a37b221 | 2010-06-10 20:23:03 -0600 | [diff] [blame] | 276 | _mesa_init_shader_object_functions(functions); |
Brian Paul | 34a5d3b | 2011-04-10 12:48:28 -0600 | [diff] [blame] | 277 | _mesa_init_sampler_object_functions(functions); |
Brian | 601a9ea | 2007-11-07 08:18:50 -0700 | [diff] [blame] | 278 | |
Brian Paul | 122c676 | 2011-12-03 10:04:18 -0700 | [diff] [blame] | 279 | functions->Accum = _mesa_accum; |
| 280 | |
Brian | 0df877a | 2008-03-18 17:16:23 -0600 | [diff] [blame] | 281 | st_init_blit_functions(functions); |
Brian | f6cd377 | 2008-03-20 14:50:17 -0600 | [diff] [blame] | 282 | st_init_bufferobject_functions(functions); |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 283 | st_init_clear_functions(functions); |
Brian Paul | 04996bc | 2008-06-17 13:13:34 -0600 | [diff] [blame] | 284 | st_init_bitmap_functions(functions); |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 285 | st_init_drawpixels_functions(functions); |
Brian | bee148c | 2007-09-10 16:28:27 -0600 | [diff] [blame] | 286 | st_init_rasterpos_functions(functions); |
Chia-I Wu | 3406475 | 2009-09-22 15:00:24 +0800 | [diff] [blame] | 287 | |
Chia-I Wu | 3406475 | 2009-09-22 15:00:24 +0800 | [diff] [blame] | 288 | st_init_drawtex_functions(functions); |
Chia-I Wu | 3406475 | 2009-09-22 15:00:24 +0800 | [diff] [blame] | 289 | |
Chia-I Wu | a1aa53b | 2010-02-25 23:10:47 +0800 | [diff] [blame] | 290 | st_init_eglimage_functions(functions); |
| 291 | |
Brian Paul | 04996bc | 2008-06-17 13:13:34 -0600 | [diff] [blame] | 292 | st_init_fbo_functions(functions); |
Brian Paul | 04996bc | 2008-06-17 13:13:34 -0600 | [diff] [blame] | 293 | st_init_feedback_functions(functions); |
Brian Paul | 04996bc | 2008-06-17 13:13:34 -0600 | [diff] [blame] | 294 | st_init_program_functions(functions); |
Brian Paul | 04996bc | 2008-06-17 13:13:34 -0600 | [diff] [blame] | 295 | st_init_query_functions(functions); |
Brian Paul | c9b5583 | 2009-12-31 14:47:21 -0700 | [diff] [blame] | 296 | st_init_cond_render_functions(functions); |
Brian | 6f27aab | 2007-08-10 11:37:21 -0600 | [diff] [blame] | 297 | st_init_readpixels_functions(functions); |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 298 | st_init_texture_functions(functions); |
Marek Olšák | aea4ed4 | 2011-03-08 11:32:35 +0100 | [diff] [blame] | 299 | st_init_texture_barrier_functions(functions); |
Keith Whitwell | 5c2c056 | 2007-08-10 12:57:14 +0100 | [diff] [blame] | 300 | st_init_flush_functions(functions); |
Keith Whitwell | 39407fd | 2007-08-10 16:42:26 +0100 | [diff] [blame] | 301 | st_init_string_functions(functions); |
Jakob Bornecrantz | a93f9f3 | 2010-05-21 20:37:23 +0100 | [diff] [blame] | 302 | st_init_viewport_functions(functions); |
Brian | d775509 | 2007-10-31 11:08:07 -0600 | [diff] [blame] | 303 | |
Brian Paul | fef6e36 | 2010-05-10 21:11:21 -0600 | [diff] [blame] | 304 | st_init_xformfb_functions(functions); |
Marek Olšák | 5257a6d | 2011-03-05 20:32:28 +0100 | [diff] [blame] | 305 | st_init_syncobj_functions(functions); |
Brian Paul | fef6e36 | 2010-05-10 21:11:21 -0600 | [diff] [blame] | 306 | |
Brian | d775509 | 2007-10-31 11:08:07 -0600 | [diff] [blame] | 307 | functions->UpdateState = st_invalidate_state; |
Brian | 6da9234 | 2007-08-06 20:53:28 +0100 | [diff] [blame] | 308 | } |