From f7c2fc7eba962a93a76cbd03673776de84bae038 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 16 Dec 2020 13:03:04 -0500 Subject: [PATCH] pan/bi: Add emit tex for builder Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index cdd86a5..722d13d 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -3582,6 +3582,37 @@ emit_tex(bi_context *ctx, nir_tex_instr *instr) } static void +bi_emit_tex(bi_builder *b, nir_tex_instr *instr) +{ + switch (instr->op) { + case nir_texop_txs: + bi_load_sysval(b, &instr->instr, 4, 0); + return; + case nir_texop_tex: + case nir_texop_txl: + case nir_texop_txb: + case nir_texop_txf: + case nir_texop_txf_ms: + break; + default: + unreachable("Invalid texture operation"); + } + + nir_alu_type base = nir_alu_type_get_base_type(instr->dest_type); + unsigned sz = nir_dest_bit_size(instr->dest); + + bool is_simple = bi_is_simple_tex(instr); + bool is_2d = instr->sampler_dim == GLSL_SAMPLER_DIM_2D || + instr->sampler_dim == GLSL_SAMPLER_DIM_EXTERNAL; + bool is_f = base == nir_type_float && (sz == 16 || sz == 32); + + if (is_simple && is_2d && is_f && !instr->is_shadow && !instr->is_array) + bi_emit_texs(b, instr); + else + bi_emit_texc(b, instr); +} + +static void emit_instr(bi_context *ctx, struct nir_instr *instr) { switch (instr->type) { -- 2.7.4