summaryrefslogtreecommitdiffstats
path: root/src/amd/common
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2017-08-15 18:09:21 +0200
committerBas Nieuwenhuizen <[email protected]>2017-08-24 00:57:03 +0200
commit6bafb56df69b5804dd113d24285312f266cadae2 (patch)
tree5b735664efb610afac7642707204202eb2372b66 /src/amd/common
parenta7f5545ede8aabd270025a59bd8077f066ba4432 (diff)
radv: Implement bc optimize.
Seems like we actually enabled it already, but did not implement the shader part. With this patch we do. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd/common')
-rw-r--r--src/amd/common/ac_nir_to_llvm.c29
-rw-r--r--src/amd/common/ac_nir_to_llvm.h1
2 files changed, 30 insertions, 0 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 88f2203316c..846840b7b06 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -5010,9 +5010,38 @@ handle_vs_inputs(struct nir_to_llvm_context *ctx,
}
static void
+prepare_interp_optimize(struct nir_to_llvm_context *ctx,
+ struct nir_shader *nir)
+{
+ if (!ctx->options->key.fs.multisample)
+ return;
+
+ bool uses_center = false;
+ bool uses_centroid = false;
+ nir_foreach_variable(variable, &nir->inputs) {
+ if (glsl_get_base_type(glsl_without_array(variable->type)) != GLSL_TYPE_FLOAT ||
+ variable->data.sample)
+ continue;
+
+ if (variable->data.centroid)
+ uses_centroid = true;
+ else
+ uses_center = true;
+ }
+
+ if (uses_center && uses_centroid) {
+ LLVMValueRef sel = LLVMBuildICmp(ctx->builder, LLVMIntSLT, ctx->prim_mask, ctx->ac.i32_0, "");
+ ctx->persp_centroid = LLVMBuildSelect(ctx->builder, sel, ctx->persp_center, ctx->persp_centroid, "");
+ ctx->linear_centroid = LLVMBuildSelect(ctx->builder, sel, ctx->linear_center, ctx->linear_centroid, "");
+ }
+}
+
+static void
handle_fs_inputs(struct nir_to_llvm_context *ctx,
struct nir_shader *nir)
{
+ prepare_interp_optimize(ctx, nir);
+
nir_foreach_variable(variable, &nir->inputs)
handle_fs_input_decl(ctx, variable);
diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h
index 376db1387a4..53ea238c3c9 100644
--- a/src/amd/common/ac_nir_to_llvm.h
+++ b/src/amd/common/ac_nir_to_llvm.h
@@ -60,6 +60,7 @@ struct ac_fs_variant_key {
uint32_t col_format;
uint32_t is_int8;
uint32_t is_int10;
+ uint32_t multisample : 1;
};
union ac_shader_variant_key {