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