From 5d33d42b4d42abc9fb8b212222ca5f6d17d94e7d Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 5 Mar 2020 11:02:56 +0100 Subject: [PATCH] panfrost: Dissociate shader meta patching from the desc emission Right now we emit two shader descriptors for the fragment shader, one when panfrost_patch_shader_state() is called, and the final one including both the shader_meta and the blend RT descriptors. The first generated fragment shader descriptor is never used, since the second one overrides the postfix.shader pointer. Let's dissociate the state patching logic from the descriptor emission so we don't upload descriptors that are never used. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 23 +++++++++++++++++++++++ src/gallium/drivers/panfrost/pan_cmdstream.h | 5 +++++ src/gallium/drivers/panfrost/pan_context.c | 20 +++++--------------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 7f723b6..18a47b0 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -28,6 +28,29 @@ #include "pan_context.h" #include "pan_job.h" +void +panfrost_emit_shader_meta(struct panfrost_batch *batch, + enum pipe_shader_type st, + struct midgard_payload_vertex_tiler *vtp) +{ + struct panfrost_context *ctx = batch->ctx; + struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, st); + + if (!ss) { + vtp->postfix.shader = 0; + return; + } + + /* Add the shader BO to the batch. */ + panfrost_batch_add_bo(batch, ss->bo, + PAN_BO_ACCESS_PRIVATE | + PAN_BO_ACCESS_READ | + panfrost_bo_access_for_stage(st)); + + vtp->postfix.shader = panfrost_upload_transient(batch, ss->tripipe, + sizeof(*ss->tripipe)); +} + static void panfrost_mali_viewport_init(struct panfrost_context *ctx, struct mali_viewport *mvp) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.h b/src/gallium/drivers/panfrost/pan_cmdstream.h index 8ad9a82..326e4b2 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.h +++ b/src/gallium/drivers/panfrost/pan_cmdstream.h @@ -33,6 +33,11 @@ #include "pan_job.h" void +panfrost_emit_shader_meta(struct panfrost_batch *batch, + enum pipe_shader_type st, + struct midgard_payload_vertex_tiler *vtp); + +void panfrost_emit_viewport(struct panfrost_batch *batch, struct midgard_payload_vertex_tiler *tp); diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index a79da05..1f59591 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -538,10 +538,8 @@ panfrost_patch_shader_state(struct panfrost_context *ctx, { struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, stage); - if (!ss) { - ctx->payloads[stage].postfix.shader = 0; + if (!ss) return; - } ss->tripipe->texture_count = ctx->sampler_view_count[stage]; ss->tripipe->sampler_count = ctx->sampler_count[stage]; @@ -550,18 +548,6 @@ panfrost_patch_shader_state(struct panfrost_context *ctx, unsigned ubo_count = panfrost_ubo_count(ctx, stage); ss->tripipe->midgard1.uniform_buffer_count = ubo_count; - - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); - - /* Add the shader BO to the batch. */ - panfrost_batch_add_bo(batch, ss->bo, - PAN_BO_ACCESS_PRIVATE | - PAN_BO_ACCESS_READ | - panfrost_bo_access_for_stage(stage)); - - ctx->payloads[stage].postfix.shader = panfrost_upload_transient(batch, - ss->tripipe, - sizeof(struct mali_shader_meta)); } /* Go through dirty flags and actualise them in the cmdstream. */ @@ -601,7 +587,11 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) } panfrost_patch_shader_state(ctx, PIPE_SHADER_VERTEX); + panfrost_emit_shader_meta(batch, PIPE_SHADER_VERTEX, + &ctx->payloads[PIPE_SHADER_VERTEX]); panfrost_patch_shader_state(ctx, PIPE_SHADER_COMPUTE); + panfrost_emit_shader_meta(batch, PIPE_SHADER_COMPUTE, + &ctx->payloads[PIPE_SHADER_COMPUTE]); if (ctx->shader[PIPE_SHADER_VERTEX] && ctx->shader[PIPE_SHADER_FRAGMENT]) { /* Check if we need to link the gl_PointSize varying */ -- 2.7.4