void draw_gs_destroy( struct draw_context *draw ) { if (draw->gs.tgsi.machine) { align_free(draw->gs.tgsi.machine->Primitives); tgsi_exec_machine_destroy(draw->gs.tgsi.machine); } }
static void softpipe_destroy( struct pipe_context *pipe ) { struct softpipe_context *softpipe = softpipe_context( pipe ); uint i, sh; #if DO_PSTIPPLE_IN_HELPER_MODULE if (softpipe->pstipple.sampler) pipe->delete_sampler_state(pipe, softpipe->pstipple.sampler); pipe_resource_reference(&softpipe->pstipple.texture, NULL); pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, NULL); #endif if (softpipe->draw) draw_destroy( softpipe->draw ); if (softpipe->quad.shade) softpipe->quad.shade->destroy( softpipe->quad.shade ); if (softpipe->quad.depth_test) softpipe->quad.depth_test->destroy( softpipe->quad.depth_test ); if (softpipe->quad.blend) softpipe->quad.blend->destroy( softpipe->quad.blend ); if (softpipe->quad.pstipple) softpipe->quad.pstipple->destroy( softpipe->quad.pstipple ); for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { sp_destroy_tile_cache(softpipe->cbuf_cache[i]); pipe_surface_reference(&softpipe->framebuffer.cbufs[i], NULL); } sp_destroy_tile_cache(softpipe->zsbuf_cache); pipe_surface_reference(&softpipe->framebuffer.zsbuf, NULL); for (sh = 0; sh < Elements(softpipe->tex_cache); sh++) { for (i = 0; i < Elements(softpipe->tex_cache[0]); i++) { sp_destroy_tex_tile_cache(softpipe->tex_cache[sh][i]); pipe_sampler_view_reference(&softpipe->sampler_views[sh][i], NULL); } } for (sh = 0; sh < Elements(softpipe->constants); sh++) { for (i = 0; i < Elements(softpipe->constants[0]); i++) { if (softpipe->constants[sh][i]) { pipe_resource_reference(&softpipe->constants[sh][i], NULL); } } } for (i = 0; i < softpipe->num_vertex_buffers; i++) { pipe_resource_reference(&softpipe->vertex_buffer[i].buffer, NULL); } tgsi_exec_machine_destroy(softpipe->fs_machine); FREE( softpipe ); }
static void softpipe_destroy( struct pipe_context *pipe ) { struct softpipe_context *softpipe = softpipe_context( pipe ); uint i; #if DO_PSTIPPLE_IN_HELPER_MODULE if (softpipe->pstipple.sampler) pipe->delete_sampler_state(pipe, softpipe->pstipple.sampler); pipe_resource_reference(&softpipe->pstipple.texture, NULL); pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, NULL); #endif if (softpipe->draw) draw_destroy( softpipe->draw ); if (softpipe->quad.shade) softpipe->quad.shade->destroy( softpipe->quad.shade ); if (softpipe->quad.depth_test) softpipe->quad.depth_test->destroy( softpipe->quad.depth_test ); if (softpipe->quad.blend) softpipe->quad.blend->destroy( softpipe->quad.blend ); if (softpipe->quad.pstipple) softpipe->quad.pstipple->destroy( softpipe->quad.pstipple ); for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { sp_destroy_tile_cache(softpipe->cbuf_cache[i]); pipe_surface_reference(&softpipe->framebuffer.cbufs[i], NULL); } sp_destroy_tile_cache(softpipe->zsbuf_cache); pipe_surface_reference(&softpipe->framebuffer.zsbuf, NULL); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { sp_destroy_tex_tile_cache(softpipe->fragment_tex_cache[i]); pipe_sampler_view_reference(&softpipe->fragment_sampler_views[i], NULL); } for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { sp_destroy_tex_tile_cache(softpipe->vertex_tex_cache[i]); pipe_sampler_view_reference(&softpipe->vertex_sampler_views[i], NULL); } for (i = 0; i < PIPE_MAX_GEOMETRY_SAMPLERS; i++) { sp_destroy_tex_tile_cache(softpipe->geometry_tex_cache[i]); pipe_sampler_view_reference(&softpipe->geometry_sampler_views[i], NULL); } for (i = 0; i < PIPE_SHADER_TYPES; i++) { uint j; for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) { if (softpipe->constants[i][j]) { pipe_resource_reference(&softpipe->constants[i][j], NULL); } } } for (i = 0; i < softpipe->num_vertex_buffers; i++) { pipe_resource_reference(&softpipe->vertex_buffer[i].buffer, NULL); } tgsi_exec_machine_destroy(softpipe->fs_machine); FREE( softpipe ); }
void softpipe_launch_grid(struct pipe_context *context, const struct pipe_grid_info *info) { struct softpipe_context *softpipe = softpipe_context(context); struct sp_compute_shader *cs = softpipe->cs; int num_threads_in_group; struct tgsi_exec_machine **machines; int bwidth, bheight, bdepth; int w, h, d, i; int g_w, g_h, g_d; uint32_t grid_size[3]; void *local_mem = NULL; softpipe_update_compute_samplers(softpipe); bwidth = cs->info.properties[TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH]; bheight = cs->info.properties[TGSI_PROPERTY_CS_FIXED_BLOCK_HEIGHT]; bdepth = cs->info.properties[TGSI_PROPERTY_CS_FIXED_BLOCK_DEPTH]; num_threads_in_group = bwidth * bheight * bdepth; fill_grid_size(context, info, grid_size); if (cs->shader.req_local_mem) { local_mem = CALLOC(1, cs->shader.req_local_mem); } machines = CALLOC(sizeof(struct tgsi_exec_machine *), num_threads_in_group); if (!machines) { FREE(local_mem); return; } /* initialise machines + GRID_SIZE + THREAD_ID + BLOCK_SIZE */ for (d = 0; d < bdepth; d++) { for (h = 0; h < bheight; h++) { for (w = 0; w < bwidth; w++) { int idx = w + (h * bwidth) + (d * bheight * bwidth); machines[idx] = tgsi_exec_machine_create(PIPE_SHADER_COMPUTE); machines[idx]->LocalMem = local_mem; machines[idx]->LocalMemSize = cs->shader.req_local_mem; cs_prepare(cs, machines[idx], w, h, d, grid_size[0], grid_size[1], grid_size[2], bwidth, bheight, bdepth, (struct tgsi_sampler *)softpipe->tgsi.sampler[PIPE_SHADER_COMPUTE], (struct tgsi_image *)softpipe->tgsi.image[PIPE_SHADER_COMPUTE], (struct tgsi_buffer *)softpipe->tgsi.buffer[PIPE_SHADER_COMPUTE]); tgsi_exec_set_constant_buffers(machines[idx], PIPE_MAX_CONSTANT_BUFFERS, softpipe->mapped_constants[PIPE_SHADER_COMPUTE], softpipe->const_buffer_size[PIPE_SHADER_COMPUTE]); } } } for (g_d = 0; g_d < grid_size[2]; g_d++) { for (g_h = 0; g_h < grid_size[1]; g_h++) { for (g_w = 0; g_w < grid_size[0]; g_w++) { run_workgroup(cs, g_w, g_h, g_d, num_threads_in_group, machines); } } } for (i = 0; i < num_threads_in_group; i++) { cs_delete(cs, machines[i]); tgsi_exec_machine_destroy(machines[i]); } FREE(local_mem); FREE(machines); }