From d2fb489e0c49db645d2b4f892fafdd1a778251a7 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Wed, 13 Nov 2024 10:25:51 +0100 Subject: [PATCH] v3dv: use the double buffer heuristic helpers Reviewed-by: Jose Maria Casanova Crespo Part-of: --- src/broadcom/vulkan/v3dv_cmd_buffer.c | 34 ++++----------------------- src/broadcom/vulkan/v3dv_private.h | 7 +----- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index c61bf64839b..c134301719b 100644 --- a/src/broadcom/vulkan/v3dv_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c @@ -532,15 +532,7 @@ job_should_enable_double_buffer(struct v3dv_job *job) if (!job->can_use_double_buffer) return false; - /* Too much geometry processing */ - if (job->double_buffer_score.geom > 2000000) - return false; - - /* Too little rendering to make up for tile store latency */ - if (job->double_buffer_score.render < 100000) - return false; - - return true; + return v3d_double_buffer_score_ok(&job->double_buffer_score); } static void @@ -2916,34 +2908,18 @@ job_update_double_buffer_score(struct v3dv_job *job, return; } - /* Keep track of vertex processing: too much geometry processing would not - * be good for double-buffer. - */ - struct v3dv_shader_variant *vs_bin = - pipeline->shared_data->variants[BROADCOM_SHADER_VERTEX_BIN]; - assert(vs_bin); - uint32_t geom_score = vertex_count * compute_prog_score(vs_bin); - struct v3dv_shader_variant *vs = pipeline->shared_data->variants[BROADCOM_SHADER_VERTEX]; assert(vs); - uint32_t vs_score = vertex_count * compute_prog_score(vs); - geom_score += vs_score; - job->double_buffer_score.geom += geom_score; - - /* Compute pixel rendering cost. - * - * We estimate that on average a draw would render 0.2% of the pixels in - * the render area. That would be a 64x64 region in a 1920x1080 area. - */ struct v3dv_shader_variant *fs = pipeline->shared_data->variants[BROADCOM_SHADER_FRAGMENT]; assert(fs); - uint32_t pixel_count = 0.002f * render_area->width * render_area->height; - uint32_t render_score = vs_score + pixel_count * compute_prog_score(fs); - job->double_buffer_score.render += render_score; + v3d_update_double_buffer_score(vertex_count, + vs->qpu_insts_size, fs->qpu_insts_size, + vs->prog_data.base, fs->prog_data.base, + &job->double_buffer_score); } void diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index 66ba9171dde..9e40f292240 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -1190,12 +1190,7 @@ struct v3dv_job { /* This structure keeps track of various scores to inform a heuristic * for double-buffer mode. */ - struct { - /* Cost of geometry shading */ - uint32_t geom; - /* Cost of shader rendering */ - uint32_t render; - } double_buffer_score; + struct v3d_double_buffer_score double_buffer_score; /* We only need to allocate tile state for all layers if the binner * writes primitives to layers other than the first. This can only be