/** * Create new lp_rasterizer. If num_threads is zero, don't create any * new threads, do rendering synchronously. * \param num_threads number of rasterizer threads to create */ struct lp_rasterizer * lp_rast_create( unsigned num_threads ) { struct lp_rasterizer *rast; unsigned i; rast = CALLOC_STRUCT(lp_rasterizer); if(!rast) return NULL; rast->full_scenes = lp_scene_queue_create(); for (i = 0; i < Elements(rast->tasks); i++) { struct lp_rasterizer_task *task = &rast->tasks[i]; task->rast = rast; task->thread_index = i; } rast->num_threads = num_threads; create_rast_threads(rast); /* for synchronizing rasterization threads */ pipe_barrier_init( &rast->barrier, rast->num_threads ); memset(lp_swizzled_cbuf, 0, sizeof lp_swizzled_cbuf); memset(lp_dummy_tile, 0, sizeof lp_dummy_tile); return rast; }
/** * Create new lp_rasterizer. If num_threads is zero, don't create any * new threads, do rendering synchronously. * \param num_threads number of rasterizer threads to create */ struct lp_rasterizer * lp_rast_create( unsigned num_threads ) { struct lp_rasterizer *rast; unsigned i; rast = CALLOC_STRUCT(lp_rasterizer); if (!rast) { goto no_rast; } rast->full_scenes = lp_scene_queue_create(); if (!rast->full_scenes) { goto no_full_scenes; } for (i = 0; i < MAX2(1, num_threads); i++) { struct lp_rasterizer_task *task = &rast->tasks[i]; task->rast = rast; task->thread_index = i; task->thread_data.cache = align_malloc(sizeof(struct lp_build_format_cache), 16); if (!task->thread_data.cache) { goto no_thread_data_cache; } } rast->num_threads = num_threads; rast->no_rast = debug_get_bool_option("LP_NO_RAST", FALSE); create_rast_threads(rast); /* for synchronizing rasterization threads */ if (rast->num_threads > 0) { pipe_barrier_init( &rast->barrier, rast->num_threads ); } memset(lp_dummy_tile, 0, sizeof lp_dummy_tile); return rast; no_thread_data_cache: for (i = 0; i < MAX2(1, rast->num_threads); i++) { if (rast->tasks[i].thread_data.cache) { align_free(rast->tasks[i].thread_data.cache); } } lp_scene_queue_destroy(rast->full_scenes); no_full_scenes: FREE(rast); no_rast: return NULL; }
/** * Create new lp_rasterizer. If num_threads is zero, don't create any * new threads, do rendering synchronously. * \param num_threads number of rasterizer threads to create */ struct lp_rasterizer * lp_rast_create( unsigned num_threads ) { struct lp_rasterizer *rast; unsigned i; rast = CALLOC_STRUCT(lp_rasterizer); if (!rast) { goto no_rast; } rast->full_scenes = lp_scene_queue_create(); if (!rast->full_scenes) { goto no_full_scenes; } for (i = 0; i < Elements(rast->tasks); i++) { struct lp_rasterizer_task *task = &rast->tasks[i]; task->rast = rast; task->thread_index = i; } rast->num_threads = num_threads; rast->no_rast = debug_get_bool_option("LP_NO_RAST", FALSE); create_rast_threads(rast); /* for synchronizing rasterization threads */ pipe_barrier_init( &rast->barrier, rast->num_threads ); memset(lp_swizzled_cbuf, 0, sizeof lp_swizzled_cbuf); memset(lp_dummy_tile, 0, sizeof lp_dummy_tile); return rast; no_full_scenes: FREE(rast); no_rast: return NULL; }