broadcom: add helpers for double-buffer heuristic

So we can share them between vulkan and gl.

Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32111>
This commit is contained in:
Iago Toral Quiroga
2024-11-13 10:55:29 +01:00
committed by Marge Bot
parent 3355ceec3b
commit d81bcbe3de
3 changed files with 53 additions and 1 deletions

View File

@@ -268,3 +268,23 @@ v3d_compute_rt_row_row_stride_128_bits(uint32_t tile_width,
return (tile_width * bpp) / 2;
}
static inline uint32_t
compute_prog_score(struct v3d_prog_data *p, uint32_t qpu_size)
{
const uint32_t inst_count = qpu_size / sizeof(uint64_t);
const uint32_t tmu_count = p->tmu_count + p->tmu_spills + p->tmu_fills;
return inst_count + 4 * tmu_count;
}
void
v3d_update_double_buffer_score(uint32_t vertex_count,
uint32_t vs_qpu_size,
uint32_t fs_qpu_size,
struct v3d_prog_data *vs,
struct v3d_prog_data *fs,
struct v3d_double_buffer_score *score)
{
score->geom += vertex_count * compute_prog_score(vs, vs_qpu_size);
score->render += compute_prog_score(fs, fs_qpu_size);
}

View File

@@ -27,6 +27,7 @@
#include "util/macros.h"
#include "common/v3d_device_info.h"
#include "compiler/shader_enums.h"
#include "broadcom/compiler/v3d_compiler.h"
#include "util/format/u_formats.h"
uint32_t
@@ -79,4 +80,35 @@ log2_tile_size(uint32_t size)
uint32_t
v3d_compute_rt_row_row_stride_128_bits(uint32_t tile_width,
uint32_t bpp);
struct v3d_double_buffer_score {
uint32_t geom;
uint32_t render;
};
void
v3d_update_double_buffer_score(uint32_t vertex_count,
uint32_t vs_qpu_size,
uint32_t fs_qpu_size,
struct v3d_prog_data *vs,
struct v3d_prog_data *fs,
struct v3d_double_buffer_score *score);
static inline bool
v3d_double_buffer_score_ok(struct v3d_double_buffer_score *score)
{
/* Double buffer decreases tile size, which increases
* VS invocations so too much geometry is not good.
*/
if (score->geom > 200000)
return false;
/* We want enough rendering work to be able to hide
* latency from tile stores.
*/
if (score->render < 200)
return false;
return true;
}
#endif

View File

@@ -70,7 +70,7 @@ libbroadcom_v3d = static_library(
link_whole : v3d_libs + per_version_libs,
link_with: [libv3d_neon],
build_by_default : false,
dependencies: [dep_valgrind, dep_thread, idep_mesautil],
dependencies: [dep_valgrind, dep_thread, idep_mesautil, idep_nir_headers],
)
if with_broadcom_vk