From bf2904010341e31d0d66954fcbd88da4da4e1cdd Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 3 Dec 2019 13:41:56 +1000 Subject: [PATCH] gallivm: fix transpose for when first channel isn't created The previous fix worked when the second channel wasn't exposed, but a couple of piglit tests have inputs with just the y/z chans, no x/w. Partly Fixes piglit ext_transform_feedback-immediate-reuse-index-buffer with llvmpipe/nir Fixes: 5363cda52b84 ("gallivm: add swizzle support where one channel isn't defined.") Reviewed-by: Roland Scheidegger --- src/gallium/auxiliary/gallivm/lp_bld_swizzle.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c index 24fbd9a5a78..b648e681994 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c @@ -662,23 +662,29 @@ lp_build_transpose_aos(struct gallivm_state *gallivm, LLVMValueRef double_type_zero = LLVMConstNull(double_type); /* Interleave x, y, z, w -> xy and zw */ - if (src[0]) { + if (src[0] || src[1]) { + LLVMValueRef src0 = src[0]; LLVMValueRef src1 = src[1]; + if (!src0) + src0 = LLVMConstNull(single_type); if (!src1) src1 = LLVMConstNull(single_type); - t0 = lp_build_interleave2_half(gallivm, single_type_lp, src[0], src1, 0); - t2 = lp_build_interleave2_half(gallivm, single_type_lp, src[0], src1, 1); + t0 = lp_build_interleave2_half(gallivm, single_type_lp, src0, src1, 0); + t2 = lp_build_interleave2_half(gallivm, single_type_lp, src0, src1, 1); /* Cast to double width type for second interleave */ t0 = LLVMBuildBitCast(gallivm->builder, t0, double_type, "t0"); t2 = LLVMBuildBitCast(gallivm->builder, t2, double_type, "t2"); } - if (src[2]) { + if (src[2] || src[3]) { + LLVMValueRef src2 = src[2]; LLVMValueRef src3 = src[3]; + if (!src2) + src2 = LLVMConstNull(single_type); if (!src3) src3 = LLVMConstNull(single_type); - t1 = lp_build_interleave2_half(gallivm, single_type_lp, src[2], src3, 0); - t3 = lp_build_interleave2_half(gallivm, single_type_lp, src[2], src3, 1); + t1 = lp_build_interleave2_half(gallivm, single_type_lp, src2, src3, 0); + t3 = lp_build_interleave2_half(gallivm, single_type_lp, src2, src3, 1); /* Cast to double width type for second interleave */ t1 = LLVMBuildBitCast(gallivm->builder, t1, double_type, "t1"); -- 2.30.2