mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 09:28:07 +02:00
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 <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4083>
This commit is contained in:
parent
0b735a2d80
commit
36725be4d9
3 changed files with 38 additions and 18 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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__ */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue