/** * Prior to context destruction, this function unbinds all state objects. */ void cso_release_all( struct cso_context *ctx ) { unsigned i; struct sampler_info *info; if (ctx->pipe) { ctx->pipe->bind_blend_state( ctx->pipe, NULL ); ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL ); ctx->pipe->bind_fragment_sampler_states( ctx->pipe, 0, NULL ); if (ctx->pipe->bind_vertex_sampler_states) ctx->pipe->bind_vertex_sampler_states(ctx->pipe, 0, NULL); ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL ); ctx->pipe->bind_fs_state( ctx->pipe, NULL ); ctx->pipe->bind_vs_state( ctx->pipe, NULL ); ctx->pipe->bind_vertex_elements_state( ctx->pipe, NULL ); ctx->pipe->set_fragment_sampler_views(ctx->pipe, 0, NULL); if (ctx->pipe->set_vertex_sampler_views) ctx->pipe->set_vertex_sampler_views(ctx->pipe, 0, NULL); if (ctx->pipe->set_stream_output_targets) ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, 0); } /* free fragment samplers, views */ info = &ctx->fragment_samplers; for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { pipe_sampler_view_reference(&info->views[i], NULL); pipe_sampler_view_reference(&info->views_saved[i], NULL); } /* free vertex samplers, views */ info = &ctx->vertex_samplers; for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { pipe_sampler_view_reference(&info->views[i], NULL); pipe_sampler_view_reference(&info->views_saved[i], NULL); } util_unreference_framebuffer_state(&ctx->fb); util_unreference_framebuffer_state(&ctx->fb_saved); util_copy_vertex_buffers(ctx->vertex_buffers, &ctx->nr_vertex_buffers, NULL, 0); util_copy_vertex_buffers(ctx->vertex_buffers_saved, &ctx->nr_vertex_buffers_saved, NULL, 0); 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; } }
/** * Prior to context destruction, this function unbinds all state objects. */ void cso_release_all( struct cso_context *ctx ) { unsigned i, shader; if (ctx->pipe) { ctx->pipe->bind_blend_state( ctx->pipe, NULL ); ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL ); ctx->pipe->bind_fragment_sampler_states( ctx->pipe, 0, NULL ); if (ctx->pipe->bind_vertex_sampler_states) ctx->pipe->bind_vertex_sampler_states(ctx->pipe, 0, NULL); ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL ); ctx->pipe->bind_fs_state( ctx->pipe, NULL ); ctx->pipe->bind_vs_state( ctx->pipe, NULL ); ctx->pipe->bind_vertex_elements_state( ctx->pipe, NULL ); ctx->pipe->set_fragment_sampler_views(ctx->pipe, 0, NULL); if (ctx->pipe->set_vertex_sampler_views) ctx->pipe->set_vertex_sampler_views(ctx->pipe, 0, NULL); if (ctx->pipe->set_stream_output_targets) ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, 0); } /* free fragment samplers, views */ for (shader = 0; shader < Elements(ctx->samplers); shader++) { struct sampler_info *info = &ctx->samplers[shader]; for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { pipe_sampler_view_reference(&info->views[i], NULL); pipe_sampler_view_reference(&info->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; } }
static void i915_clear_depth_stencil_render(struct pipe_context *pipe, struct pipe_surface *dst, unsigned clear_flags, double depth, unsigned stencil, unsigned dstx, unsigned dsty, unsigned width, unsigned height) { struct i915_context *i915 = i915_context(pipe); struct pipe_framebuffer_state fb_state; util_blitter_save_framebuffer(i915->blitter, &i915->framebuffer); fb_state.width = dst->width; fb_state.height = dst->height; fb_state.nr_cbufs = 0; fb_state.zsbuf = dst; pipe->set_framebuffer_state(pipe, &fb_state); if (i915->dirty) i915_update_derived(i915); i915_clear_emit(pipe, clear_flags & PIPE_CLEAR_DEPTHSTENCIL, NULL, depth, stencil, dstx, dsty, width, height); pipe->set_framebuffer_state(pipe, &i915->blitter->saved_fb_state); util_unreference_framebuffer_state(&i915->blitter->saved_fb_state); i915->blitter->saved_fb_state.nr_cbufs = ~0; }
static void r600_destroy_context(struct pipe_context *context) { struct r600_context *rctx = (struct r600_context *)context; si_release_all_descriptors(rctx); pipe_resource_reference(&rctx->null_const_buf.buffer, NULL); r600_resource_reference(&rctx->border_color_table, NULL); if (rctx->dummy_pixel_shader) { rctx->b.b.delete_fs_state(&rctx->b.b, rctx->dummy_pixel_shader); } for (int i = 0; i < 8; i++) { rctx->b.b.delete_depth_stencil_alpha_state(&rctx->b.b, rctx->custom_dsa_flush_depth_stencil[i]); rctx->b.b.delete_depth_stencil_alpha_state(&rctx->b.b, rctx->custom_dsa_flush_depth[i]); rctx->b.b.delete_depth_stencil_alpha_state(&rctx->b.b, rctx->custom_dsa_flush_stencil[i]); } rctx->b.b.delete_depth_stencil_alpha_state(&rctx->b.b, rctx->custom_dsa_flush_inplace); rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_resolve); rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_decompress); util_unreference_framebuffer_state(&rctx->framebuffer); util_blitter_destroy(rctx->blitter); if (rctx->uploader) { u_upload_destroy(rctx->uploader); } util_slab_destroy(&rctx->pool_transfers); r600_common_context_cleanup(&rctx->b); FREE(rctx); }
static void r300_release_referenced_objects(struct r300_context *r300) { struct pipe_framebuffer_state *fb = (struct pipe_framebuffer_state*)r300->fb_state.state; struct r300_textures_state *textures = (struct r300_textures_state*)r300->textures_state.state; unsigned i; /* Framebuffer state. */ util_unreference_framebuffer_state(fb); /* Textures. */ for (i = 0; i < textures->sampler_view_count; i++) pipe_sampler_view_reference( (struct pipe_sampler_view**)&textures->sampler_views[i], NULL); /* The special dummy texture for texkill. */ if (r300->texkill_sampler) { pipe_sampler_view_reference( (struct pipe_sampler_view**)&r300->texkill_sampler, NULL); } /* Manually-created vertex buffers. */ pipe_resource_reference(&r300->dummy_vb.buffer, NULL); pb_reference(&r300->vbo, NULL); r300->context.delete_depth_stencil_alpha_state(&r300->context, r300->dsa_decompress_zmask); }
/* * pipe_context */ static void si_destroy_context(struct pipe_context *context) { struct si_context *sctx = (struct si_context *)context; int i; si_dec_framebuffer_counters(&sctx->framebuffer.state); si_release_all_descriptors(sctx); if (sctx->ce_suballocator) u_suballocator_destroy(sctx->ce_suballocator); pipe_resource_reference(&sctx->esgs_ring, NULL); pipe_resource_reference(&sctx->gsvs_ring, NULL); pipe_resource_reference(&sctx->tf_ring, NULL); pipe_resource_reference(&sctx->tess_offchip_ring, NULL); pipe_resource_reference(&sctx->null_const_buf.buffer, NULL); r600_resource_reference(&sctx->border_color_buffer, NULL); free(sctx->border_color_table); r600_resource_reference(&sctx->scratch_buffer, NULL); r600_resource_reference(&sctx->compute_scratch_buffer, NULL); sctx->b.ws->fence_reference(&sctx->last_gfx_fence, NULL); si_pm4_free_state(sctx, sctx->init_config, ~0); if (sctx->init_config_gs_rings) si_pm4_free_state(sctx, sctx->init_config_gs_rings, ~0); for (i = 0; i < ARRAY_SIZE(sctx->vgt_shader_config); i++) si_pm4_delete_state(sctx, vgt_shader_config, sctx->vgt_shader_config[i]); if (sctx->fixed_func_tcs_shader.cso) sctx->b.b.delete_tcs_state(&sctx->b.b, sctx->fixed_func_tcs_shader.cso); if (sctx->custom_dsa_flush) sctx->b.b.delete_depth_stencil_alpha_state(&sctx->b.b, sctx->custom_dsa_flush); if (sctx->custom_blend_resolve) sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_resolve); if (sctx->custom_blend_decompress) sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_decompress); if (sctx->custom_blend_fastclear) sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_fastclear); if (sctx->custom_blend_dcc_decompress) sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_dcc_decompress); util_unreference_framebuffer_state(&sctx->framebuffer.state); if (sctx->blitter) util_blitter_destroy(sctx->blitter); r600_common_context_cleanup(&sctx->b); LLVMDisposeTargetMachine(sctx->tm); r600_resource_reference(&sctx->trace_buf, NULL); r600_resource_reference(&sctx->last_trace_buf, NULL); free(sctx->last_ib); if (sctx->last_bo_list) { for (i = 0; i < sctx->last_bo_count; i++) pb_reference(&sctx->last_bo_list[i].buf, NULL); free(sctx->last_bo_list); } FREE(sctx); }
/* * pipe_context */ static void si_destroy_context(struct pipe_context *context) { struct si_context *sctx = (struct si_context *)context; si_release_all_descriptors(sctx); pipe_resource_reference(&sctx->null_const_buf.buffer, NULL); r600_resource_reference(&sctx->border_color_table, NULL); si_pm4_delete_state(sctx, gs_rings, sctx->gs_rings); si_pm4_delete_state(sctx, gs_onoff, sctx->gs_on); si_pm4_delete_state(sctx, gs_onoff, sctx->gs_off); if (sctx->dummy_pixel_shader) { sctx->b.b.delete_fs_state(&sctx->b.b, sctx->dummy_pixel_shader); } for (int i = 0; i < 8; i++) { sctx->b.b.delete_depth_stencil_alpha_state(&sctx->b.b, sctx->custom_dsa_flush_depth_stencil[i]); sctx->b.b.delete_depth_stencil_alpha_state(&sctx->b.b, sctx->custom_dsa_flush_depth[i]); sctx->b.b.delete_depth_stencil_alpha_state(&sctx->b.b, sctx->custom_dsa_flush_stencil[i]); } sctx->b.b.delete_depth_stencil_alpha_state(&sctx->b.b, sctx->custom_dsa_flush_inplace); sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_resolve); sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_decompress); sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_fastclear); util_unreference_framebuffer_state(&sctx->framebuffer.state); util_blitter_destroy(sctx->blitter); si_pm4_cleanup(sctx); r600_common_context_cleanup(&sctx->b); FREE(sctx); }
static void nv50_context_unreference_resources(struct nv50_context *nv50) { unsigned s, i; nouveau_bufctx_del(&nv50->bufctx_3d); nouveau_bufctx_del(&nv50->bufctx); nouveau_bufctx_del(&nv50->bufctx_cp); util_unreference_framebuffer_state(&nv50->framebuffer); assert(nv50->num_vtxbufs <= PIPE_MAX_ATTRIBS); for (i = 0; i < nv50->num_vtxbufs; ++i) pipe_resource_reference(&nv50->vtxbuf[i].buffer, NULL); pipe_resource_reference(&nv50->idxbuf.buffer, NULL); for (s = 0; s < 3; ++s) { assert(nv50->num_textures[s] <= PIPE_MAX_SAMPLERS); for (i = 0; i < nv50->num_textures[s]; ++i) pipe_sampler_view_reference(&nv50->textures[s][i], NULL); for (i = 0; i < NV50_MAX_PIPE_CONSTBUFS; ++i) if (!nv50->constbuf[s][i].user) pipe_resource_reference(&nv50->constbuf[s][i].u.buf, NULL); } for (i = 0; i < nv50->global_residents.size / sizeof(struct pipe_resource *); ++i) { struct pipe_resource **res = util_dynarray_element( &nv50->global_residents, struct pipe_resource *, i); pipe_resource_reference(res, NULL); } util_dynarray_fini(&nv50->global_residents); }
static void nvc0_context_unreference_resources(struct nvc0_context *nvc0) { unsigned s, i; nouveau_bufctx_del(&nvc0->bufctx_3d); nouveau_bufctx_del(&nvc0->bufctx); util_unreference_framebuffer_state(&nvc0->framebuffer); for (i = 0; i < nvc0->num_vtxbufs; ++i) pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL); pipe_resource_reference(&nvc0->idxbuf.buffer, NULL); for (s = 0; s < 5; ++s) { for (i = 0; i < nvc0->num_textures[s]; ++i) pipe_sampler_view_reference(&nvc0->textures[s][i], NULL); for (i = 0; i < NVC0_MAX_PIPE_CONSTBUFS; ++i) if (!nvc0->constbuf[s][i].user) pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, NULL); } for (i = 0; i < nvc0->num_tfbbufs; ++i) pipe_so_target_reference(&nvc0->tfbbuf[i], NULL); }
static void blitter_restore_fb_state(struct blitter_context_priv *ctx) { struct pipe_context *pipe = ctx->base.pipe; pipe->set_framebuffer_state(pipe, &ctx->base.saved_fb_state); util_unreference_framebuffer_state(&ctx->base.saved_fb_state); }
/* Only caller is lp_setup_vbuf_destroy() */ void lp_setup_destroy( struct lp_setup_context *setup ) { uint i; lp_setup_reset( setup ); util_unreference_framebuffer_state(&setup->fb); for (i = 0; i < ARRAY_SIZE(setup->fs.current_tex); i++) { pipe_resource_reference(&setup->fs.current_tex[i], NULL); } for (i = 0; i < ARRAY_SIZE(setup->constants); i++) { pipe_resource_reference(&setup->constants[i].current.buffer, NULL); } /* free the scenes in the 'empty' queue */ for (i = 0; i < ARRAY_SIZE(setup->scenes); i++) { struct lp_scene *scene = setup->scenes[i]; if (scene->fence) lp_fence_wait(scene->fence); lp_scene_destroy(scene); } lp_fence_reference(&setup->last_fence, NULL); FREE( setup ); }
static void i915_clear_render_target_render(struct pipe_context *pipe, struct pipe_surface *dst, const union pipe_color_union *color, unsigned dstx, unsigned dsty, unsigned width, unsigned height) { struct i915_context *i915 = i915_context(pipe); struct pipe_framebuffer_state fb_state; util_blitter_save_framebuffer(i915->blitter, &i915->framebuffer); fb_state.width = dst->width; fb_state.height = dst->height; fb_state.nr_cbufs = 1; fb_state.cbufs[0] = dst; fb_state.zsbuf = NULL; pipe->set_framebuffer_state(pipe, &fb_state); if (i915->dirty) i915_update_derived(i915); i915_clear_emit(pipe, PIPE_CLEAR_COLOR, color, 0.0, 0x0, dstx, dsty, width, height); pipe->set_framebuffer_state(pipe, &i915->blitter->saved_fb_state); util_unreference_framebuffer_state(&i915->blitter->saved_fb_state); i915->blitter->saved_fb_state.nr_cbufs = ~0; }
void cso_restore_framebuffer(struct cso_context *ctx) { if (memcmp(&ctx->fb, &ctx->fb_saved, sizeof(ctx->fb))) { util_copy_framebuffer_state(&ctx->fb, &ctx->fb_saved); ctx->pipe->set_framebuffer_state(ctx->pipe, &ctx->fb); util_unreference_framebuffer_state(&ctx->fb_saved); } }
static void r600_destroy_context(struct pipe_context *context) { struct r600_context *rctx = (struct r600_context *)context; unsigned sh; r600_isa_destroy(rctx->isa); r600_sb_context_destroy(rctx->sb_context); r600_resource_reference(&rctx->dummy_cmask, NULL); r600_resource_reference(&rctx->dummy_fmask, NULL); for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { rctx->b.b.set_constant_buffer(&rctx->b.b, sh, R600_BUFFER_INFO_CONST_BUFFER, NULL); free(rctx->driver_consts[sh].constants); } if (rctx->fixed_func_tcs_shader) rctx->b.b.delete_tcs_state(&rctx->b.b, rctx->fixed_func_tcs_shader); if (rctx->dummy_pixel_shader) { rctx->b.b.delete_fs_state(&rctx->b.b, rctx->dummy_pixel_shader); } if (rctx->custom_dsa_flush) { rctx->b.b.delete_depth_stencil_alpha_state(&rctx->b.b, rctx->custom_dsa_flush); } if (rctx->custom_blend_resolve) { rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_resolve); } if (rctx->custom_blend_decompress) { rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_decompress); } if (rctx->custom_blend_fastclear) { rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_fastclear); } util_unreference_framebuffer_state(&rctx->framebuffer.state); if (rctx->blitter) { util_blitter_destroy(rctx->blitter); } if (rctx->allocator_fetch_shader) { u_suballocator_destroy(rctx->allocator_fetch_shader); } r600_release_command_buffer(&rctx->start_cs_cmd); FREE(rctx->start_compute_cs_cmd.buf); r600_common_context_cleanup(&rctx->b); r600_resource_reference(&rctx->trace_buf, NULL); r600_resource_reference(&rctx->last_trace_buf, NULL); radeon_clear_saved_cs(&rctx->last_gfx); FREE(rctx); }
static void nvc0_context_unreference_resources(struct nvc0_context *nvc0) { unsigned s, i; nouveau_bufctx_del(&nvc0->bufctx_3d); nouveau_bufctx_del(&nvc0->bufctx); nouveau_bufctx_del(&nvc0->bufctx_cp); util_unreference_framebuffer_state(&nvc0->framebuffer); for (i = 0; i < nvc0->num_vtxbufs; ++i) pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL); pipe_resource_reference(&nvc0->idxbuf.buffer, NULL); for (s = 0; s < 6; ++s) { for (i = 0; i < nvc0->num_textures[s]; ++i) pipe_sampler_view_reference(&nvc0->textures[s][i], NULL); for (i = 0; i < NVC0_MAX_PIPE_CONSTBUFS; ++i) if (!nvc0->constbuf[s][i].user) pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, NULL); for (i = 0; i < NVC0_MAX_BUFFERS; ++i) pipe_resource_reference(&nvc0->buffers[s][i].buffer, NULL); for (i = 0; i < NVC0_MAX_IMAGES; ++i) { pipe_resource_reference(&nvc0->images[s][i].resource, NULL); if (nvc0->screen->base.class_3d >= GM107_3D_CLASS) pipe_sampler_view_reference(&nvc0->images_tic[s][i], NULL); } } for (s = 0; s < 2; ++s) { for (i = 0; i < NVC0_MAX_SURFACE_SLOTS; ++i) pipe_surface_reference(&nvc0->surfaces[s][i], NULL); } for (i = 0; i < nvc0->num_tfbbufs; ++i) pipe_so_target_reference(&nvc0->tfbbuf[i], NULL); for (i = 0; i < nvc0->global_residents.size / sizeof(struct pipe_resource *); ++i) { struct pipe_resource **res = util_dynarray_element( &nvc0->global_residents, struct pipe_resource *, i); pipe_resource_reference(res, NULL); } util_dynarray_fini(&nvc0->global_residents); if (nvc0->tcp_empty) nvc0->base.pipe.delete_tcs_state(&nvc0->base.pipe, nvc0->tcp_empty); }
void r300_decompress_zmask_locked(struct r300_context *r300) { struct pipe_framebuffer_state saved_fb; memset(&saved_fb, 0, sizeof(saved_fb)); util_copy_framebuffer_state(&saved_fb, r300->fb_state.state); r300_decompress_zmask_locked_unsafe(r300); r300->context.set_framebuffer_state(&r300->context, &saved_fb); util_unreference_framebuffer_state(&saved_fb); pipe_surface_reference(&r300->locked_zbuffer, NULL); }
/* * pipe_context */ static void si_destroy_context(struct pipe_context *context) { struct si_context *sctx = (struct si_context *)context; int i; si_release_all_descriptors(sctx); pipe_resource_reference(&sctx->esgs_ring, NULL); pipe_resource_reference(&sctx->gsvs_ring, NULL); pipe_resource_reference(&sctx->tf_ring, NULL); pipe_resource_reference(&sctx->null_const_buf.buffer, NULL); r600_resource_reference(&sctx->border_color_table, NULL); r600_resource_reference(&sctx->scratch_buffer, NULL); sctx->b.ws->fence_reference(&sctx->last_gfx_fence, NULL); si_pm4_free_state(sctx, sctx->init_config, ~0); si_pm4_delete_state(sctx, gs_rings, sctx->gs_rings); si_pm4_delete_state(sctx, tf_ring, sctx->tf_state); for (i = 0; i < Elements(sctx->vgt_shader_config); i++) si_pm4_delete_state(sctx, vgt_shader_config, sctx->vgt_shader_config[i]); if (sctx->pstipple_sampler_state) sctx->b.b.delete_sampler_state(&sctx->b.b, sctx->pstipple_sampler_state); if (sctx->dummy_pixel_shader) sctx->b.b.delete_fs_state(&sctx->b.b, sctx->dummy_pixel_shader); if (sctx->fixed_func_tcs_shader) sctx->b.b.delete_tcs_state(&sctx->b.b, sctx->fixed_func_tcs_shader); if (sctx->custom_dsa_flush) sctx->b.b.delete_depth_stencil_alpha_state(&sctx->b.b, sctx->custom_dsa_flush); if (sctx->custom_blend_resolve) sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_resolve); if (sctx->custom_blend_decompress) sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_decompress); if (sctx->custom_blend_fastclear) sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_fastclear); util_unreference_framebuffer_state(&sctx->framebuffer.state); if (sctx->blitter) util_blitter_destroy(sctx->blitter); si_pm4_cleanup(sctx); r600_common_context_cleanup(&sctx->b); #if HAVE_LLVM >= 0x0306 LLVMDisposeTargetMachine(sctx->tm); #endif FREE(sctx); }
static void r600_destroy_context(struct pipe_context *context) { struct r600_context *rctx = (struct r600_context *)context; r600_isa_destroy(rctx->isa); r600_sb_context_destroy(rctx->sb_context); pipe_resource_reference((struct pipe_resource**)&rctx->dummy_cmask, NULL); pipe_resource_reference((struct pipe_resource**)&rctx->dummy_fmask, NULL); if (rctx->fixed_func_tcs_shader) rctx->b.b.delete_tcs_state(&rctx->b.b, rctx->fixed_func_tcs_shader); if (rctx->dummy_pixel_shader) { rctx->b.b.delete_fs_state(&rctx->b.b, rctx->dummy_pixel_shader); } if (rctx->custom_dsa_flush) { rctx->b.b.delete_depth_stencil_alpha_state(&rctx->b.b, rctx->custom_dsa_flush); } if (rctx->custom_blend_resolve) { rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_resolve); } if (rctx->custom_blend_decompress) { rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_decompress); } if (rctx->custom_blend_fastclear) { rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_fastclear); } util_unreference_framebuffer_state(&rctx->framebuffer.state); if (rctx->blitter) { util_blitter_destroy(rctx->blitter); } if (rctx->allocator_fetch_shader) { u_suballocator_destroy(rctx->allocator_fetch_shader); } r600_release_command_buffer(&rctx->start_cs_cmd); FREE(rctx->start_compute_cs_cmd.buf); r600_common_context_cleanup(&rctx->b); FREE(rctx); }
static void nvc0_context_unreference_resources(struct nvc0_context *nvc0) { unsigned s, i; nouveau_bufctx_del(&nvc0->bufctx_3d); nouveau_bufctx_del(&nvc0->bufctx); nouveau_bufctx_del(&nvc0->bufctx_cp); util_unreference_framebuffer_state(&nvc0->framebuffer); for (i = 0; i < nvc0->num_vtxbufs; ++i) pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL); pipe_resource_reference(&nvc0->idxbuf.buffer, NULL); for (s = 0; s < 6; ++s) { for (i = 0; i < nvc0->num_textures[s]; ++i) pipe_sampler_view_reference(&nvc0->textures[s][i], NULL); for (i = 0; i < NVC0_MAX_PIPE_CONSTBUFS; ++i) if (!nvc0->constbuf[s][i].user) pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, NULL); } for (s = 0; s < 2; ++s) { for (i = 0; i < NVC0_MAX_SURFACE_SLOTS; ++i) pipe_surface_reference(&nvc0->surfaces[s][i], NULL); } for (i = 0; i < nvc0->num_tfbbufs; ++i) pipe_so_target_reference(&nvc0->tfbbuf[i], NULL); for (i = 0; i < nvc0->global_residents.size / sizeof(struct pipe_resource *); ++i) { struct pipe_resource **res = util_dynarray_element( &nvc0->global_residents, struct pipe_resource *, i); pipe_resource_reference(res, NULL); } util_dynarray_fini(&nvc0->global_residents); }
static void nv50_context_unreference_resources(struct nv50_context *nv50) { unsigned s, i; nouveau_bufctx_del(&nv50->bufctx_3d); nouveau_bufctx_del(&nv50->bufctx); util_unreference_framebuffer_state(&nv50->framebuffer); for (i = 0; i < nv50->num_vtxbufs; ++i) pipe_resource_reference(&nv50->vtxbuf[i].buffer, NULL); pipe_resource_reference(&nv50->idxbuf.buffer, NULL); for (s = 0; s < 3; ++s) { for (i = 0; i < nv50->num_textures[s]; ++i) pipe_sampler_view_reference(&nv50->textures[s][i], NULL); for (i = 0; i < 16; ++i) pipe_resource_reference(&nv50->constbuf[s][i], NULL); } }
/** * Prior to context destruction, this function unbinds all state objects. */ void cso_release_all( struct cso_context *ctx ) { unsigned i, shader; if (ctx->pipe) { 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->bind_vs_state( ctx->pipe, 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); } /* free fragment sampler views */ for (shader = 0; shader < Elements(ctx->samplers); shader++) { struct sampler_info *info = &ctx->samplers[shader]; for (i = 0; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) { pipe_sampler_view_reference(&info->views[i], NULL); pipe_sampler_view_reference(&info->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; } }
/** * 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 ); }
/** * Free all the temporary data in a scene. */ void lp_scene_end_rasterization(struct lp_scene *scene ) { int i, j; /* Unmap color buffers */ for (i = 0; i < scene->fb.nr_cbufs; i++) { if (scene->cbufs[i].map) { struct pipe_surface *cbuf = scene->fb.cbufs[i]; if (llvmpipe_resource_is_texture(cbuf->texture)) { llvmpipe_resource_unmap(cbuf->texture, cbuf->u.tex.level, cbuf->u.tex.first_layer); } scene->cbufs[i].map = NULL; } } /* Unmap z/stencil buffer */ if (scene->zsbuf.map) { struct pipe_surface *zsbuf = scene->fb.zsbuf; llvmpipe_resource_unmap(zsbuf->texture, zsbuf->u.tex.level, zsbuf->u.tex.first_layer); scene->zsbuf.map = NULL; } /* Reset all command lists: */ for (i = 0; i < scene->tiles_x; i++) { for (j = 0; j < scene->tiles_y; j++) { struct cmd_bin *bin = lp_scene_get_bin(scene, i, j); bin->head = NULL; bin->tail = NULL; bin->last_state = NULL; } } /* If there are any bins which weren't cleared by the loop above, * they will be caught (on debug builds at least) by this assert: */ assert(lp_scene_is_empty(scene)); /* Decrement texture ref counts */ { struct resource_ref *ref; int i, j = 0; for (ref = scene->resources; ref; ref = ref->next) { for (i = 0; i < ref->count; i++) { if (LP_DEBUG & DEBUG_SETUP) debug_printf("resource %d: %p %dx%d sz %d\n", j, (void *) ref->resource[i], ref->resource[i]->width0, ref->resource[i]->height0, llvmpipe_resource_size(ref->resource[i])); j++; pipe_resource_reference(&ref->resource[i], NULL); } } if (LP_DEBUG & DEBUG_SETUP) debug_printf("scene %d resources, sz %d\n", j, scene->resource_reference_size); } /* Free all scene data blocks: */ { struct data_block_list *list = &scene->data; struct data_block *block, *tmp; for (block = list->head->next; block; block = tmp) { tmp = block->next; FREE(block); } list->head->next = NULL; list->head->used = 0; } lp_fence_reference(&scene->fence, NULL); scene->resources = NULL; scene->scene_size = 0; scene->resource_reference_size = 0; scene->has_depthstencil_clear = FALSE; scene->alloc_failed = FALSE; util_unreference_framebuffer_state( &scene->fb ); }