Mesa (master): ac: add 8-bit and 16-bit supports to ac_build_readlane()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 19 18:01:47 UTC 2019


Module: Mesa
Branch: master
Commit: c29514bd226028631b12ae92529d862f8b5de707
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c29514bd226028631b12ae92529d862f8b5de707

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Fri Nov  8 13:00:50 2019 +0100

ac: add 8-bit and 16-bit supports to ac_build_readlane()

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

---

 src/amd/llvm/ac_llvm_build.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index f2349018dee..13c093fb3e6 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -3566,14 +3566,23 @@ void ac_apply_fmask_to_sample(struct ac_llvm_context *ac, LLVMValueRef fmask,
 static LLVMValueRef
 _ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef lane)
 {
+	LLVMTypeRef type = LLVMTypeOf(src);
+	LLVMValueRef result;
+
 	ac_build_optimization_barrier(ctx, &src);
-	return ac_build_intrinsic(ctx,
+
+	src = LLVMBuildZExt(ctx->builder, src, ctx->i32, "");
+	if (lane)
+		lane = LLVMBuildZExt(ctx->builder, lane, ctx->i32, "");
+
+	result = ac_build_intrinsic(ctx,
 			lane == NULL ? "llvm.amdgcn.readfirstlane" : "llvm.amdgcn.readlane",
-			LLVMTypeOf(src), (LLVMValueRef []) {
-			src, lane },
+			ctx->i32, (LLVMValueRef []) { src, lane },
 			lane == NULL ? 1 : 2,
 			AC_FUNC_ATTR_READNONE |
 			AC_FUNC_ATTR_CONVERGENT);
+
+	return LLVMBuildTrunc(ctx->builder, result, type, "");
 }
 
 /**
@@ -3591,9 +3600,7 @@ ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef la
 	unsigned bits = LLVMGetIntTypeWidth(LLVMTypeOf(src));
 	LLVMValueRef ret;
 
-	if (bits == 32) {
-		ret = _ac_build_readlane(ctx, src, lane);
-	} else {
+	if (bits > 32) {
 		assert(bits % 32 == 0);
 		LLVMTypeRef vec_type = LLVMVectorType(ctx->i32, bits / 32);
 		LLVMValueRef src_vector =
@@ -3606,7 +3613,10 @@ ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef la
 			ret = LLVMBuildInsertElement(ctx->builder, ret, ret_comp,
 						LLVMConstInt(ctx->i32, i, 0), "");
 		}
+	} else {
+		ret = _ac_build_readlane(ctx, src, lane);
 	}
+
 	if (LLVMGetTypeKind(src_type) == LLVMPointerTypeKind)
 		return LLVMBuildIntToPtr(ctx->builder, ret, src_type, "");
 	return LLVMBuildBitCast(ctx->builder, ret, src_type, "");




More information about the mesa-commit mailing list