From: Boris Brezillon Date: Thu, 5 Mar 2020 08:57:44 +0000 (+0100) Subject: panfrost: Move shared mem desc emission out of panfrost_launch_grid() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=36725be4d952117f75c112db7eecbd3bc1f3139e;p=mesa.git panfrost: Move shared mem desc emission out of panfrost_launch_grid() Let's move the shared memory descriptor emission to a dedicated function living with its pairs in pan_cmdstream.c. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 99b3f5eeb8b..7f723b699a4 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -422,3 +422,33 @@ panfrost_emit_const_buf(struct panfrost_batch *batch, buf->dirty_mask = 0; } + +void +panfrost_emit_shared_memory(struct panfrost_batch *batch, + const struct pipe_grid_info *info, + struct midgard_payload_vertex_tiler *vtp) +{ + struct panfrost_context *ctx = batch->ctx; + struct panfrost_shader_variants *all = ctx->shader[PIPE_SHADER_COMPUTE]; + struct panfrost_shader_state *ss = &all->variants[all->active_variant]; + unsigned single_size = util_next_power_of_two(MAX2(ss->shared_size, + 128)); + unsigned shared_size = single_size * info->grid[0] * info->grid[1] * + info->grid[2] * 4; + struct panfrost_bo *bo = panfrost_batch_get_shared_memory(batch, + shared_size, + 1); + + struct mali_shared_memory shared = { + .shared_memory = bo->gpu, + .shared_workgroup_count = + util_logbase2_ceil(info->grid[0]) + + util_logbase2_ceil(info->grid[1]) + + util_logbase2_ceil(info->grid[2]), + .shared_unk1 = 0x2, + .shared_shift = util_logbase2(single_size) - 1 + }; + + vtp->postfix.shared_memory = panfrost_upload_transient(batch, &shared, + sizeof(shared)); +} diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.h b/src/gallium/drivers/panfrost/pan_cmdstream.h index a9efca75e50..8ad9a8282d7 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.h +++ b/src/gallium/drivers/panfrost/pan_cmdstream.h @@ -26,6 +26,7 @@ #define __PAN_CMDSTREAM_H__ #include "pipe/p_defines.h" +#include "pipe/p_state.h" #include "panfrost-job.h" @@ -40,4 +41,9 @@ panfrost_emit_const_buf(struct panfrost_batch *batch, enum pipe_shader_type stage, struct midgard_payload_vertex_tiler *vtp); +void +panfrost_emit_shared_memory(struct panfrost_batch *batch, + const struct pipe_grid_info *info, + struct midgard_payload_vertex_tiler *vtp); + #endif /* __PAN_CMDSTREAM_H__ */ diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c index 9747c5cdab7..d344d862243 100644 --- a/src/gallium/drivers/panfrost/pan_compute.c +++ b/src/gallium/drivers/panfrost/pan_compute.c @@ -27,6 +27,7 @@ */ #include "pan_context.h" +#include "pan_cmdstream.h" #include "pan_bo.h" #include "util/u_memory.h" #include "nir_serialize.h" @@ -106,8 +107,6 @@ panfrost_launch_grid(struct pipe_context *pipe, /* TODO: Stub */ struct midgard_payload_vertex_tiler *payload = &ctx->payloads[PIPE_SHADER_COMPUTE]; - struct panfrost_shader_variants *all = ctx->shader[PIPE_SHADER_COMPUTE]; - struct panfrost_shader_state *ss = &all->variants[all->active_variant]; /* We implement OpenCL inputs as uniforms (or a UBO -- same thing), so * reuse the graphics path for this by lowering to Gallium */ @@ -123,22 +122,7 @@ panfrost_launch_grid(struct pipe_context *pipe, pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, &ubuf); panfrost_emit_for_draw(ctx, false); - - unsigned single_size = util_next_power_of_two(MAX2(ss->shared_size, 128)); - unsigned shared_size = single_size * info->grid[0] * info->grid[1] * info->grid[2] * 4; - - struct mali_shared_memory shared = { - .shared_memory = panfrost_batch_get_shared_memory(batch, shared_size, 1)->gpu, - .shared_workgroup_count = - util_logbase2_ceil(info->grid[0]) + - util_logbase2_ceil(info->grid[1]) + - util_logbase2_ceil(info->grid[2]), - .shared_unk1 = 0x2, - .shared_shift = util_logbase2(single_size) - 1 - }; - - payload->postfix.shared_memory = - panfrost_upload_transient(batch, &shared, sizeof(shared)); + panfrost_emit_shared_memory(batch, info, payload); /* Invoke according to the grid info */