llvmpipe: add local memory allocation path
authorDave Airlie <airlied@redhat.com>
Tue, 27 Aug 2019 05:30:15 +0000 (15:30 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 4 Sep 2019 05:22:20 +0000 (15:22 +1000)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/drivers/llvmpipe/lp_state_cs.c
src/gallium/drivers/llvmpipe/lp_state_cs.h

index a04313891f34381217b0a4311e77549c7a481801..1645a185cb26c0f350efbbfd7fd2b4cb5480c3d0 100644 (file)
@@ -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];
index 481a129ab6ee1fc7e00869c4ce5363f8e42a23a2..4bc434edd28bfb6e29085d9315135aaa2c03fb3f 100644 (file)
@@ -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;