[Mesa-dev] [PATCH 2/6] ac/nir: refactor out the fmask descriptor validation.
Dave Airlie
airlied at gmail.com
Mon Mar 19 07:26:53 UTC 2018
From: Dave Airlie <airlied at redhat.com>
This just moves this out for later reuse.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/amd/common/ac_nir_to_llvm.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index fa8f91b321d..ab4441e43b4 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -1944,6 +1944,23 @@ glsl_is_array_image(const struct glsl_type *type)
dim == GLSL_SAMPLER_DIM_SUBPASS_MS;
}
+static LLVMValueRef get_fmask_desc_valid(struct ac_llvm_context *ctx,
+ LLVMValueRef fmask_desc_ptr)
+{
+ LLVMValueRef fmask_desc =
+ LLVMBuildBitCast(ctx->builder, fmask_desc_ptr,
+ ctx->v8i32, "");
+
+ LLVMValueRef fmask_word1 =
+ LLVMBuildExtractElement(ctx->builder, fmask_desc,
+ ctx->i32_1, "");
+
+ LLVMValueRef word1_is_nonzero =
+ LLVMBuildICmp(ctx->builder, LLVMIntNE,
+ fmask_word1, ctx->i32_0, "");
+
+ return word1_is_nonzero;
+}
/* Adjust the sample index according to FMASK.
*
@@ -2003,17 +2020,7 @@ static LLVMValueRef adjust_sample_index_using_fmask(struct ac_llvm_context *ctx,
/* Don't rewrite the sample index if WORD1.DATA_FORMAT of the FMASK
* resource descriptor is 0 (invalid),
*/
- LLVMValueRef fmask_desc =
- LLVMBuildBitCast(ctx->builder, fmask_desc_ptr,
- ctx->v8i32, "");
-
- LLVMValueRef fmask_word1 =
- LLVMBuildExtractElement(ctx->builder, fmask_desc,
- ctx->i32_1, "");
-
- LLVMValueRef word1_is_nonzero =
- LLVMBuildICmp(ctx->builder, LLVMIntNE,
- fmask_word1, ctx->i32_0, "");
+ LLVMValueRef word1_is_nonzero = get_fmask_desc_valid(ctx, fmask_desc_ptr);
/* Replace the MSAA sample index. */
sample_index =
--
2.14.3
More information about the mesa-dev
mailing list