[Mesa-dev] [PATCH 22/38] ac/nir: implement 8 and 16 bit ac_build_readlane

Rhys Perry pendingchaos02 at gmail.com
Fri Dec 7 17:22:15 UTC 2018


Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
---
 src/amd/common/ac_llvm_build.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index f394d16bc9..6266058b77 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -3149,9 +3149,15 @@ ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef la
 {
 	LLVMTypeRef src_type = LLVMTypeOf(src);
 	src = ac_to_integer(ctx, src);
-	unsigned bits = LLVMGetIntTypeWidth(LLVMTypeOf(src));
+	unsigned src_bits = LLVMGetIntTypeWidth(LLVMTypeOf(src));
+	unsigned bits = src_bits;
 	LLVMValueRef ret;
 
+	if (bits < 32) {
+		src = LLVMBuildZExt(ctx->builder, src, ctx->i32, "");
+		bits = 32;
+	}
+
 	if (bits == 32) {
 		ret = _ac_build_readlane(ctx, src, lane);
 	} else {
@@ -3168,6 +3174,10 @@ ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef la
 						LLVMConstInt(ctx->i32, i, 0), "");
 		}
 	}
+
+	if (src_bits < 32)
+		ret = LLVMBuildTrunc(ctx->builder, ret, ac_int_of_size(ctx, src_bits), "");
+
 	return LLVMBuildBitCast(ctx->builder, ret, src_type, "");
 }
 
-- 
2.19.2



More information about the mesa-dev mailing list