ac/nir: add support for bias/lod with texture gather
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 20 May 2020 13:50:50 +0000 (15:50 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 25 May 2020 06:51:10 +0000 (08:51 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5147>

src/amd/llvm/ac_nir_to_llvm.c

index e6f4e79aa58a3afaaa3a99a500f464e804b48243..959998c0c5dbf007e01f4f76e827103d3401ab85 100644 (file)
@@ -1470,7 +1470,8 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx,
                break;
        case nir_texop_tg4:
                args->opcode = ac_image_gather4;
-               args->level_zero = true;
+                if (!args->lod && !args->bias)
+                       args->level_zero = true;
                break;
        case nir_texop_lod:
                args->opcode = ac_image_get_lod;
@@ -4448,8 +4449,7 @@ static void visit_tex(struct ac_nir_context *ctx, nir_tex_instr *instr)
                        offset_src = i;
                        break;
                case nir_tex_src_bias:
-                       if (instr->op == nir_texop_txb)
-                               args.bias = get_src(ctx, instr->src[i].src);
+                       args.bias = get_src(ctx, instr->src[i].src);
                        break;
                case nir_tex_src_lod: {
                        if (nir_src_is_const(instr->src[i].src) && nir_src_as_uint(instr->src[i].src) == 0)