From 6453a22612d71d9b9031025f0cca16dc11fb1db8 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 27 Aug 2019 15:30:15 +1000 Subject: llvmpipe: add local memory allocation path Reviewed-by: Roland Scheidegger --- src/gallium/drivers/llvmpipe/lp_state_cs.c | 9 +++++++++ src/gallium/drivers/llvmpipe/lp_state_cs.h | 3 +++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index a04313891f3..1645a185cb2 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -48,6 +48,7 @@ struct lp_cs_job_info { unsigned grid_size[3]; unsigned block_size[3]; + unsigned req_local_mem; struct lp_cs_exec *current; }; @@ -395,6 +396,7 @@ llvmpipe_create_compute_state(struct pipe_context *pipe, assert(templ->ir_type == PIPE_SHADER_IR_TGSI); shader->base.tokens = tgsi_dup_tokens(templ->prog); + shader->req_local_mem = templ->req_local_mem; lp_build_tgsi_info(shader->base.tokens, &shader->info); make_empty_list(&shader->variants); @@ -1120,6 +1122,12 @@ cs_exec_fn(void *init_data, int iter_idx, struct lp_cs_local_mem *lmem) memset(&thread_data, 0, sizeof(thread_data)); + if (lmem->local_size < job_info->req_local_mem) { + lmem->local_size = job_info->req_local_mem; + lmem->local_mem_ptr = realloc(lmem->local_mem_ptr, lmem->local_size); + } + thread_data.shared = lmem->local_mem_ptr; + unsigned grid_z = iter_idx / (job_info->grid_size[0] * job_info->grid_size[1]); unsigned grid_y = (iter_idx - (grid_z * (job_info->grid_size[0] * job_info->grid_size[1]))) / job_info->grid_size[0]; unsigned grid_x = (iter_idx - (grid_z * (job_info->grid_size[0] * job_info->grid_size[1])) - (grid_y * job_info->grid_size[0])); @@ -1175,6 +1183,7 @@ static void llvmpipe_launch_grid(struct pipe_context *pipe, job_info.block_size[0] = info->block[0]; job_info.block_size[1] = info->block[1]; job_info.block_size[2] = info->block[2]; + job_info.req_local_mem = llvmpipe->cs->req_local_mem; job_info.current = &llvmpipe->csctx->cs.current; int num_tasks = job_info.grid_size[2] * job_info.grid_size[1] * job_info.grid_size[0]; diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.h b/src/gallium/drivers/llvmpipe/lp_state_cs.h index 481a129ab6e..4bc434edd28 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.h +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.h @@ -81,6 +81,9 @@ struct lp_compute_shader { struct lp_cs_variant_list_item variants; struct lp_tgsi_info info; + + uint32_t req_local_mem; + /* For debugging/profiling purposes */ unsigned variant_key_size; unsigned no; -- cgit v1.2.3