Mesa (master): radv: fix sample id loading

Dave Airlie airlied at kemper.freedesktop.org
Tue Nov 22 07:16:54 UTC 2016


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Nov 21 01:12:39 2016 +0000

radv: fix sample id loading

The sample id is packed into bits 8-12, so adjust
things properly.

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/amd/common/ac_nir_to_llvm.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 741a082..c68cb9c 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -379,6 +379,23 @@ static LLVMValueRef to_float(struct nir_to_llvm_context *ctx, LLVMValueRef v)
 	return v;
 }
 
+static LLVMValueRef unpack_param(struct nir_to_llvm_context *ctx,
+				 LLVMValueRef param, unsigned rshift,
+				 unsigned bitwidth)
+{
+	LLVMValueRef value = param;
+	if (rshift)
+		value = LLVMBuildLShr(ctx->builder, value,
+				      LLVMConstInt(ctx->i32, rshift, false), "");
+
+	if (rshift + bitwidth < 32) {
+		unsigned mask = (1 << bitwidth) - 1;
+		value = LLVMBuildAnd(ctx->builder, value,
+				     LLVMConstInt(ctx->i32, mask, false), "");
+	}
+	return value;
+}
+
 static LLVMValueRef build_gep0(struct nir_to_llvm_context *ctx,
 			       LLVMValueRef base_ptr, LLVMValueRef index)
 {
@@ -2895,7 +2912,7 @@ static void visit_intrinsic(struct nir_to_llvm_context *ctx,
 		result = ctx->start_instance;
 		break;
 	case nir_intrinsic_load_sample_id:
-		result = ctx->ancillary;
+		result = unpack_param(ctx, ctx->ancillary, 8, 4);
 		break;
 	case nir_intrinsic_load_sample_pos:
 		result = load_sample_pos(ctx);




More information about the mesa-commit mailing list