radv/ac/llvm: trim texture return values
authorDave Airlie <airlied@redhat.com>
Mon, 24 Oct 2016 20:53:03 +0000 (06:53 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 27 Oct 2016 01:42:03 +0000 (11:42 +1000)
The intrinsic engine asserts in llvm due to this,
as we put a vec4 into a vec1, and the next instruction
isn't expecting it.

So trim the vector at the end before inserting it.

Reported-by: Christoph Haag <haagch+mesadev@frickel.club>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.c

index b602c5e61c525df718428b672b6f597ceb43c116..c12c506a892aab41a6c5ed4e17254e4a10528038 100644 (file)
@@ -3520,7 +3520,8 @@ static void visit_tex(struct nir_to_llvm_context *ctx, nir_tex_instr *instr)
                LLVMValueRef z = LLVMBuildExtractElement(ctx->builder, result, two, "");
                z = LLVMBuildSDiv(ctx->builder, z, six, "");
                result = LLVMBuildInsertElement(ctx->builder, result, z, two, "");
-       }
+       } else if (instr->dest.ssa.num_components != 4)
+               result = trim_vector(ctx, result, instr->dest.ssa.num_components);
 
 write_result:
        if (result) {