/** * Free the CSO context. NOTE: the state tracker should have previously called * cso_release_all(). */ void cso_destroy_context( struct cso_context *ctx ) { if (ctx) { if (ctx->vbuf) u_vbuf_destroy(ctx->vbuf); FREE( ctx ); } }
/** * Free the CSO context. */ void cso_destroy_context( struct cso_context *ctx ) { unsigned i; if (ctx->pipe) { ctx->pipe->set_index_buffer(ctx->pipe, NULL); ctx->pipe->bind_blend_state( ctx->pipe, NULL ); ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL ); { static struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS] = { NULL }; static void *zeros[PIPE_MAX_SAMPLERS] = { NULL }; struct pipe_screen *scr = ctx->pipe->screen; unsigned sh; for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { int maxsam = scr->get_shader_param(scr, sh, PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS); int maxview = scr->get_shader_param(scr, sh, PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS); assert(maxsam <= PIPE_MAX_SAMPLERS); assert(maxview <= PIPE_MAX_SHADER_SAMPLER_VIEWS); if (maxsam > 0) { ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, maxsam, zeros); } if (maxview > 0) { ctx->pipe->set_sampler_views(ctx->pipe, sh, 0, maxview, views); } } } ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL ); ctx->pipe->bind_fs_state( ctx->pipe, NULL ); ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, NULL); ctx->pipe->bind_vs_state( ctx->pipe, NULL ); ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_VERTEX, 0, NULL); if (ctx->has_geometry_shader) { ctx->pipe->bind_gs_state(ctx->pipe, NULL); ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_GEOMETRY, 0, NULL); } if (ctx->has_tessellation) { ctx->pipe->bind_tcs_state(ctx->pipe, NULL); ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_TESS_CTRL, 0, NULL); ctx->pipe->bind_tes_state(ctx->pipe, NULL); ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_TESS_EVAL, 0, NULL); } if (ctx->has_compute_shader) { ctx->pipe->bind_compute_state(ctx->pipe, NULL); ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_COMPUTE, 0, NULL); } ctx->pipe->bind_vertex_elements_state( ctx->pipe, NULL ); if (ctx->has_streamout) ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, NULL); } for (i = 0; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) { pipe_sampler_view_reference(&ctx->fragment_views[i], NULL); pipe_sampler_view_reference(&ctx->fragment_views_saved[i], NULL); } util_unreference_framebuffer_state(&ctx->fb); util_unreference_framebuffer_state(&ctx->fb_saved); pipe_resource_reference(&ctx->aux_vertex_buffer_current.buffer, NULL); pipe_resource_reference(&ctx->aux_vertex_buffer_saved.buffer, NULL); for (i = 0; i < PIPE_SHADER_TYPES; i++) { pipe_resource_reference(&ctx->aux_constbuf_current[i].buffer, NULL); pipe_resource_reference(&ctx->aux_constbuf_saved[i].buffer, NULL); } for (i = 0; i < PIPE_MAX_SO_BUFFERS; i++) { pipe_so_target_reference(&ctx->so_targets[i], NULL); pipe_so_target_reference(&ctx->so_targets_saved[i], NULL); } if (ctx->cache) { cso_cache_delete( ctx->cache ); ctx->cache = NULL; } if (ctx->vbuf) u_vbuf_destroy(ctx->vbuf); FREE( ctx ); }