panfrost: Separate postfix from emits
This is the easy subset, where we have functions that take in a postfix pointer but only to use as a return address. We can use an actual return instead, which is a bit simpler and helps prepare for condensed postfix packing. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6476>
This commit is contained in:
parent
59b6e3c98c
commit
b7169367fd
|
@ -51,12 +51,10 @@ panfrost_bo_access_for_stage(enum pipe_shader_type stage)
|
|||
PAN_BO_ACCESS_VERTEX_TILER;
|
||||
}
|
||||
|
||||
static void
|
||||
panfrost_vt_emit_shared_memory(struct panfrost_context *ctx,
|
||||
struct mali_vertex_tiler_postfix *postfix)
|
||||
static mali_ptr
|
||||
panfrost_vt_emit_shared_memory(struct panfrost_batch *batch)
|
||||
{
|
||||
struct panfrost_device *dev = pan_device(ctx->base.screen);
|
||||
struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
|
||||
struct panfrost_device *dev = pan_device(batch->ctx->base.screen);
|
||||
|
||||
struct mali_shared_memory shared = {
|
||||
.shared_workgroup_count = ~0,
|
||||
|
@ -72,15 +70,7 @@ panfrost_vt_emit_shared_memory(struct panfrost_context *ctx,
|
|||
shared.scratchpad = stack->gpu;
|
||||
}
|
||||
|
||||
postfix->shared_memory = panfrost_pool_upload_aligned(&batch->pool, &shared, sizeof(shared), 64);
|
||||
}
|
||||
|
||||
static void
|
||||
panfrost_vt_attach_framebuffer(struct panfrost_context *ctx,
|
||||
struct mali_vertex_tiler_postfix *postfix)
|
||||
{
|
||||
struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
|
||||
postfix->shared_memory = panfrost_batch_reserve_framebuffer(batch);
|
||||
return panfrost_pool_upload_aligned(&batch->pool, &shared, sizeof(shared), 64);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -138,6 +128,7 @@ panfrost_vt_init(struct panfrost_context *ctx,
|
|||
struct mali_vertex_tiler_postfix *postfix)
|
||||
{
|
||||
struct panfrost_device *device = pan_device(ctx->base.screen);
|
||||
struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
|
||||
|
||||
if (!ctx->shader[stage])
|
||||
return;
|
||||
|
@ -147,10 +138,10 @@ panfrost_vt_init(struct panfrost_context *ctx,
|
|||
|
||||
if (device->quirks & IS_BIFROST) {
|
||||
postfix->gl_enables = 0x2;
|
||||
panfrost_vt_emit_shared_memory(ctx, postfix);
|
||||
postfix->shared_memory = panfrost_vt_emit_shared_memory(batch);
|
||||
} else {
|
||||
postfix->gl_enables = 0x6;
|
||||
panfrost_vt_attach_framebuffer(ctx, postfix);
|
||||
postfix->shared_memory = panfrost_batch_reserve_framebuffer(batch);
|
||||
}
|
||||
|
||||
if (stage == PIPE_SHADER_FRAGMENT) {
|
||||
|
@ -747,9 +738,8 @@ panfrost_emit_frag_shader_meta(struct panfrost_batch *batch)
|
|||
return xfer.gpu;
|
||||
}
|
||||
|
||||
void
|
||||
panfrost_emit_viewport(struct panfrost_batch *batch,
|
||||
struct mali_vertex_tiler_postfix *tiler_postfix)
|
||||
mali_ptr
|
||||
panfrost_emit_viewport(struct panfrost_batch *batch)
|
||||
{
|
||||
struct panfrost_context *ctx = batch->ctx;
|
||||
const struct pipe_viewport_state *vp = &ctx->pipe_viewport;
|
||||
|
@ -794,8 +784,8 @@ panfrost_emit_viewport(struct panfrost_batch *batch,
|
|||
cfg.maximum_z = rast->depth_clip_far ? maxz : INFINITY;
|
||||
}
|
||||
|
||||
tiler_postfix->viewport = T.gpu;
|
||||
panfrost_batch_union_scissor(batch, minx, miny, maxx, maxy);
|
||||
return T.gpu;
|
||||
}
|
||||
|
||||
static mali_ptr
|
||||
|
@ -1083,10 +1073,9 @@ panfrost_emit_const_buf(struct panfrost_batch *batch,
|
|||
buf->dirty_mask = 0;
|
||||
}
|
||||
|
||||
void
|
||||
mali_ptr
|
||||
panfrost_emit_shared_memory(struct panfrost_batch *batch,
|
||||
const struct pipe_grid_info *info,
|
||||
struct midgard_payload_vertex_tiler *vtp)
|
||||
const struct pipe_grid_info *info)
|
||||
{
|
||||
struct panfrost_context *ctx = batch->ctx;
|
||||
struct panfrost_device *dev = pan_device(ctx->base.screen);
|
||||
|
@ -1111,8 +1100,8 @@ panfrost_emit_shared_memory(struct panfrost_batch *batch,
|
|||
.shared_shift = util_logbase2(single_size) + 1
|
||||
};
|
||||
|
||||
vtp->postfix.shared_memory = panfrost_pool_upload_aligned(&batch->pool, &shared,
|
||||
sizeof(shared), 64);
|
||||
return panfrost_pool_upload_aligned(&batch->pool, &shared,
|
||||
sizeof(shared), 64);
|
||||
}
|
||||
|
||||
static mali_ptr
|
||||
|
@ -1151,16 +1140,15 @@ panfrost_update_sampler_view(struct panfrost_sampler_view *view,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
mali_ptr
|
||||
panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
|
||||
enum pipe_shader_type stage,
|
||||
struct mali_vertex_tiler_postfix *postfix)
|
||||
enum pipe_shader_type stage)
|
||||
{
|
||||
struct panfrost_context *ctx = batch->ctx;
|
||||
struct panfrost_device *device = pan_device(ctx->base.screen);
|
||||
|
||||
if (!ctx->sampler_view_count[stage])
|
||||
return;
|
||||
return 0;
|
||||
|
||||
if (device->quirks & IS_BIFROST) {
|
||||
struct panfrost_transfer T = panfrost_pool_alloc_aligned(&batch->pool,
|
||||
|
@ -1190,7 +1178,7 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
|
|||
panfrost_bo_access_for_stage(stage));
|
||||
}
|
||||
|
||||
postfix->textures = T.gpu;
|
||||
return T.gpu;
|
||||
} else {
|
||||
uint64_t trampolines[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||
|
||||
|
@ -1202,23 +1190,21 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
|
|||
trampolines[i] = panfrost_get_tex_desc(batch, stage, view);
|
||||
}
|
||||
|
||||
postfix->textures = panfrost_pool_upload_aligned(&batch->pool,
|
||||
trampolines,
|
||||
sizeof(uint64_t) *
|
||||
ctx->sampler_view_count[stage],
|
||||
sizeof(uint64_t));
|
||||
return panfrost_pool_upload_aligned(&batch->pool, trampolines,
|
||||
sizeof(uint64_t) *
|
||||
ctx->sampler_view_count[stage],
|
||||
sizeof(uint64_t));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mali_ptr
|
||||
panfrost_emit_sampler_descriptors(struct panfrost_batch *batch,
|
||||
enum pipe_shader_type stage,
|
||||
struct mali_vertex_tiler_postfix *postfix)
|
||||
enum pipe_shader_type stage)
|
||||
{
|
||||
struct panfrost_context *ctx = batch->ctx;
|
||||
|
||||
if (!ctx->sampler_count[stage])
|
||||
return;
|
||||
return 0;
|
||||
|
||||
size_t desc_size = MALI_BIFROST_SAMPLER_LENGTH;
|
||||
assert(MALI_BIFROST_SAMPLER_LENGTH == MALI_MIDGARD_SAMPLER_LENGTH);
|
||||
|
@ -1230,7 +1216,7 @@ panfrost_emit_sampler_descriptors(struct panfrost_batch *batch,
|
|||
for (unsigned i = 0; i < ctx->sampler_count[stage]; ++i)
|
||||
out[i] = ctx->samplers[stage][i]->hw;
|
||||
|
||||
postfix->sampler_descriptor = T.gpu;
|
||||
return T.gpu;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -57,29 +57,25 @@ panfrost_emit_compute_shader_meta(struct panfrost_batch *batch, enum pipe_shader
|
|||
mali_ptr
|
||||
panfrost_emit_frag_shader_meta(struct panfrost_batch *batch);
|
||||
|
||||
void
|
||||
panfrost_emit_viewport(struct panfrost_batch *batch,
|
||||
struct mali_vertex_tiler_postfix *tiler_postfix);
|
||||
mali_ptr
|
||||
panfrost_emit_viewport(struct panfrost_batch *batch);
|
||||
|
||||
void
|
||||
panfrost_emit_const_buf(struct panfrost_batch *batch,
|
||||
enum pipe_shader_type stage,
|
||||
struct mali_vertex_tiler_postfix *postfix);
|
||||
|
||||
void
|
||||
mali_ptr
|
||||
panfrost_emit_shared_memory(struct panfrost_batch *batch,
|
||||
const struct pipe_grid_info *info,
|
||||
struct midgard_payload_vertex_tiler *vtp);
|
||||
const struct pipe_grid_info *info);
|
||||
|
||||
void
|
||||
mali_ptr
|
||||
panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
|
||||
enum pipe_shader_type stage,
|
||||
struct mali_vertex_tiler_postfix *postfix);
|
||||
enum pipe_shader_type stage);
|
||||
|
||||
void
|
||||
mali_ptr
|
||||
panfrost_emit_sampler_descriptors(struct panfrost_batch *batch,
|
||||
enum pipe_shader_type stage,
|
||||
struct mali_vertex_tiler_postfix *postfix);
|
||||
enum pipe_shader_type stage);
|
||||
|
||||
void
|
||||
panfrost_emit_vertex_data(struct panfrost_batch *batch,
|
||||
|
|
|
@ -121,7 +121,7 @@ panfrost_launch_grid(struct pipe_context *pipe,
|
|||
|
||||
payload.postfix.shader = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_COMPUTE);
|
||||
panfrost_emit_const_buf(batch, PIPE_SHADER_COMPUTE, &payload.postfix);
|
||||
panfrost_emit_shared_memory(batch, info, &payload);
|
||||
payload.postfix.shared_memory = panfrost_emit_shared_memory(batch, info);
|
||||
|
||||
/* Invoke according to the grid info */
|
||||
|
||||
|
|
|
@ -325,13 +325,13 @@ panfrost_draw_vbo(
|
|||
ctx->instance_count,
|
||||
&vertex_postfix, &tiler_postfix,
|
||||
&primitive_size);
|
||||
panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
|
||||
panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
|
||||
panfrost_emit_texture_descriptors(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
|
||||
panfrost_emit_texture_descriptors(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
|
||||
vertex_postfix.sampler_descriptor = panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_VERTEX);
|
||||
tiler_postfix.sampler_descriptor = panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_FRAGMENT);
|
||||
vertex_postfix.textures = panfrost_emit_texture_descriptors(batch, PIPE_SHADER_VERTEX);
|
||||
tiler_postfix.textures = panfrost_emit_texture_descriptors(batch, PIPE_SHADER_FRAGMENT);
|
||||
panfrost_emit_const_buf(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
|
||||
panfrost_emit_const_buf(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
|
||||
panfrost_emit_viewport(batch, &tiler_postfix);
|
||||
tiler_postfix.viewport = panfrost_emit_viewport(batch);
|
||||
|
||||
vertex_postfix.shader = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_VERTEX);
|
||||
tiler_postfix.shader = panfrost_emit_frag_shader_meta(batch);
|
||||
|
|
Loading…
Reference in New Issue