From a80f02607382fc71b721f4d9d838eecd6e148bf5 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Wed, 17 May 2023 15:02:09 +0200 Subject: [PATCH] ir3: Add helper to determine when variant exceeds safe constlen This will help us not compile extra variants as often in the unlinked case, which will become the only case on turnip. Part-of: --- src/freedreno/ir3/ir3_shader.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index 02e6650..7ed917c 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -910,10 +910,8 @@ ir3_const_state(const struct ir3_shader_variant *v) return v->const_state; } -/* Given a variant, calculate the maximum constlen it can have. - */ static inline unsigned -ir3_max_const(const struct ir3_shader_variant *v) +_ir3_max_const(const struct ir3_shader_variant *v, bool safe_constlen) { const struct ir3_compiler *compiler = v->compiler; bool shared_consts_enable = ir3_const_state(v)->shared_consts_enable; @@ -935,7 +933,7 @@ ir3_max_const(const struct ir3_shader_variant *v) if ((v->type == MESA_SHADER_COMPUTE) || (v->type == MESA_SHADER_KERNEL)) { return compiler->max_const_compute - shared_consts_size; - } else if (v->key.safe_constlen) { + } else if (safe_constlen) { return compiler->max_const_safe - safe_shared_consts_size; } else if (v->type == MESA_SHADER_FRAGMENT) { return compiler->max_const_frag - shared_consts_size; @@ -944,6 +942,23 @@ ir3_max_const(const struct ir3_shader_variant *v) } } +/* Given a variant, calculate the maximum constlen it can have. + */ +static inline unsigned +ir3_max_const(const struct ir3_shader_variant *v) +{ + return _ir3_max_const(v, v->key.safe_constlen); +} + +/* Return true if a variant may need to be recompiled due to exceeding the + * maximum "safe" constlen. + */ +static inline bool +ir3_exceeds_safe_constlen(const struct ir3_shader_variant *v) +{ + return v->constlen > _ir3_max_const(v, true); +} + void *ir3_shader_assemble(struct ir3_shader_variant *v); struct ir3_shader_variant * ir3_shader_create_variant(struct ir3_shader *shader, -- 2.7.4