[Mesa-dev] [PATCH 01/14] ac: handle undefined EQAA samples in ac_apply_fmask_to_sample

Marek Olšák maraeo at gmail.com
Fri Jun 1 05:21:09 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

RADV might wanna use this helper too.
---
 src/amd/common/ac_llvm_build.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 4eebbbd4d9d..0a52c1d68bb 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -2584,25 +2584,27 @@ void ac_apply_fmask_to_sample(struct ac_llvm_context *ac, LLVMValueRef fmask,
 	LLVMValueRef fmask_value = ac_build_image_opcode(ac, &fmask_load);
 	fmask_value = LLVMBuildExtractElement(ac->builder, fmask_value,
 					      ac->i32_0, "");
 
 	/* Apply the formula. */
 	unsigned sample_chan = is_array_tex ? 3 : 2;
 	LLVMValueRef final_sample;
 	final_sample = LLVMBuildMul(ac->builder, addr[sample_chan],
 				    LLVMConstInt(ac->i32, 4, 0), "");
 	final_sample = LLVMBuildLShr(ac->builder, fmask_value, final_sample, "");
+	/* Mask the sample index by 0x7, because 0x8 means an unknown value
+	 * with EQAA, so those will map to 0. */
 	final_sample = LLVMBuildAnd(ac->builder, final_sample,
-				    LLVMConstInt(ac->i32, 0xF, 0), "");
+				    LLVMConstInt(ac->i32, 0x7, 0), "");
 
 	/* Don't rewrite the sample index if WORD1.DATA_FORMAT of the FMASK
-	 * resource descriptor is 0 (invalid),
+	 * resource descriptor is 0 (invalid).
 	 */
 	LLVMValueRef tmp;
 	tmp = LLVMBuildBitCast(ac->builder, fmask, ac->v8i32, "");
 	tmp = LLVMBuildExtractElement(ac->builder, tmp, ac->i32_1, "");
 	tmp = LLVMBuildICmp(ac->builder, LLVMIntNE, tmp, ac->i32_0, "");
 
 	/* Replace the MSAA sample index. */
 	addr[sample_chan] = LLVMBuildSelect(ac->builder, tmp, final_sample,
 					    addr[sample_chan], "");
 }
-- 
2.17.0



More information about the mesa-dev mailing list