[Mesa-dev] [RFC PATCH 2/9] ac/shader: scan uses_persp_{centroid, center}
Samuel Pitoiset
samuel.pitoiset at gmail.com
Thu Mar 8 14:08:04 UTC 2018
This allows us to remove one nir_foreach_variable loop.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/amd/common/ac_nir_to_llvm.c | 16 ++--------------
src/amd/common/ac_shader_info.c | 11 ++++++++---
src/amd/common/ac_shader_info.h | 2 ++
3 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 9586cd4d46..358e3f04fd 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -5564,20 +5564,8 @@ prepare_interp_optimize(struct radv_shader_context *ctx,
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) {
+ if (ctx->shader_info->info.ps.uses_persp_center &&
+ ctx->shader_info->info.ps.uses_persp_centroid) {
LLVMValueRef sel = LLVMBuildICmp(ctx->ac.builder, LLVMIntSLT, ctx->abi.prim_mask, ctx->ac.i32_0, "");
ctx->persp_centroid = LLVMBuildSelect(ctx->ac.builder, sel, ctx->persp_center, ctx->persp_centroid, "");
ctx->linear_centroid = LLVMBuildSelect(ctx->ac.builder, sel, ctx->linear_center, ctx->linear_centroid, "");
diff --git a/src/amd/common/ac_shader_info.c b/src/amd/common/ac_shader_info.c
index 8dda241324..60e3d62e79 100644
--- a/src/amd/common/ac_shader_info.c
+++ b/src/amd/common/ac_shader_info.c
@@ -231,9 +231,6 @@ gather_info_input_decl_ps(const nir_shader *nir, const nir_variable *var,
}
if (glsl_get_base_type(type) == GLSL_TYPE_FLOAT) {
- if (var->data.sample)
- info->ps.force_persample = true;
-
if (var->data.sample) {
info->ps.input_interp_loc[idx] = INTERP_SAMPLE;
} else if (var->data.centroid) {
@@ -242,6 +239,14 @@ gather_info_input_decl_ps(const nir_shader *nir, const nir_variable *var,
info->ps.input_interp_loc[idx] = INTERP_CENTER;
}
+ if (info->ps.input_interp_loc[idx] == INTERP_SAMPLE) {
+ info->ps.force_persample = true;
+ } else if (info->ps.input_interp_loc[idx] == INTERP_CENTROID) {
+ info->ps.uses_persp_centroid = true;
+ } else {
+ info->ps.uses_persp_center = true;
+ }
+
info->ps.input_interp_mode[idx] = var->data.interpolation;
} else {
info->ps.input_interp_mode[idx] = INTERP_MODE_FLAT;
diff --git a/src/amd/common/ac_shader_info.h b/src/amd/common/ac_shader_info.h
index 4469e8c5c9..d02841adfe 100644
--- a/src/amd/common/ac_shader_info.h
+++ b/src/amd/common/ac_shader_info.h
@@ -58,6 +58,8 @@ struct ac_shader_info {
bool layer_input;
uint8_t input_interp_loc[VARYING_SLOT_VAR31 + 1];
uint8_t input_interp_mode[VARYING_SLOT_VAR31 + 1];
+ bool uses_persp_centroid;
+ bool uses_persp_center;
} ps;
struct {
bool uses_grid_size;
--
2.16.2
More information about the mesa-dev
mailing list