From: Boris Brezillon Date: Thu, 5 Mar 2020 17:43:13 +0000 (+0100) Subject: panfrost: Move sampler/tex descs emission helpers to pan_cmdstream.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8e0a08bc8eb2214bd2ba378a894c0b40568444cc;p=mesa.git panfrost: Move sampler/tex descs emission helpers to pan_cmdstream.c Move panfrost_upload_texture_descriptors() and panfrost_upload_sampler_descriptors() to pan_cmdstream.c where other cmdstream related helpers live. While at it, change their prototype and name to make it consistent with the other helpers and prepare things for ctx->payloads[] removal. 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 8d9f3553953..467884cdd0b 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -977,3 +977,71 @@ panfrost_emit_shared_memory(struct panfrost_batch *batch, vtp->postfix.shared_memory = panfrost_upload_transient(batch, &shared, sizeof(shared)); } + +static mali_ptr +panfrost_get_tex_desc(struct panfrost_batch *batch, + enum pipe_shader_type st, + struct panfrost_sampler_view *view) +{ + if (!view) + return (mali_ptr) 0; + + struct pipe_sampler_view *pview = &view->base; + struct panfrost_resource *rsrc = pan_resource(pview->texture); + + /* Add the BO to the job so it's retained until the job is done. */ + + panfrost_batch_add_bo(batch, rsrc->bo, + PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ | + panfrost_bo_access_for_stage(st)); + + panfrost_batch_add_bo(batch, view->bo, + PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ | + panfrost_bo_access_for_stage(st)); + + return view->bo->gpu; +} + +void +panfrost_emit_texture_descriptors(struct panfrost_batch *batch, + enum pipe_shader_type stage, + struct midgard_payload_vertex_tiler *vtp) +{ + struct panfrost_context *ctx = batch->ctx; + + if (!ctx->sampler_view_count[stage]) + return; + + uint64_t trampolines[PIPE_MAX_SHADER_SAMPLER_VIEWS]; + + for (int i = 0; i < ctx->sampler_view_count[stage]; ++i) + trampolines[i] = panfrost_get_tex_desc(batch, stage, + ctx->sampler_views[stage][i]); + + vtp->postfix.texture_trampoline = panfrost_upload_transient(batch, + trampolines, + sizeof(uint64_t) * + ctx->sampler_view_count[stage]); +} + +void +panfrost_emit_sampler_descriptors(struct panfrost_batch *batch, + enum pipe_shader_type stage, + struct midgard_payload_vertex_tiler *vtp) +{ + struct panfrost_context *ctx = batch->ctx; + + if (!ctx->sampler_count[stage]) + return; + + size_t desc_size = sizeof(struct mali_sampler_descriptor); + size_t transfer_size = desc_size * ctx->sampler_count[stage]; + struct panfrost_transfer transfer = panfrost_allocate_transient(batch, + transfer_size); + struct mali_sampler_descriptor *desc = (struct mali_sampler_descriptor *)transfer.cpu; + + for (int i = 0; i < ctx->sampler_count[stage]; ++i) + desc[i] = ctx->samplers[stage][i]->hw; + + vtp->postfix.sampler_descriptor = transfer.gpu; +} diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.h b/src/gallium/drivers/panfrost/pan_cmdstream.h index b493f91fa27..aa77b8b28e1 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.h +++ b/src/gallium/drivers/panfrost/pan_cmdstream.h @@ -66,4 +66,14 @@ panfrost_emit_shared_memory(struct panfrost_batch *batch, const struct pipe_grid_info *info, struct midgard_payload_vertex_tiler *vtp); +void +panfrost_emit_texture_descriptors(struct panfrost_batch *batch, + enum pipe_shader_type stage, + struct midgard_payload_vertex_tiler *vtp); + +void +panfrost_emit_sampler_descriptors(struct panfrost_batch *batch, + enum pipe_shader_type stage, + struct midgard_payload_vertex_tiler *vtp); + #endif /* __PAN_CMDSTREAM_H__ */ diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 05a821807b3..ba844cb1ca0 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -262,82 +262,6 @@ panfrost_stage_attributes(struct panfrost_context *ctx) ctx->payloads[PIPE_SHADER_VERTEX].postfix.attribute_meta = transfer.gpu; } -static void -panfrost_upload_sampler_descriptors(struct panfrost_context *ctx) -{ - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); - size_t desc_size = sizeof(struct mali_sampler_descriptor); - - for (int t = 0; t <= PIPE_SHADER_FRAGMENT; ++t) { - mali_ptr upload = 0; - - if (ctx->sampler_count[t]) { - size_t transfer_size = desc_size * ctx->sampler_count[t]; - - struct panfrost_transfer transfer = - panfrost_allocate_transient(batch, transfer_size); - - struct mali_sampler_descriptor *desc = - (struct mali_sampler_descriptor *) transfer.cpu; - - for (int i = 0; i < ctx->sampler_count[t]; ++i) - desc[i] = ctx->samplers[t][i]->hw; - - upload = transfer.gpu; - } - - ctx->payloads[t].postfix.sampler_descriptor = upload; - } -} - -static mali_ptr -panfrost_upload_tex( - struct panfrost_context *ctx, - enum pipe_shader_type st, - struct panfrost_sampler_view *view) -{ - if (!view) - return (mali_ptr) 0; - - struct pipe_sampler_view *pview = &view->base; - struct panfrost_resource *rsrc = pan_resource(pview->texture); - - /* Add the BO to the job so it's retained until the job is done. */ - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); - - panfrost_batch_add_bo(batch, rsrc->bo, - PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ | - panfrost_bo_access_for_stage(st)); - - panfrost_batch_add_bo(batch, view->bo, - PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ | - panfrost_bo_access_for_stage(st)); - - return view->bo->gpu; -} - -static void -panfrost_upload_texture_descriptors(struct panfrost_context *ctx) -{ - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); - - for (int t = 0; t <= PIPE_SHADER_FRAGMENT; ++t) { - mali_ptr trampoline = 0; - - if (ctx->sampler_view_count[t]) { - uint64_t trampolines[PIPE_MAX_SHADER_SAMPLER_VIEWS]; - - for (int i = 0; i < ctx->sampler_view_count[t]; ++i) - trampolines[i] = - panfrost_upload_tex(ctx, t, ctx->sampler_views[t][i]); - - trampoline = panfrost_upload_transient(batch, trampolines, sizeof(uint64_t) * ctx->sampler_view_count[t]); - } - - ctx->payloads[t].postfix.texture_trampoline = trampoline; - } -} - /* Compute number of UBOs active (more specifically, compute the highest UBO * number addressable -- if there are gaps, include them in the count anyway). * We always include UBO #0 in the count, since we *need* uniforms enabled for @@ -382,11 +306,11 @@ panfrost_emit_for_draw(struct panfrost_context *ctx) if (ctx->vertex) panfrost_stage_attributes(ctx); - panfrost_upload_sampler_descriptors(ctx); - panfrost_upload_texture_descriptors(ctx); - - for (int i = 0; i <= PIPE_SHADER_FRAGMENT; ++i) + for (int i = 0; i <= PIPE_SHADER_FRAGMENT; ++i) { + panfrost_emit_sampler_descriptors(batch, i, &ctx->payloads[i]); + panfrost_emit_texture_descriptors(batch, i, &ctx->payloads[i]); panfrost_emit_const_buf(batch, i, &ctx->payloads[i]); + } /* TODO: Upload the viewport somewhere more appropriate */