From 8cf798d253c518de3f4158ee7204136316cfdbb1 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 8 Oct 2020 19:30:44 -0400 Subject: [PATCH] pan/bi: Implement FETCH For texelFetch. A few earlier header fields were wrong. Fixes dEQP-GLES2.functional.texture.mipmap.2d.generate.rgba8888_fastest Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bifrost.h | 10 ++++---- src/panfrost/bifrost/bifrost_compile.c | 32 +++++++++++++++++++++----- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index 33760227c9f..0592cc0ae0b 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -526,15 +526,15 @@ struct bifrost_texture_operation { /* Texture dimension, or 0 for a cubemap */ unsigned dimension : 2; - /* Method to compute LOD value */ - enum bifrost_lod_mode lod_mode : 3; + /* Method to compute LOD value or for a FETCH, the + * bifrost_texture_fetch component specification */ + enum bifrost_lod_mode lod_or_fetch : 3; /* Reserved */ unsigned zero : 1; - /* Register format for the result or for a FETCH, the - * bifrost_texture_fetch component specification */ - enum bifrost_texture_format_full format_or_fetch : 4; + /* Register format for the result */ + enum bifrost_texture_format_full format : 4; /* Write mask for the result */ unsigned mask : 4; diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 79ff7e74b09..ab12880a5a5 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -1184,6 +1184,7 @@ emit_texc(bi_context *ctx, nir_tex_instr *instr) case nir_texop_tex: case nir_texop_txl: case nir_texop_txb: + case nir_texop_txf: break; default: unreachable("Unsupported texture op"); @@ -1211,11 +1212,22 @@ emit_texc(bi_context *ctx, nir_tex_instr *instr) .shadow_or_clamp_disable = instr->is_shadow, .array = false, /* TODO */ .dimension = bifrost_tex_format(instr->sampler_dim), - .lod_mode = BIFROST_LOD_MODE_COMPUTE, - .format_or_fetch = bi_texture_format(instr->dest_type, BIFROST_NONE), /* TODO */ + .format = bi_texture_format(instr->dest_type, BIFROST_NONE), /* TODO */ .mask = (1 << tex.vector_channels) - 1 }; + switch (desc.op) { + case BIFROST_TEX_OP_TEX: + desc.lod_or_fetch = BIFROST_LOD_MODE_COMPUTE; + break; + case BIFROST_TEX_OP_FETCH: + /* TODO: gathers */ + desc.lod_or_fetch = BIFROST_TEXTURE_FETCH_TEXEL; + break; + default: + unreachable("texture op unsupported"); + } + /* 32-bit indices to be allocated as consecutive data registers. */ unsigned dregs[BIFROST_TEX_DREG_COUNT] = { 0 }; @@ -1235,25 +1247,33 @@ emit_texc(bi_context *ctx, nir_tex_instr *instr) case nir_tex_src_lod: if (nir_src_is_const(instr->src[i].src) && nir_src_as_uint(instr->src[i].src) == 0) { - desc.lod_mode = BIFROST_LOD_MODE_ZERO; - } else { + desc.lod_or_fetch = BIFROST_LOD_MODE_ZERO; + } else if (desc.op == BIFROST_TEX_OP_TEX) { assert(base == nir_type_float); assert(sz == 16 || sz == 32); dregs[BIFROST_TEX_DREG_LOD] = bi_emit_lod_88(ctx, index, sz == 16); - desc.lod_mode = BIFROST_LOD_MODE_EXPLICIT; + desc.lod_or_fetch = BIFROST_LOD_MODE_EXPLICIT; + } else { + assert(desc.op == BIFROST_TEX_OP_FETCH); + assert(base == nir_type_uint || base == nir_type_int); + assert(sz == 16 || sz == 32); + + dregs[BIFROST_TEX_DREG_LOD] = + bi_emit_lod_cube(ctx, index); } break; case nir_tex_src_bias: /* Upper 16-bits interpreted as a clamp, leave zero */ + assert(desc.op == BIFROST_TEX_OP_TEX); assert(base == nir_type_float); assert(sz == 16 || sz == 32); dregs[BIFROST_TEX_DREG_LOD] = bi_emit_lod_88(ctx, index, sz == 16); - desc.lod_mode = BIFROST_LOD_MODE_BIAS; + desc.lod_or_fetch = BIFROST_LOD_MODE_BIAS; break; default: