From 03350eb8b809d369a6af884a41dca0804c22de69 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 13 Aug 2019 09:27:16 -0700 Subject: [PATCH] pan/midgard: Add mir_ubo_shift helper Different UBO reads have different shift requirements. Signed-off-by: Alyssa Rosenzweig --- src/panfrost/midgard/compiler.h | 1 + src/panfrost/midgard/mir.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index e7b786dd7ac..942d288a326 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -441,6 +441,7 @@ bool mir_special_index(compiler_context *ctx, unsigned idx); unsigned mir_use_count(compiler_context *ctx, unsigned value); bool mir_is_written_before(compiler_context *ctx, midgard_instruction *ins, unsigned node); unsigned mir_mask_of_read_components(midgard_instruction *ins, unsigned node); +unsigned mir_ubo_shift(midgard_load_store_op op); /* MIR printing */ diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c index 8422e93c989..97921a419f2 100644 --- a/src/panfrost/midgard/mir.c +++ b/src/panfrost/midgard/mir.c @@ -425,3 +425,24 @@ mir_mask_of_read_components(midgard_instruction *ins, unsigned node) return mask; } + +unsigned +mir_ubo_shift(midgard_load_store_op op) +{ + switch (op) { + case midgard_op_ld_ubo_char: + return 0; + case midgard_op_ld_ubo_char2: + return 1; + case midgard_op_ld_ubo_char4: + return 2; + case midgard_op_ld_ubo_short4: + return 3; + case midgard_op_ld_ubo_int4: + return 4; + default: + unreachable("Invalid op"); + } +} + + -- 2.30.2