From 211aeb2dda17ddce2bdbdf36ecf39e169a42e364 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 11 May 2023 13:28:55 +0200 Subject: [PATCH] ir3: Add ir3_find_input_loc() helper Part-of: --- src/freedreno/ir3/ir3_shader.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index 5c62daeb544..1ace8840cc0 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -1035,6 +1035,29 @@ ir3_next_varying(const struct ir3_shader_variant *so, int i) return i; } +static inline int +ir3_find_input(const struct ir3_shader_variant *so, gl_varying_slot slot) +{ + int j = -1; + + while (true) { + j = ir3_next_varying(so, j); + + if (j >= so->inputs_count) + return -1; + + if (so->inputs[j].slot == slot) + return j; + } +} + +static inline unsigned +ir3_find_input_loc(const struct ir3_shader_variant *so, gl_varying_slot slot) +{ + int var = ir3_find_input(so, slot); + return var == -1 ? 0xff : so->inputs[var].inloc; +} + struct ir3_shader_linkage { /* Maximum location either consumed by the fragment shader or produced by * the last geometry stage, i.e. the size required for each vertex in the